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

Proposed by Andrea Cimitan
Status: Superseded
Proposed branch: lp:~cimi/overlay-scrollbar/fix-motion-after-reconnection
Merge into: lp:overlay-scrollbar
Diff against target: 183 lines (+83/-30) (has conflicts)
1 file modified
os/os-scrollbar.c (+83/-30)
Text conflict in os/os-scrollbar.c
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/fix-motion-after-reconnection
Reviewer Review Type Date Requested Status
Ayatana Scrollbar Team Pending
Review via email: mp+84497@code.launchpad.net

This proposal has been superseded by 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.
318. By Andrea Cimitan

Updated to trunk

Unmerged revisions

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:27:25 +0000
4@@ -71,14 +71,15 @@
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+<<<<<<< TREE
21 OS_STATE_NONE = 0,
22 OS_STATE_CONNECTED = 1,
23 OS_STATE_DETACHED = 2,
24@@ -87,15 +88,24 @@
25 OS_STATE_INTERNAL = 16,
26 OS_STATE_LOCKED = 32,
27 OS_STATE_RECONNECTING = 64
28+=======
29+ OS_STATE_NONE = 0, /* No state. */
30+ OS_STATE_CONNECTED = 1, /* Thumb and bar move connected, like a native scrollbar. */
31+ OS_STATE_DETACHED = 2, /* The thumb is visually detached from the bar, and you can see the tail. */
32+ OS_STATE_FULLSIZE = 4, /* The scrollbar is fullsize, so we hide it. */
33+ OS_STATE_INTERNAL = 8, /* The thumb is touching a strut or a screen edge, it's internal. */
34+ OS_STATE_LOCKED = 16, /* Thumb is locked in its position when moving in the proximity area. */
35+ OS_STATE_RECONNECTING = 32 /* The thumb is reconnecting with the bar, there's likely an animation in progress. */
36+>>>>>>> MERGE-SOURCE
37 } OsStateFlags;
38
39 typedef enum
40 {
41- OS_STRUT_SIDE_NONE = 0,
42- OS_STRUT_SIDE_TOP = 1,
43- OS_STRUT_SIDE_BOTTOM = 2,
44- OS_STRUT_SIDE_LEFT = 4,
45- OS_STRUT_SIDE_RIGHT = 8
46+ OS_STRUT_SIDE_NONE = 0, /* No strut. */
47+ OS_STRUT_SIDE_TOP = 1, /* Strut at top. */
48+ OS_STRUT_SIDE_BOTTOM = 2, /* Strut at bottom. */
49+ OS_STRUT_SIDE_LEFT = 4, /* Strut at left. */
50+ OS_STRUT_SIDE_RIGHT = 8 /* Strut at right. */
51 } OsStrutSideFlags;
52
53 typedef struct
54@@ -996,10 +1006,55 @@
55
56 priv = scrollbar->priv;
57
58- priv->state &= ~(OS_STATE_RECONNECTING);
59-
60- check_connection (scrollbar);
61-}
62+ /* Only update the slide values at the end of a reconnection,
63+ * with the button pressed, otherwise it's not needed. */
64+ if ((priv->state & OS_STATE_RECONNECTING) &&
65+ (priv->event & OS_EVENT_BUTTON_PRESS))
66+ {
67+ gint x_pos, y_pos;
68+
69+ gdk_window_get_origin (gtk_widget_get_window (priv->thumb), &x_pos, &y_pos);
70+
71+ if (priv->orientation == GTK_ORIENTATION_VERTICAL)
72+ {
73+ priv->slide_initial_slider_position = MIN (priv->slider.y, priv->overlay.y);
74+ priv->slide_initial_coordinate = y_pos + priv->pointer.y;
75+ }
76+ else
77+ {
78+ priv->slide_initial_slider_position = MIN (priv->slider.x, priv->overlay.x);
79+ priv->slide_initial_coordinate = x_pos + priv->pointer.x;
80+ }
81+ }
82+
83+ /* Check if the thumb can be considered connected after the animation. */
84+ check_connection (scrollbar);
85+
86+ /* Unset OS_STATE_RECONNECTING since the animation ended. */
87+ priv->state &= ~(OS_STATE_RECONNECTING);
88+}
89+
90+/* Stop function called by the scrolling animation. */
91+static void
92+scrolling_stop_cb (gpointer user_data)
93+{
94+ OsScrollbar *scrollbar;
95+ OsScrollbarPrivate *priv;
96+
97+ scrollbar = OS_SCROLLBAR (user_data);
98+
99+ priv = scrollbar->priv;
100+
101+ /* No slide values update here,
102+ * handle them separately! */
103+
104+ /* Check if the thumb can be considered connected after the animation. */
105+ check_connection (scrollbar);
106+
107+ /* Unset OS_STATE_RECONNECTING since the animation ended. */
108+ priv->state &= ~(OS_STATE_RECONNECTING);
109+}
110+
111
112 /* Swap adjustment pointer. */
113 static void
114@@ -1521,29 +1576,17 @@
115 {
116 /* Reconnect the thumb with the bar. */
117 gdouble new_value;
118- gint c, delta;
119+ gint c;
120 gint32 duration;
121
122 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
123- {
124- priv->slide_initial_slider_position = event->y_root - priv->thumb_win.y - event->y;
125- priv->slide_initial_coordinate = event->y_root;
126-
127- delta = event->y_root - priv->slide_initial_coordinate;
128- }
129+ c = event->y_root - priv->thumb_win.y - event->y;
130 else
131- {
132- priv->slide_initial_slider_position = event->x_root - priv->thumb_win.x - event->x;
133- priv->slide_initial_coordinate = event->x_root;
134-
135- delta = event->x_root - priv->slide_initial_coordinate;
136- }
137-
138- c = priv->slide_initial_slider_position + delta;
139+ c = event->x_root - priv->thumb_win.x - event->x;
140
141 /* If a scrolling animation is running,
142 * stop it and add the new value. */
143- os_animation_stop (priv->animation, NULL);
144+ os_animation_stop (priv->animation, scrolling_stop_cb);
145
146 new_value = coord_to_value (scrollbar, c);
147
148@@ -1603,8 +1646,13 @@
149 * stop it and add the new value. */
150 if (os_animation_is_running (priv->animation))
151 {
152+<<<<<<< TREE
153 os_animation_stop (priv->animation, NULL);
154 new_value = priv->value + increment;
155+=======
156+ os_animation_stop (priv->animation, scrolling_stop_cb);
157+ new_value = priv->value + gtk_adjustment_get_page_increment (priv->adjustment);
158+>>>>>>> MERGE-SOURCE
159 }
160 else
161 new_value = gtk_adjustment_get_value (priv->adjustment) + increment;
162@@ -1650,8 +1698,13 @@
163 * stop it and subtract the new value. */
164 if (os_animation_is_running (priv->animation))
165 {
166+<<<<<<< TREE
167 os_animation_stop (priv->animation, NULL);
168 new_value = priv->value - increment;
169+=======
170+ os_animation_stop (priv->animation, scrolling_stop_cb);
171+ new_value = priv->value - gtk_adjustment_get_page_increment (priv->adjustment);
172+>>>>>>> MERGE-SOURCE
173 }
174 else
175 new_value = gtk_adjustment_get_value (priv->adjustment) - increment;
176@@ -1950,7 +2003,7 @@
177 else
178 {
179 /* Stop the paging animation now. */
180- os_animation_stop (priv->animation, NULL);
181+ os_animation_stop (priv->animation, scrolling_stop_cb);
182 }
183 }
184

Subscribers

People subscribed via source and target branches