fix: keep manual USB selection available during keyboard grabs
This commit is contained in:
@@ -8,20 +8,20 @@
|
||||
gboolean attach;
|
||||
gboolean shared;
|
||||
gboolean quitting;
|
||||
@@ -951,6 +952,13 @@
|
||||
{
|
||||
@@ -952,6 +953,13 @@
|
||||
gchar *subtitle = NULL;
|
||||
const gchar *title = virt_viewer_app_get_title(app);
|
||||
+
|
||||
|
||||
+ /* Hidden fullscreen windows use the requested title as stable identity. */
|
||||
+ if (title != NULL && virt_viewer_app_get_hide_toolbar(app) &&
|
||||
+ virt_viewer_app_get_fullscreen(app)) {
|
||||
+ g_object_set(window, "subtitle", title, NULL);
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
+
|
||||
if (title != NULL) {
|
||||
VirtViewerDisplay *display = virt_viewer_window_get_display(window);
|
||||
gchar *d = strstr(title, "%d");
|
||||
@@ -2134,6 +2142,7 @@
|
||||
static gboolean opt_verbose = FALSE;
|
||||
static gboolean opt_debug = FALSE;
|
||||
@@ -110,3 +110,38 @@
|
||||
gtk_window_set_title(GTK_WINDOW(self->window), title);
|
||||
if (self->subtitle) {
|
||||
gtk_header_bar_set_title(GTK_HEADER_BAR(header), self->subtitle);
|
||||
@@ -1467,6 +1475,34 @@
|
||||
display = self->display;
|
||||
event = (GdkEventKey *)ev;
|
||||
|
||||
+ /* Keyboard grabs remove GTK's application accelerator group so normal
|
||||
+ * shortcuts reach the guest. Keep only the explicitly configured manual
|
||||
+ * USB selector available before forwarding this event to the display. */
|
||||
+ if (!self->kiosk) {
|
||||
+ gchar **accels = gtk_application_get_accels_for_action(
|
||||
+ GTK_APPLICATION(self->app), "win.usb-device-select");
|
||||
+ gboolean matched = FALSE;
|
||||
+ for (guint i = 0; accels[i]; i++) {
|
||||
+ guint key;
|
||||
+ GdkModifierType mods;
|
||||
+ gtk_accelerator_parse(accels[i], &key, &mods);
|
||||
+ if (key && gdk_keyval_to_lower(event->keyval) == key &&
|
||||
+ (event->state & gtk_accelerator_get_default_mod_mask()) == mods) {
|
||||
+ matched = TRUE;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ g_strfreev(accels);
|
||||
+ if (matched) {
|
||||
+ GAction *action = g_action_map_lookup_action(
|
||||
+ G_ACTION_MAP(self->window), "usb-device-select");
|
||||
+ if (action && g_action_get_enabled(action)) {
|
||||
+ g_action_activate(action, NULL);
|
||||
+ return TRUE;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
gtk_widget_grab_focus(GTK_WIDGET(display));
|
||||
|
||||
// Look through keymaps - if set for mappings and intercept
|
||||
|
||||
Reference in New Issue
Block a user