Merge lp:~cimi/overlay-scrollbar/use-enums into lp:overlay-scrollbar

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
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.

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
6 G_BEGIN_DECLS
7
8+typedef enum
9+{
10+ OS_EVENT_NONE = 0,
11+ OS_EVENT_BUTTON_PRESS = 1,
12+ OS_EVENT_ENTER_NOTIFY = 2,
13+ OS_EVENT_MOTION_NOTIFY = 4,
14+ OS_EVENT_VALUE_CHANGED = 8
15+} OsEvent;
16+
17 /* os-log.c */
18
19 /* Severity levels. */
20@@ -71,7 +80,7 @@
21 } \
22 } G_STMT_END
23
24-/* Macro loggging an error message to stderr and breaking the program execution
25+/* Macro logging an error message to stderr and breaking the program execution
26 * if the assertion fails. */
27 #define OS_CHECK(cond) \
28 G_STMT_START { \
29
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 OsAnimation *animation;
35 OsPager *pager;
36 OsSide side;
37- gboolean button_press_event;
38- gboolean enter_notify_event;
39- gboolean motion_notify_event;
40- gboolean value_changed_event;
41+ OsEvent event;
42 gboolean active_window;
43 gboolean can_deactivate_pager;
44 gboolean can_hide;
45+ gboolean detached_scroll;
46 gboolean filter;
47 gboolean fullsize;
48 gboolean internal;
49@@ -368,10 +366,7 @@
50 priv = scrollbar->priv;
51
52 if (priv->can_hide)
53- {
54- priv->value_changed_event = FALSE;
55- gtk_widget_hide (priv->thumb);
56- }
57+ gtk_widget_hide (priv->thumb);
58 }
59
60 /* timeout before hiding the thumb */
61@@ -773,19 +768,6 @@
62 gtk_adjustment_set_value (priv->adjustment, new_value);
63 }
64
65-/* stop_func called by the set-scroll animation */
66-static void
67-set_scroll_stop_cb (gpointer user_data)
68-{
69- OsScrollbar *scrollbar;
70- OsScrollbarPrivate *priv;
71-
72- scrollbar = OS_SCROLLBAR (user_data);
73- priv = scrollbar->priv;
74-
75- priv->value = gtk_adjustment_get_value (priv->adjustment);
76-}
77-
78 /* swap adjustment pointer */
79 static void
80 swap_adjustment (OsScrollbar *scrollbar,
81@@ -933,12 +915,98 @@
82 calc_layout_pager (scrollbar, gtk_adjustment_get_value (adjustment));
83 calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment));
84
85- if (!priv->motion_notify_event && !priv->enter_notify_event)
86+ if (!(priv->event & OS_EVENT_ENTER_NOTIFY) &&
87+ !(priv->event & OS_EVENT_MOTION_NOTIFY))
88 gtk_widget_hide (priv->thumb);
89
90 move_pager (scrollbar);
91 }
92
93+/* update the visual connection between pager and thumb. */
94+static void
95+update_visual_connection (OsScrollbar *scrollbar)
96+{
97+ OsScrollbarPrivate *priv;
98+ gint x_pos, y_pos;
99+
100+ priv = scrollbar->priv;
101+
102+ gdk_window_get_origin (gtk_widget_get_window (priv->thumb), &x_pos, &y_pos);
103+
104+ if (priv->orientation == GTK_ORIENTATION_VERTICAL)
105+ {
106+ if (priv->win_y + priv->overlay.y >= y_pos + priv->slider.height)
107+ {
108+ GdkRectangle mask;
109+
110+ mask.x = 0;
111+ mask.y = y_pos + priv->slider.height / 2 - priv->win_y;
112+ mask.width = priv->pager_all.width;
113+ mask.height = priv->overlay.y - mask.y;
114+
115+ os_pager_connect (priv->pager, mask);
116+ os_pager_set_detached (priv->pager, TRUE);
117+
118+ os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE);
119+ }
120+ else if (priv->win_y + priv->overlay.y + priv->overlay.height <= y_pos)
121+ {
122+ GdkRectangle mask;
123+
124+ mask.x = 0;
125+ mask.y = priv->overlay.y + priv->overlay.height;
126+ mask.width = priv->pager_all.width;
127+ mask.height = y_pos + priv->slider.height / 2 - priv->win_y - mask.y;
128+
129+ os_pager_connect (priv->pager, mask);
130+ os_pager_set_detached (priv->pager, TRUE);
131+
132+ os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE);
133+ }
134+ else
135+ {
136+ os_pager_set_detached (priv->pager, FALSE);
137+ os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE);
138+ }
139+ }
140+ else
141+ {
142+ if (priv->win_x + priv->overlay.x >= x_pos + priv->slider.width)
143+ {
144+ GdkRectangle mask;
145+
146+ mask.x = x_pos + priv->slider.width / 2 - priv->win_x;
147+ mask.y = 0;
148+ mask.width = priv->overlay.x - mask.x;
149+ mask.height = priv->pager_all.height;
150+
151+ os_pager_connect (priv->pager, mask);
152+ os_pager_set_detached (priv->pager, TRUE);
153+
154+ os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE);
155+ }
156+ else if (priv->win_x + priv->overlay.x + priv->overlay.width <= x_pos)
157+ {
158+ GdkRectangle mask;
159+
160+ mask.x = priv->overlay.x + priv->overlay.width;
161+ mask.y = 0;
162+ mask.width = x_pos + priv->slider.width / 2 - priv->win_x - mask.x;
163+ mask.height = priv->pager_all.height;
164+
165+ os_pager_connect (priv->pager, mask);
166+ os_pager_set_detached (priv->pager, TRUE);
167+
168+ os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE);
169+ }
170+ else
171+ {
172+ os_pager_set_detached (priv->pager, FALSE);
173+ os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE);
174+ }
175+ }
176+}
177+
178 static void
179 adjustment_value_changed_cb (GtkAdjustment *adjustment,
180 gpointer user_data)
181@@ -952,95 +1020,20 @@
182 calc_layout_pager (scrollbar, gtk_adjustment_get_value (adjustment));
183 calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment));
184
185- if (!priv->motion_notify_event && !priv->enter_notify_event)
186+ if (!(priv->event & OS_EVENT_ENTER_NOTIFY) &&
187+ !(priv->event & OS_EVENT_MOTION_NOTIFY))
188 gtk_widget_hide (priv->thumb);
189
190 if (gtk_widget_get_mapped (priv->thumb))
191 {
192 /* if we're dragging the thumb, it can't be detached. */
193- if (priv->motion_notify_event)
194+ if (priv->event & OS_EVENT_MOTION_NOTIFY)
195 {
196 os_pager_set_detached (priv->pager, FALSE);
197 os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE);
198 }
199 else
200- {
201- gint x_pos, y_pos;
202- gdk_window_get_origin (gtk_widget_get_window (priv->thumb), &x_pos, &y_pos);
203-
204- if (priv->orientation == GTK_ORIENTATION_VERTICAL)
205- {
206- if (priv->win_y + priv->overlay.y > y_pos + priv->slider.height)
207- {
208- GdkRectangle mask;
209-
210- mask.x = 0;
211- mask.y = y_pos + priv->slider.height / 2 - priv->win_y;
212- mask.width = priv->pager_all.width;
213- mask.height = priv->overlay.y - mask.y;
214-
215- os_pager_connect (priv->pager, mask);
216- os_pager_set_detached (priv->pager, TRUE);
217-
218- os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE);
219- }
220- else if (priv->win_y + priv->overlay.y + priv->overlay.height < y_pos)
221- {
222- GdkRectangle mask;
223-
224- mask.x = 0;
225- mask.y = priv->overlay.y + priv->overlay.height;
226- mask.width = priv->pager_all.width;
227- mask.height = y_pos + priv->slider.height / 2 - priv->win_y - mask.y;
228-
229- os_pager_connect (priv->pager, mask);
230- os_pager_set_detached (priv->pager, TRUE);
231-
232- os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE);
233- }
234- else
235- {
236- os_pager_set_detached (priv->pager, FALSE);
237- os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE);
238- }
239- }
240- else
241- {
242- if (priv->win_x + priv->overlay.x > x_pos + priv->slider.width)
243- {
244- GdkRectangle mask;
245-
246- mask.x = x_pos + priv->slider.width / 2 - priv->win_x;
247- mask.y = 0;
248- mask.width = priv->overlay.x - mask.x;
249- mask.height = priv->pager_all.height;
250-
251- os_pager_connect (priv->pager, mask);
252- os_pager_set_detached (priv->pager, TRUE);
253-
254- os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE);
255- }
256- else if (priv->win_x + priv->overlay.x + priv->overlay.width < x_pos)
257- {
258- GdkRectangle mask;
259-
260- mask.x = priv->overlay.x + priv->overlay.width;
261- mask.y = 0;
262- mask.width = x_pos + priv->slider.width / 2 - priv->win_x - mask.x;
263- mask.height = priv->pager_all.height;
264-
265- os_pager_connect (priv->pager, mask);
266- os_pager_set_detached (priv->pager, TRUE);
267-
268- os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE);
269- }
270- else
271- {
272- os_pager_set_detached (priv->pager, FALSE);
273- os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE);
274- }
275- }
276- }
277+ update_visual_connection (scrollbar);
278 }
279
280 move_pager (scrollbar);
281@@ -1257,8 +1250,10 @@
282 priv->present_time = g_get_monotonic_time ();
283 present_gdk_window_with_timestamp (GTK_WIDGET (scrollbar), event->time);
284
285- priv->button_press_event = TRUE;
286- priv->motion_notify_event = FALSE;
287+ priv->event |= OS_EVENT_BUTTON_PRESS;
288+ priv->event &= ~(OS_EVENT_MOTION_NOTIFY);
289+
290+ priv->detached_scroll = FALSE;
291
292 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
293 {
294@@ -1352,7 +1347,7 @@
295
296 gtk_window_set_transient_for (GTK_WINDOW (widget), NULL);
297
298- if (!priv->motion_notify_event)
299+ if (!(priv->event & OS_EVENT_MOTION_NOTIFY) && !priv->detached_scroll)
300 {
301 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
302 {
303@@ -1369,11 +1364,10 @@
304 page_down (scrollbar);
305 }
306
307- priv->value_changed_event = TRUE;
308+ priv->event |= OS_EVENT_VALUE_CHANGED;
309 }
310
311- priv->button_press_event = FALSE;
312- priv->motion_notify_event = FALSE;
313+ priv->event &= ~(OS_EVENT_BUTTON_PRESS | OS_EVENT_MOTION_NOTIFY);
314 }
315 }
316
317@@ -1391,7 +1385,8 @@
318 scrollbar = OS_SCROLLBAR (user_data);
319 priv = scrollbar->priv;
320
321- priv->enter_notify_event = TRUE;
322+ priv->event |= OS_EVENT_ENTER_NOTIFY;
323+
324 priv->can_deactivate_pager = FALSE;
325 priv->can_hide = FALSE;
326
327@@ -1414,7 +1409,7 @@
328
329 /* add the timeouts only if you are
330 * not interacting with the thumb. */
331- if (!priv->button_press_event)
332+ if (!(priv->event & OS_EVENT_BUTTON_PRESS))
333 {
334 /* never deactivate the pager in an active window. */
335 if (!priv->active_window)
336@@ -1586,46 +1581,6 @@
337 gtk_adjustment_set_value (priv->adjustment, new_value);
338 }
339
340-/* from pointer movement, store the right adjustment value */
341-static void
342-capture_movement_for_animation (OsScrollbar *scrollbar,
343- gint mouse_x,
344- gint mouse_y)
345-{
346- OsScrollbarPrivate *priv;
347- gint delta;
348- gint c;
349- gdouble current_value, old_value, new_value;
350-
351- priv = scrollbar->priv;
352-
353- if (priv->orientation == GTK_ORIENTATION_VERTICAL)
354- delta = mouse_y - priv->slide_initial_coordinate;
355- else
356- delta = mouse_x - priv->slide_initial_coordinate;
357-
358- c = priv->slide_initial_slider_position + delta;
359-
360- current_value = gtk_adjustment_get_value (priv->adjustment);
361- old_value = priv->value;
362- new_value = coord_to_value (scrollbar, c);
363-
364- /* stop the animation if we are connecting. */
365- if ((current_value > old_value &&
366- new_value > current_value) ||
367- (current_value < old_value &&
368- new_value < current_value))
369- {
370- os_animation_stop (priv->animation, NULL);
371-
372- gtk_adjustment_set_value (priv->adjustment, new_value);
373- }
374-
375- /* update the adjustment value for the reconnect animation:
376- * set_scroll_cb could be running at that time. */
377- priv->value = new_value;
378-}
379-
380 static gboolean
381 thumb_motion_notify_event_cb (GtkWidget *widget,
382 GdkEventMotion *event,
383@@ -1637,72 +1592,129 @@
384 scrollbar = OS_SCROLLBAR (user_data);
385 priv = scrollbar->priv;
386
387- if (priv->button_press_event)
388+ if (priv->event & OS_EVENT_BUTTON_PRESS)
389 {
390 gint x, y;
391
392- /* reconnect slider and overlay after key press */
393- if (priv->value_changed_event)
394+ /* thumb and pager are detached.
395+ * Detached scroll: keep the thumb detached during the scroll,
396+ * update the visual connection when reaching an edge. */
397+ if (priv->event & OS_EVENT_VALUE_CHANGED)
398 {
399 /* return if the mouse movement is small. */
400 if (abs (priv->pointer_x - event->x) <= TOLERANCE_PIXELS &&
401 abs (priv->pointer_y - event->y) <= TOLERANCE_PIXELS)
402 return FALSE;
403
404- if (priv->orientation == GTK_ORIENTATION_VERTICAL)
405- {
406- priv->slide_initial_slider_position = event->y_root - priv->win_y - event->y;
407- priv->slide_initial_coordinate = event->y_root;
408- }
409- else
410- {
411- priv->slide_initial_slider_position = event->x_root - priv->win_x - event->x;
412- priv->slide_initial_coordinate = event->x_root;
413- }
414+ priv->detached_scroll = TRUE;
415
416 /* stop the scroll animation if it's running. */
417- os_animation_stop (priv->animation, set_scroll_stop_cb);
418-
419- /* set the initial adjustment value required for reconnect. */
420- capture_movement_for_animation (scrollbar, event->x_root, event->y_root);
421-
422- /* animate the reconnect, using the same animation object. */
423- os_animation_start (priv->animation);
424-
425- priv->value_changed_event = FALSE;
426- }
427-
428- /* only the reconnect animation can be running at that time. */
429- if (os_animation_is_running (priv->animation))
430- {
431- /* update the adjustment value. */
432- capture_movement_for_animation (scrollbar, event->x_root, event->y_root);
433-
434- /* limit x and y within the thumb allocation. */
435+ os_animation_stop (priv->animation, NULL);
436+
437+ /* limit x and y within the allocation. */
438 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
439 {
440 x = priv->win_x;
441 y = CLAMP (event->y_root - priv->pointer_y,
442 priv->win_y,
443- priv->win_y + priv->thumb_all.height);
444+ priv->win_y + priv->thumb_all.height - priv->slider.height);
445 }
446 else
447 {
448 x = CLAMP (event->x_root - priv->pointer_x,
449 priv->win_x,
450- priv->win_x + priv->thumb_all.width);
451+ priv->win_x + priv->thumb_all.width - priv->slider.width);
452 y = priv->win_y;
453 }
454
455+ /* fine scroll while detached,
456+ * do not scroll when hitting an edge. */
457+ if ((priv->orientation == GTK_ORIENTATION_VERTICAL &&
458+ y > priv->win_y &&
459+ y < priv->win_y + priv->thumb_all.height - priv->slider.height) ||
460+ (priv->orientation == GTK_ORIENTATION_HORIZONTAL &&
461+ x > priv->win_x &&
462+ x < priv->win_x + priv->thumb_all.width - priv->slider.width))
463+ capture_movement (scrollbar, event->x_root, event->y_root);
464+
465 move_thumb (scrollbar, x, y);
466
467- /* return if the reconnect animation is still running after
468- * capture_movement_for_animation. */
469- if (os_animation_is_running (priv->animation))
470- return FALSE;
471+ if (priv->orientation == GTK_ORIENTATION_VERTICAL)
472+ {
473+ if (gtk_adjustment_get_value (priv->adjustment) == 0)
474+ {
475+ update_visual_connection (scrollbar);
476+
477+ if (priv->overlay.height > priv->slider.height)
478+ {
479+ priv->slide_initial_slider_position = 0;
480+ priv->slide_initial_coordinate = MAX (event->y_root, priv->win_y + priv->pointer_y);
481+ }
482+ else
483+ {
484+ priv->slide_initial_slider_position = 0;
485+ priv->slide_initial_coordinate = event->y_root;
486+ }
487+ }
488+ else if (priv->overlay.y + priv->overlay.height >= priv->trough.height)
489+ {
490+ update_visual_connection (scrollbar);
491+
492+ if (priv->overlay.height > priv->slider.height)
493+ {
494+ priv->slide_initial_slider_position = priv->trough.height - priv->overlay.height;
495+ priv->slide_initial_coordinate = MAX (event->y_root, priv->win_y + priv->pointer_y);
496+ }
497+ else
498+ {
499+ priv->slide_initial_slider_position = priv->trough.height - priv->slider.height;
500+ priv->slide_initial_coordinate = event->y_root;
501+ }
502+ }
503+ }
504+ else
505+ {
506+ if (gtk_adjustment_get_value (priv->adjustment) == 0)
507+ {
508+ update_visual_connection (scrollbar);
509+
510+ if (priv->overlay.width > priv->slider.width)
511+ {
512+ priv->slide_initial_slider_position = 0;
513+ priv->slide_initial_coordinate = MAX (event->x_root, priv->win_x + priv->pointer_x);
514+ }
515+ else
516+ {
517+ priv->slide_initial_slider_position = 0;
518+ priv->slide_initial_coordinate = event->x_root;
519+ }
520+ }
521+ else if (priv->overlay.x + priv->overlay.width >= priv->trough.width)
522+ {
523+ update_visual_connection (scrollbar);
524+
525+ if (priv->overlay.width > priv->slider.width)
526+ {
527+ priv->slide_initial_slider_position = priv->trough.width - priv->overlay.width;
528+ priv->slide_initial_coordinate = MAX (event->x_root, priv->win_x + priv->pointer_x);
529+ }
530+ else
531+ {
532+ priv->slide_initial_slider_position = priv->trough.width - priv->slider.width;
533+ priv->slide_initial_coordinate = event->x_root;
534+ }
535+ }
536+ }
537+
538+ return FALSE;
539 }
540
541- priv->motion_notify_event = TRUE;
542+ OS_DCHECK (!priv->detached_scroll);
543+
544+ /* thumb and pager are connected.
545+ * Normal scroll: keep the thumb in sync with the pager,
546+ * do not update the visual connection. */
547+ priv->event |= OS_EVENT_MOTION_NOTIFY;
548
549 capture_movement (scrollbar, event->x_root, event->y_root);
550
551@@ -1798,7 +1810,7 @@
552 scrollbar = OS_SCROLLBAR (user_data);
553 priv = scrollbar->priv;
554
555- priv->value_changed_event = TRUE;
556+ priv->event |= OS_EVENT_VALUE_CHANGED;
557
558 delta = get_wheel_delta (scrollbar, event->direction);
559
560@@ -1821,9 +1833,9 @@
561 scrollbar = OS_SCROLLBAR (user_data);
562 priv = scrollbar->priv;
563
564- priv->button_press_event = FALSE;
565- priv->motion_notify_event = FALSE;
566- priv->enter_notify_event = FALSE;
567+ priv->event = OS_EVENT_NONE;
568+
569+ priv->detached_scroll = FALSE;
570
571 os_pager_set_detached (priv->pager, FALSE);
572 }
573@@ -2555,14 +2567,12 @@
574 os_root_list = g_list_append (os_root_list, scrollbar);
575 }
576
577- priv->button_press_event = FALSE;
578- priv->enter_notify_event = FALSE;
579- priv->motion_notify_event = FALSE;
580- priv->value_changed_event = FALSE;
581+ priv->event = OS_EVENT_NONE;
582
583 priv->active_window = FALSE;
584 priv->can_deactivate_pager = TRUE;
585 priv->can_hide = TRUE;
586+ priv->detached_scroll = FALSE;
587 priv->filter = FALSE;
588 priv->fullsize = FALSE;
589 priv->internal = FALSE;
590
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 GtkOrientation orientation;
596 GtkWidget *grabbed_widget;
597 OsAnimation *animation;
598- gboolean button_press_event;
599- gboolean motion_notify_event;
600+ OsEvent event;
601 gboolean can_rgba;
602 gboolean detached;
603 gboolean use_tolerance;
604@@ -190,8 +189,7 @@
605 OsThumbPrivate);
606 priv = thumb->priv;
607
608- priv->button_press_event = FALSE;
609- priv->motion_notify_event = FALSE;
610+ priv->event = OS_EVENT_NONE;
611
612 priv->can_rgba = FALSE;
613 priv->detached = FALSE;
614@@ -245,8 +243,8 @@
615 priv->pointer_x = event->x;
616 priv->pointer_y = event->y;
617
618- priv->button_press_event = TRUE;
619- priv->motion_notify_event = FALSE;
620+ priv->event |= OS_EVENT_BUTTON_PRESS;
621+ priv->event &= ~(OS_EVENT_MOTION_NOTIFY);
622
623 priv->use_tolerance = TRUE;
624
625@@ -276,8 +274,7 @@
626 {
627 gtk_grab_remove (widget);
628
629- priv->button_press_event = FALSE;
630- priv->motion_notify_event = FALSE;
631+ priv->event &= ~(OS_EVENT_BUTTON_PRESS | OS_EVENT_MOTION_NOTIFY);
632
633 gtk_widget_queue_draw (widget);
634 }
635@@ -687,7 +684,8 @@
636 else
637 pat = cairo_pattern_create_linear (0, 0, width, 0);
638
639- if (priv->button_press_event && !priv->motion_notify_event)
640+ if ((priv->event & OS_EVENT_BUTTON_PRESS) &&
641+ !(priv->event & OS_EVENT_MOTION_NOTIFY))
642 {
643 if ((priv->orientation == GTK_ORIENTATION_VERTICAL && (priv->pointer_y < height / 2)) ||
644 (priv->orientation == GTK_ORIENTATION_HORIZONTAL && (priv->pointer_x < width / 2)))
645@@ -715,7 +713,7 @@
646 cairo_set_source (cr, pat);
647 cairo_pattern_destroy (pat);
648
649- if (priv->motion_notify_event)
650+ if (priv->event & OS_EVENT_MOTION_NOTIFY)
651 {
652 cairo_fill_preserve (cr);
653 set_source_gdk_rgba (cr, &bg_arrow_down, 0.3);
654@@ -837,8 +835,8 @@
655 /* If we exit the thumb when a button is pressed,
656 * there's no need to stop the animation, it should
657 * already be stopped.
658- * Stop it only if priv->button_press_event is FALSE. */
659- if (!priv->button_press_event)
660+ * Stop it only if OS_EVENT_BUTTON_PRESS is not set. */
661+ if (!(priv->event & OS_EVENT_BUTTON_PRESS))
662 {
663 if (priv->source_id != 0)
664 {
665@@ -901,9 +899,9 @@
666
667 /* If you're not dragging, and you're outside
668 * the tolerance pixels, enable the fade-out.
669- * priv->motion_notify_event is TRUE only on dragging,
670+ * OS_EVENT_MOTION_NOTIFY is set only on dragging,
671 * see code few lines below. */
672- if (!priv->motion_notify_event)
673+ if (!(priv->event & OS_EVENT_MOTION_NOTIFY))
674 {
675 if (!priv->use_tolerance ||
676 (abs (priv->pointer_x - event->x) > TOLERANCE_PIXELS ||
677@@ -916,12 +914,12 @@
678 }
679 }
680
681- if (priv->button_press_event)
682+ if (priv->event & OS_EVENT_BUTTON_PRESS)
683 {
684- if (!priv->motion_notify_event)
685+ if (!(priv->event & OS_EVENT_MOTION_NOTIFY))
686 gtk_widget_queue_draw (widget);
687
688- priv->motion_notify_event = TRUE;
689+ priv->event |= OS_EVENT_MOTION_NOTIFY;
690 }
691
692 return FALSE;
693@@ -988,8 +986,7 @@
694 thumb = OS_THUMB (widget);
695 priv = thumb->priv;
696
697- priv->button_press_event = FALSE;
698- priv->motion_notify_event = FALSE;
699+ priv->event = OS_EVENT_NONE;
700
701 priv->use_tolerance = FALSE;
702
703@@ -1155,6 +1152,7 @@
704 if (priv->detached != detached)
705 {
706 priv->detached = detached;
707+
708 gtk_widget_queue_draw (GTK_WIDGET (thumb));
709 }
710 }

Subscribers

People subscribed via source and target branches