Merge lp:~cimi/overlay-scrollbar/fix-motion-after-reconnection into lp:overlay-scrollbar

Proposed by Andrea Cimitan
Status: Merged
Approved by: Ted Gould
Approved revision: 318
Merged at revision: 321
Proposed branch: lp:~cimi/overlay-scrollbar/fix-motion-after-reconnection
Merge into: lp:overlay-scrollbar
Diff against target: 163 lines (+64/-40)
1 file modified
os/os-scrollbar.c (+64/-40)
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/fix-motion-after-reconnection
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+84500@code.launchpad.net

This proposal supersedes a proposal from 2011-12-05.

Description of the change

Fixes motion notify event after reconnection animation ended. Plus add some comments.

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'os/os-scrollbar.c'
2--- os/os-scrollbar.c 2011-12-02 17:04:13 +0000
3+++ os/os-scrollbar.c 2011-12-05 16:52:24 +0000
4@@ -71,31 +71,31 @@
5
6 typedef enum
7 {
8- OS_SIDE_TOP,
9- OS_SIDE_BOTTOM,
10- OS_SIDE_LEFT,
11- OS_SIDE_RIGHT
12+ OS_SIDE_TOP, /* Scrollbar is at top. */
13+ OS_SIDE_BOTTOM, /* Scrollbar is at bottom. */
14+ OS_SIDE_LEFT, /* Scrollbar is at left. */
15+ OS_SIDE_RIGHT /* Scrollbar is at right. */
16 } OsSide;
17
18 typedef enum
19 {
20- OS_STATE_NONE = 0,
21- OS_STATE_CONNECTED = 1,
22- OS_STATE_DETACHED = 2,
23- OS_STATE_FINE_SCROLL = 4,
24- OS_STATE_FULLSIZE = 8,
25- OS_STATE_INTERNAL = 16,
26- OS_STATE_LOCKED = 32,
27- OS_STATE_RECONNECTING = 64
28+ OS_STATE_NONE = 0, /* No state. */
29+ OS_STATE_CONNECTED = 1, /* Thumb and bar move connected, like a native scrollbar. */
30+ OS_STATE_DETACHED = 2, /* The thumb is visually detached from the bar, and you can see the tail. */
31+ OS_STATE_FINE_SCROLL = 4, /* A fine scroll is currently running, the modifier key must be pressed. */
32+ OS_STATE_FULLSIZE = 8, /* The scrollbar is fullsize, so we hide it. */
33+ OS_STATE_INTERNAL = 16, /* The thumb is touching a strut or a screen edge, it's internal. */
34+ OS_STATE_LOCKED = 32, /* Thumb is locked in its position when moving in the proximity area. */
35+ OS_STATE_RECONNECTING = 64 /* The thumb is reconnecting with the bar, there's likely an animation in progress. */
36 } OsStateFlags;
37
38 typedef enum
39 {
40- OS_STRUT_SIDE_NONE = 0,
41- OS_STRUT_SIDE_TOP = 1,
42- OS_STRUT_SIDE_BOTTOM = 2,
43- OS_STRUT_SIDE_LEFT = 4,
44- OS_STRUT_SIDE_RIGHT = 8
45+ OS_STRUT_SIDE_NONE = 0, /* No strut. */
46+ OS_STRUT_SIDE_TOP = 1, /* Strut at top. */
47+ OS_STRUT_SIDE_BOTTOM = 2, /* Strut at bottom. */
48+ OS_STRUT_SIDE_LEFT = 4, /* Strut at left. */
49+ OS_STRUT_SIDE_RIGHT = 8 /* Strut at right. */
50 } OsStrutSideFlags;
51
52 typedef struct
53@@ -996,10 +996,46 @@
54
55 priv = scrollbar->priv;
56
57- priv->state &= ~(OS_STATE_RECONNECTING);
58-
59- check_connection (scrollbar);
60-}
61+ /* Only update the slide values at the end of a reconnection,
62+ * with the button pressed, otherwise it's not needed. */
63+ if ((priv->state & OS_STATE_RECONNECTING) &&
64+ (priv->event & OS_EVENT_BUTTON_PRESS))
65+ {
66+ gint x_pos, y_pos;
67+
68+ gdk_window_get_origin (gtk_widget_get_window (priv->thumb), &x_pos, &y_pos);
69+
70+ calc_precise_slide_values (scrollbar, x_pos + priv->pointer.x, y_pos + priv->pointer.y);
71+ }
72+
73+ /* Check if the thumb can be considered connected after the animation. */
74+ check_connection (scrollbar);
75+
76+ /* Unset OS_STATE_RECONNECTING since the animation ended. */
77+ priv->state &= ~(OS_STATE_RECONNECTING);
78+}
79+
80+/* Stop function called by the scrolling animation. */
81+static void
82+scrolling_stop_cb (gpointer user_data)
83+{
84+ OsScrollbar *scrollbar;
85+ OsScrollbarPrivate *priv;
86+
87+ scrollbar = OS_SCROLLBAR (user_data);
88+
89+ priv = scrollbar->priv;
90+
91+ /* No slide values update here,
92+ * handle them separately! */
93+
94+ /* Check if the thumb can be considered connected after the animation. */
95+ check_connection (scrollbar);
96+
97+ /* Unset OS_STATE_RECONNECTING since the animation ended. */
98+ priv->state &= ~(OS_STATE_RECONNECTING);
99+}
100+
101
102 /* Swap adjustment pointer. */
103 static void
104@@ -1521,29 +1557,17 @@
105 {
106 /* Reconnect the thumb with the bar. */
107 gdouble new_value;
108- gint c, delta;
109+ gfloat c;
110 gint32 duration;
111
112 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
113- {
114- priv->slide_initial_slider_position = event->y_root - priv->thumb_win.y - event->y;
115- priv->slide_initial_coordinate = event->y_root;
116-
117- delta = event->y_root - priv->slide_initial_coordinate;
118- }
119+ c = event->y_root - priv->thumb_win.y - event->y;
120 else
121- {
122- priv->slide_initial_slider_position = event->x_root - priv->thumb_win.x - event->x;
123- priv->slide_initial_coordinate = event->x_root;
124-
125- delta = event->x_root - priv->slide_initial_coordinate;
126- }
127-
128- c = priv->slide_initial_slider_position + delta;
129+ c = event->x_root - priv->thumb_win.x - event->x;
130
131 /* If a scrolling animation is running,
132 * stop it and add the new value. */
133- os_animation_stop (priv->animation, NULL);
134+ os_animation_stop (priv->animation, scrolling_stop_cb);
135
136 new_value = coord_to_value (scrollbar, c);
137
138@@ -1603,7 +1627,7 @@
139 * stop it and add the new value. */
140 if (os_animation_is_running (priv->animation))
141 {
142- os_animation_stop (priv->animation, NULL);
143+ os_animation_stop (priv->animation, scrolling_stop_cb);
144 new_value = priv->value + increment;
145 }
146 else
147@@ -1650,7 +1674,7 @@
148 * stop it and subtract the new value. */
149 if (os_animation_is_running (priv->animation))
150 {
151- os_animation_stop (priv->animation, NULL);
152+ os_animation_stop (priv->animation, scrolling_stop_cb);
153 new_value = priv->value - increment;
154 }
155 else
156@@ -1950,7 +1974,7 @@
157 else
158 {
159 /* Stop the paging animation now. */
160- os_animation_stop (priv->animation, NULL);
161+ os_animation_stop (priv->animation, scrolling_stop_cb);
162 }
163 }
164

Subscribers

People subscribed via source and target branches