[gtk] Fix menuitem hover
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] Fix menuitem hover
- Date: Mon, 1 Apr 2019 01:55:44 +0000 (UTC)
commit d2e0553384cca0bcd7c2a7df404e1e44bf82f8d4
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Mar 31 21:53:55 2019 -0400
Fix menuitem hover
We need to pay attention to details
of enter and leave events.
Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1795
gtk/gtkmenuitem.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index e7213ebe58..61519beccc 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -1128,6 +1128,7 @@ gtk_menu_item_enter (GtkEventController *controller,
GtkMenuItem *menu_item = GTK_MENU_ITEM (user_data);
GtkWidget *menu_shell;
GdkEvent *event;
+ gboolean is_focus, contains_focus;
event = gtk_get_current_event (); /* FIXME controller event */
@@ -1142,8 +1143,14 @@ gtk_menu_item_enter (GtkEventController *controller,
menu_shell = gtk_widget_get_parent (GTK_WIDGET (menu_item));
+ g_object_get (controller,
+ "is-pointer-focus", &is_focus,
+ "contains-pointer-focus", &contains_focus,
+ NULL);
+
if (GTK_IS_MENU_SHELL (menu_shell) &&
- GTK_MENU_SHELL (menu_shell)->priv->active)
+ GTK_MENU_SHELL (menu_shell)->priv->active &&
+ (is_focus || contains_focus))
gtk_menu_shell_select_item (GTK_MENU_SHELL (menu_shell), GTK_WIDGET (menu_item));
}
@@ -1155,8 +1162,16 @@ gtk_menu_item_leave (GtkEventController *controller,
{
GtkMenuItem *menu_item = GTK_MENU_ITEM (user_data);
GtkWidget *menu_shell = gtk_widget_get_parent (GTK_WIDGET (menu_item));
+ gboolean is_focus, contains_focus;
+
+ g_object_get (controller,
+ "is-pointer-focus", &is_focus,
+ "contains-pointer-focus", &contains_focus,
+ NULL);
- if (GTK_IS_MENU_SHELL (menu_shell) && !menu_item->priv->submenu)
+ if (GTK_IS_MENU_SHELL (menu_shell) &&
+ !menu_item->priv->submenu &&
+ !(is_focus || contains_focus))
gtk_menu_shell_deselect (GTK_MENU_SHELL (menu_shell));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]