diff options
author | Lars Uebernickel <lars.uebernickel@canonical.com> | 2015-01-21 19:14:49 +0100 |
---|---|---|
committer | Lars Uebernickel <lars.uebernickel@canonical.com> | 2015-01-21 19:14:49 +0100 |
commit | 3ae1abbaed410eceb3591a6e180c0dedb50ddd92 (patch) | |
tree | 657830198319121642eda2dc264c431768fb7548 | |
parent | b42893f39c3bc3eb0b02ce8b9130bb7729cb19d1 (diff) | |
download | ayatana-ido-3ae1abbaed410eceb3591a6e180c0dedb50ddd92.tar.gz ayatana-ido-3ae1abbaed410eceb3591a6e180c0dedb50ddd92.tar.bz2 ayatana-ido-3ae1abbaed410eceb3591a6e180c0dedb50ddd92.zip |
idoscalemenuitem: only forward button events that are inside the scale
-rw-r--r-- | src/idoscalemenuitem.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/idoscalemenuitem.c b/src/idoscalemenuitem.c index 3bc2934..4d6ce1a 100644 --- a/src/idoscalemenuitem.c +++ b/src/idoscalemenuitem.c @@ -491,8 +491,14 @@ ido_scale_menu_item_button_press_event (GtkWidget *menuitem, GdkEventButton *event) { IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem); + GtkAllocation alloc; + gint x, y; + + gtk_widget_get_allocation (priv->scale, &alloc); + gtk_widget_translate_coordinates (menuitem, priv->scale, event->x, event->y, &x, &y); - gtk_widget_event (priv->scale, (GdkEvent *) event); + if (x > 0 && x < alloc.width && y > 0 && y < alloc.height) + gtk_widget_event (priv->scale, (GdkEvent *) event); if (!priv->grabbed) { @@ -511,11 +517,13 @@ ido_scale_menu_item_button_release_event (GtkWidget *menuitem, IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem); GtkWidget *scale = priv->scale; GtkAllocation alloc; + gint x, y; gtk_widget_get_allocation (priv->scale, &alloc); + gtk_widget_translate_coordinates (menuitem, priv->scale, event->x, event->y, &x, &y); /* if user clicked to the left of the scale... */ - if (event->x < alloc.x) + if (x < 0) { if (gtk_widget_get_direction (menuitem) == GTK_TEXT_DIR_LTR) { @@ -528,7 +536,7 @@ ido_scale_menu_item_button_release_event (GtkWidget *menuitem, } /* if user clicked to the right of the scale... */ - else if (event->x > alloc.x + alloc.width) + else if (x > alloc.width) { if (gtk_widget_get_direction (menuitem) == GTK_TEXT_DIR_LTR) { @@ -541,7 +549,7 @@ ido_scale_menu_item_button_release_event (GtkWidget *menuitem, } /* user clicked on the scale... */ - else + else if (x > 0 && x < alloc.width && y > 0 && y < alloc.height) { gtk_widget_event (scale, (GdkEvent*) event); } @@ -561,7 +569,17 @@ ido_scale_menu_item_motion_notify_event (GtkWidget *menuitem, { IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem); - return gtk_widget_event (priv->scale, (GdkEvent *) event); + GtkAllocation alloc; + gint x, y; + + gtk_widget_get_allocation (priv->scale, &alloc); + gtk_widget_translate_coordinates (menuitem, priv->scale, event->x, event->y, &x, &y); + + if (priv->grabbed || + (x > 0 && x < alloc.width && y > 0 && y < alloc.height)) + gtk_widget_event (priv->scale, (GdkEvent *) event); + + return TRUE; } static void |