[gtk+/touch-for-3.4: 31/65] menus: Don't popdown submenus on button release for touch devices
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/touch-for-3.4: 31/65] menus: Don't popdown submenus on button release for touch devices
- Date: Fri, 24 Feb 2012 15:27:26 +0000 (UTC)
commit 330a9bfbc341af0345b20c9e0e941590a43fa77c
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Dec 12 20:07:57 2011 +0100
menus: Don't popdown submenus on button release for touch devices
This is so submenus stay open as the parent menu item is
pressed/released, since the user would typically lift the
finger in order to select a submenu item.
gtk/gtkmenu.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index c32479a..3e4e86b 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -3349,9 +3349,17 @@ static gboolean
gtk_menu_button_press (GtkWidget *widget,
GdkEventButton *event)
{
+ GdkDevice *source_device;
+ GtkWidget *event_widget;
+ GtkMenu *menu;
+
if (event->type != GDK_BUTTON_PRESS)
return FALSE;
+ source_device = gdk_event_get_source_device ((GdkEvent *) event);
+ event_widget = gtk_get_event_widget ((GdkEvent *) event);
+ menu = GTK_MENU (widget);
+
/* Don't pass down to menu shell if a non-menuitem part of the menu
* was clicked. The check for the event_widget being a GtkMenuShell
* works because we have the pointer grabbed on menu_shell->window
@@ -3359,10 +3367,16 @@ gtk_menu_button_press (GtkWidget *widget,
* the menu or on its border are delivered relative to
* menu_shell->window.
*/
- if (GTK_IS_MENU_SHELL (gtk_get_event_widget ((GdkEvent *) event)) &&
+ if (GTK_IS_MENU_SHELL (event_widget) &&
pointer_in_menu_window (widget, event->x_root, event->y_root))
return TRUE;
+ if (GTK_IS_MENU_ITEM (event_widget) &&
+ gdk_device_get_source (source_device) == GDK_SOURCE_TOUCH &&
+ GTK_MENU_ITEM (event_widget)->priv->submenu != NULL &&
+ !gtk_widget_is_drawable (GTK_MENU_ITEM (event_widget)->priv->submenu))
+ menu->priv->ignore_button_release = TRUE;
+
return GTK_WIDGET_CLASS (gtk_menu_parent_class)->button_press_event (widget, event);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]