diff options
author | Lars Uebernickel <lars.uebernickel@canonical.com> | 2015-01-22 11:56:09 +0000 |
---|---|---|
committer | CI Train Bot <ci-train-bot@canonical.com> | 2015-01-22 11:56:09 +0000 |
commit | 9f8609c1919a10d93e148200d7149c0d0b76d70c (patch) | |
tree | 394a5b2b1e3cb72946304bc1cd51700daf2895b6 | |
parent | d69f78b0708e2054382b68b92366a37e61ef7171 (diff) | |
parent | 22e14c5119b9e4137a13279a7219fdb5e7fcdb35 (diff) | |
download | ayatana-ido-9f8609c1919a10d93e148200d7149c0d0b76d70c.tar.gz ayatana-ido-9f8609c1919a10d93e148200d7149c0d0b76d70c.tar.bz2 ayatana-ido-9f8609c1919a10d93e148200d7149c0d0b76d70c.zip |
idoscalemenuitem: fix slider event forwarding
Approved by: Iain Lane, PS Jenkins bot
-rw-r--r-- | src/idoscalemenuitem.c | 66 |
1 files changed, 19 insertions, 47 deletions
diff --git a/src/idoscalemenuitem.c b/src/idoscalemenuitem.c index 6b1da0a..9898b63 100644 --- a/src/idoscalemenuitem.c +++ b/src/idoscalemenuitem.c @@ -437,20 +437,6 @@ ido_scale_menu_item_get_property (GObject *object, } } -static void -ido_scale_menu_item_get_scale_allocation (IdoScaleMenuItem *menuitem, - GtkAllocation *allocation) -{ - IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem); - GtkAllocation parent_allocation; - - gtk_widget_get_allocation (GTK_WIDGET (menuitem), &parent_allocation); - gtk_widget_get_allocation (priv->scale, allocation); - - allocation->x -= parent_allocation.x; - allocation->y -= parent_allocation.y; -} - static gboolean ido_scale_menu_item_parent_key_press_event (GtkWidget *widget, GdkEventKey *event, @@ -506,19 +492,13 @@ ido_scale_menu_item_button_press_event (GtkWidget *menuitem, { IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem); GtkAllocation alloc; + gint x, y; - ido_scale_menu_item_get_scale_allocation (IDO_SCALE_MENU_ITEM (menuitem), &alloc); - - // can we block emissions of "grab-notify" on parent?? - - event->x -= alloc.x; - event->y -= alloc.y; + gtk_widget_get_allocation (priv->scale, &alloc); + gtk_widget_translate_coordinates (menuitem, priv->scale, event->x, event->y, &x, &y); - event->x_root -= alloc.x; - event->y_root -= alloc.y; - - gtk_widget_event (priv->scale, - ((GdkEvent *)(void*)(event))); + if (x > 0 && x < alloc.width && y > 0 && y < alloc.height) + gtk_widget_event (priv->scale, (GdkEvent *) event); if (!priv->grabbed) { @@ -526,7 +506,7 @@ ido_scale_menu_item_button_press_event (GtkWidget *menuitem, g_signal_emit (menuitem, signals[SLIDER_GRABBED], 0); } - return FALSE; + return TRUE; } static gboolean @@ -537,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; - ido_scale_menu_item_get_scale_allocation (IDO_SCALE_MENU_ITEM (menuitem), &alloc); + 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) { @@ -554,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) { @@ -567,15 +549,9 @@ 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) { - event->x -= alloc.x; - event->y -= alloc.y; - - event->x_root -= alloc.x; - event->y_root -= alloc.y; - - gtk_widget_event (scale, (GdkEvent*)event); + gtk_widget_event (scale, (GdkEvent*) event); } if (priv->grabbed) @@ -592,19 +568,15 @@ ido_scale_menu_item_motion_notify_event (GtkWidget *menuitem, GdkEventMotion *event) { IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem); - GtkWidget *scale = priv->scale; GtkAllocation alloc; + gint x, y; - ido_scale_menu_item_get_scale_allocation (IDO_SCALE_MENU_ITEM (menuitem), &alloc); - - event->x -= alloc.x; - event->y -= alloc.y; - - event->x_root -= alloc.x; - event->y_root -= alloc.y; + gtk_widget_get_allocation (priv->scale, &alloc); + gtk_widget_translate_coordinates (menuitem, priv->scale, event->x, event->y, &x, &y); - gtk_widget_event (scale, - ((GdkEvent *)(void*)(event))); + if (priv->grabbed || + (x > 0 && x < alloc.width && y > 0 && y < alloc.height)) + gtk_widget_event (priv->scale, (GdkEvent *) event); return TRUE; } |