summaryrefslogtreecommitdiff
path: root/mate-panel/panel-menu-button.c
diff options
context:
space:
mode:
authorSamuel Thibault <[email protected]>2018-08-30 18:11:29 +0200
committerColomban Wendling <[email protected]>2018-10-17 18:12:37 +0200
commitcdaf08f254981d920918fcfdb1aa356dfdf66306 (patch)
tree03acfd5226bdf7adbe1df74372364f0e4794214e /mate-panel/panel-menu-button.c
parentd9dcf9c2166b24677994ff1efe938e16c33c4b6c (diff)
downloadmate-panel-cdaf08f254981d920918fcfdb1aa356dfdf66306.tar.bz2
mate-panel-cdaf08f254981d920918fcfdb1aa356dfdf66306.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 This a backport of commit f0f4c5e1217eefd46edf9f98633fb32967c67461.
Diffstat (limited to 'mate-panel/panel-menu-button.c')
-rw-r--r--mate-panel/panel-menu-button.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/mate-panel/panel-menu-button.c b/mate-panel/panel-menu-button.c
index b111edff..1574d2f3 100644
--- a/mate-panel/panel-menu-button.c
+++ b/mate-panel/panel-menu-button.c
@@ -26,9 +26,12 @@
#include "panel-menu-button.h"
+#include <X11/Xlib.h>
+
#include <string.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
+#include <gdk/gdkx.h>
#include <matemenu-tree.h>
@@ -92,6 +95,8 @@ struct _PanelMenuButtonPrivate {
char *custom_icon;
char *tooltip;
+ Window interrupted_window;
+
MenuPathRoot path_root;
guint use_menu_path : 1;
guint use_custom_icon : 1;
@@ -424,12 +429,23 @@ panel_menu_button_recreate_menu (PanelMenuButton *button)
button->priv->menu = NULL;
}
+static gboolean panel_menu_button_menu_deactivate (GtkWidget* widget, PanelMenuButton* button)
+{
+ GtkWidget *toplevel = gtk_widget_get_toplevel(widget);
+ panel_util_set_current_active_window(toplevel, button->priv->interrupted_window);
+ button->priv->interrupted_window = None;
+
+ return FALSE;
+}
+
void
panel_menu_button_popup_menu (PanelMenuButton *button,
guint n_button,
guint32 activate_time)
{
GdkScreen *screen;
+ GtkWidget *toplevel;
+ GdkWindow *window;
g_return_if_fail (PANEL_IS_MENU_BUTTON (button));
@@ -449,6 +465,12 @@ panel_menu_button_popup_menu (PanelMenuButton *button,
GTK_WIDGET (button),
n_button,
activate_time);
+
+ g_signal_connect(GTK_MENU_SHELL (button->priv->menu), "deactivate", G_CALLBACK (panel_menu_button_menu_deactivate), button);
+ toplevel = gtk_widget_get_toplevel(GTK_WIDGET(button->priv->toplevel));
+ button->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));
}
static void