[gtk+/wip/garnacho/window-dragging: 1/2] gtkmenubutton: Popup menu/popover on button release
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/garnacho/window-dragging: 1/2] gtkmenubutton: Popup menu/popover on button release
- Date: Wed, 25 Feb 2015 20:24:15 +0000 (UTC)
commit 8e44031d688b5f690025d298c2ffbce9140addcf
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Feb 25 20:31:09 2015 +0100
gtkmenubutton: Popup menu/popover on button release
The button press is just accounted, in order to avoid showing the menu
again while dismissing it (the menu grab is removed, and the button
would just receive the button release)
gtk/gtkmenubutton.c | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c
index de06bf1..d80e460 100644
--- a/gtk/gtkmenubutton.c
+++ b/gtk/gtkmenubutton.c
@@ -132,6 +132,7 @@ struct _GtkMenuButtonPrivate
GtkWidget *arrow_widget;
GtkArrowType arrow_type;
gboolean use_popover;
+ guint press_handled : 1;
};
enum
@@ -440,11 +441,23 @@ gtk_menu_button_button_press_event (GtkWidget *widget,
GtkMenuButton *menu_button = GTK_MENU_BUTTON (widget);
GtkMenuButtonPrivate *priv = menu_button->priv;
- if (event->button == GDK_BUTTON_PRIMARY)
+ if (event->type == GDK_BUTTON_PRESS &&
+ event->button == GDK_BUTTON_PRIMARY)
+ priv->press_handled = TRUE;
+
+ return GTK_WIDGET_CLASS (gtk_menu_button_parent_class)->button_press_event (widget, event);
+}
+
+static gboolean
+gtk_menu_button_button_release_event (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ GtkMenuButton *menu_button = GTK_MENU_BUTTON (widget);
+ GtkMenuButtonPrivate *priv = menu_button->priv;
+
+ if (priv->press_handled && event->button == GDK_BUTTON_PRIMARY)
{
- /* Filter out double/triple clicks */
- if (event->type != GDK_BUTTON_PRESS)
- return TRUE;
+ priv->press_handled = FALSE;
if (priv->menu && !gtk_widget_get_visible (priv->menu))
popup_menu (menu_button, event);
@@ -458,7 +471,7 @@ gtk_menu_button_button_press_event (GtkWidget *widget,
return TRUE;
}
- return GTK_WIDGET_CLASS (gtk_menu_button_parent_class)->button_press_event (widget, event);
+ return GTK_WIDGET_CLASS (gtk_menu_button_parent_class)->button_release_event (widget, event);
}
static void
@@ -499,6 +512,7 @@ gtk_menu_button_class_init (GtkMenuButtonClass *klass)
widget_class->state_flags_changed = gtk_menu_button_state_flags_changed;
widget_class->button_press_event = gtk_menu_button_button_press_event;
+ widget_class->button_release_event = gtk_menu_button_button_release_event;
container_class->add = gtk_menu_button_add;
container_class->remove = gtk_menu_button_remove;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]