Merge lp:~larsu/ido/fix-volume-slider into lp:ido/15.04

Proposed by Lars Karlitski
Status: Merged
Approved by: Iain Lane
Approved revision: 189
Merged at revision: 187
Proposed branch: lp:~larsu/ido/fix-volume-slider
Merge into: lp:ido/15.04
Diff against target: 131 lines (+23/-51)
1 file modified
src/idoscalemenuitem.c (+23/-51)
To merge this branch: bzr merge lp:~larsu/ido/fix-volume-slider
Reviewer Review Type Date Requested Status
Iain Lane Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+247198@code.launchpad.net

Commit message

idoscalemenuitem: fix slider event forwarding

Description of the change

idoscalemenuitem: fix slider event forwarding

The slider behaves weirdly when clicking/dragging it right now. This patch fixes that.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Iain Lane (laney) wrote :

Looks nice, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/idoscalemenuitem.c'
2--- src/idoscalemenuitem.c 2014-03-12 17:25:55 +0000
3+++ src/idoscalemenuitem.c 2015-01-21 18:25:20 +0000
4@@ -437,20 +437,6 @@
5 }
6 }
7
8-static void
9-ido_scale_menu_item_get_scale_allocation (IdoScaleMenuItem *menuitem,
10- GtkAllocation *allocation)
11-{
12- IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);
13- GtkAllocation parent_allocation;
14-
15- gtk_widget_get_allocation (GTK_WIDGET (menuitem), &parent_allocation);
16- gtk_widget_get_allocation (priv->scale, allocation);
17-
18- allocation->x -= parent_allocation.x;
19- allocation->y -= parent_allocation.y;
20-}
21-
22 static gboolean
23 ido_scale_menu_item_parent_key_press_event (GtkWidget *widget,
24 GdkEventKey *event,
25@@ -506,19 +492,13 @@
26 {
27 IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);
28 GtkAllocation alloc;
29-
30- ido_scale_menu_item_get_scale_allocation (IDO_SCALE_MENU_ITEM (menuitem), &alloc);
31-
32- // can we block emissions of "grab-notify" on parent??
33-
34- event->x -= alloc.x;
35- event->y -= alloc.y;
36-
37- event->x_root -= alloc.x;
38- event->y_root -= alloc.y;
39-
40- gtk_widget_event (priv->scale,
41- ((GdkEvent *)(void*)(event)));
42+ gint x, y;
43+
44+ gtk_widget_get_allocation (priv->scale, &alloc);
45+ gtk_widget_translate_coordinates (menuitem, priv->scale, event->x, event->y, &x, &y);
46+
47+ if (x > 0 && x < alloc.width && y > 0 && y < alloc.height)
48+ gtk_widget_event (priv->scale, (GdkEvent *) event);
49
50 if (!priv->grabbed)
51 {
52@@ -526,7 +506,7 @@
53 g_signal_emit (menuitem, signals[SLIDER_GRABBED], 0);
54 }
55
56- return FALSE;
57+ return TRUE;
58 }
59
60 static gboolean
61@@ -537,11 +517,13 @@
62 IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);
63 GtkWidget *scale = priv->scale;
64 GtkAllocation alloc;
65+ gint x, y;
66
67- ido_scale_menu_item_get_scale_allocation (IDO_SCALE_MENU_ITEM (menuitem), &alloc);
68+ gtk_widget_get_allocation (priv->scale, &alloc);
69+ gtk_widget_translate_coordinates (menuitem, priv->scale, event->x, event->y, &x, &y);
70
71 /* if user clicked to the left of the scale... */
72- if (event->x < alloc.x)
73+ if (x < 0)
74 {
75 if (gtk_widget_get_direction (menuitem) == GTK_TEXT_DIR_LTR)
76 {
77@@ -554,7 +536,7 @@
78 }
79
80 /* if user clicked to the right of the scale... */
81- else if (event->x > alloc.x + alloc.width)
82+ else if (x > alloc.width)
83 {
84 if (gtk_widget_get_direction (menuitem) == GTK_TEXT_DIR_LTR)
85 {
86@@ -567,15 +549,9 @@
87 }
88
89 /* user clicked on the scale... */
90- else
91+ else if (x > 0 && x < alloc.width && y > 0 && y < alloc.height)
92 {
93- event->x -= alloc.x;
94- event->y -= alloc.y;
95-
96- event->x_root -= alloc.x;
97- event->y_root -= alloc.y;
98-
99- gtk_widget_event (scale, (GdkEvent*)event);
100+ gtk_widget_event (scale, (GdkEvent*) event);
101 }
102
103 if (priv->grabbed)
104@@ -592,19 +568,15 @@
105 GdkEventMotion *event)
106 {
107 IdoScaleMenuItemPrivate *priv = GET_PRIVATE (menuitem);
108- GtkWidget *scale = priv->scale;
109 GtkAllocation alloc;
110-
111- ido_scale_menu_item_get_scale_allocation (IDO_SCALE_MENU_ITEM (menuitem), &alloc);
112-
113- event->x -= alloc.x;
114- event->y -= alloc.y;
115-
116- event->x_root -= alloc.x;
117- event->y_root -= alloc.y;
118-
119- gtk_widget_event (scale,
120- ((GdkEvent *)(void*)(event)));
121+ gint x, y;
122+
123+ gtk_widget_get_allocation (priv->scale, &alloc);
124+ gtk_widget_translate_coordinates (menuitem, priv->scale, event->x, event->y, &x, &y);
125+
126+ if (priv->grabbed ||
127+ (x > 0 && x < alloc.width && y > 0 && y < alloc.height))
128+ gtk_widget_event (priv->scale, (GdkEvent *) event);
129
130 return TRUE;
131 }

Subscribers

People subscribed via source and target branches