mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/virt-viewer
synced 2025-12-27 23:00:54 +00:00
Grab the focus when showing the display
Override the grab_focus() method in the display class. Since both VNC and Spice displays are the direct child, let's just grab the child. It can be that this behaviour need to be overriden if Spice or VNC display become more complex (using sub-childs or different objects)
This commit is contained in:
parent
d679451659
commit
0e6f0847d8
@ -63,6 +63,7 @@ static void virt_viewer_display_get_property(GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void virt_viewer_display_grab_focus(GtkWidget *widget);
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE(VirtViewerDisplay, virt_viewer_display, GTK_TYPE_BIN)
|
||||
|
||||
@ -93,6 +94,7 @@ virt_viewer_display_class_init(VirtViewerDisplayClass *class)
|
||||
widget_class->size_request = virt_viewer_display_size_request;
|
||||
#endif
|
||||
widget_class->size_allocate = virt_viewer_display_size_allocate;
|
||||
widget_class->grab_focus = virt_viewer_display_grab_focus;
|
||||
|
||||
g_object_class_install_property(object_class,
|
||||
PROP_DESKTOP_WIDTH,
|
||||
@ -288,6 +290,15 @@ virt_viewer_display_get_property(GObject *object,
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
virt_viewer_display_grab_focus(GtkWidget *widget)
|
||||
{
|
||||
GtkBin *bin = GTK_BIN(widget);
|
||||
|
||||
gtk_widget_grab_focus(gtk_bin_get_child(bin));
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
virt_viewer_display_idle(gpointer opaque)
|
||||
{
|
||||
|
||||
@ -127,6 +127,7 @@ virt_viewer_notebook_show_display(VirtViewerNotebook *self)
|
||||
|
||||
display = gtk_notebook_get_nth_page(GTK_NOTEBOOK(self), 1);
|
||||
g_warn_if_fail(display != NULL);
|
||||
gtk_widget_grab_focus(display);
|
||||
|
||||
gtk_notebook_set_current_page(GTK_NOTEBOOK(self), 1);
|
||||
gtk_widget_show_all(GTK_WIDGET(self));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user