Merge lp:~cimi/overlay-scrollbar/use-enums into lp:overlay-scrollbar
- use-enums
- Merge into trunk
Proposed by
Andrea Cimitan
Status: | Superseded |
---|---|
Proposed branch: | lp:~cimi/overlay-scrollbar/use-enums |
Merge into: | lp:overlay-scrollbar |
Diff against target: |
710 lines (+232/-215) 3 files modified
os/os-private.h (+10/-1) os/os-scrollbar.c (+205/-195) os/os-thumb.c (+17/-19) |
To merge this branch: | bzr merge lp:~cimi/overlay-scrollbar/use-enums |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ayatana Scrollbar Team | Pending | ||
Review via email: mp+67203@code.launchpad.net |
This proposal has been superseded by a proposal from 2011-07-07.
Commit message
Description of the change
If you have ideas on namings or other sets of enums to create, just ping me in IRC and not marking as "NEED FIXING" :)
Or they could be handled in separated branches
To post a comment you must log in.
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'os/os-private.h' | |||
2 | --- os/os-private.h 2011-06-27 17:03:25 +0000 | |||
3 | +++ os/os-private.h 2011-07-07 15:06:32 +0000 | |||
4 | @@ -36,6 +36,15 @@ | |||
5 | 36 | 36 | ||
6 | 37 | G_BEGIN_DECLS | 37 | G_BEGIN_DECLS |
7 | 38 | 38 | ||
8 | 39 | typedef enum | ||
9 | 40 | { | ||
10 | 41 | OS_EVENT_NONE = 0, | ||
11 | 42 | OS_EVENT_BUTTON_PRESS = 1, | ||
12 | 43 | OS_EVENT_ENTER_NOTIFY = 2, | ||
13 | 44 | OS_EVENT_MOTION_NOTIFY = 4, | ||
14 | 45 | OS_EVENT_VALUE_CHANGED = 8 | ||
15 | 46 | } OsEvent; | ||
16 | 47 | |||
17 | 39 | /* os-log.c */ | 48 | /* os-log.c */ |
18 | 40 | 49 | ||
19 | 41 | /* Severity levels. */ | 50 | /* Severity levels. */ |
20 | @@ -71,7 +80,7 @@ | |||
21 | 71 | } \ | 80 | } \ |
22 | 72 | } G_STMT_END | 81 | } G_STMT_END |
23 | 73 | 82 | ||
25 | 74 | /* Macro loggging an error message to stderr and breaking the program execution | 83 | /* Macro logging an error message to stderr and breaking the program execution |
26 | 75 | * if the assertion fails. */ | 84 | * if the assertion fails. */ |
27 | 76 | #define OS_CHECK(cond) \ | 85 | #define OS_CHECK(cond) \ |
28 | 77 | G_STMT_START { \ | 86 | G_STMT_START { \ |
29 | 78 | 87 | ||
30 | === modified file 'os/os-scrollbar.c' | |||
31 | --- os/os-scrollbar.c 2011-07-05 18:13:09 +0000 | |||
32 | +++ os/os-scrollbar.c 2011-07-07 15:06:32 +0000 | |||
33 | @@ -91,13 +91,11 @@ | |||
34 | 91 | OsAnimation *animation; | 91 | OsAnimation *animation; |
35 | 92 | OsPager *pager; | 92 | OsPager *pager; |
36 | 93 | OsSide side; | 93 | OsSide side; |
41 | 94 | gboolean button_press_event; | 94 | OsEvent event; |
38 | 95 | gboolean enter_notify_event; | ||
39 | 96 | gboolean motion_notify_event; | ||
40 | 97 | gboolean value_changed_event; | ||
42 | 98 | gboolean active_window; | 95 | gboolean active_window; |
43 | 99 | gboolean can_deactivate_pager; | 96 | gboolean can_deactivate_pager; |
44 | 100 | gboolean can_hide; | 97 | gboolean can_hide; |
45 | 98 | gboolean detached_scroll; | ||
46 | 101 | gboolean filter; | 99 | gboolean filter; |
47 | 102 | gboolean fullsize; | 100 | gboolean fullsize; |
48 | 103 | gboolean internal; | 101 | gboolean internal; |
49 | @@ -368,10 +366,7 @@ | |||
50 | 368 | priv = scrollbar->priv; | 366 | priv = scrollbar->priv; |
51 | 369 | 367 | ||
52 | 370 | if (priv->can_hide) | 368 | if (priv->can_hide) |
57 | 371 | { | 369 | gtk_widget_hide (priv->thumb); |
54 | 372 | priv->value_changed_event = FALSE; | ||
55 | 373 | gtk_widget_hide (priv->thumb); | ||
56 | 374 | } | ||
58 | 375 | } | 370 | } |
59 | 376 | 371 | ||
60 | 377 | /* timeout before hiding the thumb */ | 372 | /* timeout before hiding the thumb */ |
61 | @@ -773,19 +768,6 @@ | |||
62 | 773 | gtk_adjustment_set_value (priv->adjustment, new_value); | 768 | gtk_adjustment_set_value (priv->adjustment, new_value); |
63 | 774 | } | 769 | } |
64 | 775 | 770 | ||
65 | 776 | /* stop_func called by the set-scroll animation */ | ||
66 | 777 | static void | ||
67 | 778 | set_scroll_stop_cb (gpointer user_data) | ||
68 | 779 | { | ||
69 | 780 | OsScrollbar *scrollbar; | ||
70 | 781 | OsScrollbarPrivate *priv; | ||
71 | 782 | |||
72 | 783 | scrollbar = OS_SCROLLBAR (user_data); | ||
73 | 784 | priv = scrollbar->priv; | ||
74 | 785 | |||
75 | 786 | priv->value = gtk_adjustment_get_value (priv->adjustment); | ||
76 | 787 | } | ||
77 | 788 | |||
78 | 789 | /* swap adjustment pointer */ | 771 | /* swap adjustment pointer */ |
79 | 790 | static void | 772 | static void |
80 | 791 | swap_adjustment (OsScrollbar *scrollbar, | 773 | swap_adjustment (OsScrollbar *scrollbar, |
81 | @@ -933,12 +915,98 @@ | |||
82 | 933 | calc_layout_pager (scrollbar, gtk_adjustment_get_value (adjustment)); | 915 | calc_layout_pager (scrollbar, gtk_adjustment_get_value (adjustment)); |
83 | 934 | calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment)); | 916 | calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment)); |
84 | 935 | 917 | ||
86 | 936 | if (!priv->motion_notify_event && !priv->enter_notify_event) | 918 | if (!(priv->event & OS_EVENT_ENTER_NOTIFY) && |
87 | 919 | !(priv->event & OS_EVENT_MOTION_NOTIFY)) | ||
88 | 937 | gtk_widget_hide (priv->thumb); | 920 | gtk_widget_hide (priv->thumb); |
89 | 938 | 921 | ||
90 | 939 | move_pager (scrollbar); | 922 | move_pager (scrollbar); |
91 | 940 | } | 923 | } |
92 | 941 | 924 | ||
93 | 925 | /* update the visual connection between pager and thumb. */ | ||
94 | 926 | static void | ||
95 | 927 | update_visual_connection (OsScrollbar *scrollbar) | ||
96 | 928 | { | ||
97 | 929 | OsScrollbarPrivate *priv; | ||
98 | 930 | gint x_pos, y_pos; | ||
99 | 931 | |||
100 | 932 | priv = scrollbar->priv; | ||
101 | 933 | |||
102 | 934 | gdk_window_get_origin (gtk_widget_get_window (priv->thumb), &x_pos, &y_pos); | ||
103 | 935 | |||
104 | 936 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | ||
105 | 937 | { | ||
106 | 938 | if (priv->win_y + priv->overlay.y >= y_pos + priv->slider.height) | ||
107 | 939 | { | ||
108 | 940 | GdkRectangle mask; | ||
109 | 941 | |||
110 | 942 | mask.x = 0; | ||
111 | 943 | mask.y = y_pos + priv->slider.height / 2 - priv->win_y; | ||
112 | 944 | mask.width = priv->pager_all.width; | ||
113 | 945 | mask.height = priv->overlay.y - mask.y; | ||
114 | 946 | |||
115 | 947 | os_pager_connect (priv->pager, mask); | ||
116 | 948 | os_pager_set_detached (priv->pager, TRUE); | ||
117 | 949 | |||
118 | 950 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); | ||
119 | 951 | } | ||
120 | 952 | else if (priv->win_y + priv->overlay.y + priv->overlay.height <= y_pos) | ||
121 | 953 | { | ||
122 | 954 | GdkRectangle mask; | ||
123 | 955 | |||
124 | 956 | mask.x = 0; | ||
125 | 957 | mask.y = priv->overlay.y + priv->overlay.height; | ||
126 | 958 | mask.width = priv->pager_all.width; | ||
127 | 959 | mask.height = y_pos + priv->slider.height / 2 - priv->win_y - mask.y; | ||
128 | 960 | |||
129 | 961 | os_pager_connect (priv->pager, mask); | ||
130 | 962 | os_pager_set_detached (priv->pager, TRUE); | ||
131 | 963 | |||
132 | 964 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); | ||
133 | 965 | } | ||
134 | 966 | else | ||
135 | 967 | { | ||
136 | 968 | os_pager_set_detached (priv->pager, FALSE); | ||
137 | 969 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); | ||
138 | 970 | } | ||
139 | 971 | } | ||
140 | 972 | else | ||
141 | 973 | { | ||
142 | 974 | if (priv->win_x + priv->overlay.x >= x_pos + priv->slider.width) | ||
143 | 975 | { | ||
144 | 976 | GdkRectangle mask; | ||
145 | 977 | |||
146 | 978 | mask.x = x_pos + priv->slider.width / 2 - priv->win_x; | ||
147 | 979 | mask.y = 0; | ||
148 | 980 | mask.width = priv->overlay.x - mask.x; | ||
149 | 981 | mask.height = priv->pager_all.height; | ||
150 | 982 | |||
151 | 983 | os_pager_connect (priv->pager, mask); | ||
152 | 984 | os_pager_set_detached (priv->pager, TRUE); | ||
153 | 985 | |||
154 | 986 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); | ||
155 | 987 | } | ||
156 | 988 | else if (priv->win_x + priv->overlay.x + priv->overlay.width <= x_pos) | ||
157 | 989 | { | ||
158 | 990 | GdkRectangle mask; | ||
159 | 991 | |||
160 | 992 | mask.x = priv->overlay.x + priv->overlay.width; | ||
161 | 993 | mask.y = 0; | ||
162 | 994 | mask.width = x_pos + priv->slider.width / 2 - priv->win_x - mask.x; | ||
163 | 995 | mask.height = priv->pager_all.height; | ||
164 | 996 | |||
165 | 997 | os_pager_connect (priv->pager, mask); | ||
166 | 998 | os_pager_set_detached (priv->pager, TRUE); | ||
167 | 999 | |||
168 | 1000 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); | ||
169 | 1001 | } | ||
170 | 1002 | else | ||
171 | 1003 | { | ||
172 | 1004 | os_pager_set_detached (priv->pager, FALSE); | ||
173 | 1005 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); | ||
174 | 1006 | } | ||
175 | 1007 | } | ||
176 | 1008 | } | ||
177 | 1009 | |||
178 | 942 | static void | 1010 | static void |
179 | 943 | adjustment_value_changed_cb (GtkAdjustment *adjustment, | 1011 | adjustment_value_changed_cb (GtkAdjustment *adjustment, |
180 | 944 | gpointer user_data) | 1012 | gpointer user_data) |
181 | @@ -952,95 +1020,20 @@ | |||
182 | 952 | calc_layout_pager (scrollbar, gtk_adjustment_get_value (adjustment)); | 1020 | calc_layout_pager (scrollbar, gtk_adjustment_get_value (adjustment)); |
183 | 953 | calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment)); | 1021 | calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment)); |
184 | 954 | 1022 | ||
186 | 955 | if (!priv->motion_notify_event && !priv->enter_notify_event) | 1023 | if (!(priv->event & OS_EVENT_ENTER_NOTIFY) && |
187 | 1024 | !(priv->event & OS_EVENT_MOTION_NOTIFY)) | ||
188 | 956 | gtk_widget_hide (priv->thumb); | 1025 | gtk_widget_hide (priv->thumb); |
189 | 957 | 1026 | ||
190 | 958 | if (gtk_widget_get_mapped (priv->thumb)) | 1027 | if (gtk_widget_get_mapped (priv->thumb)) |
191 | 959 | { | 1028 | { |
192 | 960 | /* if we're dragging the thumb, it can't be detached. */ | 1029 | /* if we're dragging the thumb, it can't be detached. */ |
194 | 961 | if (priv->motion_notify_event) | 1030 | if (priv->event & OS_EVENT_MOTION_NOTIFY) |
195 | 962 | { | 1031 | { |
196 | 963 | os_pager_set_detached (priv->pager, FALSE); | 1032 | os_pager_set_detached (priv->pager, FALSE); |
197 | 964 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); | 1033 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); |
198 | 965 | } | 1034 | } |
199 | 966 | else | 1035 | else |
277 | 967 | { | 1036 | update_visual_connection (scrollbar); |
201 | 968 | gint x_pos, y_pos; | ||
202 | 969 | gdk_window_get_origin (gtk_widget_get_window (priv->thumb), &x_pos, &y_pos); | ||
203 | 970 | |||
204 | 971 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | ||
205 | 972 | { | ||
206 | 973 | if (priv->win_y + priv->overlay.y > y_pos + priv->slider.height) | ||
207 | 974 | { | ||
208 | 975 | GdkRectangle mask; | ||
209 | 976 | |||
210 | 977 | mask.x = 0; | ||
211 | 978 | mask.y = y_pos + priv->slider.height / 2 - priv->win_y; | ||
212 | 979 | mask.width = priv->pager_all.width; | ||
213 | 980 | mask.height = priv->overlay.y - mask.y; | ||
214 | 981 | |||
215 | 982 | os_pager_connect (priv->pager, mask); | ||
216 | 983 | os_pager_set_detached (priv->pager, TRUE); | ||
217 | 984 | |||
218 | 985 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); | ||
219 | 986 | } | ||
220 | 987 | else if (priv->win_y + priv->overlay.y + priv->overlay.height < y_pos) | ||
221 | 988 | { | ||
222 | 989 | GdkRectangle mask; | ||
223 | 990 | |||
224 | 991 | mask.x = 0; | ||
225 | 992 | mask.y = priv->overlay.y + priv->overlay.height; | ||
226 | 993 | mask.width = priv->pager_all.width; | ||
227 | 994 | mask.height = y_pos + priv->slider.height / 2 - priv->win_y - mask.y; | ||
228 | 995 | |||
229 | 996 | os_pager_connect (priv->pager, mask); | ||
230 | 997 | os_pager_set_detached (priv->pager, TRUE); | ||
231 | 998 | |||
232 | 999 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); | ||
233 | 1000 | } | ||
234 | 1001 | else | ||
235 | 1002 | { | ||
236 | 1003 | os_pager_set_detached (priv->pager, FALSE); | ||
237 | 1004 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); | ||
238 | 1005 | } | ||
239 | 1006 | } | ||
240 | 1007 | else | ||
241 | 1008 | { | ||
242 | 1009 | if (priv->win_x + priv->overlay.x > x_pos + priv->slider.width) | ||
243 | 1010 | { | ||
244 | 1011 | GdkRectangle mask; | ||
245 | 1012 | |||
246 | 1013 | mask.x = x_pos + priv->slider.width / 2 - priv->win_x; | ||
247 | 1014 | mask.y = 0; | ||
248 | 1015 | mask.width = priv->overlay.x - mask.x; | ||
249 | 1016 | mask.height = priv->pager_all.height; | ||
250 | 1017 | |||
251 | 1018 | os_pager_connect (priv->pager, mask); | ||
252 | 1019 | os_pager_set_detached (priv->pager, TRUE); | ||
253 | 1020 | |||
254 | 1021 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); | ||
255 | 1022 | } | ||
256 | 1023 | else if (priv->win_x + priv->overlay.x + priv->overlay.width < x_pos) | ||
257 | 1024 | { | ||
258 | 1025 | GdkRectangle mask; | ||
259 | 1026 | |||
260 | 1027 | mask.x = priv->overlay.x + priv->overlay.width; | ||
261 | 1028 | mask.y = 0; | ||
262 | 1029 | mask.width = x_pos + priv->slider.width / 2 - priv->win_x - mask.x; | ||
263 | 1030 | mask.height = priv->pager_all.height; | ||
264 | 1031 | |||
265 | 1032 | os_pager_connect (priv->pager, mask); | ||
266 | 1033 | os_pager_set_detached (priv->pager, TRUE); | ||
267 | 1034 | |||
268 | 1035 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); | ||
269 | 1036 | } | ||
270 | 1037 | else | ||
271 | 1038 | { | ||
272 | 1039 | os_pager_set_detached (priv->pager, FALSE); | ||
273 | 1040 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); | ||
274 | 1041 | } | ||
275 | 1042 | } | ||
276 | 1043 | } | ||
278 | 1044 | } | 1037 | } |
279 | 1045 | 1038 | ||
280 | 1046 | move_pager (scrollbar); | 1039 | move_pager (scrollbar); |
281 | @@ -1257,8 +1250,10 @@ | |||
282 | 1257 | priv->present_time = g_get_monotonic_time (); | 1250 | priv->present_time = g_get_monotonic_time (); |
283 | 1258 | present_gdk_window_with_timestamp (GTK_WIDGET (scrollbar), event->time); | 1251 | present_gdk_window_with_timestamp (GTK_WIDGET (scrollbar), event->time); |
284 | 1259 | 1252 | ||
287 | 1260 | priv->button_press_event = TRUE; | 1253 | priv->event |= OS_EVENT_BUTTON_PRESS; |
288 | 1261 | priv->motion_notify_event = FALSE; | 1254 | priv->event &= ~(OS_EVENT_MOTION_NOTIFY); |
289 | 1255 | |||
290 | 1256 | priv->detached_scroll = FALSE; | ||
291 | 1262 | 1257 | ||
292 | 1263 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 1258 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
293 | 1264 | { | 1259 | { |
294 | @@ -1352,7 +1347,7 @@ | |||
295 | 1352 | 1347 | ||
296 | 1353 | gtk_window_set_transient_for (GTK_WINDOW (widget), NULL); | 1348 | gtk_window_set_transient_for (GTK_WINDOW (widget), NULL); |
297 | 1354 | 1349 | ||
299 | 1355 | if (!priv->motion_notify_event) | 1350 | if (!(priv->event & OS_EVENT_MOTION_NOTIFY) && !priv->detached_scroll) |
300 | 1356 | { | 1351 | { |
301 | 1357 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 1352 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
302 | 1358 | { | 1353 | { |
303 | @@ -1369,11 +1364,10 @@ | |||
304 | 1369 | page_down (scrollbar); | 1364 | page_down (scrollbar); |
305 | 1370 | } | 1365 | } |
306 | 1371 | 1366 | ||
308 | 1372 | priv->value_changed_event = TRUE; | 1367 | priv->event |= OS_EVENT_VALUE_CHANGED; |
309 | 1373 | } | 1368 | } |
310 | 1374 | 1369 | ||
313 | 1375 | priv->button_press_event = FALSE; | 1370 | priv->event &= ~(OS_EVENT_BUTTON_PRESS | OS_EVENT_MOTION_NOTIFY); |
312 | 1376 | priv->motion_notify_event = FALSE; | ||
314 | 1377 | } | 1371 | } |
315 | 1378 | } | 1372 | } |
316 | 1379 | 1373 | ||
317 | @@ -1391,7 +1385,8 @@ | |||
318 | 1391 | scrollbar = OS_SCROLLBAR (user_data); | 1385 | scrollbar = OS_SCROLLBAR (user_data); |
319 | 1392 | priv = scrollbar->priv; | 1386 | priv = scrollbar->priv; |
320 | 1393 | 1387 | ||
322 | 1394 | priv->enter_notify_event = TRUE; | 1388 | priv->event |= OS_EVENT_ENTER_NOTIFY; |
323 | 1389 | |||
324 | 1395 | priv->can_deactivate_pager = FALSE; | 1390 | priv->can_deactivate_pager = FALSE; |
325 | 1396 | priv->can_hide = FALSE; | 1391 | priv->can_hide = FALSE; |
326 | 1397 | 1392 | ||
327 | @@ -1414,7 +1409,7 @@ | |||
328 | 1414 | 1409 | ||
329 | 1415 | /* add the timeouts only if you are | 1410 | /* add the timeouts only if you are |
330 | 1416 | * not interacting with the thumb. */ | 1411 | * not interacting with the thumb. */ |
332 | 1417 | if (!priv->button_press_event) | 1412 | if (!(priv->event & OS_EVENT_BUTTON_PRESS)) |
333 | 1418 | { | 1413 | { |
334 | 1419 | /* never deactivate the pager in an active window. */ | 1414 | /* never deactivate the pager in an active window. */ |
335 | 1420 | if (!priv->active_window) | 1415 | if (!priv->active_window) |
336 | @@ -1586,46 +1581,6 @@ | |||
337 | 1586 | gtk_adjustment_set_value (priv->adjustment, new_value); | 1581 | gtk_adjustment_set_value (priv->adjustment, new_value); |
338 | 1587 | } | 1582 | } |
339 | 1588 | 1583 | ||
340 | 1589 | /* from pointer movement, store the right adjustment value */ | ||
341 | 1590 | static void | ||
342 | 1591 | capture_movement_for_animation (OsScrollbar *scrollbar, | ||
343 | 1592 | gint mouse_x, | ||
344 | 1593 | gint mouse_y) | ||
345 | 1594 | { | ||
346 | 1595 | OsScrollbarPrivate *priv; | ||
347 | 1596 | gint delta; | ||
348 | 1597 | gint c; | ||
349 | 1598 | gdouble current_value, old_value, new_value; | ||
350 | 1599 | |||
351 | 1600 | priv = scrollbar->priv; | ||
352 | 1601 | |||
353 | 1602 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | ||
354 | 1603 | delta = mouse_y - priv->slide_initial_coordinate; | ||
355 | 1604 | else | ||
356 | 1605 | delta = mouse_x - priv->slide_initial_coordinate; | ||
357 | 1606 | |||
358 | 1607 | c = priv->slide_initial_slider_position + delta; | ||
359 | 1608 | |||
360 | 1609 | current_value = gtk_adjustment_get_value (priv->adjustment); | ||
361 | 1610 | old_value = priv->value; | ||
362 | 1611 | new_value = coord_to_value (scrollbar, c); | ||
363 | 1612 | |||
364 | 1613 | /* stop the animation if we are connecting. */ | ||
365 | 1614 | if ((current_value > old_value && | ||
366 | 1615 | new_value > current_value) || | ||
367 | 1616 | (current_value < old_value && | ||
368 | 1617 | new_value < current_value)) | ||
369 | 1618 | { | ||
370 | 1619 | os_animation_stop (priv->animation, NULL); | ||
371 | 1620 | |||
372 | 1621 | gtk_adjustment_set_value (priv->adjustment, new_value); | ||
373 | 1622 | } | ||
374 | 1623 | |||
375 | 1624 | /* update the adjustment value for the reconnect animation: | ||
376 | 1625 | * set_scroll_cb could be running at that time. */ | ||
377 | 1626 | priv->value = new_value; | ||
378 | 1627 | } | ||
379 | 1628 | |||
380 | 1629 | static gboolean | 1584 | static gboolean |
381 | 1630 | thumb_motion_notify_event_cb (GtkWidget *widget, | 1585 | thumb_motion_notify_event_cb (GtkWidget *widget, |
382 | 1631 | GdkEventMotion *event, | 1586 | GdkEventMotion *event, |
383 | @@ -1637,72 +1592,129 @@ | |||
384 | 1637 | scrollbar = OS_SCROLLBAR (user_data); | 1592 | scrollbar = OS_SCROLLBAR (user_data); |
385 | 1638 | priv = scrollbar->priv; | 1593 | priv = scrollbar->priv; |
386 | 1639 | 1594 | ||
388 | 1640 | if (priv->button_press_event) | 1595 | if (priv->event & OS_EVENT_BUTTON_PRESS) |
389 | 1641 | { | 1596 | { |
390 | 1642 | gint x, y; | 1597 | gint x, y; |
391 | 1643 | 1598 | ||
394 | 1644 | /* reconnect slider and overlay after key press */ | 1599 | /* thumb and pager are detached. |
395 | 1645 | if (priv->value_changed_event) | 1600 | * Detached scroll: keep the thumb detached during the scroll, |
396 | 1601 | * update the visual connection when reaching an edge. */ | ||
397 | 1602 | if (priv->event & OS_EVENT_VALUE_CHANGED) | ||
398 | 1646 | { | 1603 | { |
399 | 1647 | /* return if the mouse movement is small. */ | 1604 | /* return if the mouse movement is small. */ |
400 | 1648 | if (abs (priv->pointer_x - event->x) <= TOLERANCE_PIXELS && | 1605 | if (abs (priv->pointer_x - event->x) <= TOLERANCE_PIXELS && |
401 | 1649 | abs (priv->pointer_y - event->y) <= TOLERANCE_PIXELS) | 1606 | abs (priv->pointer_y - event->y) <= TOLERANCE_PIXELS) |
402 | 1650 | return FALSE; | 1607 | return FALSE; |
403 | 1651 | 1608 | ||
414 | 1652 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 1609 | priv->detached_scroll = TRUE; |
405 | 1653 | { | ||
406 | 1654 | priv->slide_initial_slider_position = event->y_root - priv->win_y - event->y; | ||
407 | 1655 | priv->slide_initial_coordinate = event->y_root; | ||
408 | 1656 | } | ||
409 | 1657 | else | ||
410 | 1658 | { | ||
411 | 1659 | priv->slide_initial_slider_position = event->x_root - priv->win_x - event->x; | ||
412 | 1660 | priv->slide_initial_coordinate = event->x_root; | ||
413 | 1661 | } | ||
415 | 1662 | 1610 | ||
416 | 1663 | /* stop the scroll animation if it's running. */ | 1611 | /* stop the scroll animation if it's running. */ |
435 | 1664 | os_animation_stop (priv->animation, set_scroll_stop_cb); | 1612 | os_animation_stop (priv->animation, NULL); |
436 | 1665 | 1613 | ||
437 | 1666 | /* set the initial adjustment value required for reconnect. */ | 1614 | /* limit x and y within the allocation. */ |
420 | 1667 | capture_movement_for_animation (scrollbar, event->x_root, event->y_root); | ||
421 | 1668 | |||
422 | 1669 | /* animate the reconnect, using the same animation object. */ | ||
423 | 1670 | os_animation_start (priv->animation); | ||
424 | 1671 | |||
425 | 1672 | priv->value_changed_event = FALSE; | ||
426 | 1673 | } | ||
427 | 1674 | |||
428 | 1675 | /* only the reconnect animation can be running at that time. */ | ||
429 | 1676 | if (os_animation_is_running (priv->animation)) | ||
430 | 1677 | { | ||
431 | 1678 | /* update the adjustment value. */ | ||
432 | 1679 | capture_movement_for_animation (scrollbar, event->x_root, event->y_root); | ||
433 | 1680 | |||
434 | 1681 | /* limit x and y within the thumb allocation. */ | ||
438 | 1682 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 1615 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
439 | 1683 | { | 1616 | { |
440 | 1684 | x = priv->win_x; | 1617 | x = priv->win_x; |
441 | 1685 | y = CLAMP (event->y_root - priv->pointer_y, | 1618 | y = CLAMP (event->y_root - priv->pointer_y, |
442 | 1686 | priv->win_y, | 1619 | priv->win_y, |
444 | 1687 | priv->win_y + priv->thumb_all.height); | 1620 | priv->win_y + priv->thumb_all.height - priv->slider.height); |
445 | 1688 | } | 1621 | } |
446 | 1689 | else | 1622 | else |
447 | 1690 | { | 1623 | { |
448 | 1691 | x = CLAMP (event->x_root - priv->pointer_x, | 1624 | x = CLAMP (event->x_root - priv->pointer_x, |
449 | 1692 | priv->win_x, | 1625 | priv->win_x, |
451 | 1693 | priv->win_x + priv->thumb_all.width); | 1626 | priv->win_x + priv->thumb_all.width - priv->slider.width); |
452 | 1694 | y = priv->win_y; | 1627 | y = priv->win_y; |
453 | 1695 | } | 1628 | } |
454 | 1696 | 1629 | ||
455 | 1630 | /* fine scroll while detached, | ||
456 | 1631 | * do not scroll when hitting an edge. */ | ||
457 | 1632 | if ((priv->orientation == GTK_ORIENTATION_VERTICAL && | ||
458 | 1633 | y > priv->win_y && | ||
459 | 1634 | y < priv->win_y + priv->thumb_all.height - priv->slider.height) || | ||
460 | 1635 | (priv->orientation == GTK_ORIENTATION_HORIZONTAL && | ||
461 | 1636 | x > priv->win_x && | ||
462 | 1637 | x < priv->win_x + priv->thumb_all.width - priv->slider.width)) | ||
463 | 1638 | capture_movement (scrollbar, event->x_root, event->y_root); | ||
464 | 1639 | |||
465 | 1697 | move_thumb (scrollbar, x, y); | 1640 | move_thumb (scrollbar, x, y); |
466 | 1698 | 1641 | ||
471 | 1699 | /* return if the reconnect animation is still running after | 1642 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
472 | 1700 | * capture_movement_for_animation. */ | 1643 | { |
473 | 1701 | if (os_animation_is_running (priv->animation)) | 1644 | if (gtk_adjustment_get_value (priv->adjustment) == 0) |
474 | 1702 | return FALSE; | 1645 | { |
475 | 1646 | update_visual_connection (scrollbar); | ||
476 | 1647 | |||
477 | 1648 | if (priv->overlay.height > priv->slider.height) | ||
478 | 1649 | { | ||
479 | 1650 | priv->slide_initial_slider_position = 0; | ||
480 | 1651 | priv->slide_initial_coordinate = MAX (event->y_root, priv->win_y + priv->pointer_y); | ||
481 | 1652 | } | ||
482 | 1653 | else | ||
483 | 1654 | { | ||
484 | 1655 | priv->slide_initial_slider_position = 0; | ||
485 | 1656 | priv->slide_initial_coordinate = event->y_root; | ||
486 | 1657 | } | ||
487 | 1658 | } | ||
488 | 1659 | else if (priv->overlay.y + priv->overlay.height >= priv->trough.height) | ||
489 | 1660 | { | ||
490 | 1661 | update_visual_connection (scrollbar); | ||
491 | 1662 | |||
492 | 1663 | if (priv->overlay.height > priv->slider.height) | ||
493 | 1664 | { | ||
494 | 1665 | priv->slide_initial_slider_position = priv->trough.height - priv->overlay.height; | ||
495 | 1666 | priv->slide_initial_coordinate = MAX (event->y_root, priv->win_y + priv->pointer_y); | ||
496 | 1667 | } | ||
497 | 1668 | else | ||
498 | 1669 | { | ||
499 | 1670 | priv->slide_initial_slider_position = priv->trough.height - priv->slider.height; | ||
500 | 1671 | priv->slide_initial_coordinate = event->y_root; | ||
501 | 1672 | } | ||
502 | 1673 | } | ||
503 | 1674 | } | ||
504 | 1675 | else | ||
505 | 1676 | { | ||
506 | 1677 | if (gtk_adjustment_get_value (priv->adjustment) == 0) | ||
507 | 1678 | { | ||
508 | 1679 | update_visual_connection (scrollbar); | ||
509 | 1680 | |||
510 | 1681 | if (priv->overlay.width > priv->slider.width) | ||
511 | 1682 | { | ||
512 | 1683 | priv->slide_initial_slider_position = 0; | ||
513 | 1684 | priv->slide_initial_coordinate = MAX (event->x_root, priv->win_x + priv->pointer_x); | ||
514 | 1685 | } | ||
515 | 1686 | else | ||
516 | 1687 | { | ||
517 | 1688 | priv->slide_initial_slider_position = 0; | ||
518 | 1689 | priv->slide_initial_coordinate = event->x_root; | ||
519 | 1690 | } | ||
520 | 1691 | } | ||
521 | 1692 | else if (priv->overlay.x + priv->overlay.width >= priv->trough.width) | ||
522 | 1693 | { | ||
523 | 1694 | update_visual_connection (scrollbar); | ||
524 | 1695 | |||
525 | 1696 | if (priv->overlay.width > priv->slider.width) | ||
526 | 1697 | { | ||
527 | 1698 | priv->slide_initial_slider_position = priv->trough.width - priv->overlay.width; | ||
528 | 1699 | priv->slide_initial_coordinate = MAX (event->x_root, priv->win_x + priv->pointer_x); | ||
529 | 1700 | } | ||
530 | 1701 | else | ||
531 | 1702 | { | ||
532 | 1703 | priv->slide_initial_slider_position = priv->trough.width - priv->slider.width; | ||
533 | 1704 | priv->slide_initial_coordinate = event->x_root; | ||
534 | 1705 | } | ||
535 | 1706 | } | ||
536 | 1707 | } | ||
537 | 1708 | |||
538 | 1709 | return FALSE; | ||
539 | 1703 | } | 1710 | } |
540 | 1704 | 1711 | ||
542 | 1705 | priv->motion_notify_event = TRUE; | 1712 | OS_DCHECK (!priv->detached_scroll); |
543 | 1713 | |||
544 | 1714 | /* thumb and pager are connected. | ||
545 | 1715 | * Normal scroll: keep the thumb in sync with the pager, | ||
546 | 1716 | * do not update the visual connection. */ | ||
547 | 1717 | priv->event |= OS_EVENT_MOTION_NOTIFY; | ||
548 | 1706 | 1718 | ||
549 | 1707 | capture_movement (scrollbar, event->x_root, event->y_root); | 1719 | capture_movement (scrollbar, event->x_root, event->y_root); |
550 | 1708 | 1720 | ||
551 | @@ -1798,7 +1810,7 @@ | |||
552 | 1798 | scrollbar = OS_SCROLLBAR (user_data); | 1810 | scrollbar = OS_SCROLLBAR (user_data); |
553 | 1799 | priv = scrollbar->priv; | 1811 | priv = scrollbar->priv; |
554 | 1800 | 1812 | ||
556 | 1801 | priv->value_changed_event = TRUE; | 1813 | priv->event |= OS_EVENT_VALUE_CHANGED; |
557 | 1802 | 1814 | ||
558 | 1803 | delta = get_wheel_delta (scrollbar, event->direction); | 1815 | delta = get_wheel_delta (scrollbar, event->direction); |
559 | 1804 | 1816 | ||
560 | @@ -1821,9 +1833,9 @@ | |||
561 | 1821 | scrollbar = OS_SCROLLBAR (user_data); | 1833 | scrollbar = OS_SCROLLBAR (user_data); |
562 | 1822 | priv = scrollbar->priv; | 1834 | priv = scrollbar->priv; |
563 | 1823 | 1835 | ||
567 | 1824 | priv->button_press_event = FALSE; | 1836 | priv->event = OS_EVENT_NONE; |
568 | 1825 | priv->motion_notify_event = FALSE; | 1837 | |
569 | 1826 | priv->enter_notify_event = FALSE; | 1838 | priv->detached_scroll = FALSE; |
570 | 1827 | 1839 | ||
571 | 1828 | os_pager_set_detached (priv->pager, FALSE); | 1840 | os_pager_set_detached (priv->pager, FALSE); |
572 | 1829 | } | 1841 | } |
573 | @@ -2555,14 +2567,12 @@ | |||
574 | 2555 | os_root_list = g_list_append (os_root_list, scrollbar); | 2567 | os_root_list = g_list_append (os_root_list, scrollbar); |
575 | 2556 | } | 2568 | } |
576 | 2557 | 2569 | ||
581 | 2558 | priv->button_press_event = FALSE; | 2570 | priv->event = OS_EVENT_NONE; |
578 | 2559 | priv->enter_notify_event = FALSE; | ||
579 | 2560 | priv->motion_notify_event = FALSE; | ||
580 | 2561 | priv->value_changed_event = FALSE; | ||
582 | 2562 | 2571 | ||
583 | 2563 | priv->active_window = FALSE; | 2572 | priv->active_window = FALSE; |
584 | 2564 | priv->can_deactivate_pager = TRUE; | 2573 | priv->can_deactivate_pager = TRUE; |
585 | 2565 | priv->can_hide = TRUE; | 2574 | priv->can_hide = TRUE; |
586 | 2575 | priv->detached_scroll = FALSE; | ||
587 | 2566 | priv->filter = FALSE; | 2576 | priv->filter = FALSE; |
588 | 2567 | priv->fullsize = FALSE; | 2577 | priv->fullsize = FALSE; |
589 | 2568 | priv->internal = FALSE; | 2578 | priv->internal = FALSE; |
590 | 2569 | 2579 | ||
591 | === modified file 'os/os-thumb.c' | |||
592 | --- os/os-thumb.c 2011-06-30 10:52:41 +0000 | |||
593 | +++ os/os-thumb.c 2011-07-07 15:06:32 +0000 | |||
594 | @@ -56,8 +56,7 @@ | |||
595 | 56 | GtkOrientation orientation; | 56 | GtkOrientation orientation; |
596 | 57 | GtkWidget *grabbed_widget; | 57 | GtkWidget *grabbed_widget; |
597 | 58 | OsAnimation *animation; | 58 | OsAnimation *animation; |
600 | 59 | gboolean button_press_event; | 59 | OsEvent event; |
599 | 60 | gboolean motion_notify_event; | ||
601 | 61 | gboolean can_rgba; | 60 | gboolean can_rgba; |
602 | 62 | gboolean detached; | 61 | gboolean detached; |
603 | 63 | gboolean use_tolerance; | 62 | gboolean use_tolerance; |
604 | @@ -190,8 +189,7 @@ | |||
605 | 190 | OsThumbPrivate); | 189 | OsThumbPrivate); |
606 | 191 | priv = thumb->priv; | 190 | priv = thumb->priv; |
607 | 192 | 191 | ||
610 | 193 | priv->button_press_event = FALSE; | 192 | priv->event = OS_EVENT_NONE; |
609 | 194 | priv->motion_notify_event = FALSE; | ||
611 | 195 | 193 | ||
612 | 196 | priv->can_rgba = FALSE; | 194 | priv->can_rgba = FALSE; |
613 | 197 | priv->detached = FALSE; | 195 | priv->detached = FALSE; |
614 | @@ -245,8 +243,8 @@ | |||
615 | 245 | priv->pointer_x = event->x; | 243 | priv->pointer_x = event->x; |
616 | 246 | priv->pointer_y = event->y; | 244 | priv->pointer_y = event->y; |
617 | 247 | 245 | ||
620 | 248 | priv->button_press_event = TRUE; | 246 | priv->event |= OS_EVENT_BUTTON_PRESS; |
621 | 249 | priv->motion_notify_event = FALSE; | 247 | priv->event &= ~(OS_EVENT_MOTION_NOTIFY); |
622 | 250 | 248 | ||
623 | 251 | priv->use_tolerance = TRUE; | 249 | priv->use_tolerance = TRUE; |
624 | 252 | 250 | ||
625 | @@ -276,8 +274,7 @@ | |||
626 | 276 | { | 274 | { |
627 | 277 | gtk_grab_remove (widget); | 275 | gtk_grab_remove (widget); |
628 | 278 | 276 | ||
631 | 279 | priv->button_press_event = FALSE; | 277 | priv->event &= ~(OS_EVENT_BUTTON_PRESS | OS_EVENT_MOTION_NOTIFY); |
630 | 280 | priv->motion_notify_event = FALSE; | ||
632 | 281 | 278 | ||
633 | 282 | gtk_widget_queue_draw (widget); | 279 | gtk_widget_queue_draw (widget); |
634 | 283 | } | 280 | } |
635 | @@ -687,7 +684,8 @@ | |||
636 | 687 | else | 684 | else |
637 | 688 | pat = cairo_pattern_create_linear (0, 0, width, 0); | 685 | pat = cairo_pattern_create_linear (0, 0, width, 0); |
638 | 689 | 686 | ||
640 | 690 | if (priv->button_press_event && !priv->motion_notify_event) | 687 | if ((priv->event & OS_EVENT_BUTTON_PRESS) && |
641 | 688 | !(priv->event & OS_EVENT_MOTION_NOTIFY)) | ||
642 | 691 | { | 689 | { |
643 | 692 | if ((priv->orientation == GTK_ORIENTATION_VERTICAL && (priv->pointer_y < height / 2)) || | 690 | if ((priv->orientation == GTK_ORIENTATION_VERTICAL && (priv->pointer_y < height / 2)) || |
644 | 693 | (priv->orientation == GTK_ORIENTATION_HORIZONTAL && (priv->pointer_x < width / 2))) | 691 | (priv->orientation == GTK_ORIENTATION_HORIZONTAL && (priv->pointer_x < width / 2))) |
645 | @@ -715,7 +713,7 @@ | |||
646 | 715 | cairo_set_source (cr, pat); | 713 | cairo_set_source (cr, pat); |
647 | 716 | cairo_pattern_destroy (pat); | 714 | cairo_pattern_destroy (pat); |
648 | 717 | 715 | ||
650 | 718 | if (priv->motion_notify_event) | 716 | if (priv->event & OS_EVENT_MOTION_NOTIFY) |
651 | 719 | { | 717 | { |
652 | 720 | cairo_fill_preserve (cr); | 718 | cairo_fill_preserve (cr); |
653 | 721 | set_source_gdk_rgba (cr, &bg_arrow_down, 0.3); | 719 | set_source_gdk_rgba (cr, &bg_arrow_down, 0.3); |
654 | @@ -837,8 +835,8 @@ | |||
655 | 837 | /* If we exit the thumb when a button is pressed, | 835 | /* If we exit the thumb when a button is pressed, |
656 | 838 | * there's no need to stop the animation, it should | 836 | * there's no need to stop the animation, it should |
657 | 839 | * already be stopped. | 837 | * already be stopped. |
660 | 840 | * Stop it only if priv->button_press_event is FALSE. */ | 838 | * Stop it only if OS_EVENT_BUTTON_PRESS is not set. */ |
661 | 841 | if (!priv->button_press_event) | 839 | if (!(priv->event & OS_EVENT_BUTTON_PRESS)) |
662 | 842 | { | 840 | { |
663 | 843 | if (priv->source_id != 0) | 841 | if (priv->source_id != 0) |
664 | 844 | { | 842 | { |
665 | @@ -901,9 +899,9 @@ | |||
666 | 901 | 899 | ||
667 | 902 | /* If you're not dragging, and you're outside | 900 | /* If you're not dragging, and you're outside |
668 | 903 | * the tolerance pixels, enable the fade-out. | 901 | * the tolerance pixels, enable the fade-out. |
670 | 904 | * priv->motion_notify_event is TRUE only on dragging, | 902 | * OS_EVENT_MOTION_NOTIFY is set only on dragging, |
671 | 905 | * see code few lines below. */ | 903 | * see code few lines below. */ |
673 | 906 | if (!priv->motion_notify_event) | 904 | if (!(priv->event & OS_EVENT_MOTION_NOTIFY)) |
674 | 907 | { | 905 | { |
675 | 908 | if (!priv->use_tolerance || | 906 | if (!priv->use_tolerance || |
676 | 909 | (abs (priv->pointer_x - event->x) > TOLERANCE_PIXELS || | 907 | (abs (priv->pointer_x - event->x) > TOLERANCE_PIXELS || |
677 | @@ -916,12 +914,12 @@ | |||
678 | 916 | } | 914 | } |
679 | 917 | } | 915 | } |
680 | 918 | 916 | ||
682 | 919 | if (priv->button_press_event) | 917 | if (priv->event & OS_EVENT_BUTTON_PRESS) |
683 | 920 | { | 918 | { |
685 | 921 | if (!priv->motion_notify_event) | 919 | if (!(priv->event & OS_EVENT_MOTION_NOTIFY)) |
686 | 922 | gtk_widget_queue_draw (widget); | 920 | gtk_widget_queue_draw (widget); |
687 | 923 | 921 | ||
689 | 924 | priv->motion_notify_event = TRUE; | 922 | priv->event |= OS_EVENT_MOTION_NOTIFY; |
690 | 925 | } | 923 | } |
691 | 926 | 924 | ||
692 | 927 | return FALSE; | 925 | return FALSE; |
693 | @@ -988,8 +986,7 @@ | |||
694 | 988 | thumb = OS_THUMB (widget); | 986 | thumb = OS_THUMB (widget); |
695 | 989 | priv = thumb->priv; | 987 | priv = thumb->priv; |
696 | 990 | 988 | ||
699 | 991 | priv->button_press_event = FALSE; | 989 | priv->event = OS_EVENT_NONE; |
698 | 992 | priv->motion_notify_event = FALSE; | ||
700 | 993 | 990 | ||
701 | 994 | priv->use_tolerance = FALSE; | 991 | priv->use_tolerance = FALSE; |
702 | 995 | 992 | ||
703 | @@ -1155,6 +1152,7 @@ | |||
704 | 1155 | if (priv->detached != detached) | 1152 | if (priv->detached != detached) |
705 | 1156 | { | 1153 | { |
706 | 1157 | priv->detached = detached; | 1154 | priv->detached = detached; |
707 | 1155 | |||
708 | 1158 | gtk_widget_queue_draw (GTK_WIDGET (thumb)); | 1156 | gtk_widget_queue_draw (GTK_WIDGET (thumb)); |
709 | 1159 | } | 1157 | } |
710 | 1160 | } | 1158 | } |