mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/virt-viewer
synced 2026-01-10 23:57:46 +00:00
Show display and rise its window when we have the display show hint
Track event for Spice, and imitate it for VNC.
This commit is contained in:
parent
045f3ac9ea
commit
b5724b8f06
@ -386,6 +386,38 @@ virt_viewer_app_window_new(VirtViewerApp *self, GtkWidget *container, gint nth)
|
||||
return window;
|
||||
}
|
||||
|
||||
static void
|
||||
display_show_hint(VirtViewerDisplay *display,
|
||||
GParamSpec *pspec G_GNUC_UNUSED,
|
||||
VirtViewerWindow *win)
|
||||
{
|
||||
VirtViewerApp *self;
|
||||
VirtViewerNotebook *nb = virt_viewer_window_get_notebook(win);
|
||||
GtkWindow *w = virt_viewer_window_get_window(win);
|
||||
gint nth, hint;
|
||||
|
||||
g_object_get(win,
|
||||
"app", &self,
|
||||
NULL);
|
||||
g_object_get(display,
|
||||
"nth-display", &nth,
|
||||
"show-hint", &hint,
|
||||
NULL);
|
||||
|
||||
if (hint == VIRT_VIEWER_DISPLAY_SHOW_HINT_HIDE) {
|
||||
if (win != self->priv->main_window &&
|
||||
g_getenv("VIRT_VIEWER_HIDE"))
|
||||
gtk_widget_hide(GTK_WIDGET(w));
|
||||
virt_viewer_notebook_show_status(nb, _("Waiting for display %d..."), nth + 1);
|
||||
} else {
|
||||
virt_viewer_notebook_show_display(nb);
|
||||
gtk_widget_show(GTK_WIDGET(w));
|
||||
gtk_window_present(w);
|
||||
}
|
||||
|
||||
g_object_unref(self);
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_app_display_added(VirtViewerSession *session G_GNUC_UNUSED,
|
||||
VirtViewerDisplay *display,
|
||||
@ -409,6 +441,9 @@ virt_viewer_app_display_added(VirtViewerSession *session G_GNUC_UNUSED,
|
||||
}
|
||||
|
||||
virt_viewer_window_set_display(window, display);
|
||||
g_signal_connect(display, "notify::show-hint",
|
||||
G_CALLBACK(display_show_hint), window);
|
||||
g_object_notify(G_OBJECT(display), "show-hint"); /* call display_show_hint */
|
||||
}
|
||||
|
||||
|
||||
@ -750,7 +785,6 @@ static void
|
||||
virt_viewer_app_initialized(VirtViewerSession *session G_GNUC_UNUSED,
|
||||
VirtViewerApp *self)
|
||||
{
|
||||
virt_viewer_notebook_show_display(VIRT_VIEWER_NOTEBOOK(self->priv->main_notebook));
|
||||
virt_viewer_app_update_title(self);
|
||||
}
|
||||
|
||||
|
||||
@ -100,19 +100,29 @@ virt_viewer_display_spice_get_pixbuf(VirtViewerDisplay *display)
|
||||
}
|
||||
|
||||
static void
|
||||
virt_viewer_display_spice_primary_create(SpiceChannel *channel G_GNUC_UNUSED,
|
||||
gint format G_GNUC_UNUSED,
|
||||
gint width,
|
||||
gint height,
|
||||
gint stride G_GNUC_UNUSED,
|
||||
gint shmid G_GNUC_UNUSED,
|
||||
gpointer imgdata G_GNUC_UNUSED,
|
||||
VirtViewerDisplay *display)
|
||||
display_mark(SpiceChannel *channel G_GNUC_UNUSED,
|
||||
gint mark,
|
||||
VirtViewerDisplay *display)
|
||||
{
|
||||
DEBUG_LOG("desktop resize %dx%d", width, height);
|
||||
DEBUG_LOG("display mark %d", mark);
|
||||
|
||||
virt_viewer_display_set_desktop_size(display, width, height);
|
||||
g_signal_emit_by_name(display, "display-desktop-resize");
|
||||
virt_viewer_display_set_show_hint(display, mark);
|
||||
}
|
||||
|
||||
static void
|
||||
primary_create(SpiceChannel *channel G_GNUC_UNUSED,
|
||||
gint format G_GNUC_UNUSED,
|
||||
gint width,
|
||||
gint height,
|
||||
gint stride G_GNUC_UNUSED,
|
||||
gint shmid G_GNUC_UNUSED,
|
||||
gpointer imgdata G_GNUC_UNUSED,
|
||||
VirtViewerDisplay *display)
|
||||
{
|
||||
DEBUG_LOG("spice desktop resize %dx%d", width, height);
|
||||
|
||||
virt_viewer_display_set_desktop_size(display, width, height);
|
||||
g_signal_emit_by_name(display, "display-desktop-resize");
|
||||
}
|
||||
|
||||
|
||||
@ -135,7 +145,9 @@ virt_viewer_display_spice_new(SpiceChannel *channel,
|
||||
self->priv->display = g_object_ref(display);
|
||||
|
||||
g_signal_connect(channel, "display-primary-create",
|
||||
G_CALLBACK(virt_viewer_display_spice_primary_create), self);
|
||||
G_CALLBACK(primary_create), self);
|
||||
g_signal_connect(channel, "display-mark",
|
||||
G_CALLBACK(display_mark), self);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(self), GTK_WIDGET(self->priv->display));
|
||||
gtk_widget_show(GTK_WIDGET(self->priv->display));
|
||||
|
||||
@ -86,6 +86,8 @@ virt_viewer_session_vnc_connected(VncDisplay *vnc G_GNUC_UNUSED,
|
||||
{
|
||||
GtkWidget *display = virt_viewer_display_vnc_new(session->priv->vnc);
|
||||
g_signal_emit_by_name(session, "session-connected");
|
||||
virt_viewer_display_set_show_hint(VIRT_VIEWER_DISPLAY(display),
|
||||
VIRT_VIEWER_DISPLAY_SHOW_HINT_READY);
|
||||
virt_viewer_session_add_display(VIRT_VIEWER_SESSION(session),
|
||||
VIRT_VIEWER_DISPLAY(display));
|
||||
}
|
||||
@ -95,6 +97,9 @@ virt_viewer_session_vnc_disconnected(VncDisplay *vnc G_GNUC_UNUSED,
|
||||
VirtViewerSessionVnc *session)
|
||||
{
|
||||
g_signal_emit_by_name(session, "session-disconnected");
|
||||
/* TODO perhaps? */
|
||||
/* virt_viewer_display_set_show_hint(VIRT_VIEWER_DISPLAY(session->priv->vnc), */
|
||||
/* VIRT_VIEWER_DISPLAY_SHOW_HINT_HIDE); */
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Loading…
Reference in New Issue
Block a user