diff options
author | Samuel Thibault <[email protected]> | 2018-08-30 18:11:29 +0200 |
---|---|---|
committer | lukefromdc <[email protected]> | 2018-09-26 00:18:03 -0400 |
commit | f0f4c5e1217eefd46edf9f98633fb32967c67461 (patch) | |
tree | cf66d12ba747544370762d077417409a2064a01d /mate-panel/panel-menu-bar.c | |
parent | 4c30c52e4857da9d23e284aa75b12c8ab62e2ee4 (diff) | |
download | mate-panel-f0f4c5e1217eefd46edf9f98633fb32967c67461.tar.bz2 mate-panel-f0f4c5e1217eefd46edf9f98633fb32967c67461.tar.xz |
menu-bar: transfer focus correctly on alt-F1
The background is in https://gitlab.gnome.org/GNOME/gtk/issues/85 . One of
the conclusions, in https://gitlab.gnome.org/GNOME/gtk/issues/85#note_264804
, is that mate-panel needs to properly transfer focus on alt-F1 keyboard
shortcut.
It used to work only by luck before, only because gtk used to
deactivate itself during a keyboard grab. But as discussed in
https://gitlab.gnome.org/GNOME/gtk/issues/85 that behavior poses
accessibility feedback issues, is not coherent, and keyboard grab
feedback will not be available in wayland anyway. Thus @ebassi saying
in https://gitlab.gnome.org/GNOME/gtk/issues/85#note_264804 that not
transferring focus properly is the actual bug.
This change explictly switches to the menu bar after saving which X Window
had the focus, and on menu bar deactivation restores focus to that X Window.
Fixes #851
Diffstat (limited to 'mate-panel/panel-menu-bar.c')
-rw-r--r-- | mate-panel/panel-menu-bar.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/mate-panel/panel-menu-bar.c b/mate-panel/panel-menu-bar.c index 955e9c4b..06fca819 100644 --- a/mate-panel/panel-menu-bar.c +++ b/mate-panel/panel-menu-bar.c @@ -28,6 +28,9 @@ #include "panel-menu-bar.h" +#include <X11/Xlib.h> +#include <gdk/gdkx.h> + #include <string.h> #include <glib/gi18n.h> @@ -65,6 +68,8 @@ struct _PanelMenuBarPrivate { GSettings* settings; PanelOrientation orientation; + + Window interrupted_window; }; enum { @@ -83,6 +88,15 @@ static gboolean panel_menu_bar_reinit_tooltip(GtkWidget* widget, PanelMenuBar* m return FALSE; } +static gboolean panel_menu_bar_deactivate (GtkWidget* widget, PanelMenuBar* menubar) +{ + GtkWidget *toplevel = gtk_widget_get_toplevel (widget); + panel_util_set_current_active_window (toplevel, menubar->priv->interrupted_window); + menubar->priv->interrupted_window = None; + + return FALSE; +} + static gboolean panel_menu_bar_hide_tooltip_and_focus(GtkWidget* widget, PanelMenuBar* menubar) { /* remove focus that would be drawn on the currently focused child of @@ -108,6 +122,7 @@ static void panel_menu_bar_setup_tooltip(PanelMenuBar* menubar) /* Reset tooltip when the menu bar is not used */ g_signal_connect(GTK_MENU_SHELL (menubar), "deactivate", G_CALLBACK (panel_menu_bar_reinit_tooltip), menubar); + g_signal_connect(GTK_MENU_SHELL (menubar), "deactivate", G_CALLBACK (panel_menu_bar_deactivate), menubar); } static void panel_menu_bar_update_visibility (GSettings* settings, gchar* key, PanelMenuBar* menubar) @@ -411,11 +426,18 @@ void panel_menu_bar_popup_menu(PanelMenuBar* menubar, guint32 activate_time) { GtkMenu* menu; GtkMenuShell* menu_shell; + GtkWidget* toplevel; + GdkWindow* window; g_return_if_fail(PANEL_IS_MENU_BAR(menubar)); menu = GTK_MENU(menubar->priv->applications_menu); + toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menubar)); + menubar->priv->interrupted_window = panel_util_get_current_active_window (toplevel); + window = gtk_widget_get_window (toplevel); + panel_util_set_current_active_window (toplevel, GDK_WINDOW_XID(window)); + /* * We need to call _gtk_menu_shell_activate() here as is done in * window_key_press_handler in gtkmenubar.c which pops up menu |