From 9854e82312de01630452f01c353af79c755f9fb3 Mon Sep 17 00:00:00 2001 From: Simon Steinbeiss <simon.steinbeiss@elfenbeinturm.at> Date: Thu, 5 Mar 2015 17:43:54 +0100 Subject: [PATCH] Fix the scale's slider with Gtk3.14 This change was ported from libido upstream: http://bazaar.launchpad.net/~indicator-applet-developers/ido/trunk.15.04/revision/187 --- .../power-manager-plugin/scalemenuitem.c | 44 +++++-------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/panel-plugins/power-manager-plugin/scalemenuitem.c b/panel-plugins/power-manager-plugin/scalemenuitem.c index d16ff74f..3a598e43 100644 --- a/panel-plugins/power-manager-plugin/scalemenuitem.c +++ b/panel-plugins/power-manager-plugin/scalemenuitem.c @@ -248,40 +248,22 @@ scale_menu_item_init (ScaleMenuItem *self) { } - -static void -scale_menu_item_get_scale_allocation (ScaleMenuItem *menuitem, - GtkAllocation *allocation) -{ - ScaleMenuItemPrivate *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 scale_menu_item_button_press_event (GtkWidget *menuitem, GdkEventButton *event) { ScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem); GtkAllocation alloc; + gint x, y; TRACE("entering"); - scale_menu_item_get_scale_allocation (SCALE_MENU_ITEM (menuitem), &alloc); - - 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 *)(void*)(event))); if (!priv->grabbed) { @@ -319,16 +301,14 @@ scale_menu_item_motion_notify_event (GtkWidget *menuitem, ScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem); GtkWidget *scale = priv->scale; GtkAllocation alloc; + gint x, y; - scale_menu_item_get_scale_allocation (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*)event); + if (priv->grabbed || + (x > 0 && x < alloc.width && y > 0 && y < alloc.height)) + gtk_widget_event (scale, (GdkEvent*)event); return TRUE; } -- GitLab