Merge lp:~cimi/overlay-scrollbar/new-thumb-functionalities into lp:overlay-scrollbar
- new-thumb-functionalities
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 311 |
Proposed branch: | lp:~cimi/overlay-scrollbar/new-thumb-functionalities |
Merge into: | lp:overlay-scrollbar |
Diff against target: |
4177 lines (+1568/-1308) 5 files modified
os/Makefile.am (+1/-1) os/os-bar.c (+454/-355) os/os-private.h (+63/-53) os/os-scrollbar.c (+1008/-866) os/os-thumb.c (+42/-33) |
To merge this branch: | bzr merge lp:~cimi/overlay-scrollbar/new-thumb-functionalities |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ted Gould (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
Big changes... are you really sure you want to review that? :-)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
From an usability point of view I'd reduce the value of TIMEOUT_THUMB_SHOW to 50ms. It seems better here.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Andrea Cimitan (cimi) wrote : | # |
Marco, I'm thinking about increasing it to 150 :-) Please notice that the timeout is not respected when the thumb is touching the screen edge.
Anyway, the branch is still in progress :-) Not ready for review (see the "Status"!)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Ted Gould (ted) wrote : | # |
In general, I'm a little uncomfortable with all the bit twittling for the state variable. I think that you should put that into its own function. Two reasons, it's easy to mess up. And it seems to be likely someplace you'll want to put a g_debug() statement when things are going wrong.
Also, the diffs would be a lot smaller if the name changes weren't included with the logic changes. I think next time you should split those out into two different merge requests.
Other than that, it was a big diff! :-) I didn't see anything on a general read through.
Preview Diff
1 | === modified file 'os/Makefile.am' | |||
2 | --- os/Makefile.am 2011-10-05 12:24:21 +0000 | |||
3 | +++ os/Makefile.am 2011-10-12 17:16:23 +0000 | |||
4 | @@ -16,8 +16,8 @@ | |||
5 | 16 | 16 | ||
6 | 17 | source_c = \ | 17 | source_c = \ |
7 | 18 | $(srcdir)/os-animation.c \ | 18 | $(srcdir)/os-animation.c \ |
8 | 19 | $(srcdir)/os-bar.c \ | ||
9 | 19 | $(srcdir)/os-log.c \ | 20 | $(srcdir)/os-log.c \ |
10 | 20 | $(srcdir)/os-pager.c \ | ||
11 | 21 | $(srcdir)/os-scrollbar.c \ | 21 | $(srcdir)/os-scrollbar.c \ |
12 | 22 | $(srcdir)/os-thumb.c \ | 22 | $(srcdir)/os-thumb.c \ |
13 | 23 | $(srcdir)/os-utils.c | 23 | $(srcdir)/os-utils.c |
14 | 24 | 24 | ||
15 | === renamed file 'os/os-pager.c' => 'os/os-bar.c' | |||
16 | --- os/os-pager.c 2011-10-05 12:24:21 +0000 | |||
17 | +++ os/os-bar.c 2011-10-12 17:16:23 +0000 | |||
18 | @@ -29,78 +29,45 @@ | |||
19 | 29 | #include <cairo-xlib.h> | 29 | #include <cairo-xlib.h> |
20 | 30 | #include <gdk/gdkx.h> | 30 | #include <gdk/gdkx.h> |
21 | 31 | 31 | ||
22 | 32 | /* Rate of the fade. */ | ||
23 | 33 | #define RATE_FADE 30 | ||
24 | 34 | |||
25 | 35 | /* Duration of the fade-in. */ | 32 | /* Duration of the fade-in. */ |
26 | 36 | #define DURATION_FADE_IN 200 | 33 | #define DURATION_FADE_IN 200 |
27 | 37 | 34 | ||
28 | 38 | /* Duration of the fade-out. */ | 35 | /* Duration of the fade-out. */ |
29 | 39 | #define DURATION_FADE_OUT 400 | 36 | #define DURATION_FADE_OUT 400 |
30 | 40 | 37 | ||
31 | 38 | /* Max duration of the retracting tail. */ | ||
32 | 39 | #define MAX_DURATION_TAIL 600 | ||
33 | 40 | |||
34 | 41 | /* Min duration of the retracting tail. */ | ||
35 | 42 | #define MIN_DURATION_TAIL 100 | ||
36 | 43 | |||
37 | 41 | #ifdef USE_GTK3 | 44 | #ifdef USE_GTK3 |
38 | 42 | #define SHAPE_REGION(x) (cairo_region_create_rectangle (x)) | 45 | #define SHAPE_REGION(x) (cairo_region_create_rectangle (x)) |
39 | 43 | #else | 46 | #else |
40 | 44 | #define SHAPE_REGION(x) (gdk_region_rectangle (x)) | 47 | #define SHAPE_REGION(x) (gdk_region_rectangle (x)) |
41 | 45 | #endif | 48 | #endif |
42 | 46 | 49 | ||
46 | 47 | struct _OsPagerPrivate { | 50 | struct _OsBarPrivate { |
47 | 48 | GdkWindow *pager_window; | 51 | GdkRectangle bar_mask; |
48 | 49 | GdkWindow *connection_window; | 52 | GdkRectangle tail_mask; /* In theory not needed, but easier to read. */ |
49 | 53 | GdkRectangle allocation; | ||
50 | 54 | GdkWindow *bar_window; | ||
51 | 55 | GdkWindow *tail_window; | ||
52 | 50 | GtkWidget *parent; | 56 | GtkWidget *parent; |
57 | 51 | GdkRectangle mask; | 57 | OsAnimation *state_animation; |
58 | 52 | GdkRectangle connection_mask; /* In theory not needed, but easier to read. */ | 58 | OsAnimation *tail_animation; |
55 | 53 | GdkRectangle allocation; | ||
56 | 54 | OsAnimation *animation; | ||
59 | 55 | gboolean active; | 59 | gboolean active; |
60 | 56 | gboolean detached; | 60 | gboolean detached; |
61 | 57 | gboolean visible; | 61 | gboolean visible; |
62 | 58 | gfloat weight; | 62 | gfloat weight; |
63 | 59 | gulong handler_id; | ||
64 | 60 | }; | 63 | }; |
65 | 61 | 64 | ||
108 | 62 | static void os_pager_dispose (GObject *object); | 65 | static void os_bar_dispose (GObject *object); |
109 | 63 | static void os_pager_finalize (GObject *object); | 66 | static void os_bar_finalize (GObject *object); |
110 | 64 | 67 | ||
111 | 65 | /* Draw on the connection_window. */ | 68 | /* Draw on the bar_window. */ |
112 | 66 | static void | 69 | static void |
113 | 67 | draw_connection (OsPager *pager) | 70 | draw_bar (OsBar *bar) |
72 | 68 | { | ||
73 | 69 | #ifdef USE_GTK3 | ||
74 | 70 | GdkRGBA color; | ||
75 | 71 | GtkStyleContext *style_context; | ||
76 | 72 | #else | ||
77 | 73 | GdkColor color; | ||
78 | 74 | GtkStyle *style; | ||
79 | 75 | #endif | ||
80 | 76 | OsPagerPrivate *priv; | ||
81 | 77 | |||
82 | 78 | priv = pager->priv; | ||
83 | 79 | |||
84 | 80 | #ifdef USE_GTK3 | ||
85 | 81 | style_context = gtk_widget_get_style_context (priv->parent); | ||
86 | 82 | |||
87 | 83 | gtk_style_context_get_background_color (style_context, GTK_STATE_FLAG_ACTIVE, &color); | ||
88 | 84 | |||
89 | 85 | color.alpha = 1.0; | ||
90 | 86 | |||
91 | 87 | gdk_window_set_background_rgba (priv->connection_window, &color); | ||
92 | 88 | #else | ||
93 | 89 | style = gtk_widget_get_style (priv->parent); | ||
94 | 90 | |||
95 | 91 | color = style->bg[GTK_STATE_ACTIVE]; | ||
96 | 92 | |||
97 | 93 | gdk_colormap_alloc_color (gdk_drawable_get_colormap (priv->connection_window), &color, FALSE, TRUE); | ||
98 | 94 | |||
99 | 95 | gdk_window_set_background (priv->connection_window, &color); | ||
100 | 96 | #endif | ||
101 | 97 | |||
102 | 98 | gdk_window_invalidate_rect (gtk_widget_get_window (priv->parent), &priv->allocation, TRUE); | ||
103 | 99 | } | ||
104 | 100 | |||
105 | 101 | /* Draw on the pager_window. */ | ||
106 | 102 | static void | ||
107 | 103 | draw_pager (OsPager *pager) | ||
114 | 104 | { | 71 | { |
115 | 105 | #ifdef USE_GTK3 | 72 | #ifdef USE_GTK3 |
116 | 106 | GdkRGBA c1, c2, color; | 73 | GdkRGBA c1, c2, color; |
117 | @@ -109,10 +76,10 @@ | |||
118 | 109 | GdkColor c1, c2, color; | 76 | GdkColor c1, c2, color; |
119 | 110 | GtkStyle *style; | 77 | GtkStyle *style; |
120 | 111 | #endif | 78 | #endif |
122 | 112 | OsPagerPrivate *priv; | 79 | OsBarPrivate *priv; |
123 | 113 | gfloat weight; | 80 | gfloat weight; |
124 | 114 | 81 | ||
126 | 115 | priv = pager->priv; | 82 | priv = bar->priv; |
127 | 116 | 83 | ||
128 | 117 | weight = priv->weight; | 84 | weight = priv->weight; |
129 | 118 | 85 | ||
130 | @@ -135,7 +102,7 @@ | |||
131 | 135 | color.blue = weight * c1.blue + (1.0 - weight) * c2.blue; | 102 | color.blue = weight * c1.blue + (1.0 - weight) * c2.blue; |
132 | 136 | color.alpha = 1.0; | 103 | color.alpha = 1.0; |
133 | 137 | 104 | ||
135 | 138 | gdk_window_set_background_rgba (priv->pager_window, &color); | 105 | gdk_window_set_background_rgba (priv->bar_window, &color); |
136 | 139 | #else | 106 | #else |
137 | 140 | style = gtk_widget_get_style (priv->parent); | 107 | style = gtk_widget_get_style (priv->parent); |
138 | 141 | 108 | ||
139 | @@ -154,9 +121,45 @@ | |||
140 | 154 | color.green = weight * c1.green + (1.0 - weight) * c2.green; | 121 | color.green = weight * c1.green + (1.0 - weight) * c2.green; |
141 | 155 | color.blue = weight * c1.blue + (1.0 - weight) * c2.blue; | 122 | color.blue = weight * c1.blue + (1.0 - weight) * c2.blue; |
142 | 156 | 123 | ||
146 | 157 | gdk_colormap_alloc_color (gdk_drawable_get_colormap (priv->pager_window), &color, FALSE, TRUE); | 124 | gdk_colormap_alloc_color (gdk_drawable_get_colormap (priv->bar_window), &color, FALSE, TRUE); |
147 | 158 | 125 | ||
148 | 159 | gdk_window_set_background (priv->pager_window, &color); | 126 | gdk_window_set_background (priv->bar_window, &color); |
149 | 127 | #endif | ||
150 | 128 | |||
151 | 129 | gdk_window_invalidate_rect (gtk_widget_get_window (priv->parent), &priv->allocation, TRUE); | ||
152 | 130 | } | ||
153 | 131 | |||
154 | 132 | /* Draw on the tail_window. */ | ||
155 | 133 | static void | ||
156 | 134 | draw_tail (OsBar *bar) | ||
157 | 135 | { | ||
158 | 136 | #ifdef USE_GTK3 | ||
159 | 137 | GdkRGBA color; | ||
160 | 138 | GtkStyleContext *style_context; | ||
161 | 139 | #else | ||
162 | 140 | GdkColor color; | ||
163 | 141 | GtkStyle *style; | ||
164 | 142 | #endif | ||
165 | 143 | OsBarPrivate *priv; | ||
166 | 144 | |||
167 | 145 | priv = bar->priv; | ||
168 | 146 | |||
169 | 147 | #ifdef USE_GTK3 | ||
170 | 148 | style_context = gtk_widget_get_style_context (priv->parent); | ||
171 | 149 | |||
172 | 150 | gtk_style_context_get_background_color (style_context, GTK_STATE_FLAG_ACTIVE, &color); | ||
173 | 151 | |||
174 | 152 | color.alpha = 1.0; | ||
175 | 153 | |||
176 | 154 | gdk_window_set_background_rgba (priv->tail_window, &color); | ||
177 | 155 | #else | ||
178 | 156 | style = gtk_widget_get_style (priv->parent); | ||
179 | 157 | |||
180 | 158 | color = style->bg[GTK_STATE_ACTIVE]; | ||
181 | 159 | |||
182 | 160 | gdk_colormap_alloc_color (gdk_drawable_get_colormap (priv->tail_window), &color, FALSE, TRUE); | ||
183 | 161 | |||
184 | 162 | gdk_window_set_background (priv->tail_window, &color); | ||
185 | 160 | #endif | 163 | #endif |
186 | 161 | 164 | ||
187 | 162 | gdk_window_invalidate_rect (gtk_widget_get_window (priv->parent), &priv->allocation, TRUE); | 165 | gdk_window_invalidate_rect (gtk_widget_get_window (priv->parent), &priv->allocation, TRUE); |
188 | @@ -167,35 +170,35 @@ | |||
189 | 167 | change_state_cb (gfloat weight, | 170 | change_state_cb (gfloat weight, |
190 | 168 | gpointer user_data) | 171 | gpointer user_data) |
191 | 169 | { | 172 | { |
198 | 170 | OsPager *pager; | 173 | OsBar *bar; |
199 | 171 | OsPagerPrivate *priv; | 174 | OsBarPrivate *priv; |
200 | 172 | 175 | ||
201 | 173 | pager = OS_PAGER (user_data); | 176 | bar = OS_BAR (user_data); |
202 | 174 | 177 | ||
203 | 175 | priv = pager->priv; | 178 | priv = bar->priv; |
204 | 176 | 179 | ||
205 | 177 | priv->weight = weight; | 180 | priv->weight = weight; |
206 | 178 | 181 | ||
207 | 179 | if (priv->parent == NULL) | 182 | if (priv->parent == NULL) |
208 | 180 | return; | 183 | return; |
209 | 181 | 184 | ||
211 | 182 | draw_pager (pager); | 185 | draw_bar (bar); |
212 | 183 | } | 186 | } |
213 | 184 | 187 | ||
214 | 185 | /* Stop function called by the change-state animation. */ | 188 | /* Stop function called by the change-state animation. */ |
215 | 186 | static void | 189 | static void |
216 | 187 | change_state_stop_cb (gpointer user_data) | 190 | change_state_stop_cb (gpointer user_data) |
217 | 188 | { | 191 | { |
224 | 189 | OsPager *pager; | 192 | OsBar *bar; |
225 | 190 | OsPagerPrivate *priv; | 193 | OsBarPrivate *priv; |
226 | 191 | 194 | ||
227 | 192 | pager = OS_PAGER (user_data); | 195 | bar = OS_BAR (user_data); |
228 | 193 | 196 | ||
229 | 194 | priv = pager->priv; | 197 | priv = bar->priv; |
230 | 195 | 198 | ||
231 | 196 | priv->weight = 1.0f; | 199 | priv->weight = 1.0f; |
232 | 197 | 200 | ||
234 | 198 | draw_pager (pager); | 201 | draw_bar (bar); |
235 | 199 | } | 202 | } |
236 | 200 | 203 | ||
237 | 201 | /* Callback called when the Gtk+ theme changes. */ | 204 | /* Callback called when the Gtk+ theme changes. */ |
238 | @@ -204,19 +207,19 @@ | |||
239 | 204 | GParamSpec* pspec, | 207 | GParamSpec* pspec, |
240 | 205 | gpointer user_data) | 208 | gpointer user_data) |
241 | 206 | { | 209 | { |
244 | 207 | OsPager *pager; | 210 | OsBar *bar; |
245 | 208 | OsPagerPrivate *priv; | 211 | OsBarPrivate *priv; |
246 | 209 | 212 | ||
249 | 210 | pager = OS_PAGER (user_data); | 213 | bar = OS_BAR (user_data); |
250 | 211 | priv = pager->priv; | 214 | priv = bar->priv; |
251 | 212 | 215 | ||
252 | 213 | if (priv->parent == NULL || | 216 | if (priv->parent == NULL || |
255 | 214 | priv->pager_window == NULL || | 217 | priv->bar_window == NULL || |
256 | 215 | priv->connection_window == NULL) | 218 | priv->tail_window == NULL) |
257 | 216 | return; | 219 | return; |
258 | 217 | 220 | ||
261 | 218 | draw_connection (pager); | 221 | draw_tail (bar); |
262 | 219 | draw_pager (pager); | 222 | draw_bar (bar); |
263 | 220 | } | 223 | } |
264 | 221 | 224 | ||
265 | 222 | /* Check if two GdkRectangle are different. */ | 225 | /* Check if two GdkRectangle are different. */ |
266 | @@ -232,29 +235,93 @@ | |||
267 | 232 | return FALSE; | 235 | return FALSE; |
268 | 233 | } | 236 | } |
269 | 234 | 237 | ||
274 | 235 | G_DEFINE_TYPE (OsPager, os_pager, G_TYPE_OBJECT); | 238 | /* Callback called by the retract-tail animation. */ |
275 | 236 | 239 | static void | |
276 | 237 | static void | 240 | retract_tail_cb (gfloat weight, |
277 | 238 | os_pager_class_init (OsPagerClass *class) | 241 | gpointer user_data) |
278 | 242 | { | ||
279 | 243 | GdkRectangle tail_mask; | ||
280 | 244 | OsBar *bar; | ||
281 | 245 | OsBarPrivate *priv; | ||
282 | 246 | |||
283 | 247 | bar = OS_BAR (user_data); | ||
284 | 248 | |||
285 | 249 | priv = bar->priv; | ||
286 | 250 | |||
287 | 251 | if (priv->parent == NULL) | ||
288 | 252 | return; | ||
289 | 253 | |||
290 | 254 | tail_mask = priv->tail_mask; | ||
291 | 255 | |||
292 | 256 | if (priv->allocation.height >= priv->allocation.width) | ||
293 | 257 | { | ||
294 | 258 | tail_mask.height = tail_mask.height * (1.0 - weight); | ||
295 | 259 | |||
296 | 260 | if (priv->tail_mask.y + priv->tail_mask.height < priv->bar_mask.y + priv->bar_mask.height) | ||
297 | 261 | tail_mask.y = priv->tail_mask.y + priv->tail_mask.height - tail_mask.height; | ||
298 | 262 | } | ||
299 | 263 | else | ||
300 | 264 | { | ||
301 | 265 | tail_mask.width = tail_mask.width * (1.0 - weight); | ||
302 | 266 | |||
303 | 267 | if (priv->tail_mask.x + priv->tail_mask.width < priv->bar_mask.x + priv->bar_mask.width) | ||
304 | 268 | tail_mask.x = priv->tail_mask.x + priv->tail_mask.width - tail_mask.width; | ||
305 | 269 | } | ||
306 | 270 | |||
307 | 271 | if (weight < 1.0) | ||
308 | 272 | gdk_window_shape_combine_region (priv->tail_window, | ||
309 | 273 | SHAPE_REGION(&tail_mask), | ||
310 | 274 | 0, 0); | ||
311 | 275 | else | ||
312 | 276 | { | ||
313 | 277 | /* Store the new tail_mask and hide the tail_window. */ | ||
314 | 278 | priv->tail_mask = tail_mask; | ||
315 | 279 | gdk_window_hide (priv->tail_window); | ||
316 | 280 | } | ||
317 | 281 | } | ||
318 | 282 | |||
319 | 283 | /* Stop function called by the retract-tail animation. */ | ||
320 | 284 | static void | ||
321 | 285 | retract_tail_stop_cb (gpointer user_data) | ||
322 | 286 | { | ||
323 | 287 | OsBar *bar; | ||
324 | 288 | OsBarPrivate *priv; | ||
325 | 289 | |||
326 | 290 | bar = OS_BAR (user_data); | ||
327 | 291 | |||
328 | 292 | priv = bar->priv; | ||
329 | 293 | |||
330 | 294 | if (priv->parent == NULL) | ||
331 | 295 | return; | ||
332 | 296 | |||
333 | 297 | gdk_window_shape_combine_region (priv->tail_window, | ||
334 | 298 | SHAPE_REGION(&priv->tail_mask), | ||
335 | 299 | 0, 0); | ||
336 | 300 | } | ||
337 | 301 | |||
338 | 302 | G_DEFINE_TYPE (OsBar, os_bar, G_TYPE_OBJECT); | ||
339 | 303 | |||
340 | 304 | static void | ||
341 | 305 | os_bar_class_init (OsBarClass *class) | ||
342 | 239 | { | 306 | { |
343 | 240 | GObjectClass *gobject_class = G_OBJECT_CLASS (class); | 307 | GObjectClass *gobject_class = G_OBJECT_CLASS (class); |
344 | 241 | 308 | ||
347 | 242 | gobject_class->dispose = os_pager_dispose; | 309 | gobject_class->dispose = os_bar_dispose; |
348 | 243 | gobject_class->finalize = os_pager_finalize; | 310 | gobject_class->finalize = os_bar_finalize; |
349 | 244 | 311 | ||
351 | 245 | g_type_class_add_private (gobject_class, sizeof (OsPagerPrivate)); | 312 | g_type_class_add_private (gobject_class, sizeof (OsBarPrivate)); |
352 | 246 | } | 313 | } |
353 | 247 | 314 | ||
354 | 248 | static void | 315 | static void |
356 | 249 | os_pager_init (OsPager *pager) | 316 | os_bar_init (OsBar *bar) |
357 | 250 | { | 317 | { |
358 | 251 | GdkRectangle allocation, mask; | 318 | GdkRectangle allocation, mask; |
360 | 252 | OsPagerPrivate *priv; | 319 | OsBarPrivate *priv; |
361 | 253 | 320 | ||
366 | 254 | pager->priv = G_TYPE_INSTANCE_GET_PRIVATE (pager, | 321 | bar->priv = G_TYPE_INSTANCE_GET_PRIVATE (bar, |
367 | 255 | OS_TYPE_PAGER, | 322 | OS_TYPE_BAR, |
368 | 256 | OsPagerPrivate); | 323 | OsBarPrivate); |
369 | 257 | priv = pager->priv; | 324 | priv = bar->priv; |
370 | 258 | 325 | ||
371 | 259 | allocation.x = 0; | 326 | allocation.x = 0; |
372 | 260 | allocation.y = 0; | 327 | allocation.y = 0; |
373 | @@ -268,8 +335,8 @@ | |||
374 | 268 | mask.width = 1; | 335 | mask.width = 1; |
375 | 269 | mask.height = 1; | 336 | mask.height = 1; |
376 | 270 | 337 | ||
379 | 271 | priv->connection_mask = mask; | 338 | priv->bar_mask = mask; |
380 | 272 | priv->mask = mask; | 339 | priv->tail_mask = mask; |
381 | 273 | 340 | ||
382 | 274 | priv->active = FALSE; | 341 | priv->active = FALSE; |
383 | 275 | priv->detached = FALSE; | 342 | priv->detached = FALSE; |
384 | @@ -277,217 +344,227 @@ | |||
385 | 277 | 344 | ||
386 | 278 | priv->weight = 1.0f; | 345 | priv->weight = 1.0f; |
387 | 279 | 346 | ||
450 | 280 | priv->animation = os_animation_new (RATE_FADE, DURATION_FADE_OUT, | 347 | priv->state_animation = os_animation_new (RATE_ANIMATION, DURATION_FADE_OUT, |
451 | 281 | change_state_cb, NULL, pager); | 348 | change_state_cb, NULL, bar); |
452 | 282 | 349 | priv->tail_animation = os_animation_new (RATE_ANIMATION, MAX_DURATION_TAIL, | |
453 | 283 | priv->handler_id = g_signal_connect (gtk_settings_get_default (), "notify::gtk-theme-name", | 350 | retract_tail_cb, NULL, bar); |
454 | 284 | G_CALLBACK (notify_gtk_theme_name_cb), pager); | 351 | |
455 | 285 | } | 352 | g_signal_connect (gtk_settings_get_default (), "notify::gtk-theme-name", |
456 | 286 | 353 | G_CALLBACK (notify_gtk_theme_name_cb), bar); | |
457 | 287 | static void | 354 | } |
458 | 288 | os_pager_dispose (GObject *object) | 355 | |
459 | 289 | { | 356 | static void |
460 | 290 | OsPager *pager; | 357 | os_bar_dispose (GObject *object) |
461 | 291 | OsPagerPrivate *priv; | 358 | { |
462 | 292 | 359 | OsBar *bar; | |
463 | 293 | pager = OS_PAGER (object); | 360 | OsBarPrivate *priv; |
464 | 294 | priv = pager->priv; | 361 | |
465 | 295 | 362 | bar = OS_BAR (object); | |
466 | 296 | if (priv->animation != NULL) | 363 | priv = bar->priv; |
467 | 297 | { | 364 | |
468 | 298 | g_object_unref (priv->animation); | 365 | if (priv->tail_animation != NULL) |
469 | 299 | priv->animation = NULL; | 366 | { |
470 | 300 | } | 367 | g_object_unref (priv->tail_animation); |
471 | 301 | 368 | priv->tail_animation = NULL; | |
472 | 302 | if (priv->connection_window != NULL) | 369 | } |
473 | 303 | { | 370 | |
474 | 304 | /* From the Gdk documentation: | 371 | if (priv->state_animation != NULL) |
475 | 305 | * "Note that a window will not be destroyed | 372 | { |
476 | 306 | * automatically when its reference count | 373 | g_object_unref (priv->state_animation); |
477 | 307 | * reaches zero. You must call | 374 | priv->state_animation = NULL; |
478 | 308 | * gdk_window_destroy () | 375 | } |
479 | 309 | * yourself before that happens". */ | 376 | |
480 | 310 | gdk_window_destroy (priv->connection_window); | 377 | if (priv->tail_window != NULL) |
481 | 311 | 378 | { | |
482 | 312 | g_object_unref (priv->connection_window); | 379 | /* From the Gdk documentation: |
483 | 313 | priv->connection_window = NULL; | 380 | * "Note that a window will not be destroyed |
484 | 314 | } | 381 | * automatically when its reference count |
485 | 315 | 382 | * reaches zero. You must call | |
486 | 316 | if (priv->pager_window != NULL) | 383 | * gdk_window_destroy () |
487 | 317 | { | 384 | * yourself before that happens". */ |
488 | 318 | /* From the Gdk documentation: | 385 | gdk_window_destroy (priv->tail_window); |
489 | 319 | * "Note that a window will not be destroyed | 386 | |
490 | 320 | * automatically when its reference count | 387 | g_object_unref (priv->tail_window); |
491 | 321 | * reaches zero. You must call | 388 | priv->tail_window = NULL; |
492 | 322 | * gdk_window_destroy () | 389 | } |
493 | 323 | * yourself before that happens". */ | 390 | |
494 | 324 | gdk_window_destroy (priv->pager_window); | 391 | if (priv->bar_window != NULL) |
495 | 325 | 392 | { | |
496 | 326 | g_object_unref (priv->pager_window); | 393 | /* From the Gdk documentation: |
497 | 327 | priv->pager_window = NULL; | 394 | * "Note that a window will not be destroyed |
498 | 328 | } | 395 | * automatically when its reference count |
499 | 329 | 396 | * reaches zero. You must call | |
500 | 330 | os_pager_set_parent (pager, NULL); | 397 | * gdk_window_destroy () |
501 | 331 | 398 | * yourself before that happens". */ | |
502 | 332 | g_signal_handler_disconnect (gtk_settings_get_default (), | 399 | gdk_window_destroy (priv->bar_window); |
503 | 333 | priv->handler_id); | 400 | |
504 | 334 | 401 | g_object_unref (priv->bar_window); | |
505 | 335 | G_OBJECT_CLASS (os_pager_parent_class)->dispose (object); | 402 | priv->bar_window = NULL; |
506 | 336 | } | 403 | } |
507 | 337 | 404 | ||
508 | 338 | static void | 405 | os_bar_set_parent (bar, NULL); |
509 | 339 | os_pager_finalize (GObject *object) | 406 | |
510 | 340 | { | 407 | G_OBJECT_CLASS (os_bar_parent_class)->dispose (object); |
511 | 341 | G_OBJECT_CLASS (os_pager_parent_class)->finalize (object); | 408 | } |
512 | 409 | |||
513 | 410 | static void | ||
514 | 411 | os_bar_finalize (GObject *object) | ||
515 | 412 | { | ||
516 | 413 | G_OBJECT_CLASS (os_bar_parent_class)->finalize (object); | ||
517 | 342 | } | 414 | } |
518 | 343 | 415 | ||
519 | 344 | /* Public functions. */ | 416 | /* Public functions. */ |
520 | 345 | 417 | ||
521 | 346 | /** | 418 | /** |
527 | 347 | * os_pager_new: | 419 | * os_bar_new: |
528 | 348 | * | 420 | * |
529 | 349 | * Creates a new #OsPager instance. | 421 | * Creates a new #OsBar instance. |
530 | 350 | * | 422 | * |
531 | 351 | * Returns: the new #OsPager instance. | 423 | * Returns: the new #OsBar instance. |
532 | 352 | **/ | 424 | **/ |
535 | 353 | OsPager* | 425 | OsBar* |
536 | 354 | os_pager_new (void) | 426 | os_bar_new (void) |
537 | 355 | { | 427 | { |
539 | 356 | return g_object_new (OS_TYPE_PAGER, NULL); | 428 | return g_object_new (OS_TYPE_BAR, NULL); |
540 | 357 | } | 429 | } |
541 | 358 | 430 | ||
543 | 359 | /* Move a mask on the connection_window, fake movement. */ | 431 | /* Move a mask on the tail_window, fake movement. */ |
544 | 360 | static void | 432 | static void |
546 | 361 | mask_connection (OsPager *pager) | 433 | mask_tail (OsBar *bar) |
547 | 362 | { | 434 | { |
554 | 363 | OsPagerPrivate *priv; | 435 | OsBarPrivate *priv; |
555 | 364 | 436 | ||
556 | 365 | priv = pager->priv; | 437 | priv = bar->priv; |
557 | 366 | 438 | ||
558 | 367 | gdk_window_shape_combine_region (priv->connection_window, | 439 | gdk_window_shape_combine_region (priv->tail_window, |
559 | 368 | SHAPE_REGION(&priv->connection_mask), | 440 | SHAPE_REGION(&priv->tail_mask), |
560 | 369 | 0, 0); | 441 | 0, 0); |
561 | 370 | } | 442 | } |
562 | 371 | 443 | ||
563 | 372 | /** | 444 | /** |
609 | 373 | * os_pager_connect: | 445 | * os_bar_connect: |
610 | 374 | * @pager: a #OsPager | 446 | * @bar: a #OsBar |
611 | 375 | * @mask: a #GdkRectangle with the position and dimension of the connection | 447 | * @mask: a #GdkRectangle with the position and dimension of the tail |
612 | 376 | * | 448 | * |
613 | 377 | * Moves and resizes connection. | 449 | * Moves and resizes tail. |
614 | 378 | **/ | 450 | **/ |
615 | 379 | void | 451 | void |
616 | 380 | os_pager_connect (OsPager *pager, | 452 | os_bar_connect (OsBar *bar, |
617 | 381 | GdkRectangle mask) | 453 | GdkRectangle mask) |
618 | 382 | { | 454 | { |
619 | 383 | OsPagerPrivate *priv; | 455 | OsBarPrivate *priv; |
620 | 384 | 456 | ||
621 | 385 | g_return_if_fail (OS_IS_PAGER (pager)); | 457 | g_return_if_fail (OS_IS_BAR (bar)); |
622 | 386 | 458 | ||
623 | 387 | priv = pager->priv; | 459 | priv = bar->priv; |
624 | 388 | 460 | ||
625 | 389 | if (!rectangle_changed (priv->connection_mask, mask)) | 461 | if (!os_animation_is_running (priv->tail_animation) && |
626 | 390 | return; | 462 | !rectangle_changed (priv->tail_mask, mask)) |
582 | 391 | |||
583 | 392 | priv->connection_mask = mask; | ||
584 | 393 | |||
585 | 394 | if (priv->parent == NULL) | ||
586 | 395 | return; | ||
587 | 396 | |||
588 | 397 | mask_connection (pager); | ||
589 | 398 | } | ||
590 | 399 | |||
591 | 400 | /** | ||
592 | 401 | * os_pager_hide: | ||
593 | 402 | * @pager: a #OsPager | ||
594 | 403 | * | ||
595 | 404 | * Hides the #OsPager. | ||
596 | 405 | **/ | ||
597 | 406 | void | ||
598 | 407 | os_pager_hide (OsPager *pager) | ||
599 | 408 | { | ||
600 | 409 | OsPagerPrivate *priv; | ||
601 | 410 | |||
602 | 411 | g_return_if_fail (OS_IS_PAGER (pager)); | ||
603 | 412 | |||
604 | 413 | priv = pager->priv; | ||
605 | 414 | |||
606 | 415 | priv->visible = FALSE; | ||
607 | 416 | |||
608 | 417 | if (priv->parent == NULL) | ||
627 | 418 | return; | 463 | return; |
628 | 419 | 464 | ||
629 | 420 | /* If there's an animation currently running, stop it. */ | 465 | /* If there's an animation currently running, stop it. */ |
637 | 421 | os_animation_stop (priv->animation, change_state_stop_cb); | 466 | os_animation_stop (priv->tail_animation, NULL); |
638 | 422 | 467 | ||
639 | 423 | gdk_window_hide (priv->connection_window); | 468 | priv->tail_mask = mask; |
640 | 424 | gdk_window_hide (priv->pager_window); | 469 | |
641 | 425 | } | 470 | if (priv->parent == NULL) |
642 | 426 | 471 | return; | |
643 | 427 | /* Move a mask on the pager_window, fake movement. */ | 472 | |
644 | 473 | mask_tail (bar); | ||
645 | 474 | } | ||
646 | 475 | |||
647 | 476 | /** | ||
648 | 477 | * os_bar_hide: | ||
649 | 478 | * @bar: a #OsBar | ||
650 | 479 | * | ||
651 | 480 | * Hides the #OsBar. | ||
652 | 481 | **/ | ||
653 | 482 | void | ||
654 | 483 | os_bar_hide (OsBar *bar) | ||
655 | 484 | { | ||
656 | 485 | OsBarPrivate *priv; | ||
657 | 486 | |||
658 | 487 | g_return_if_fail (OS_IS_BAR (bar)); | ||
659 | 488 | |||
660 | 489 | priv = bar->priv; | ||
661 | 490 | |||
662 | 491 | priv->visible = FALSE; | ||
663 | 492 | |||
664 | 493 | if (priv->parent == NULL) | ||
665 | 494 | return; | ||
666 | 495 | |||
667 | 496 | /* Immediately hide, then stop animations. */ | ||
668 | 497 | gdk_window_hide (priv->tail_window); | ||
669 | 498 | gdk_window_hide (priv->bar_window); | ||
670 | 499 | |||
671 | 500 | os_animation_stop (priv->tail_animation, retract_tail_stop_cb); | ||
672 | 501 | os_animation_stop (priv->state_animation, change_state_stop_cb); | ||
673 | 502 | } | ||
674 | 503 | |||
675 | 504 | /* Move a mask on the bar_window, fake movement. */ | ||
676 | 428 | static void | 505 | static void |
678 | 429 | mask_pager (OsPager *pager) | 506 | mask_bar (OsBar *bar) |
679 | 430 | { | 507 | { |
686 | 431 | OsPagerPrivate *priv; | 508 | OsBarPrivate *priv; |
687 | 432 | 509 | ||
688 | 433 | priv = pager->priv; | 510 | priv = bar->priv; |
689 | 434 | 511 | ||
690 | 435 | gdk_window_shape_combine_region (priv->pager_window, | 512 | gdk_window_shape_combine_region (priv->bar_window, |
691 | 436 | SHAPE_REGION(&priv->mask), | 513 | SHAPE_REGION(&priv->bar_mask), |
692 | 437 | 0, 0); | 514 | 0, 0); |
693 | 438 | } | 515 | } |
694 | 439 | 516 | ||
695 | 440 | /** | 517 | /** |
699 | 441 | * os_pager_move_resize: | 518 | * os_bar_move_resize: |
700 | 442 | * @pager: a #OsPager | 519 | * @bar: a #OsBar |
701 | 443 | * @mask: a #GdkRectangle with the position and dimension of the #OsPager | 520 | * @mask: a #GdkRectangle with the position and dimension of the #OsBar |
702 | 444 | * | 521 | * |
704 | 445 | * Moves and resizes @pager. | 522 | * Moves and resizes @bar. |
705 | 446 | **/ | 523 | **/ |
706 | 447 | void | 524 | void |
709 | 448 | os_pager_move_resize (OsPager *pager, | 525 | os_bar_move_resize (OsBar *bar, |
710 | 449 | GdkRectangle mask) | 526 | GdkRectangle mask) |
711 | 450 | { | 527 | { |
719 | 451 | OsPagerPrivate *priv; | 528 | OsBarPrivate *priv; |
720 | 452 | 529 | ||
721 | 453 | g_return_if_fail (OS_IS_PAGER (pager)); | 530 | g_return_if_fail (OS_IS_BAR (bar)); |
722 | 454 | 531 | ||
723 | 455 | priv = pager->priv; | 532 | priv = bar->priv; |
724 | 456 | 533 | ||
725 | 457 | if (!rectangle_changed (priv->mask, mask)) | 534 | if (!rectangle_changed (priv->bar_mask, mask)) |
726 | 458 | return; | 535 | return; |
727 | 459 | 536 | ||
729 | 460 | priv->mask = mask; | 537 | priv->bar_mask = mask; |
730 | 461 | 538 | ||
731 | 462 | if (priv->parent == NULL) | 539 | if (priv->parent == NULL) |
732 | 463 | return; | 540 | return; |
733 | 464 | 541 | ||
735 | 465 | mask_pager (pager); | 542 | mask_bar (bar); |
736 | 466 | } | 543 | } |
737 | 467 | 544 | ||
738 | 468 | /** | 545 | /** |
741 | 469 | * os_pager_set_active: | 546 | * os_bar_set_active: |
742 | 470 | * @pager: a #OsPager | 547 | * @bar: a #OsBar |
743 | 471 | * @active: whether is active or not | 548 | * @active: whether is active or not |
745 | 472 | * @animation: whether animate it or not | 549 | * @animate: whether animate it or not |
746 | 473 | * | 550 | * |
748 | 474 | * Changes the activity state of @pager. | 551 | * Changes the activity state of @bar. |
749 | 475 | **/ | 552 | **/ |
750 | 476 | void | 553 | void |
754 | 477 | os_pager_set_active (OsPager *pager, | 554 | os_bar_set_active (OsBar *bar, |
755 | 478 | gboolean active, | 555 | gboolean active, |
756 | 479 | gboolean animate) | 556 | gboolean animate) |
757 | 480 | { | 557 | { |
766 | 481 | OsPagerPrivate *priv; | 558 | OsBarPrivate *priv; |
767 | 482 | 559 | ||
768 | 483 | g_return_if_fail (OS_IS_PAGER (pager)); | 560 | g_return_if_fail (OS_IS_BAR (bar)); |
769 | 484 | 561 | ||
770 | 485 | priv = pager->priv; | 562 | priv = bar->priv; |
771 | 486 | 563 | ||
772 | 487 | /* Set the state and draw even if there's an animation running, that is | 564 | /* Set the state and draw even if there's a state_animation running, that is |
773 | 488 | * (!animate && os_animation_is_running (priv->animation)). */ | 565 | * (!animate && os_animation_is_running (priv->state_animation)). */ |
774 | 489 | if ((priv->active != active) || | 566 | if ((priv->active != active) || |
776 | 490 | (!animate && os_animation_is_running (priv->animation))) | 567 | (!animate && os_animation_is_running (priv->state_animation))) |
777 | 491 | { | 568 | { |
778 | 492 | gboolean visible; | 569 | gboolean visible; |
779 | 493 | 570 | ||
780 | @@ -496,43 +573,45 @@ | |||
781 | 496 | if (priv->parent == NULL) | 573 | if (priv->parent == NULL) |
782 | 497 | return; | 574 | return; |
783 | 498 | 575 | ||
785 | 499 | visible = gdk_window_is_visible (priv->pager_window); | 576 | visible = gdk_window_is_visible (priv->bar_window); |
786 | 500 | 577 | ||
787 | 501 | if (visible) | 578 | if (visible) |
789 | 502 | os_animation_stop (priv->animation, NULL); | 579 | os_animation_stop (priv->state_animation, NULL); |
790 | 503 | 580 | ||
791 | 504 | if (visible && animate) | 581 | if (visible && animate) |
792 | 505 | { | 582 | { |
796 | 506 | os_animation_set_duration (priv->animation, priv->active ? DURATION_FADE_IN : | 583 | os_animation_set_duration (priv->state_animation, priv->active ? DURATION_FADE_IN : |
797 | 507 | DURATION_FADE_OUT); | 584 | DURATION_FADE_OUT); |
798 | 508 | os_animation_start (priv->animation); | 585 | os_animation_start (priv->state_animation); |
799 | 509 | } | 586 | } |
800 | 510 | 587 | ||
801 | 511 | if (!visible || !animate) | 588 | if (!visible || !animate) |
802 | 512 | { | 589 | { |
803 | 513 | priv->weight = 1.0f; | 590 | priv->weight = 1.0f; |
804 | 514 | 591 | ||
806 | 515 | draw_pager (pager); | 592 | draw_bar (bar); |
807 | 516 | } | 593 | } |
808 | 517 | } | 594 | } |
809 | 518 | } | 595 | } |
810 | 519 | 596 | ||
811 | 520 | /** | 597 | /** |
815 | 521 | * os_pager_set_detached: | 598 | * os_bar_set_detached: |
816 | 522 | * @pager: a #OsPager | 599 | * @bar: a #OsBar |
817 | 523 | * @detached: whether the pager is detached or not | 600 | * @detached: whether the bar is detached or not |
818 | 601 | * @animate: whether animate it or not | ||
819 | 524 | * | 602 | * |
821 | 525 | * Changes the detached state of @pager. | 603 | * Changes the detached state of @bar. |
822 | 526 | **/ | 604 | **/ |
823 | 527 | void | 605 | void |
826 | 528 | os_pager_set_detached (OsPager *pager, | 606 | os_bar_set_detached (OsBar *bar, |
827 | 529 | gboolean detached) | 607 | gboolean detached, |
828 | 608 | gboolean animate) | ||
829 | 530 | { | 609 | { |
835 | 531 | OsPagerPrivate *priv; | 610 | OsBarPrivate *priv; |
836 | 532 | 611 | ||
837 | 533 | g_return_if_fail (OS_IS_PAGER (pager)); | 612 | g_return_if_fail (OS_IS_BAR (bar)); |
838 | 534 | 613 | ||
839 | 535 | priv = pager->priv; | 614 | priv = bar->priv; |
840 | 536 | 615 | ||
841 | 537 | if (priv->detached != detached) | 616 | if (priv->detached != detached) |
842 | 538 | { | 617 | { |
843 | @@ -543,27 +622,49 @@ | |||
844 | 543 | 622 | ||
845 | 544 | if (priv->detached) | 623 | if (priv->detached) |
846 | 545 | { | 624 | { |
849 | 546 | gdk_window_show (priv->connection_window); | 625 | /* If there's a tail animation currently running, stop it. */ |
850 | 547 | gdk_window_raise (priv->pager_window); | 626 | os_animation_stop (priv->tail_animation, retract_tail_stop_cb); |
851 | 627 | |||
852 | 628 | /* No tail connection animation yet. */ | ||
853 | 629 | gdk_window_show (priv->tail_window); | ||
854 | 630 | gdk_window_raise (priv->bar_window); | ||
855 | 631 | } | ||
856 | 632 | else if (animate) | ||
857 | 633 | { | ||
858 | 634 | gint32 duration; | ||
859 | 635 | |||
860 | 636 | /* The detached state should already stop this. */ | ||
861 | 637 | OS_DCHECK (!os_animation_is_running (priv->tail_animation)); | ||
862 | 638 | |||
863 | 639 | /* Calculate and set the duration. */ | ||
864 | 640 | if (priv->allocation.height >= priv->allocation.width) | ||
865 | 641 | duration = MIN_DURATION_TAIL + ((gdouble) priv->tail_mask.height / priv->allocation.height) * | ||
866 | 642 | (MAX_DURATION_TAIL - MIN_DURATION_TAIL); | ||
867 | 643 | else | ||
868 | 644 | duration = MIN_DURATION_TAIL + ((gdouble) priv->tail_mask.width / priv->allocation.width) * | ||
869 | 645 | (MAX_DURATION_TAIL - MIN_DURATION_TAIL); | ||
870 | 646 | os_animation_set_duration (priv->tail_animation, duration); | ||
871 | 647 | |||
872 | 648 | os_animation_start (priv->tail_animation); | ||
873 | 548 | } | 649 | } |
874 | 549 | else | 650 | else |
876 | 550 | gdk_window_hide (priv->connection_window); | 651 | gdk_window_hide (priv->tail_window); |
877 | 551 | } | 652 | } |
878 | 552 | } | 653 | } |
879 | 553 | 654 | ||
881 | 554 | /* Create connection_window and pager_window. */ | 655 | /* Create tail_window and bar_window. */ |
882 | 555 | static void | 656 | static void |
884 | 556 | create_windows (OsPager *pager) | 657 | create_windows (OsBar *bar) |
885 | 557 | { | 658 | { |
886 | 558 | GdkWindowAttr attributes; | 659 | GdkWindowAttr attributes; |
888 | 559 | OsPagerPrivate *priv; | 660 | OsBarPrivate *priv; |
889 | 560 | 661 | ||
891 | 561 | priv = pager->priv; | 662 | priv = bar->priv; |
892 | 562 | 663 | ||
893 | 563 | /* Instead reparenting, | 664 | /* Instead reparenting, |
894 | 564 | * which doesn't seem to work well, | 665 | * which doesn't seem to work well, |
895 | 565 | * destroy the two windows. */ | 666 | * destroy the two windows. */ |
897 | 566 | if (priv->connection_window != NULL) | 667 | if (priv->tail_window != NULL) |
898 | 567 | { | 668 | { |
899 | 568 | /* From the Gdk documentation: | 669 | /* From the Gdk documentation: |
900 | 569 | * "Note that a window will not be destroyed | 670 | * "Note that a window will not be destroyed |
901 | @@ -571,13 +672,13 @@ | |||
902 | 571 | * reaches zero. You must call | 672 | * reaches zero. You must call |
903 | 572 | * gdk_window_destroy () | 673 | * gdk_window_destroy () |
904 | 573 | * yourself before that happens". */ | 674 | * yourself before that happens". */ |
906 | 574 | gdk_window_destroy (priv->connection_window); | 675 | gdk_window_destroy (priv->tail_window); |
907 | 575 | 676 | ||
910 | 576 | g_object_unref (priv->connection_window); | 677 | g_object_unref (priv->tail_window); |
911 | 577 | priv->connection_window = NULL; | 678 | priv->tail_window = NULL; |
912 | 578 | } | 679 | } |
913 | 579 | 680 | ||
915 | 580 | if (priv->pager_window != NULL) | 681 | if (priv->bar_window != NULL) |
916 | 581 | { | 682 | { |
917 | 582 | /* From the Gdk documentation: | 683 | /* From the Gdk documentation: |
918 | 583 | * "Note that a window will not be destroyed | 684 | * "Note that a window will not be destroyed |
919 | @@ -585,10 +686,10 @@ | |||
920 | 585 | * reaches zero. You must call | 686 | * reaches zero. You must call |
921 | 586 | * gdk_window_destroy () | 687 | * gdk_window_destroy () |
922 | 587 | * yourself before that happens". */ | 688 | * yourself before that happens". */ |
924 | 588 | gdk_window_destroy (priv->pager_window); | 689 | gdk_window_destroy (priv->bar_window); |
925 | 589 | 690 | ||
928 | 590 | g_object_unref (priv->pager_window); | 691 | g_object_unref (priv->bar_window); |
929 | 591 | priv->pager_window = NULL; | 692 | priv->bar_window = NULL; |
930 | 592 | } | 693 | } |
931 | 593 | 694 | ||
932 | 594 | attributes.event_mask = 0; | 695 | attributes.event_mask = 0; |
933 | @@ -601,8 +702,8 @@ | |||
934 | 601 | attributes.colormap = gtk_widget_get_colormap (priv->parent); | 702 | attributes.colormap = gtk_widget_get_colormap (priv->parent); |
935 | 602 | #endif | 703 | #endif |
936 | 603 | 704 | ||
939 | 604 | /* connection_window. */ | 705 | /* tail_window. */ |
940 | 605 | priv->connection_window = gdk_window_new (gtk_widget_get_window (priv->parent), | 706 | priv->tail_window = gdk_window_new (gtk_widget_get_window (priv->parent), |
941 | 606 | &attributes, | 707 | &attributes, |
942 | 607 | #ifdef USE_GTK3 | 708 | #ifdef USE_GTK3 |
943 | 608 | GDK_WA_VISUAL); | 709 | GDK_WA_VISUAL); |
944 | @@ -610,13 +711,13 @@ | |||
945 | 610 | GDK_WA_VISUAL | GDK_WA_COLORMAP); | 711 | GDK_WA_VISUAL | GDK_WA_COLORMAP); |
946 | 611 | #endif | 712 | #endif |
947 | 612 | 713 | ||
949 | 613 | g_object_ref_sink (priv->connection_window); | 714 | g_object_ref_sink (priv->tail_window); |
950 | 614 | 715 | ||
952 | 615 | gdk_window_set_transient_for (priv->connection_window, | 716 | gdk_window_set_transient_for (priv->tail_window, |
953 | 616 | gtk_widget_get_window (priv->parent)); | 717 | gtk_widget_get_window (priv->parent)); |
954 | 617 | 718 | ||
955 | 618 | /* FIXME(Cimi) maybe this is not required with 0 as event mask. */ | 719 | /* FIXME(Cimi) maybe this is not required with 0 as event mask. */ |
957 | 619 | gdk_window_input_shape_combine_region (priv->connection_window, | 720 | gdk_window_input_shape_combine_region (priv->tail_window, |
958 | 620 | #ifdef USE_GTK3 | 721 | #ifdef USE_GTK3 |
959 | 621 | cairo_region_create (), | 722 | cairo_region_create (), |
960 | 622 | #else | 723 | #else |
961 | @@ -624,22 +725,22 @@ | |||
962 | 624 | #endif | 725 | #endif |
963 | 625 | 0, 0); | 726 | 0, 0); |
964 | 626 | 727 | ||
968 | 627 | /* pager_window. */ | 728 | /* bar_window. */ |
969 | 628 | priv->pager_window = gdk_window_new (gtk_widget_get_window (priv->parent), | 729 | priv->bar_window = gdk_window_new (gtk_widget_get_window (priv->parent), |
970 | 629 | &attributes, | 730 | &attributes, |
971 | 630 | #ifdef USE_GTK3 | 731 | #ifdef USE_GTK3 |
973 | 631 | GDK_WA_VISUAL); | 732 | GDK_WA_VISUAL); |
974 | 632 | #else | 733 | #else |
976 | 633 | GDK_WA_VISUAL | GDK_WA_COLORMAP); | 734 | GDK_WA_VISUAL | GDK_WA_COLORMAP); |
977 | 634 | #endif | 735 | #endif |
978 | 635 | 736 | ||
980 | 636 | g_object_ref_sink (priv->pager_window); | 737 | g_object_ref_sink (priv->bar_window); |
981 | 637 | 738 | ||
983 | 638 | gdk_window_set_transient_for (priv->pager_window, | 739 | gdk_window_set_transient_for (priv->bar_window, |
984 | 639 | gtk_widget_get_window (priv->parent)); | 740 | gtk_widget_get_window (priv->parent)); |
985 | 640 | 741 | ||
986 | 641 | /* FIXME(Cimi) maybe this is not required with 0 as event mask. */ | 742 | /* FIXME(Cimi) maybe this is not required with 0 as event mask. */ |
988 | 642 | gdk_window_input_shape_combine_region (priv->pager_window, | 743 | gdk_window_input_shape_combine_region (priv->bar_window, |
989 | 643 | #ifdef USE_GTK3 | 744 | #ifdef USE_GTK3 |
990 | 644 | cairo_region_create (), | 745 | cairo_region_create (), |
991 | 645 | #else | 746 | #else |
992 | @@ -649,30 +750,30 @@ | |||
993 | 649 | } | 750 | } |
994 | 650 | 751 | ||
995 | 651 | /** | 752 | /** |
998 | 652 | * os_pager_set_parent: | 753 | * os_bar_set_parent: |
999 | 653 | * @pager: a #OsPager | 754 | * @bar: a #OsBar |
1000 | 654 | * @parent: a #GtkWidget | 755 | * @parent: a #GtkWidget |
1001 | 655 | * | 756 | * |
1002 | 656 | * Sets the parent widget | 757 | * Sets the parent widget |
1003 | 657 | **/ | 758 | **/ |
1004 | 658 | void | 759 | void |
1007 | 659 | os_pager_set_parent (OsPager *pager, | 760 | os_bar_set_parent (OsBar *bar, |
1008 | 660 | GtkWidget *parent) | 761 | GtkWidget *parent) |
1009 | 661 | { | 762 | { |
1019 | 662 | OsPagerPrivate *priv; | 763 | OsBarPrivate *priv; |
1020 | 663 | 764 | ||
1021 | 664 | g_return_if_fail (OS_IS_PAGER (pager)); | 765 | g_return_if_fail (OS_IS_BAR (bar)); |
1022 | 665 | 766 | ||
1023 | 666 | priv = pager->priv; | 767 | priv = bar->priv; |
1024 | 667 | 768 | ||
1025 | 668 | /* Stop currently running animation. */ | 769 | /* Stop currently running animations. */ |
1026 | 669 | if (priv->animation != NULL) | 770 | if (priv->tail_animation != NULL) |
1027 | 670 | os_animation_stop (priv->animation, NULL); | 771 | os_animation_stop (priv->tail_animation, retract_tail_stop_cb); |
1028 | 772 | if (priv->state_animation != NULL) | ||
1029 | 773 | os_animation_stop (priv->state_animation, NULL); | ||
1030 | 671 | 774 | ||
1031 | 672 | if (priv->parent != NULL) | 775 | if (priv->parent != NULL) |
1035 | 673 | { | 776 | g_object_unref (priv->parent); |
1033 | 674 | g_object_unref (priv->parent); | ||
1034 | 675 | } | ||
1036 | 676 | 777 | ||
1037 | 677 | priv->parent = parent; | 778 | priv->parent = parent; |
1038 | 678 | 779 | ||
1039 | @@ -682,69 +783,67 @@ | |||
1040 | 682 | 783 | ||
1041 | 683 | priv->weight = 1.0f; | 784 | priv->weight = 1.0f; |
1042 | 684 | 785 | ||
1047 | 685 | create_windows (pager); | 786 | create_windows (bar); |
1048 | 686 | draw_connection (pager); | 787 | draw_tail (bar); |
1049 | 687 | draw_pager (pager); | 788 | draw_bar (bar); |
1050 | 688 | mask_pager (pager); | 789 | mask_bar (bar); |
1051 | 689 | 790 | ||
1053 | 690 | gdk_window_move_resize (priv->connection_window, | 791 | gdk_window_move_resize (priv->tail_window, |
1054 | 691 | priv->allocation.x, | 792 | priv->allocation.x, |
1055 | 692 | priv->allocation.y, | 793 | priv->allocation.y, |
1056 | 693 | priv->allocation.width, | 794 | priv->allocation.width, |
1057 | 694 | priv->allocation.height); | 795 | priv->allocation.height); |
1058 | 695 | 796 | ||
1060 | 696 | gdk_window_move_resize (priv->pager_window, | 797 | gdk_window_move_resize (priv->bar_window, |
1061 | 697 | priv->allocation.x, | 798 | priv->allocation.x, |
1062 | 698 | priv->allocation.y, | 799 | priv->allocation.y, |
1063 | 699 | priv->allocation.width, | 800 | priv->allocation.width, |
1064 | 700 | priv->allocation.height); | 801 | priv->allocation.height); |
1065 | 701 | 802 | ||
1066 | 702 | if (priv->visible) | 803 | if (priv->visible) |
1070 | 703 | { | 804 | gdk_window_show (priv->bar_window); |
1068 | 704 | gdk_window_show (priv->pager_window); | ||
1069 | 705 | } | ||
1071 | 706 | } | 805 | } |
1072 | 707 | } | 806 | } |
1073 | 708 | 807 | ||
1074 | 709 | /** | 808 | /** |
1077 | 710 | * os_pager_show: | 809 | * os_bar_show: |
1078 | 711 | * @pager: a #OsPager | 810 | * @bar: a #OsBar |
1079 | 712 | * | 811 | * |
1081 | 713 | * Shows @pager. | 812 | * Shows @bar. |
1082 | 714 | **/ | 813 | **/ |
1083 | 715 | void | 814 | void |
1085 | 716 | os_pager_show (OsPager *pager) | 815 | os_bar_show (OsBar *bar) |
1086 | 717 | { | 816 | { |
1092 | 718 | OsPagerPrivate *priv; | 817 | OsBarPrivate *priv; |
1093 | 719 | 818 | ||
1094 | 720 | g_return_if_fail (OS_IS_PAGER (pager)); | 819 | g_return_if_fail (OS_IS_BAR (bar)); |
1095 | 721 | 820 | ||
1096 | 722 | priv = pager->priv; | 821 | priv = bar->priv; |
1097 | 723 | 822 | ||
1098 | 724 | priv->visible = TRUE; | 823 | priv->visible = TRUE; |
1099 | 725 | 824 | ||
1100 | 726 | if (priv->parent == NULL) | 825 | if (priv->parent == NULL) |
1101 | 727 | return; | 826 | return; |
1102 | 728 | 827 | ||
1104 | 729 | gdk_window_show (priv->pager_window); | 828 | gdk_window_show (priv->bar_window); |
1105 | 730 | } | 829 | } |
1106 | 731 | 830 | ||
1107 | 732 | /** | 831 | /** |
1110 | 733 | * os_pager_size_allocate: | 832 | * os_bar_size_allocate: |
1111 | 734 | * @pager: a #OsPager | 833 | * @bar: a #OsBar |
1112 | 735 | * @rectangle: a #GdkRectangle | 834 | * @rectangle: a #GdkRectangle |
1113 | 736 | * | 835 | * |
1114 | 737 | * Sets the position and dimension of the whole area. | 836 | * Sets the position and dimension of the whole area. |
1115 | 738 | **/ | 837 | **/ |
1116 | 739 | void | 838 | void |
1119 | 740 | os_pager_size_allocate (OsPager *pager, | 839 | os_bar_size_allocate (OsBar *bar, |
1120 | 741 | GdkRectangle rectangle) | 840 | GdkRectangle rectangle) |
1121 | 742 | { | 841 | { |
1127 | 743 | OsPagerPrivate *priv; | 842 | OsBarPrivate *priv; |
1128 | 744 | 843 | ||
1129 | 745 | g_return_if_fail (OS_IS_PAGER (pager)); | 844 | g_return_if_fail (OS_IS_BAR (bar)); |
1130 | 746 | 845 | ||
1131 | 747 | priv = pager->priv; | 846 | priv = bar->priv; |
1132 | 748 | 847 | ||
1133 | 749 | if (!rectangle_changed (priv->allocation, rectangle)) | 848 | if (!rectangle_changed (priv->allocation, rectangle)) |
1134 | 750 | return; | 849 | return; |
1135 | @@ -754,13 +853,13 @@ | |||
1136 | 754 | if (priv->parent == NULL) | 853 | if (priv->parent == NULL) |
1137 | 755 | return; | 854 | return; |
1138 | 756 | 855 | ||
1140 | 757 | gdk_window_move_resize (priv->connection_window, | 856 | gdk_window_move_resize (priv->tail_window, |
1141 | 758 | rectangle.x, | 857 | rectangle.x, |
1142 | 759 | rectangle.y, | 858 | rectangle.y, |
1143 | 760 | rectangle.width, | 859 | rectangle.width, |
1144 | 761 | rectangle.height); | 860 | rectangle.height); |
1145 | 762 | 861 | ||
1147 | 763 | gdk_window_move_resize (priv->pager_window, | 862 | gdk_window_move_resize (priv->bar_window, |
1148 | 764 | rectangle.x, | 863 | rectangle.x, |
1149 | 765 | rectangle.y, | 864 | rectangle.y, |
1150 | 766 | rectangle.width, | 865 | rectangle.width, |
1151 | 767 | 866 | ||
1152 | === modified file 'os/os-private.h' | |||
1153 | --- os/os-private.h 2011-10-05 12:24:21 +0000 | |||
1154 | +++ os/os-private.h 2011-10-12 17:16:23 +0000 | |||
1155 | @@ -30,7 +30,11 @@ | |||
1156 | 30 | #pragma GCC visibility push(hidden) | 30 | #pragma GCC visibility push(hidden) |
1157 | 31 | #endif /* __GNUC__ */ | 31 | #endif /* __GNUC__ */ |
1158 | 32 | 32 | ||
1159 | 33 | /* Rate of the animations (frames per second). */ | ||
1160 | 34 | #define RATE_ANIMATION 30 | ||
1161 | 35 | |||
1162 | 33 | /* Size of the thumb in pixels. */ | 36 | /* Size of the thumb in pixels. */ |
1163 | 37 | #define MIN_THUMB_HEIGHT 35 | ||
1164 | 34 | #define THUMB_WIDTH 17 | 38 | #define THUMB_WIDTH 17 |
1165 | 35 | #define THUMB_HEIGHT 69 | 39 | #define THUMB_HEIGHT 69 |
1166 | 36 | 40 | ||
1167 | @@ -39,14 +43,19 @@ | |||
1168 | 39 | 43 | ||
1169 | 40 | G_BEGIN_DECLS | 44 | G_BEGIN_DECLS |
1170 | 41 | 45 | ||
1171 | 46 | typedef struct | ||
1172 | 47 | { | ||
1173 | 48 | gint x; | ||
1174 | 49 | gint y; | ||
1175 | 50 | } OsCoordinate; | ||
1176 | 51 | |||
1177 | 42 | typedef enum | 52 | typedef enum |
1178 | 43 | { | 53 | { |
1179 | 44 | OS_EVENT_NONE = 0, | 54 | OS_EVENT_NONE = 0, |
1180 | 45 | OS_EVENT_BUTTON_PRESS = 1, | 55 | OS_EVENT_BUTTON_PRESS = 1, |
1181 | 46 | OS_EVENT_ENTER_NOTIFY = 2, | 56 | OS_EVENT_ENTER_NOTIFY = 2, |
1185 | 47 | OS_EVENT_MOTION_NOTIFY = 4, | 57 | OS_EVENT_MOTION_NOTIFY = 4 |
1186 | 48 | OS_EVENT_VALUE_CHANGED = 8 | 58 | } OsEventFlags; |
1184 | 49 | } OsEvent; | ||
1187 | 50 | 59 | ||
1188 | 51 | /* os-log.c */ | 60 | /* os-log.c */ |
1189 | 52 | 61 | ||
1190 | @@ -150,6 +159,57 @@ | |||
1191 | 150 | void os_animation_stop (OsAnimation *animation, | 159 | void os_animation_stop (OsAnimation *animation, |
1192 | 151 | OsAnimationStopFunc stop_func); | 160 | OsAnimationStopFunc stop_func); |
1193 | 152 | 161 | ||
1194 | 162 | /* os-bar.c */ | ||
1195 | 163 | |||
1196 | 164 | #define OS_TYPE_BAR (os_bar_get_type ()) | ||
1197 | 165 | #define OS_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OS_TYPE_BAR, OsBar)) | ||
1198 | 166 | #define OS_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OS_TYPE_BAR, OsBarClass)) | ||
1199 | 167 | #define OS_IS_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OS_TYPE_BAR)) | ||
1200 | 168 | #define OS_IS_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OS_TYPE_BAR)) | ||
1201 | 169 | #define OS_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OS_TYPE_BAR, OsBarClass)) | ||
1202 | 170 | |||
1203 | 171 | typedef struct _OsBar OsBar; | ||
1204 | 172 | typedef struct _OsBarClass OsBarClass; | ||
1205 | 173 | typedef struct _OsBarPrivate OsBarPrivate; | ||
1206 | 174 | |||
1207 | 175 | struct _OsBar { | ||
1208 | 176 | GObject parent_instance; | ||
1209 | 177 | |||
1210 | 178 | OsBarPrivate *priv; | ||
1211 | 179 | }; | ||
1212 | 180 | |||
1213 | 181 | struct _OsBarClass { | ||
1214 | 182 | GObjectClass parent_class; | ||
1215 | 183 | }; | ||
1216 | 184 | |||
1217 | 185 | GType os_bar_get_type (void) G_GNUC_CONST; | ||
1218 | 186 | |||
1219 | 187 | OsBar* os_bar_new (void); | ||
1220 | 188 | |||
1221 | 189 | void os_bar_hide (OsBar *bar); | ||
1222 | 190 | |||
1223 | 191 | void os_bar_connect (OsBar *bar, | ||
1224 | 192 | GdkRectangle mask); | ||
1225 | 193 | |||
1226 | 194 | void os_bar_move_resize (OsBar *bar, | ||
1227 | 195 | GdkRectangle mask); | ||
1228 | 196 | |||
1229 | 197 | void os_bar_set_active (OsBar *bar, | ||
1230 | 198 | gboolean active, | ||
1231 | 199 | gboolean animate); | ||
1232 | 200 | |||
1233 | 201 | void os_bar_set_detached (OsBar *bar, | ||
1234 | 202 | gboolean detached, | ||
1235 | 203 | gboolean animate); | ||
1236 | 204 | |||
1237 | 205 | void os_bar_set_parent (OsBar *bar, | ||
1238 | 206 | GtkWidget *parent); | ||
1239 | 207 | |||
1240 | 208 | void os_bar_show (OsBar *bar); | ||
1241 | 209 | |||
1242 | 210 | void os_bar_size_allocate (OsBar *bar, | ||
1243 | 211 | GdkRectangle rectangle); | ||
1244 | 212 | |||
1245 | 153 | /* os-thumb.c */ | 213 | /* os-thumb.c */ |
1246 | 154 | 214 | ||
1247 | 155 | #define OS_TYPE_THUMB (os_thumb_get_type ()) | 215 | #define OS_TYPE_THUMB (os_thumb_get_type ()) |
1248 | @@ -184,56 +244,6 @@ | |||
1249 | 184 | void os_thumb_set_detached (OsThumb *thumb, | 244 | void os_thumb_set_detached (OsThumb *thumb, |
1250 | 185 | gboolean detached); | 245 | gboolean detached); |
1251 | 186 | 246 | ||
1252 | 187 | /* os-pager.c */ | ||
1253 | 188 | |||
1254 | 189 | #define OS_TYPE_PAGER (os_pager_get_type ()) | ||
1255 | 190 | #define OS_PAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OS_TYPE_PAGER, OsPager)) | ||
1256 | 191 | #define OS_PAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OS_TYPE_PAGER, OsPagerClass)) | ||
1257 | 192 | #define OS_IS_PAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OS_TYPE_PAGER)) | ||
1258 | 193 | #define OS_IS_PAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OS_TYPE_PAGER)) | ||
1259 | 194 | #define OS_PAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OS_TYPE_PAGER, OsPagerClass)) | ||
1260 | 195 | |||
1261 | 196 | typedef struct _OsPager OsPager; | ||
1262 | 197 | typedef struct _OsPagerClass OsPagerClass; | ||
1263 | 198 | typedef struct _OsPagerPrivate OsPagerPrivate; | ||
1264 | 199 | |||
1265 | 200 | struct _OsPager { | ||
1266 | 201 | GObject parent_instance; | ||
1267 | 202 | |||
1268 | 203 | OsPagerPrivate *priv; | ||
1269 | 204 | }; | ||
1270 | 205 | |||
1271 | 206 | struct _OsPagerClass { | ||
1272 | 207 | GObjectClass parent_class; | ||
1273 | 208 | }; | ||
1274 | 209 | |||
1275 | 210 | GType os_pager_get_type (void) G_GNUC_CONST; | ||
1276 | 211 | |||
1277 | 212 | OsPager* os_pager_new (void); | ||
1278 | 213 | |||
1279 | 214 | void os_pager_hide (OsPager *pager); | ||
1280 | 215 | |||
1281 | 216 | void os_pager_connect (OsPager *pager, | ||
1282 | 217 | GdkRectangle mask); | ||
1283 | 218 | |||
1284 | 219 | void os_pager_move_resize (OsPager *pager, | ||
1285 | 220 | GdkRectangle mask); | ||
1286 | 221 | |||
1287 | 222 | void os_pager_set_active (OsPager *pager, | ||
1288 | 223 | gboolean active, | ||
1289 | 224 | gboolean animate); | ||
1290 | 225 | |||
1291 | 226 | void os_pager_set_detached (OsPager *pager, | ||
1292 | 227 | gboolean detached); | ||
1293 | 228 | |||
1294 | 229 | void os_pager_set_parent (OsPager *pager, | ||
1295 | 230 | GtkWidget *parent); | ||
1296 | 231 | |||
1297 | 232 | void os_pager_show (OsPager *pager); | ||
1298 | 233 | |||
1299 | 234 | void os_pager_size_allocate (OsPager *pager, | ||
1300 | 235 | GdkRectangle rectangle); | ||
1301 | 236 | |||
1302 | 237 | G_END_DECLS | 247 | G_END_DECLS |
1303 | 238 | 248 | ||
1304 | 239 | #ifdef __GNUC__ | 249 | #ifdef __GNUC__ |
1305 | 240 | 250 | ||
1306 | === modified file 'os/os-scrollbar.c' | |||
1307 | --- os/os-scrollbar.c 2011-10-05 12:24:21 +0000 | |||
1308 | +++ os/os-scrollbar.c 2011-10-12 17:16:23 +0000 | |||
1309 | @@ -34,20 +34,17 @@ | |||
1310 | 34 | #include <X11/Xutil.h> | 34 | #include <X11/Xutil.h> |
1311 | 35 | #include <X11/extensions/XInput2.h> | 35 | #include <X11/extensions/XInput2.h> |
1312 | 36 | 36 | ||
1315 | 37 | /* Size of the pager in pixels. */ | 37 | /* Size of the bar in pixels. */ |
1316 | 38 | #define PAGER_SIZE 3 | 38 | #define BAR_SIZE 3 |
1317 | 39 | 39 | ||
1318 | 40 | /* Size of the proximity effect in pixels. */ | 40 | /* Size of the proximity effect in pixels. */ |
1319 | 41 | #define PROXIMITY_SIZE 30 | 41 | #define PROXIMITY_SIZE 30 |
1320 | 42 | 42 | ||
1329 | 43 | /* Rate of the paging. */ | 43 | /* Max duration of the scrolling. */ |
1330 | 44 | #define RATE_PAGING 30 | 44 | #define MAX_DURATION_SCROLLING 1000 |
1331 | 45 | 45 | ||
1332 | 46 | /* Max duration of the paging. */ | 46 | /* Min duration of the scrolling. */ |
1333 | 47 | #define MAX_DURATION_PAGING 1000 | 47 | #define MIN_DURATION_SCROLLING 250 |
1326 | 48 | |||
1327 | 49 | /* Min duration of the paging. */ | ||
1328 | 50 | #define MIN_DURATION_PAGING 250 | ||
1334 | 51 | 48 | ||
1335 | 52 | /* Timeout assumed for PropertyNotify _NET_ACTIVE_WINDOW event. */ | 49 | /* Timeout assumed for PropertyNotify _NET_ACTIVE_WINDOW event. */ |
1336 | 53 | #define TIMEOUT_PRESENT_WINDOW 400 | 50 | #define TIMEOUT_PRESENT_WINDOW 400 |
1337 | @@ -58,6 +55,9 @@ | |||
1338 | 58 | /* Timeout before hiding in ms, after leaving the thumb. */ | 55 | /* Timeout before hiding in ms, after leaving the thumb. */ |
1339 | 59 | #define TIMEOUT_THUMB_HIDE 200 | 56 | #define TIMEOUT_THUMB_HIDE 200 |
1340 | 60 | 57 | ||
1341 | 58 | /* Timeout before showing in ms, after entering the proximity. */ | ||
1342 | 59 | #define TIMEOUT_THUMB_SHOW 100 | ||
1343 | 60 | |||
1344 | 61 | /* Timeout before hiding in ms, after leaving the toplevel. */ | 61 | /* Timeout before hiding in ms, after leaving the toplevel. */ |
1345 | 62 | #define TIMEOUT_TOPLEVEL_HIDE 200 | 62 | #define TIMEOUT_TOPLEVEL_HIDE 200 |
1346 | 63 | 63 | ||
1347 | @@ -71,48 +71,60 @@ | |||
1348 | 71 | 71 | ||
1349 | 72 | typedef enum | 72 | typedef enum |
1350 | 73 | { | 73 | { |
1351 | 74 | OS_STATE_NONE = 0, | ||
1352 | 75 | OS_STATE_CONNECTED = 1, | ||
1353 | 76 | OS_STATE_DETACHED = 2, | ||
1354 | 77 | OS_STATE_FULLSIZE = 4, | ||
1355 | 78 | OS_STATE_INTERNAL = 8, | ||
1356 | 79 | OS_STATE_LOCKED = 16, | ||
1357 | 80 | OS_STATE_RECONNECTING = 32 | ||
1358 | 81 | } OsStateFlags; | ||
1359 | 82 | |||
1360 | 83 | typedef enum | ||
1361 | 84 | { | ||
1362 | 74 | OS_STRUT_SIDE_NONE = 0, | 85 | OS_STRUT_SIDE_NONE = 0, |
1363 | 75 | OS_STRUT_SIDE_TOP = 1, | 86 | OS_STRUT_SIDE_TOP = 1, |
1364 | 76 | OS_STRUT_SIDE_BOTTOM = 2, | 87 | OS_STRUT_SIDE_BOTTOM = 2, |
1365 | 77 | OS_STRUT_SIDE_LEFT = 4, | 88 | OS_STRUT_SIDE_LEFT = 4, |
1366 | 78 | OS_STRUT_SIDE_RIGHT = 8 | 89 | OS_STRUT_SIDE_RIGHT = 8 |
1368 | 79 | } OsStrutSide; | 90 | } OsStrutSideFlags; |
1369 | 91 | |||
1370 | 92 | typedef struct | ||
1371 | 93 | { | ||
1372 | 94 | gboolean proximity; | ||
1373 | 95 | gboolean running; | ||
1374 | 96 | } OsWindowFilter; | ||
1375 | 80 | 97 | ||
1376 | 81 | struct _OsScrollbarPrivate | 98 | struct _OsScrollbarPrivate |
1377 | 82 | { | 99 | { |
1378 | 83 | GdkRectangle overlay; | 100 | GdkRectangle overlay; |
1379 | 84 | GdkRectangle slider; | 101 | GdkRectangle slider; |
1380 | 85 | GdkRectangle trough; | 102 | GdkRectangle trough; |
1382 | 86 | GtkAllocation pager_all; | 103 | GtkAllocation bar_all; |
1383 | 87 | GtkAllocation thumb_all; | 104 | GtkAllocation thumb_all; |
1384 | 88 | GtkAdjustment *adjustment; | 105 | GtkAdjustment *adjustment; |
1385 | 89 | GtkOrientation orientation; | 106 | GtkOrientation orientation; |
1386 | 90 | GtkWidget *thumb; | 107 | GtkWidget *thumb; |
1387 | 91 | GtkWindowGroup *window_group; | 108 | GtkWindowGroup *window_group; |
1388 | 92 | OsAnimation *animation; | 109 | OsAnimation *animation; |
1390 | 93 | OsPager *pager; | 110 | OsBar *bar; |
1391 | 111 | OsCoordinate pointer; | ||
1392 | 112 | OsCoordinate thumb_win; | ||
1393 | 113 | OsEventFlags event; | ||
1394 | 114 | OsStateFlags state; | ||
1395 | 94 | OsSide side; | 115 | OsSide side; |
1397 | 95 | OsEvent event; | 116 | OsWindowFilter filter; |
1398 | 96 | gboolean active_window; | 117 | gboolean active_window; |
1408 | 97 | gboolean can_deactivate_pager; | 118 | gboolean deactivable_bar; |
1409 | 98 | gboolean can_hide; | 119 | gboolean hidable_thumb; |
1410 | 99 | gboolean detached_scroll; | 120 | gboolean window_button_press; /* FIXME(Cimi) to replace with X11 input events. */ |
1402 | 100 | gboolean filter; | ||
1403 | 101 | gboolean fullsize; | ||
1404 | 102 | gboolean internal; | ||
1405 | 103 | gboolean lock_position; | ||
1406 | 104 | gboolean proximity; | ||
1407 | 105 | gboolean toplevel_button_press; | ||
1411 | 106 | gdouble value; | 121 | gdouble value; |
1412 | 107 | gint win_x; | ||
1413 | 108 | gint win_y; | ||
1414 | 109 | gint slide_initial_slider_position; | 122 | gint slide_initial_slider_position; |
1415 | 110 | gint slide_initial_coordinate; | 123 | gint slide_initial_coordinate; |
1416 | 111 | gint pointer_x; | ||
1417 | 112 | gint pointer_y; | ||
1418 | 113 | gint64 present_time; | 124 | gint64 present_time; |
1420 | 114 | guint32 source_deactivate_pager_id; | 125 | guint32 source_deactivate_bar_id; |
1421 | 115 | guint32 source_hide_thumb_id; | 126 | guint32 source_hide_thumb_id; |
1422 | 127 | guint32 source_show_thumb_id; | ||
1423 | 116 | guint32 source_unlock_thumb_id; | 128 | guint32 source_unlock_thumb_id; |
1424 | 117 | }; | 129 | }; |
1425 | 118 | 130 | ||
1426 | @@ -159,10 +171,10 @@ | |||
1427 | 159 | static void os_scrollbar_dispose (GObject *object); | 171 | static void os_scrollbar_dispose (GObject *object); |
1428 | 160 | static void os_scrollbar_finalize (GObject *object); | 172 | static void os_scrollbar_finalize (GObject *object); |
1429 | 161 | 173 | ||
1431 | 162 | /* Calculate pager layout info. */ | 174 | /* Calculate bar layout info. */ |
1432 | 163 | static void | 175 | static void |
1435 | 164 | calc_layout_pager (OsScrollbar *scrollbar, | 176 | calc_layout_bar (OsScrollbar *scrollbar, |
1436 | 165 | gdouble adjustment_value) | 177 | gdouble adjustment_value) |
1437 | 166 | { | 178 | { |
1438 | 167 | OsScrollbarPrivate *priv; | 179 | OsScrollbarPrivate *priv; |
1439 | 168 | 180 | ||
1440 | @@ -279,6 +291,23 @@ | |||
1441 | 279 | } | 291 | } |
1442 | 280 | } | 292 | } |
1443 | 281 | 293 | ||
1444 | 294 | /* Calculate the position of the thumb window. */ | ||
1445 | 295 | static void | ||
1446 | 296 | calc_thumb_window_position (OsScrollbar *scrollbar) | ||
1447 | 297 | { | ||
1448 | 298 | OsScrollbarPrivate *priv; | ||
1449 | 299 | gint x_pos, y_pos; | ||
1450 | 300 | |||
1451 | 301 | priv = scrollbar->priv; | ||
1452 | 302 | |||
1453 | 303 | /* In reality, I'm storing widget's window, not the toplevel. | ||
1454 | 304 | * Is that the same with gdk_window_get_origin? */ | ||
1455 | 305 | gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos); | ||
1456 | 306 | |||
1457 | 307 | priv->thumb_win.x = x_pos + priv->thumb_all.x; | ||
1458 | 308 | priv->thumb_win.y = y_pos + priv->thumb_all.y; | ||
1459 | 309 | } | ||
1460 | 310 | |||
1461 | 282 | /* Calculate the workarea using _UNITY_NET_WORKAREA_REGION. */ | 311 | /* Calculate the workarea using _UNITY_NET_WORKAREA_REGION. */ |
1462 | 283 | static void | 312 | static void |
1463 | 284 | calc_workarea (Display *display, | 313 | calc_workarea (Display *display, |
1464 | @@ -327,21 +356,114 @@ | |||
1465 | 327 | } | 356 | } |
1466 | 328 | } | 357 | } |
1467 | 329 | 358 | ||
1481 | 330 | /* Deactivate the pager if it's the case. */ | 359 | /* Check whether the thumb movement can be considered connected or not. */ |
1482 | 331 | static void | 360 | static void |
1483 | 332 | deactivate_pager (OsScrollbar *scrollbar) | 361 | check_connection (OsScrollbar *scrollbar) |
1484 | 333 | { | 362 | { |
1485 | 334 | OsScrollbarPrivate *priv; | 363 | OsScrollbarPrivate *priv; |
1486 | 335 | 364 | gint x_pos, y_pos; | |
1487 | 336 | priv = scrollbar->priv; | 365 | |
1488 | 337 | 366 | priv = scrollbar->priv; | |
1489 | 338 | if (priv->pager != NULL && priv->can_deactivate_pager) | 367 | |
1490 | 339 | os_pager_set_active (priv->pager, FALSE, TRUE); | 368 | /* This seems to be required to get proper values. */ |
1491 | 340 | } | 369 | calc_layout_bar (scrollbar, gtk_adjustment_get_value (priv->adjustment)); |
1492 | 341 | 370 | calc_layout_slider (scrollbar, gtk_adjustment_get_value (priv->adjustment)); | |
1493 | 342 | /* Timeout before deactivating the pager. */ | 371 | |
1494 | 372 | gdk_window_get_origin (gtk_widget_get_window (priv->thumb), &x_pos, &y_pos); | ||
1495 | 373 | |||
1496 | 374 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | ||
1497 | 375 | { | ||
1498 | 376 | if (priv->overlay.height > priv->slider.height) | ||
1499 | 377 | { | ||
1500 | 378 | if (y_pos >= priv->thumb_win.y + priv->overlay.y && | ||
1501 | 379 | y_pos + priv->slider.height <= priv->thumb_win.y + priv->overlay.y + priv->overlay.height) | ||
1502 | 380 | priv->state |= OS_STATE_CONNECTED; | ||
1503 | 381 | else | ||
1504 | 382 | priv->state &= ~(OS_STATE_CONNECTED); | ||
1505 | 383 | } | ||
1506 | 384 | else | ||
1507 | 385 | { | ||
1508 | 386 | if (y_pos == priv->thumb_win.y + priv->slider.y) | ||
1509 | 387 | priv->state |= OS_STATE_CONNECTED; | ||
1510 | 388 | else | ||
1511 | 389 | priv->state &= ~(OS_STATE_CONNECTED); | ||
1512 | 390 | } | ||
1513 | 391 | } | ||
1514 | 392 | else | ||
1515 | 393 | { | ||
1516 | 394 | if (priv->overlay.width > priv->slider.width) | ||
1517 | 395 | { | ||
1518 | 396 | if (x_pos >= priv->thumb_win.x + priv->overlay.x && | ||
1519 | 397 | x_pos + priv->slider.width <= priv->thumb_win.x + priv->overlay.x + priv->overlay.width) | ||
1520 | 398 | priv->state |= OS_STATE_CONNECTED; | ||
1521 | 399 | else | ||
1522 | 400 | priv->state &= ~(OS_STATE_CONNECTED); | ||
1523 | 401 | } | ||
1524 | 402 | else | ||
1525 | 403 | { | ||
1526 | 404 | if (x_pos == priv->thumb_win.x + priv->slider.x) | ||
1527 | 405 | priv->state |= OS_STATE_CONNECTED; | ||
1528 | 406 | else | ||
1529 | 407 | priv->state &= ~(OS_STATE_CONNECTED); | ||
1530 | 408 | } | ||
1531 | 409 | } | ||
1532 | 410 | } | ||
1533 | 411 | |||
1534 | 412 | /* Traduce coordinates into GtkRange values. */ | ||
1535 | 413 | static gdouble | ||
1536 | 414 | coord_to_value (OsScrollbar *scrollbar, | ||
1537 | 415 | gint coord) | ||
1538 | 416 | { | ||
1539 | 417 | OsScrollbarPrivate *priv; | ||
1540 | 418 | gdouble frac; | ||
1541 | 419 | gdouble value; | ||
1542 | 420 | gint trough_length; | ||
1543 | 421 | gint slider_length; | ||
1544 | 422 | |||
1545 | 423 | priv = scrollbar->priv; | ||
1546 | 424 | |||
1547 | 425 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | ||
1548 | 426 | { | ||
1549 | 427 | trough_length = priv->trough.height; | ||
1550 | 428 | slider_length = MAX (priv->slider.height, priv->overlay.height); | ||
1551 | 429 | } | ||
1552 | 430 | else | ||
1553 | 431 | { | ||
1554 | 432 | trough_length = priv->trough.width; | ||
1555 | 433 | slider_length = MAX (priv->slider.width, priv->overlay.width); | ||
1556 | 434 | } | ||
1557 | 435 | |||
1558 | 436 | if (trough_length == slider_length) | ||
1559 | 437 | frac = 1.0; | ||
1560 | 438 | else | ||
1561 | 439 | frac = (MAX (0, coord) / (gdouble) (trough_length - slider_length)); | ||
1562 | 440 | |||
1563 | 441 | value = gtk_adjustment_get_lower (priv->adjustment) + frac * (gtk_adjustment_get_upper (priv->adjustment) - | ||
1564 | 442 | gtk_adjustment_get_lower (priv->adjustment) - | ||
1565 | 443 | gtk_adjustment_get_page_size (priv->adjustment)); | ||
1566 | 444 | |||
1567 | 445 | value = CLAMP (value, | ||
1568 | 446 | gtk_adjustment_get_lower (priv->adjustment), | ||
1569 | 447 | gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment)); | ||
1570 | 448 | |||
1571 | 449 | return value; | ||
1572 | 450 | } | ||
1573 | 451 | |||
1574 | 452 | /* Deactivate the bar if it's the case. */ | ||
1575 | 453 | static void | ||
1576 | 454 | deactivate_bar (OsScrollbar *scrollbar) | ||
1577 | 455 | { | ||
1578 | 456 | OsScrollbarPrivate *priv; | ||
1579 | 457 | |||
1580 | 458 | priv = scrollbar->priv; | ||
1581 | 459 | |||
1582 | 460 | if (priv->bar != NULL && priv->deactivable_bar) | ||
1583 | 461 | os_bar_set_active (priv->bar, FALSE, TRUE); | ||
1584 | 462 | } | ||
1585 | 463 | |||
1586 | 464 | /* Timeout before deactivating the bar. */ | ||
1587 | 343 | static gboolean | 465 | static gboolean |
1589 | 344 | deactivate_pager_cb (gpointer user_data) | 466 | deactivate_bar_cb (gpointer user_data) |
1590 | 345 | { | 467 | { |
1591 | 346 | OsScrollbar *scrollbar; | 468 | OsScrollbar *scrollbar; |
1592 | 347 | OsScrollbarPrivate *priv; | 469 | OsScrollbarPrivate *priv; |
1593 | @@ -351,8 +473,8 @@ | |||
1594 | 351 | 473 | ||
1595 | 352 | OS_DCHECK (!priv->active_window); | 474 | OS_DCHECK (!priv->active_window); |
1596 | 353 | 475 | ||
1599 | 354 | deactivate_pager (scrollbar); | 476 | deactivate_bar (scrollbar); |
1600 | 355 | priv->source_deactivate_pager_id = 0; | 477 | priv->source_deactivate_bar_id = 0; |
1601 | 356 | 478 | ||
1602 | 357 | return FALSE; | 479 | return FALSE; |
1603 | 358 | } | 480 | } |
1604 | @@ -365,7 +487,7 @@ | |||
1605 | 365 | 487 | ||
1606 | 366 | priv = scrollbar->priv; | 488 | priv = scrollbar->priv; |
1607 | 367 | 489 | ||
1609 | 368 | if (priv->can_hide) | 490 | if (priv->hidable_thumb) |
1610 | 369 | gtk_widget_hide (priv->thumb); | 491 | gtk_widget_hide (priv->thumb); |
1611 | 370 | } | 492 | } |
1612 | 371 | 493 | ||
1613 | @@ -396,9 +518,9 @@ | |||
1614 | 396 | #endif | 518 | #endif |
1615 | 397 | } | 519 | } |
1616 | 398 | 520 | ||
1618 | 399 | /* Move the pager. */ | 521 | /* Move the bar. */ |
1619 | 400 | static void | 522 | static void |
1621 | 401 | move_pager (OsScrollbar *scrollbar) | 523 | move_bar (OsScrollbar *scrollbar) |
1622 | 402 | { | 524 | { |
1623 | 403 | GdkRectangle mask; | 525 | GdkRectangle mask; |
1624 | 404 | OsScrollbarPrivate *priv; | 526 | OsScrollbarPrivate *priv; |
1625 | @@ -409,7 +531,7 @@ | |||
1626 | 409 | { | 531 | { |
1627 | 410 | mask.x = 0; | 532 | mask.x = 0; |
1628 | 411 | mask.y = priv->overlay.y; | 533 | mask.y = priv->overlay.y; |
1630 | 412 | mask.width = priv->pager_all.width; | 534 | mask.width = priv->bar_all.width; |
1631 | 413 | mask.height = priv->overlay.height; | 535 | mask.height = priv->overlay.height; |
1632 | 414 | } | 536 | } |
1633 | 415 | else | 537 | else |
1634 | @@ -417,10 +539,10 @@ | |||
1635 | 417 | mask.x = priv->overlay.x; | 539 | mask.x = priv->overlay.x; |
1636 | 418 | mask.y = 0; | 540 | mask.y = 0; |
1637 | 419 | mask.width = priv->overlay.width; | 541 | mask.width = priv->overlay.width; |
1639 | 420 | mask.height = priv->pager_all.height; | 542 | mask.height = priv->bar_all.height; |
1640 | 421 | } | 543 | } |
1641 | 422 | 544 | ||
1643 | 423 | os_pager_move_resize (priv->pager, mask); | 545 | os_bar_move_resize (priv->bar, mask); |
1644 | 424 | } | 546 | } |
1645 | 425 | 547 | ||
1646 | 426 | /* Sanitize x coordinate of thumb window. */ | 548 | /* Sanitize x coordinate of thumb window. */ |
1647 | @@ -481,7 +603,7 @@ | |||
1648 | 481 | 603 | ||
1649 | 482 | for (i = 0; i < cairo_region_num_rectangles (struts_region); i++) | 604 | for (i = 0; i < cairo_region_num_rectangles (struts_region); i++) |
1650 | 483 | { | 605 | { |
1652 | 484 | OsStrutSide strut_side; | 606 | OsStrutSideFlags strut_side; |
1653 | 485 | gint count; | 607 | gint count; |
1654 | 486 | 608 | ||
1655 | 487 | cairo_region_get_rectangle (struts_region, i, &tmp_rect); | 609 | cairo_region_get_rectangle (struts_region, i, &tmp_rect); |
1656 | @@ -548,7 +670,7 @@ | |||
1657 | 548 | (n_monitor != gdk_screen_get_monitor_at_point (screen, monitor_x + priv->thumb_all.width, y) || | 670 | (n_monitor != gdk_screen_get_monitor_at_point (screen, monitor_x + priv->thumb_all.width, y) || |
1658 | 549 | monitor_x + priv->thumb_all.width >= screen_width)) | 671 | monitor_x + priv->thumb_all.width >= screen_width)) |
1659 | 550 | { | 672 | { |
1661 | 551 | priv->internal = TRUE; | 673 | priv->state |= OS_STATE_INTERNAL; |
1662 | 552 | return MAX (x - priv->thumb_all.width, screen_width - priv->thumb_all.width); | 674 | return MAX (x - priv->thumb_all.width, screen_width - priv->thumb_all.width); |
1663 | 553 | } | 675 | } |
1664 | 554 | 676 | ||
1665 | @@ -556,12 +678,12 @@ | |||
1666 | 556 | (n_monitor != gdk_screen_get_monitor_at_point (screen, monitor_x - priv->thumb_all.width, y) || | 678 | (n_monitor != gdk_screen_get_monitor_at_point (screen, monitor_x - priv->thumb_all.width, y) || |
1667 | 557 | monitor_x - priv->thumb_all.width <= screen_x)) | 679 | monitor_x - priv->thumb_all.width <= screen_x)) |
1668 | 558 | { | 680 | { |
1670 | 559 | priv->internal = TRUE; | 681 | priv->state |= OS_STATE_INTERNAL; |
1671 | 560 | return MAX (x, screen_x); | 682 | return MAX (x, screen_x); |
1672 | 561 | } | 683 | } |
1673 | 562 | 684 | ||
1674 | 563 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 685 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
1676 | 564 | priv->internal = FALSE; | 686 | priv->state &= ~(OS_STATE_INTERNAL); |
1677 | 565 | 687 | ||
1678 | 566 | return x; | 688 | return x; |
1679 | 567 | } | 689 | } |
1680 | @@ -624,7 +746,7 @@ | |||
1681 | 624 | 746 | ||
1682 | 625 | for (i = 0; i < cairo_region_num_rectangles (struts_region); i++) | 747 | for (i = 0; i < cairo_region_num_rectangles (struts_region); i++) |
1683 | 626 | { | 748 | { |
1685 | 627 | OsStrutSide strut_side; | 749 | OsStrutSideFlags strut_side; |
1686 | 628 | gint count; | 750 | gint count; |
1687 | 629 | 751 | ||
1688 | 630 | cairo_region_get_rectangle (struts_region, i, &tmp_rect); | 752 | cairo_region_get_rectangle (struts_region, i, &tmp_rect); |
1689 | @@ -691,7 +813,7 @@ | |||
1690 | 691 | (n_monitor != gdk_screen_get_monitor_at_point (screen, x, monitor_y + priv->thumb_all.height) || | 813 | (n_monitor != gdk_screen_get_monitor_at_point (screen, x, monitor_y + priv->thumb_all.height) || |
1691 | 692 | monitor_y + priv->thumb_all.height >= screen_height)) | 814 | monitor_y + priv->thumb_all.height >= screen_height)) |
1692 | 693 | { | 815 | { |
1694 | 694 | priv->internal = TRUE; | 816 | priv->state |= OS_STATE_INTERNAL; |
1695 | 695 | return MAX (y - priv->thumb_all.height, screen_height - priv->thumb_all.height); | 817 | return MAX (y - priv->thumb_all.height, screen_height - priv->thumb_all.height); |
1696 | 696 | } | 818 | } |
1697 | 697 | 819 | ||
1698 | @@ -699,12 +821,12 @@ | |||
1699 | 699 | (n_monitor != gdk_screen_get_monitor_at_point (screen, x, monitor_y - priv->thumb_all.height) || | 821 | (n_monitor != gdk_screen_get_monitor_at_point (screen, x, monitor_y - priv->thumb_all.height) || |
1700 | 700 | monitor_y - priv->thumb_all.height <= screen_y)) | 822 | monitor_y - priv->thumb_all.height <= screen_y)) |
1701 | 701 | { | 823 | { |
1703 | 702 | priv->internal = TRUE; | 824 | priv->state |= OS_STATE_INTERNAL; |
1704 | 703 | return MAX (y, screen_y); | 825 | return MAX (y, screen_y); |
1705 | 704 | } | 826 | } |
1706 | 705 | 827 | ||
1707 | 706 | if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) | 828 | if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) |
1709 | 707 | priv->internal = FALSE; | 829 | priv->state &= ~(OS_STATE_INTERNAL); |
1710 | 708 | 830 | ||
1711 | 709 | return y; | 831 | return y; |
1712 | 710 | } | 832 | } |
1713 | @@ -752,10 +874,10 @@ | |||
1714 | 752 | swap_thumb (scrollbar, os_thumb_new (priv->orientation)); | 874 | swap_thumb (scrollbar, os_thumb_new (priv->orientation)); |
1715 | 753 | } | 875 | } |
1716 | 754 | 876 | ||
1718 | 755 | /* Callback called by the paging animation. */ | 877 | /* Callback called by the scrolling animation. */ |
1719 | 756 | static void | 878 | static void |
1722 | 757 | paging_cb (gfloat weight, | 879 | scrolling_cb (gfloat weight, |
1723 | 758 | gpointer user_data) | 880 | gpointer user_data) |
1724 | 759 | { | 881 | { |
1725 | 760 | gdouble new_value; | 882 | gdouble new_value; |
1726 | 761 | OsScrollbar *scrollbar; | 883 | OsScrollbar *scrollbar; |
1727 | @@ -779,6 +901,22 @@ | |||
1728 | 779 | gtk_adjustment_set_value (priv->adjustment, new_value); | 901 | gtk_adjustment_set_value (priv->adjustment, new_value); |
1729 | 780 | } | 902 | } |
1730 | 781 | 903 | ||
1731 | 904 | /* End function called by the scrolling animation. */ | ||
1732 | 905 | static void | ||
1733 | 906 | scrolling_end_cb (gpointer user_data) | ||
1734 | 907 | { | ||
1735 | 908 | OsScrollbar *scrollbar; | ||
1736 | 909 | OsScrollbarPrivate *priv; | ||
1737 | 910 | |||
1738 | 911 | scrollbar = OS_SCROLLBAR (user_data); | ||
1739 | 912 | |||
1740 | 913 | priv = scrollbar->priv; | ||
1741 | 914 | |||
1742 | 915 | priv->state &= ~(OS_STATE_RECONNECTING); | ||
1743 | 916 | |||
1744 | 917 | check_connection (scrollbar); | ||
1745 | 918 | } | ||
1746 | 919 | |||
1747 | 782 | /* Swap adjustment pointer. */ | 920 | /* Swap adjustment pointer. */ |
1748 | 783 | static void | 921 | static void |
1749 | 784 | swap_adjustment (OsScrollbar *scrollbar, | 922 | swap_adjustment (OsScrollbar *scrollbar, |
1750 | @@ -879,8 +1017,8 @@ | |||
1751 | 879 | scrollbar = OS_SCROLLBAR (user_data); | 1017 | scrollbar = OS_SCROLLBAR (user_data); |
1752 | 880 | priv = scrollbar->priv; | 1018 | priv = scrollbar->priv; |
1753 | 881 | 1019 | ||
1756 | 882 | if (priv->can_hide) | 1020 | if (priv->hidable_thumb) |
1757 | 883 | priv->lock_position = FALSE; | 1021 | priv->state &= ~(OS_STATE_LOCKED); |
1758 | 884 | 1022 | ||
1759 | 885 | priv->source_unlock_thumb_id = 0; | 1023 | priv->source_unlock_thumb_id = 0; |
1760 | 886 | 1024 | ||
1761 | @@ -899,43 +1037,43 @@ | |||
1762 | 899 | scrollbar = OS_SCROLLBAR (user_data); | 1037 | scrollbar = OS_SCROLLBAR (user_data); |
1763 | 900 | priv = scrollbar->priv; | 1038 | priv = scrollbar->priv; |
1764 | 901 | 1039 | ||
1767 | 902 | /* FIXME(Cimi) we should control each time os_pager_show()/hide() | 1040 | /* FIXME(Cimi) we should control each time os_bar_show ()/hide () |
1768 | 903 | * is called here and in map()/unmap(). | 1041 | * is called here and in map ()/unmap (). |
1769 | 904 | * We are arbitrary calling that and I'm frightened we should show or keep | 1042 | * We are arbitrary calling that and I'm frightened we should show or keep |
1773 | 905 | * hidden a pager that is meant to be hidden/shown. | 1043 | * hidden a bar that is meant to be hidden/shown. |
1774 | 906 | * I don't want to see pagers reappearing because | 1044 | * I don't want to see bars reappearing because |
1775 | 907 | * of a change in the adjustment of an invisible pager or viceversa. */ | 1045 | * of a change in the adjustment of an invisible bar or viceversa. */ |
1776 | 908 | if (gtk_adjustment_get_upper (adjustment) - gtk_adjustment_get_lower (adjustment) > | 1046 | if (gtk_adjustment_get_upper (adjustment) - gtk_adjustment_get_lower (adjustment) > |
1777 | 909 | gtk_adjustment_get_page_size (adjustment)) | 1047 | gtk_adjustment_get_page_size (adjustment)) |
1778 | 910 | { | 1048 | { |
1782 | 911 | priv->fullsize = FALSE; | 1049 | priv->state &= ~(OS_STATE_FULLSIZE); |
1783 | 912 | if (priv->proximity != FALSE) | 1050 | if (priv->filter.proximity) |
1784 | 913 | os_pager_show (priv->pager); | 1051 | os_bar_show (priv->bar); |
1785 | 914 | } | 1052 | } |
1786 | 915 | else | 1053 | else |
1787 | 916 | { | 1054 | { |
1790 | 917 | priv->fullsize = TRUE; | 1055 | priv->state |= OS_STATE_FULLSIZE; |
1791 | 918 | if (priv->proximity != FALSE) | 1056 | if (priv->filter.proximity) |
1792 | 919 | { | 1057 | { |
1794 | 920 | os_pager_hide (priv->pager); | 1058 | os_bar_hide (priv->bar); |
1795 | 921 | 1059 | ||
1796 | 922 | gtk_widget_hide (priv->thumb); | 1060 | gtk_widget_hide (priv->thumb); |
1797 | 923 | } | 1061 | } |
1798 | 924 | } | 1062 | } |
1799 | 925 | 1063 | ||
1801 | 926 | calc_layout_pager (scrollbar, gtk_adjustment_get_value (adjustment)); | 1064 | calc_layout_bar (scrollbar, gtk_adjustment_get_value (adjustment)); |
1802 | 927 | calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment)); | 1065 | calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment)); |
1803 | 928 | 1066 | ||
1804 | 929 | if (!(priv->event & OS_EVENT_ENTER_NOTIFY) && | 1067 | if (!(priv->event & OS_EVENT_ENTER_NOTIFY) && |
1805 | 930 | !(priv->event & OS_EVENT_MOTION_NOTIFY)) | 1068 | !(priv->event & OS_EVENT_MOTION_NOTIFY)) |
1806 | 931 | gtk_widget_hide (priv->thumb); | 1069 | gtk_widget_hide (priv->thumb); |
1807 | 932 | 1070 | ||
1809 | 933 | move_pager (scrollbar); | 1071 | move_bar (scrollbar); |
1810 | 934 | } | 1072 | } |
1811 | 935 | 1073 | ||
1813 | 936 | /* Update the visual connection between pager and thumb. */ | 1074 | /* Update the tail (visual connection) between bar and thumb. */ |
1814 | 937 | static void | 1075 | static void |
1816 | 938 | update_visual_connection (OsScrollbar *scrollbar) | 1076 | update_tail (OsScrollbar *scrollbar) |
1817 | 939 | { | 1077 | { |
1818 | 940 | OsScrollbarPrivate *priv; | 1078 | OsScrollbarPrivate *priv; |
1819 | 941 | gint x_pos, y_pos; | 1079 | gint x_pos, y_pos; |
1820 | @@ -946,73 +1084,85 @@ | |||
1821 | 946 | 1084 | ||
1822 | 947 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 1085 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
1823 | 948 | { | 1086 | { |
1825 | 949 | if (priv->win_y + priv->overlay.y >= y_pos + priv->slider.height) | 1087 | if (priv->thumb_win.y + priv->overlay.y >= y_pos + priv->slider.height) |
1826 | 950 | { | 1088 | { |
1827 | 951 | GdkRectangle mask; | 1089 | GdkRectangle mask; |
1828 | 952 | 1090 | ||
1829 | 953 | mask.x = 0; | 1091 | mask.x = 0; |
1832 | 954 | mask.y = y_pos + priv->slider.height / 2 - priv->win_y; | 1092 | mask.y = y_pos + priv->slider.height / 2 - priv->thumb_win.y; |
1833 | 955 | mask.width = priv->pager_all.width; | 1093 | mask.width = priv->bar_all.width; |
1834 | 956 | mask.height = priv->overlay.y - mask.y; | 1094 | mask.height = priv->overlay.y - mask.y; |
1835 | 957 | 1095 | ||
1839 | 958 | os_pager_connect (priv->pager, mask); | 1096 | os_bar_connect (priv->bar, mask); |
1840 | 959 | os_pager_set_detached (priv->pager, TRUE); | 1097 | |
1841 | 960 | 1098 | priv->state |= OS_STATE_DETACHED; | |
1842 | 1099 | |||
1843 | 1100 | os_bar_set_detached (priv->bar, TRUE, FALSE); | ||
1844 | 961 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); | 1101 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); |
1845 | 962 | } | 1102 | } |
1847 | 963 | else if (priv->win_y + priv->overlay.y + priv->overlay.height <= y_pos) | 1103 | else if (priv->thumb_win.y + priv->overlay.y + priv->overlay.height <= y_pos) |
1848 | 964 | { | 1104 | { |
1849 | 965 | GdkRectangle mask; | 1105 | GdkRectangle mask; |
1850 | 966 | 1106 | ||
1851 | 967 | mask.x = 0; | 1107 | mask.x = 0; |
1852 | 968 | mask.y = priv->overlay.y + priv->overlay.height; | 1108 | mask.y = priv->overlay.y + priv->overlay.height; |
1859 | 969 | mask.width = priv->pager_all.width; | 1109 | mask.width = priv->bar_all.width; |
1860 | 970 | mask.height = y_pos + priv->slider.height / 2 - priv->win_y - mask.y; | 1110 | mask.height = y_pos + priv->slider.height / 2 - priv->thumb_win.y - mask.y; |
1861 | 971 | 1111 | ||
1862 | 972 | os_pager_connect (priv->pager, mask); | 1112 | os_bar_connect (priv->bar, mask); |
1863 | 973 | os_pager_set_detached (priv->pager, TRUE); | 1113 | |
1864 | 974 | 1114 | priv->state |= OS_STATE_DETACHED; | |
1865 | 1115 | |||
1866 | 1116 | os_bar_set_detached (priv->bar, TRUE, FALSE); | ||
1867 | 975 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); | 1117 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); |
1868 | 976 | } | 1118 | } |
1870 | 977 | else | 1119 | else |
1871 | 978 | { | 1120 | { |
1873 | 979 | os_pager_set_detached (priv->pager, FALSE); | 1121 | priv->state &= ~(OS_STATE_DETACHED); |
1874 | 1122 | |||
1875 | 1123 | os_bar_set_detached (priv->bar, FALSE, FALSE); | ||
1876 | 980 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); | 1124 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); |
1877 | 981 | } | 1125 | } |
1878 | 982 | } | 1126 | } |
1879 | 983 | else | 1127 | else |
1880 | 984 | { | 1128 | { |
1882 | 985 | if (priv->win_x + priv->overlay.x >= x_pos + priv->slider.width) | 1129 | if (priv->thumb_win.x + priv->overlay.x >= x_pos + priv->slider.width) |
1883 | 986 | { | 1130 | { |
1884 | 987 | GdkRectangle mask; | 1131 | GdkRectangle mask; |
1885 | 988 | 1132 | ||
1887 | 989 | mask.x = x_pos + priv->slider.width / 2 - priv->win_x; | 1133 | mask.x = x_pos + priv->slider.width / 2 - priv->thumb_win.x; |
1888 | 990 | mask.y = 0; | 1134 | mask.y = 0; |
1889 | 991 | mask.width = priv->overlay.x - mask.x; | 1135 | mask.width = priv->overlay.x - mask.x; |
1895 | 992 | mask.height = priv->pager_all.height; | 1136 | mask.height = priv->bar_all.height; |
1896 | 993 | 1137 | ||
1897 | 994 | os_pager_connect (priv->pager, mask); | 1138 | os_bar_connect (priv->bar, mask); |
1898 | 995 | os_pager_set_detached (priv->pager, TRUE); | 1139 | |
1899 | 996 | 1140 | priv->state |= OS_STATE_DETACHED; | |
1900 | 1141 | |||
1901 | 1142 | os_bar_set_detached (priv->bar, TRUE, FALSE); | ||
1902 | 997 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); | 1143 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); |
1903 | 998 | } | 1144 | } |
1905 | 999 | else if (priv->win_x + priv->overlay.x + priv->overlay.width <= x_pos) | 1145 | else if (priv->thumb_win.x + priv->overlay.x + priv->overlay.width <= x_pos) |
1906 | 1000 | { | 1146 | { |
1907 | 1001 | GdkRectangle mask; | 1147 | GdkRectangle mask; |
1908 | 1002 | 1148 | ||
1909 | 1003 | mask.x = priv->overlay.x + priv->overlay.width; | 1149 | mask.x = priv->overlay.x + priv->overlay.width; |
1910 | 1004 | mask.y = 0; | 1150 | mask.y = 0; |
1917 | 1005 | mask.width = x_pos + priv->slider.width / 2 - priv->win_x - mask.x; | 1151 | mask.width = x_pos + priv->slider.width / 2 - priv->thumb_win.x - mask.x; |
1918 | 1006 | mask.height = priv->pager_all.height; | 1152 | mask.height = priv->bar_all.height; |
1919 | 1007 | 1153 | ||
1920 | 1008 | os_pager_connect (priv->pager, mask); | 1154 | os_bar_connect (priv->bar, mask); |
1921 | 1009 | os_pager_set_detached (priv->pager, TRUE); | 1155 | |
1922 | 1010 | 1156 | priv->state |= OS_STATE_DETACHED; | |
1923 | 1157 | |||
1924 | 1158 | os_bar_set_detached (priv->bar, TRUE, FALSE); | ||
1925 | 1011 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); | 1159 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); |
1926 | 1012 | } | 1160 | } |
1927 | 1013 | else | 1161 | else |
1928 | 1014 | { | 1162 | { |
1930 | 1015 | os_pager_set_detached (priv->pager, FALSE); | 1163 | priv->state &= ~(OS_STATE_DETACHED); |
1931 | 1164 | |||
1932 | 1165 | os_bar_set_detached (priv->bar, FALSE, FALSE); | ||
1933 | 1016 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); | 1166 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); |
1934 | 1017 | } | 1167 | } |
1935 | 1018 | } | 1168 | } |
1936 | @@ -1028,35 +1178,28 @@ | |||
1937 | 1028 | scrollbar = OS_SCROLLBAR (user_data); | 1178 | scrollbar = OS_SCROLLBAR (user_data); |
1938 | 1029 | priv = scrollbar->priv; | 1179 | priv = scrollbar->priv; |
1939 | 1030 | 1180 | ||
1941 | 1031 | calc_layout_pager (scrollbar, gtk_adjustment_get_value (adjustment)); | 1181 | calc_layout_bar (scrollbar, gtk_adjustment_get_value (adjustment)); |
1942 | 1032 | calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment)); | 1182 | calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment)); |
1943 | 1033 | 1183 | ||
1944 | 1034 | if (!(priv->event & OS_EVENT_ENTER_NOTIFY) && | 1184 | if (!(priv->event & OS_EVENT_ENTER_NOTIFY) && |
1945 | 1035 | !(priv->event & OS_EVENT_MOTION_NOTIFY)) | 1185 | !(priv->event & OS_EVENT_MOTION_NOTIFY)) |
1946 | 1036 | gtk_widget_hide (priv->thumb); | 1186 | gtk_widget_hide (priv->thumb); |
1947 | 1037 | 1187 | ||
1959 | 1038 | if (gtk_widget_get_mapped (priv->thumb)) | 1188 | if (gtk_widget_get_mapped (priv->thumb) && |
1960 | 1039 | { | 1189 | !((priv->event & OS_EVENT_MOTION_NOTIFY) && |
1961 | 1040 | /* If we're dragging the thumb, it can't be detached. */ | 1190 | (priv->state & OS_STATE_CONNECTED))) |
1962 | 1041 | if (priv->event & OS_EVENT_MOTION_NOTIFY) | 1191 | update_tail (scrollbar); |
1952 | 1042 | { | ||
1953 | 1043 | os_pager_set_detached (priv->pager, FALSE); | ||
1954 | 1044 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); | ||
1955 | 1045 | } | ||
1956 | 1046 | else | ||
1957 | 1047 | update_visual_connection (scrollbar); | ||
1958 | 1048 | } | ||
1963 | 1049 | 1192 | ||
1965 | 1050 | move_pager (scrollbar); | 1193 | move_bar (scrollbar); |
1966 | 1051 | } | 1194 | } |
1967 | 1052 | 1195 | ||
1969 | 1053 | /* Pager functions. */ | 1196 | /* Bar functions. */ |
1970 | 1054 | 1197 | ||
1972 | 1055 | /* Set the state of the pager checking mouse position. */ | 1198 | /* Set the state of the bar checking mouse position. */ |
1973 | 1056 | static void | 1199 | static void |
1977 | 1057 | pager_set_state_from_pointer (OsScrollbar *scrollbar, | 1200 | bar_set_state_from_pointer (OsScrollbar *scrollbar, |
1978 | 1058 | gint x, | 1201 | gint x, |
1979 | 1059 | gint y) | 1202 | gint y) |
1980 | 1060 | { | 1203 | { |
1981 | 1061 | GtkAllocation allocation; | 1204 | GtkAllocation allocation; |
1982 | 1062 | OsScrollbarPrivate *priv; | 1205 | OsScrollbarPrivate *priv; |
1983 | @@ -1070,13 +1213,13 @@ | |||
1984 | 1070 | if ((x > allocation.x && x < allocation.x + allocation.width) && | 1213 | if ((x > allocation.x && x < allocation.x + allocation.width) && |
1985 | 1071 | (y > allocation.y && y < allocation.y + allocation.height)) | 1214 | (y > allocation.y && y < allocation.y + allocation.height)) |
1986 | 1072 | { | 1215 | { |
1989 | 1073 | priv->can_deactivate_pager = FALSE; | 1216 | priv->deactivable_bar = FALSE; |
1990 | 1074 | os_pager_set_active (priv->pager, TRUE, TRUE); | 1217 | os_bar_set_active (priv->bar, TRUE, TRUE); |
1991 | 1075 | } | 1218 | } |
1992 | 1076 | else | 1219 | else |
1993 | 1077 | { | 1220 | { |
1996 | 1078 | priv->can_deactivate_pager = TRUE; | 1221 | priv->deactivable_bar = TRUE; |
1997 | 1079 | os_pager_set_active (priv->pager, FALSE, TRUE); | 1222 | os_bar_set_active (priv->bar, FALSE, TRUE); |
1998 | 1080 | } | 1223 | } |
1999 | 1081 | } | 1224 | } |
2000 | 1082 | 1225 | ||
2001 | @@ -1105,16 +1248,16 @@ | |||
2002 | 1105 | gdk_screen_get_active_window (gtk_widget_get_screen (GTK_WIDGET (scrollbar)))) | 1248 | gdk_screen_get_active_window (gtk_widget_get_screen (GTK_WIDGET (scrollbar)))) |
2003 | 1106 | { | 1249 | { |
2004 | 1107 | /* Stops potential running timeout. */ | 1250 | /* Stops potential running timeout. */ |
2006 | 1108 | if (priv->source_deactivate_pager_id != 0) | 1251 | if (priv->source_deactivate_bar_id != 0) |
2007 | 1109 | { | 1252 | { |
2010 | 1110 | g_source_remove (priv->source_deactivate_pager_id); | 1253 | g_source_remove (priv->source_deactivate_bar_id); |
2011 | 1111 | priv->source_deactivate_pager_id = 0; | 1254 | priv->source_deactivate_bar_id = 0; |
2012 | 1112 | } | 1255 | } |
2013 | 1113 | 1256 | ||
2014 | 1114 | priv->active_window = TRUE; | 1257 | priv->active_window = TRUE; |
2015 | 1115 | 1258 | ||
2018 | 1116 | priv->can_deactivate_pager = FALSE; | 1259 | priv->deactivable_bar = FALSE; |
2019 | 1117 | os_pager_set_active (priv->pager, TRUE, TRUE); | 1260 | os_bar_set_active (priv->bar, TRUE, TRUE); |
2020 | 1118 | } | 1261 | } |
2021 | 1119 | else if (priv->active_window) | 1262 | else if (priv->active_window) |
2022 | 1120 | { | 1263 | { |
2023 | @@ -1147,13 +1290,13 @@ | |||
2024 | 1147 | /* When the window is unfocused, | 1290 | /* When the window is unfocused, |
2025 | 1148 | * check the position of the pointer | 1291 | * check the position of the pointer |
2026 | 1149 | * and set the state accordingly. */ | 1292 | * and set the state accordingly. */ |
2028 | 1150 | pager_set_state_from_pointer (scrollbar, x, y); | 1293 | bar_set_state_from_pointer (scrollbar, x, y); |
2029 | 1151 | } | 1294 | } |
2030 | 1152 | else | 1295 | else |
2031 | 1153 | { | 1296 | { |
2032 | 1154 | /* If the pointer is outside of the window, set it inactive. */ | 1297 | /* If the pointer is outside of the window, set it inactive. */ |
2035 | 1155 | priv->can_deactivate_pager = TRUE; | 1298 | priv->deactivable_bar = TRUE; |
2036 | 1156 | os_pager_set_active (priv->pager, FALSE, TRUE); | 1299 | os_bar_set_active (priv->bar, FALSE, TRUE); |
2037 | 1157 | } | 1300 | } |
2038 | 1158 | 1301 | ||
2039 | 1159 | if ((current_time > end_time) && priv->thumb != NULL) | 1302 | if ((current_time > end_time) && priv->thumb != NULL) |
2040 | @@ -1251,7 +1394,8 @@ | |||
2041 | 1251 | { | 1394 | { |
2042 | 1252 | if (event->type == GDK_BUTTON_PRESS) | 1395 | if (event->type == GDK_BUTTON_PRESS) |
2043 | 1253 | { | 1396 | { |
2045 | 1254 | if (event->button == 1) | 1397 | if (event->button == 1 || |
2046 | 1398 | event->button == 2) | ||
2047 | 1255 | { | 1399 | { |
2048 | 1256 | OsScrollbar *scrollbar; | 1400 | OsScrollbar *scrollbar; |
2049 | 1257 | OsScrollbarPrivate *priv; | 1401 | OsScrollbarPrivate *priv; |
2050 | @@ -1268,7 +1412,60 @@ | |||
2051 | 1268 | priv->event |= OS_EVENT_BUTTON_PRESS; | 1412 | priv->event |= OS_EVENT_BUTTON_PRESS; |
2052 | 1269 | priv->event &= ~(OS_EVENT_MOTION_NOTIFY); | 1413 | priv->event &= ~(OS_EVENT_MOTION_NOTIFY); |
2053 | 1270 | 1414 | ||
2055 | 1271 | priv->detached_scroll = FALSE; | 1415 | if (event->button == 2) |
2056 | 1416 | { | ||
2057 | 1417 | /* Reconnect the thumb with the bar. */ | ||
2058 | 1418 | gdouble new_value; | ||
2059 | 1419 | gint c, delta; | ||
2060 | 1420 | gint32 duration; | ||
2061 | 1421 | |||
2062 | 1422 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | ||
2063 | 1423 | { | ||
2064 | 1424 | priv->slide_initial_slider_position = event->y_root - priv->thumb_win.y - event->y; | ||
2065 | 1425 | priv->slide_initial_coordinate = event->y_root; | ||
2066 | 1426 | |||
2067 | 1427 | delta = event->y_root - priv->slide_initial_coordinate; | ||
2068 | 1428 | } | ||
2069 | 1429 | else | ||
2070 | 1430 | { | ||
2071 | 1431 | priv->slide_initial_slider_position = event->x_root - priv->thumb_win.x - event->x; | ||
2072 | 1432 | priv->slide_initial_coordinate = event->x_root; | ||
2073 | 1433 | |||
2074 | 1434 | delta = event->x_root - priv->slide_initial_coordinate; | ||
2075 | 1435 | } | ||
2076 | 1436 | |||
2077 | 1437 | c = priv->slide_initial_slider_position + delta; | ||
2078 | 1438 | |||
2079 | 1439 | /* If a scrolling animation is running, | ||
2080 | 1440 | * stop it and add the new value. */ | ||
2081 | 1441 | os_animation_stop (priv->animation, NULL); | ||
2082 | 1442 | |||
2083 | 1443 | new_value = coord_to_value (scrollbar, c); | ||
2084 | 1444 | |||
2085 | 1445 | /* Only start the animation if needed. */ | ||
2086 | 1446 | if (new_value != gtk_adjustment_get_value (priv->adjustment)) | ||
2087 | 1447 | { | ||
2088 | 1448 | priv->state |= OS_STATE_RECONNECTING; | ||
2089 | 1449 | |||
2090 | 1450 | priv->value = new_value; | ||
2091 | 1451 | |||
2092 | 1452 | /* Calculate and set the duration. */ | ||
2093 | 1453 | if (priv->value > gtk_adjustment_get_value (priv->adjustment)) | ||
2094 | 1454 | duration = MIN_DURATION_SCROLLING + ((priv->value - gtk_adjustment_get_value (priv->adjustment)) / | ||
2095 | 1455 | (gtk_adjustment_get_upper (priv->adjustment) - | ||
2096 | 1456 | gtk_adjustment_get_lower (priv->adjustment))) * | ||
2097 | 1457 | (MAX_DURATION_SCROLLING - MIN_DURATION_SCROLLING); | ||
2098 | 1458 | else | ||
2099 | 1459 | duration = MIN_DURATION_SCROLLING + ((gtk_adjustment_get_value (priv->adjustment) - priv->value) / | ||
2100 | 1460 | (gtk_adjustment_get_upper (priv->adjustment) - | ||
2101 | 1461 | gtk_adjustment_get_lower (priv->adjustment))) * | ||
2102 | 1462 | (MAX_DURATION_SCROLLING - MIN_DURATION_SCROLLING); | ||
2103 | 1463 | os_animation_set_duration (priv->animation, duration); | ||
2104 | 1464 | |||
2105 | 1465 | /* Start the scrolling animation. */ | ||
2106 | 1466 | os_animation_start (priv->animation); | ||
2107 | 1467 | } | ||
2108 | 1468 | } | ||
2109 | 1272 | 1469 | ||
2110 | 1273 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 1470 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
2111 | 1274 | { | 1471 | { |
2112 | @@ -1281,8 +1478,8 @@ | |||
2113 | 1281 | priv->slide_initial_coordinate = event->x_root; | 1478 | priv->slide_initial_coordinate = event->x_root; |
2114 | 1282 | } | 1479 | } |
2115 | 1283 | 1480 | ||
2118 | 1284 | priv->pointer_x = event->x; | 1481 | priv->pointer.x = event->x; |
2119 | 1285 | priv->pointer_y = event->y; | 1482 | priv->pointer.y = event->y; |
2120 | 1286 | } | 1483 | } |
2121 | 1287 | } | 1484 | } |
2122 | 1288 | 1485 | ||
2123 | @@ -1299,7 +1496,7 @@ | |||
2124 | 1299 | 1496 | ||
2125 | 1300 | priv = scrollbar->priv; | 1497 | priv = scrollbar->priv; |
2126 | 1301 | 1498 | ||
2128 | 1302 | /* If a paging animation is running, | 1499 | /* If a scrolling animation is running, |
2129 | 1303 | * stop it and add the new value. */ | 1500 | * stop it and add the new value. */ |
2130 | 1304 | if (os_animation_is_running (priv->animation)) | 1501 | if (os_animation_is_running (priv->animation)) |
2131 | 1305 | { | 1502 | { |
2132 | @@ -1314,13 +1511,17 @@ | |||
2133 | 1314 | gtk_adjustment_get_lower (priv->adjustment), | 1511 | gtk_adjustment_get_lower (priv->adjustment), |
2134 | 1315 | gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment)); | 1512 | gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment)); |
2135 | 1316 | 1513 | ||
2136 | 1514 | /* There's no need to do start a new animation. */ | ||
2137 | 1515 | if (priv->value == gtk_adjustment_get_value (priv->adjustment)) | ||
2138 | 1516 | return; | ||
2139 | 1517 | |||
2140 | 1317 | /* Calculate and set the duration. */ | 1518 | /* Calculate and set the duration. */ |
2144 | 1318 | duration = MIN_DURATION_PAGING + ((priv->value - gtk_adjustment_get_value (priv->adjustment)) / | 1519 | duration = MIN_DURATION_SCROLLING + ((priv->value - gtk_adjustment_get_value (priv->adjustment)) / |
2145 | 1319 | gtk_adjustment_get_page_increment (priv->adjustment)) * | 1520 | gtk_adjustment_get_page_increment (priv->adjustment)) * |
2146 | 1320 | (MAX_DURATION_PAGING - MIN_DURATION_PAGING); | 1521 | (MAX_DURATION_SCROLLING - MIN_DURATION_SCROLLING); |
2147 | 1321 | os_animation_set_duration (priv->animation, duration); | 1522 | os_animation_set_duration (priv->animation, duration); |
2148 | 1322 | 1523 | ||
2150 | 1323 | /* Start the paging animation. */ | 1524 | /* Start the scrolling animation. */ |
2151 | 1324 | os_animation_start (priv->animation); | 1525 | os_animation_start (priv->animation); |
2152 | 1325 | } | 1526 | } |
2153 | 1326 | 1527 | ||
2154 | @@ -1334,7 +1535,7 @@ | |||
2155 | 1334 | 1535 | ||
2156 | 1335 | priv = scrollbar->priv; | 1536 | priv = scrollbar->priv; |
2157 | 1336 | 1537 | ||
2159 | 1337 | /* If a paging animation is running, | 1538 | /* If a scrolling animation is running, |
2160 | 1338 | * stop it and subtract the new value. */ | 1539 | * stop it and subtract the new value. */ |
2161 | 1339 | if (os_animation_is_running (priv->animation)) | 1540 | if (os_animation_is_running (priv->animation)) |
2162 | 1340 | { | 1541 | { |
2163 | @@ -1349,13 +1550,17 @@ | |||
2164 | 1349 | gtk_adjustment_get_lower (priv->adjustment), | 1550 | gtk_adjustment_get_lower (priv->adjustment), |
2165 | 1350 | gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment)); | 1551 | gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment)); |
2166 | 1351 | 1552 | ||
2167 | 1553 | /* There's no need to do start a new animation. */ | ||
2168 | 1554 | if (priv->value == gtk_adjustment_get_value (priv->adjustment)) | ||
2169 | 1555 | return; | ||
2170 | 1556 | |||
2171 | 1352 | /* Calculate and set the duration. */ | 1557 | /* Calculate and set the duration. */ |
2175 | 1353 | duration = MIN_DURATION_PAGING + ((gtk_adjustment_get_value (priv->adjustment) - priv->value) / | 1558 | duration = MIN_DURATION_SCROLLING + ((gtk_adjustment_get_value (priv->adjustment) - priv->value) / |
2176 | 1354 | gtk_adjustment_get_page_increment (priv->adjustment)) * | 1559 | gtk_adjustment_get_page_increment (priv->adjustment)) * |
2177 | 1355 | (MAX_DURATION_PAGING - MIN_DURATION_PAGING); | 1560 | (MAX_DURATION_SCROLLING - MIN_DURATION_SCROLLING); |
2178 | 1356 | os_animation_set_duration (priv->animation, duration); | 1561 | os_animation_set_duration (priv->animation, duration); |
2179 | 1357 | 1562 | ||
2181 | 1358 | /* Start the paging animation. */ | 1563 | /* Start the scrolling animation. */ |
2182 | 1359 | os_animation_start (priv->animation); | 1564 | os_animation_start (priv->animation); |
2183 | 1360 | } | 1565 | } |
2184 | 1361 | 1566 | ||
2185 | @@ -1366,7 +1571,8 @@ | |||
2186 | 1366 | { | 1571 | { |
2187 | 1367 | if (event->type == GDK_BUTTON_RELEASE) | 1572 | if (event->type == GDK_BUTTON_RELEASE) |
2188 | 1368 | { | 1573 | { |
2190 | 1369 | if (event->button == 1) | 1574 | if (event->button == 1 || |
2191 | 1575 | event->button == 2) | ||
2192 | 1370 | { | 1576 | { |
2193 | 1371 | OsScrollbar *scrollbar; | 1577 | OsScrollbar *scrollbar; |
2194 | 1372 | OsScrollbarPrivate *priv; | 1578 | OsScrollbarPrivate *priv; |
2195 | @@ -1376,24 +1582,23 @@ | |||
2196 | 1376 | 1582 | ||
2197 | 1377 | gtk_window_set_transient_for (GTK_WINDOW (widget), NULL); | 1583 | gtk_window_set_transient_for (GTK_WINDOW (widget), NULL); |
2198 | 1378 | 1584 | ||
2200 | 1379 | if (!(priv->event & OS_EVENT_MOTION_NOTIFY) && !priv->detached_scroll) | 1585 | if (event->button == 1 && |
2201 | 1586 | !(priv->event & OS_EVENT_MOTION_NOTIFY)) | ||
2202 | 1380 | { | 1587 | { |
2203 | 1381 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 1588 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
2204 | 1382 | { | 1589 | { |
2206 | 1383 | if (priv->pointer_y < priv->slider.height / 2) | 1590 | if (priv->pointer.y < priv->slider.height / 2) |
2207 | 1384 | page_up (scrollbar); | 1591 | page_up (scrollbar); |
2208 | 1385 | else | 1592 | else |
2209 | 1386 | page_down (scrollbar); | 1593 | page_down (scrollbar); |
2210 | 1387 | } | 1594 | } |
2211 | 1388 | else | 1595 | else |
2212 | 1389 | { | 1596 | { |
2214 | 1390 | if (priv->pointer_x < priv->slider.width / 2) | 1597 | if (priv->pointer.x < priv->slider.width / 2) |
2215 | 1391 | page_up (scrollbar); | 1598 | page_up (scrollbar); |
2216 | 1392 | else | 1599 | else |
2217 | 1393 | page_down (scrollbar); | 1600 | page_down (scrollbar); |
2218 | 1394 | } | 1601 | } |
2219 | 1395 | |||
2220 | 1396 | priv->event |= OS_EVENT_VALUE_CHANGED; | ||
2221 | 1397 | } | 1602 | } |
2222 | 1398 | 1603 | ||
2223 | 1399 | priv->event &= ~(OS_EVENT_BUTTON_PRESS | OS_EVENT_MOTION_NOTIFY); | 1604 | priv->event &= ~(OS_EVENT_BUTTON_PRESS | OS_EVENT_MOTION_NOTIFY); |
2224 | @@ -1416,11 +1621,11 @@ | |||
2225 | 1416 | 1621 | ||
2226 | 1417 | priv->event |= OS_EVENT_ENTER_NOTIFY; | 1622 | priv->event |= OS_EVENT_ENTER_NOTIFY; |
2227 | 1418 | 1623 | ||
2230 | 1419 | priv->can_deactivate_pager = FALSE; | 1624 | priv->deactivable_bar = FALSE; |
2231 | 1420 | priv->can_hide = FALSE; | 1625 | priv->hidable_thumb = FALSE; |
2232 | 1421 | 1626 | ||
2235 | 1422 | if (priv->internal) | 1627 | if (priv->state & OS_STATE_INTERNAL) |
2236 | 1423 | priv->lock_position = TRUE; | 1628 | priv->state |= OS_STATE_LOCKED; |
2237 | 1424 | 1629 | ||
2238 | 1425 | return FALSE; | 1630 | return FALSE; |
2239 | 1426 | } | 1631 | } |
2240 | @@ -1440,20 +1645,20 @@ | |||
2241 | 1440 | * not interacting with the thumb. */ | 1645 | * not interacting with the thumb. */ |
2242 | 1441 | if (!(priv->event & OS_EVENT_BUTTON_PRESS)) | 1646 | if (!(priv->event & OS_EVENT_BUTTON_PRESS)) |
2243 | 1442 | { | 1647 | { |
2245 | 1443 | /* Never deactivate the pager in an active window. */ | 1648 | /* Never deactivate the bar in an active window. */ |
2246 | 1444 | if (!priv->active_window) | 1649 | if (!priv->active_window) |
2247 | 1445 | { | 1650 | { |
2256 | 1446 | priv->can_deactivate_pager = TRUE; | 1651 | priv->deactivable_bar = TRUE; |
2257 | 1447 | 1652 | ||
2258 | 1448 | if (priv->source_deactivate_pager_id != 0) | 1653 | if (priv->source_deactivate_bar_id != 0) |
2259 | 1449 | g_source_remove (priv->source_deactivate_pager_id); | 1654 | g_source_remove (priv->source_deactivate_bar_id); |
2260 | 1450 | 1655 | ||
2261 | 1451 | priv->source_deactivate_pager_id = g_timeout_add (TIMEOUT_THUMB_HIDE, | 1656 | priv->source_deactivate_bar_id = g_timeout_add (TIMEOUT_THUMB_HIDE, |
2262 | 1452 | deactivate_pager_cb, | 1657 | deactivate_bar_cb, |
2263 | 1453 | scrollbar); | 1658 | scrollbar); |
2264 | 1454 | } | 1659 | } |
2265 | 1455 | 1660 | ||
2267 | 1456 | priv->can_hide = TRUE; | 1661 | priv->hidable_thumb = TRUE; |
2268 | 1457 | 1662 | ||
2269 | 1458 | if (priv->source_hide_thumb_id != 0) | 1663 | if (priv->source_hide_thumb_id != 0) |
2270 | 1459 | g_source_remove (priv->source_hide_thumb_id); | 1664 | g_source_remove (priv->source_hide_thumb_id); |
2271 | @@ -1481,9 +1686,9 @@ | |||
2272 | 1481 | scrollbar = OS_SCROLLBAR (user_data); | 1686 | scrollbar = OS_SCROLLBAR (user_data); |
2273 | 1482 | priv = scrollbar->priv; | 1687 | priv = scrollbar->priv; |
2274 | 1483 | 1688 | ||
2278 | 1484 | /* Immediately set the pager to be active. */ | 1689 | /* Immediately set the bar to be active. */ |
2279 | 1485 | priv->can_deactivate_pager = FALSE; | 1690 | priv->deactivable_bar = FALSE; |
2280 | 1486 | os_pager_set_active (priv->pager, TRUE, FALSE); | 1691 | os_bar_set_active (priv->bar, TRUE, FALSE); |
2281 | 1487 | 1692 | ||
2282 | 1488 | xid = GDK_WINDOW_XID (gtk_widget_get_window (widget)); | 1693 | xid = GDK_WINDOW_XID (gtk_widget_get_window (widget)); |
2283 | 1489 | xid_parent = GDK_WINDOW_XID (gtk_widget_get_window (gtk_widget_get_toplevel (GTK_WIDGET (scrollbar)))); | 1694 | xid_parent = GDK_WINDOW_XID (gtk_widget_get_window (gtk_widget_get_toplevel (GTK_WIDGET (scrollbar)))); |
2284 | @@ -1542,46 +1747,6 @@ | |||
2285 | 1542 | } | 1747 | } |
2286 | 1543 | } | 1748 | } |
2287 | 1544 | 1749 | ||
2288 | 1545 | /* Traduce coordinates into GtkRange values. */ | ||
2289 | 1546 | static gdouble | ||
2290 | 1547 | coord_to_value (OsScrollbar *scrollbar, | ||
2291 | 1548 | gint coord) | ||
2292 | 1549 | { | ||
2293 | 1550 | OsScrollbarPrivate *priv; | ||
2294 | 1551 | gdouble frac; | ||
2295 | 1552 | gdouble value; | ||
2296 | 1553 | gint trough_length; | ||
2297 | 1554 | gint slider_length; | ||
2298 | 1555 | |||
2299 | 1556 | priv = scrollbar->priv; | ||
2300 | 1557 | |||
2301 | 1558 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | ||
2302 | 1559 | { | ||
2303 | 1560 | trough_length = priv->trough.height; | ||
2304 | 1561 | slider_length = MAX (priv->slider.height, priv->overlay.height); | ||
2305 | 1562 | } | ||
2306 | 1563 | else | ||
2307 | 1564 | { | ||
2308 | 1565 | trough_length = priv->trough.width; | ||
2309 | 1566 | slider_length = MAX (priv->slider.width, priv->overlay.width); | ||
2310 | 1567 | } | ||
2311 | 1568 | |||
2312 | 1569 | if (trough_length == slider_length) | ||
2313 | 1570 | frac = 1.0; | ||
2314 | 1571 | else | ||
2315 | 1572 | frac = (MAX (0, coord) / (gdouble) (trough_length - slider_length)); | ||
2316 | 1573 | |||
2317 | 1574 | value = gtk_adjustment_get_lower (priv->adjustment) + frac * (gtk_adjustment_get_upper (priv->adjustment) - | ||
2318 | 1575 | gtk_adjustment_get_lower (priv->adjustment) - | ||
2319 | 1576 | gtk_adjustment_get_page_size (priv->adjustment)); | ||
2320 | 1577 | |||
2321 | 1578 | value = CLAMP (value, | ||
2322 | 1579 | gtk_adjustment_get_lower (priv->adjustment), | ||
2323 | 1580 | gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment)); | ||
2324 | 1581 | |||
2325 | 1582 | return value; | ||
2326 | 1583 | } | ||
2327 | 1584 | |||
2328 | 1585 | /* From pointer movement, set adjustment value. */ | 1750 | /* From pointer movement, set adjustment value. */ |
2329 | 1586 | static void | 1751 | static void |
2330 | 1587 | capture_movement (OsScrollbar *scrollbar, | 1752 | capture_movement (OsScrollbar *scrollbar, |
2331 | @@ -1622,184 +1787,214 @@ | |||
2332 | 1622 | { | 1787 | { |
2333 | 1623 | gint x, y; | 1788 | gint x, y; |
2334 | 1624 | 1789 | ||
2349 | 1625 | /* Thumb and pager are detached. | 1790 | /* Use tolerance at the first calls to this motion notify event. */ |
2350 | 1626 | * Detached scroll: keep the thumb detached during the scroll, | 1791 | if (!(priv->event & OS_EVENT_MOTION_NOTIFY) && |
2351 | 1627 | * update the visual connection when reaching an edge. */ | 1792 | abs (priv->pointer.x - event->x) <= TOLERANCE_MOTION && |
2352 | 1628 | if (priv->event & OS_EVENT_VALUE_CHANGED) | 1793 | abs (priv->pointer.y - event->y) <= TOLERANCE_MOTION) |
2353 | 1629 | { | 1794 | return FALSE; |
2354 | 1630 | /* Return if the mouse movement is small. */ | 1795 | |
2355 | 1631 | if (abs (priv->pointer_x - event->x) <= TOLERANCE_MOTION && | 1796 | if (!(priv->event & OS_EVENT_MOTION_NOTIFY)) |
2356 | 1632 | abs (priv->pointer_y - event->y) <= TOLERANCE_MOTION) | 1797 | { |
2357 | 1633 | return FALSE; | 1798 | /* Check if we can consider the thumb movement connected with the overlay. */ |
2358 | 1634 | 1799 | check_connection (scrollbar); | |
2359 | 1635 | priv->detached_scroll = TRUE; | 1800 | |
2360 | 1636 | 1801 | priv->event |= OS_EVENT_MOTION_NOTIFY; | |
2361 | 1637 | /* Stop the paging animation if it's running. */ | 1802 | } |
2362 | 1638 | os_animation_stop (priv->animation, NULL); | 1803 | |
2363 | 1804 | /* Before stopping the animation, | ||
2364 | 1805 | * check if it's reconnecting. | ||
2365 | 1806 | * In this case we need to update the slide values | ||
2366 | 1807 | * with the current position. */ | ||
2367 | 1808 | if (os_animation_is_running (priv->animation)) | ||
2368 | 1809 | { | ||
2369 | 1810 | if (priv->state & OS_STATE_RECONNECTING) | ||
2370 | 1811 | { | ||
2371 | 1812 | /* It's a reconnecting animation. */ | ||
2372 | 1813 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | ||
2373 | 1814 | { | ||
2374 | 1815 | priv->slide_initial_slider_position = MIN (priv->slider.y, priv->overlay.y); | ||
2375 | 1816 | priv->slide_initial_coordinate = event->y_root; | ||
2376 | 1817 | } | ||
2377 | 1818 | else | ||
2378 | 1819 | { | ||
2379 | 1820 | priv->slide_initial_slider_position = MIN (priv->slider.x, priv->overlay.x); | ||
2380 | 1821 | priv->slide_initial_coordinate = event->x_root; | ||
2381 | 1822 | } | ||
2382 | 1823 | } | ||
2383 | 1824 | else | ||
2384 | 1825 | { | ||
2385 | 1826 | /* Stop the paging animation now. */ | ||
2386 | 1827 | os_animation_stop (priv->animation, NULL); | ||
2387 | 1828 | } | ||
2388 | 1829 | } | ||
2389 | 1830 | |||
2390 | 1831 | /* Behave differently when the thumb is connected or not. */ | ||
2391 | 1832 | if (priv->state & OS_STATE_CONNECTED) | ||
2392 | 1833 | { | ||
2393 | 1834 | /* This is a connected scroll, | ||
2394 | 1835 | * the thumb movement is kept in sync with the overlay. */ | ||
2395 | 1836 | |||
2396 | 1837 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | ||
2397 | 1838 | { | ||
2398 | 1839 | if (priv->overlay.height > priv->slider.height) | ||
2399 | 1840 | { | ||
2400 | 1841 | /* Limit x and y within the overlay. */ | ||
2401 | 1842 | x = priv->thumb_win.x; | ||
2402 | 1843 | y = CLAMP (event->y_root - priv->pointer.y, | ||
2403 | 1844 | priv->thumb_win.y + priv->overlay.y, | ||
2404 | 1845 | priv->thumb_win.y + priv->overlay.y + priv->overlay.height - priv->slider.height); | ||
2405 | 1846 | } | ||
2406 | 1847 | else | ||
2407 | 1848 | { | ||
2408 | 1849 | x = priv->thumb_win.x; | ||
2409 | 1850 | y = priv->thumb_win.y + priv->slider.y; | ||
2410 | 1851 | } | ||
2411 | 1852 | } | ||
2412 | 1853 | else | ||
2413 | 1854 | { | ||
2414 | 1855 | if (priv->overlay.width > priv->slider.width) | ||
2415 | 1856 | { | ||
2416 | 1857 | /* Limit x and y within the overlay. */ | ||
2417 | 1858 | x = CLAMP (event->x_root - priv->pointer.x, | ||
2418 | 1859 | priv->thumb_win.x + priv->overlay.x, | ||
2419 | 1860 | priv->thumb_win.x + priv->overlay.x + priv->overlay.width - priv->slider.width); | ||
2420 | 1861 | y = priv->thumb_win.y; | ||
2421 | 1862 | } | ||
2422 | 1863 | else | ||
2423 | 1864 | { | ||
2424 | 1865 | x = priv->thumb_win.x + priv->slider.x; | ||
2425 | 1866 | y = priv->thumb_win.y; | ||
2426 | 1867 | } | ||
2427 | 1868 | } | ||
2428 | 1869 | |||
2429 | 1870 | /* There's no need to stop animations, | ||
2430 | 1871 | * since the reconnecting animation should not have | ||
2431 | 1872 | * state OS_STATE_CONNECTED, unless it's ended. | ||
2432 | 1873 | * Just capture the movement and change adjustment's value (scroll). */ | ||
2433 | 1874 | capture_movement (scrollbar, event->x_root, event->y_root); | ||
2434 | 1875 | } | ||
2435 | 1876 | else | ||
2436 | 1877 | { | ||
2437 | 1878 | /* This is a fine scroll, works subtly different. | ||
2438 | 1879 | * It has to take care of reconnection, | ||
2439 | 1880 | * and scrolling is not allowed when hitting an edge. */ | ||
2440 | 1639 | 1881 | ||
2441 | 1640 | /* Limit x and y within the allocation. */ | 1882 | /* Limit x and y within the allocation. */ |
2442 | 1641 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 1883 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
2443 | 1642 | { | 1884 | { |
2448 | 1643 | x = priv->win_x; | 1885 | x = priv->thumb_win.x; |
2449 | 1644 | y = CLAMP (event->y_root - priv->pointer_y, | 1886 | y = CLAMP (event->y_root - priv->pointer.y, |
2450 | 1645 | priv->win_y, | 1887 | priv->thumb_win.y, |
2451 | 1646 | priv->win_y + priv->thumb_all.height - priv->slider.height); | 1888 | priv->thumb_win.y + priv->thumb_all.height - priv->slider.height); |
2452 | 1647 | } | 1889 | } |
2453 | 1648 | else | 1890 | else |
2454 | 1649 | { | 1891 | { |
2459 | 1650 | x = CLAMP (event->x_root - priv->pointer_x, | 1892 | x = CLAMP (event->x_root - priv->pointer.x, |
2460 | 1651 | priv->win_x, | 1893 | priv->thumb_win.x, |
2461 | 1652 | priv->win_x + priv->thumb_all.width - priv->slider.width); | 1894 | priv->thumb_win.x + priv->thumb_all.width - priv->slider.width); |
2462 | 1653 | y = priv->win_y; | 1895 | y = priv->thumb_win.y; |
2463 | 1654 | } | 1896 | } |
2464 | 1655 | 1897 | ||
2465 | 1656 | /* Fine scroll while detached, | 1898 | /* Fine scroll while detached, |
2466 | 1657 | * do not scroll when hitting an edge. */ | 1899 | * do not scroll when hitting an edge. */ |
2467 | 1658 | if ((priv->orientation == GTK_ORIENTATION_VERTICAL && | 1900 | if ((priv->orientation == GTK_ORIENTATION_VERTICAL && |
2470 | 1659 | y > priv->win_y && | 1901 | y > priv->thumb_win.y && |
2471 | 1660 | y < priv->win_y + priv->thumb_all.height - priv->slider.height) || | 1902 | y < priv->thumb_win.y + priv->thumb_all.height - priv->slider.height) || |
2472 | 1661 | (priv->orientation == GTK_ORIENTATION_HORIZONTAL && | 1903 | (priv->orientation == GTK_ORIENTATION_HORIZONTAL && |
2613 | 1662 | x > priv->win_x && | 1904 | x > priv->thumb_win.x && |
2614 | 1663 | x < priv->win_x + priv->thumb_all.width - priv->slider.width)) | 1905 | x < priv->thumb_win.x + priv->thumb_all.width - priv->slider.width)) |
2615 | 1664 | capture_movement (scrollbar, event->x_root, event->y_root); | 1906 | { |
2616 | 1665 | 1907 | /* Stop the animation now. | |
2617 | 1666 | move_thumb (scrollbar, x, y); | 1908 | * Only the reconnecting animation can be running now, |
2618 | 1667 | 1909 | * because the paging animations were stop before. */ | |
2619 | 1668 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 1910 | os_animation_stop (priv->animation, NULL); |
2620 | 1669 | { | 1911 | |
2621 | 1670 | if (gtk_adjustment_get_value (priv->adjustment) == 0) | 1912 | /* Capture the movement and change adjustment's value (scroll). */ |
2622 | 1671 | { | 1913 | capture_movement (scrollbar, event->x_root, event->y_root); |
2623 | 1672 | update_visual_connection (scrollbar); | 1914 | } |
2624 | 1673 | 1915 | else if (!os_animation_is_running (priv->animation) && | |
2625 | 1674 | if (priv->overlay.height > priv->slider.height) | 1916 | !(priv->state & OS_STATE_DETACHED)) |
2626 | 1675 | { | 1917 | { |
2627 | 1676 | priv->slide_initial_slider_position = 0; | 1918 | /* Animate scrolling till reaches the edge. */ |
2628 | 1677 | priv->slide_initial_coordinate = MAX (event->y_root, priv->win_y + priv->pointer_y); | 1919 | if ((priv->orientation == GTK_ORIENTATION_VERTICAL && y <= priv->thumb_win.y) || |
2629 | 1678 | } | 1920 | (priv->orientation == GTK_ORIENTATION_HORIZONTAL && x <= priv->thumb_win.x)) |
2630 | 1679 | else | 1921 | priv->value = gtk_adjustment_get_lower (priv->adjustment); |
2631 | 1680 | { | 1922 | else |
2632 | 1681 | priv->slide_initial_slider_position = 0; | 1923 | priv->value = gtk_adjustment_get_upper (priv->adjustment) - |
2633 | 1682 | priv->slide_initial_coordinate = event->y_root; | 1924 | gtk_adjustment_get_page_size (priv->adjustment); |
2634 | 1683 | } | 1925 | |
2635 | 1684 | } | 1926 | /* Proceed with the reconnection only if needed. */ |
2636 | 1685 | else if (priv->overlay.y + priv->overlay.height >= priv->trough.height) | 1927 | if (priv->value != gtk_adjustment_get_value (priv->adjustment)) |
2637 | 1686 | { | 1928 | { |
2638 | 1687 | update_visual_connection (scrollbar); | 1929 | /* If the thumb is not detached, proceed with reconnection. */ |
2639 | 1688 | 1930 | priv->state |= OS_STATE_RECONNECTING; | |
2640 | 1689 | if (priv->overlay.height > priv->slider.height) | 1931 | |
2641 | 1690 | { | 1932 | os_animation_set_duration (priv->animation, MIN_DURATION_SCROLLING); |
2642 | 1691 | priv->slide_initial_slider_position = priv->trough.height - priv->overlay.height; | 1933 | |
2643 | 1692 | priv->slide_initial_coordinate = MAX (event->y_root, priv->win_y + priv->pointer_y); | 1934 | /* Start the scrolling animation. */ |
2644 | 1693 | } | 1935 | os_animation_start (priv->animation); |
2645 | 1694 | else | 1936 | } |
2646 | 1695 | { | 1937 | } |
2647 | 1696 | priv->slide_initial_slider_position = priv->trough.height - priv->slider.height; | 1938 | } |
2648 | 1697 | priv->slide_initial_coordinate = event->y_root; | 1939 | |
2649 | 1698 | } | 1940 | /* Move the thumb window. */ |
2510 | 1699 | } | ||
2511 | 1700 | } | ||
2512 | 1701 | else | ||
2513 | 1702 | { | ||
2514 | 1703 | if (gtk_adjustment_get_value (priv->adjustment) == 0) | ||
2515 | 1704 | { | ||
2516 | 1705 | update_visual_connection (scrollbar); | ||
2517 | 1706 | |||
2518 | 1707 | if (priv->overlay.width > priv->slider.width) | ||
2519 | 1708 | { | ||
2520 | 1709 | priv->slide_initial_slider_position = 0; | ||
2521 | 1710 | priv->slide_initial_coordinate = MAX (event->x_root, priv->win_x + priv->pointer_x); | ||
2522 | 1711 | } | ||
2523 | 1712 | else | ||
2524 | 1713 | { | ||
2525 | 1714 | priv->slide_initial_slider_position = 0; | ||
2526 | 1715 | priv->slide_initial_coordinate = event->x_root; | ||
2527 | 1716 | } | ||
2528 | 1717 | } | ||
2529 | 1718 | else if (priv->overlay.x + priv->overlay.width >= priv->trough.width) | ||
2530 | 1719 | { | ||
2531 | 1720 | update_visual_connection (scrollbar); | ||
2532 | 1721 | |||
2533 | 1722 | if (priv->overlay.width > priv->slider.width) | ||
2534 | 1723 | { | ||
2535 | 1724 | priv->slide_initial_slider_position = priv->trough.width - priv->overlay.width; | ||
2536 | 1725 | priv->slide_initial_coordinate = MAX (event->x_root, priv->win_x + priv->pointer_x); | ||
2537 | 1726 | } | ||
2538 | 1727 | else | ||
2539 | 1728 | { | ||
2540 | 1729 | priv->slide_initial_slider_position = priv->trough.width - priv->slider.width; | ||
2541 | 1730 | priv->slide_initial_coordinate = event->x_root; | ||
2542 | 1731 | } | ||
2543 | 1732 | } | ||
2544 | 1733 | } | ||
2545 | 1734 | |||
2546 | 1735 | return FALSE; | ||
2547 | 1736 | } | ||
2548 | 1737 | |||
2549 | 1738 | OS_DCHECK (!priv->detached_scroll); | ||
2550 | 1739 | |||
2551 | 1740 | /* Thumb and pager are connected. | ||
2552 | 1741 | * Normal scroll: keep the thumb in sync with the pager, | ||
2553 | 1742 | * do not update the visual connection. */ | ||
2554 | 1743 | priv->event |= OS_EVENT_MOTION_NOTIFY; | ||
2555 | 1744 | |||
2556 | 1745 | capture_movement (scrollbar, event->x_root, event->y_root); | ||
2557 | 1746 | |||
2558 | 1747 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | ||
2559 | 1748 | { | ||
2560 | 1749 | if (priv->overlay.height > priv->slider.height) | ||
2561 | 1750 | { | ||
2562 | 1751 | /* Limit x and y within the overlay. */ | ||
2563 | 1752 | x = priv->win_x; | ||
2564 | 1753 | y = CLAMP (event->y_root - priv->pointer_y, | ||
2565 | 1754 | priv->win_y + priv->overlay.y, | ||
2566 | 1755 | priv->win_y + priv->overlay.y + priv->overlay.height - priv->slider.height); | ||
2567 | 1756 | |||
2568 | 1757 | if (gtk_adjustment_get_value (priv->adjustment) == 0) | ||
2569 | 1758 | { | ||
2570 | 1759 | priv->slide_initial_slider_position = 0; | ||
2571 | 1760 | priv->slide_initial_coordinate = MAX (event->y_root, priv->win_y + priv->pointer_y); | ||
2572 | 1761 | } | ||
2573 | 1762 | else if (priv->overlay.y + priv->overlay.height >= priv->trough.height) | ||
2574 | 1763 | { | ||
2575 | 1764 | priv->slide_initial_slider_position = priv->trough.height - priv->overlay.height; | ||
2576 | 1765 | priv->slide_initial_coordinate = MAX (event->y_root, priv->win_y + priv->pointer_y); | ||
2577 | 1766 | } | ||
2578 | 1767 | } | ||
2579 | 1768 | else | ||
2580 | 1769 | { | ||
2581 | 1770 | x = priv->win_x; | ||
2582 | 1771 | y = priv->win_y + priv->slider.y; | ||
2583 | 1772 | } | ||
2584 | 1773 | } | ||
2585 | 1774 | else | ||
2586 | 1775 | { | ||
2587 | 1776 | if (priv->overlay.width > priv->slider.width) | ||
2588 | 1777 | { | ||
2589 | 1778 | /* Limit x and y within the overlay. */ | ||
2590 | 1779 | x = CLAMP (event->x_root - priv->pointer_x, | ||
2591 | 1780 | priv->win_x + priv->overlay.x, | ||
2592 | 1781 | priv->win_x + priv->overlay.x + priv->overlay.width - priv->slider.width); | ||
2593 | 1782 | y = priv->win_y; | ||
2594 | 1783 | |||
2595 | 1784 | if (gtk_adjustment_get_value (priv->adjustment) == 0) | ||
2596 | 1785 | { | ||
2597 | 1786 | priv->slide_initial_slider_position = 0; | ||
2598 | 1787 | priv->slide_initial_coordinate = MAX (event->x_root, priv->win_x + priv->pointer_x); | ||
2599 | 1788 | } | ||
2600 | 1789 | else if (priv->overlay.x + priv->overlay.width >= priv->trough.width) | ||
2601 | 1790 | { | ||
2602 | 1791 | priv->slide_initial_slider_position = priv->trough.width - priv->overlay.width; | ||
2603 | 1792 | priv->slide_initial_coordinate = MAX (event->x_root, priv->win_x + priv->pointer_x); | ||
2604 | 1793 | } | ||
2605 | 1794 | } | ||
2606 | 1795 | else | ||
2607 | 1796 | { | ||
2608 | 1797 | x = priv->win_x + priv->slider.x; | ||
2609 | 1798 | y = priv->win_y; | ||
2610 | 1799 | } | ||
2611 | 1800 | } | ||
2612 | 1801 | |||
2650 | 1802 | move_thumb (scrollbar, x, y); | 1941 | move_thumb (scrollbar, x, y); |
2651 | 1942 | |||
2652 | 1943 | /* Adjust slide values in some special situations, | ||
2653 | 1944 | * update the tail if the thumb is detached and | ||
2654 | 1945 | * check if the movement changed the thumb state to connected. */ | ||
2655 | 1946 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | ||
2656 | 1947 | { | ||
2657 | 1948 | if (gtk_adjustment_get_value (priv->adjustment) <= gtk_adjustment_get_lower (priv->adjustment)) | ||
2658 | 1949 | { | ||
2659 | 1950 | if (priv->state & OS_STATE_DETACHED) | ||
2660 | 1951 | update_tail (scrollbar); | ||
2661 | 1952 | |||
2662 | 1953 | if (!(priv->state & OS_STATE_CONNECTED)) | ||
2663 | 1954 | check_connection (scrollbar); | ||
2664 | 1955 | |||
2665 | 1956 | priv->slide_initial_slider_position = 0; | ||
2666 | 1957 | priv->slide_initial_coordinate = MAX (event->y_root, priv->thumb_win.y + priv->pointer.y); | ||
2667 | 1958 | } | ||
2668 | 1959 | else if (priv->overlay.y + priv->overlay.height >= priv->trough.height) | ||
2669 | 1960 | { | ||
2670 | 1961 | if (priv->state & OS_STATE_DETACHED) | ||
2671 | 1962 | update_tail (scrollbar); | ||
2672 | 1963 | |||
2673 | 1964 | if (!(priv->state & OS_STATE_CONNECTED)) | ||
2674 | 1965 | check_connection (scrollbar); | ||
2675 | 1966 | |||
2676 | 1967 | priv->slide_initial_slider_position = priv->trough.height - MAX (priv->overlay.height, priv->slider.height); | ||
2677 | 1968 | priv->slide_initial_coordinate = MIN (event->y_root, (priv->thumb_win.y + priv->trough.height - | ||
2678 | 1969 | priv->slider.height + priv->pointer.y)); | ||
2679 | 1970 | } | ||
2680 | 1971 | } | ||
2681 | 1972 | else | ||
2682 | 1973 | { | ||
2683 | 1974 | if (gtk_adjustment_get_value (priv->adjustment) <= gtk_adjustment_get_lower (priv->adjustment)) | ||
2684 | 1975 | { | ||
2685 | 1976 | if (priv->state & OS_STATE_DETACHED) | ||
2686 | 1977 | update_tail (scrollbar); | ||
2687 | 1978 | |||
2688 | 1979 | if (!(priv->state & OS_STATE_CONNECTED)) | ||
2689 | 1980 | check_connection (scrollbar); | ||
2690 | 1981 | |||
2691 | 1982 | priv->slide_initial_slider_position = 0; | ||
2692 | 1983 | priv->slide_initial_coordinate = MAX (event->x_root, priv->thumb_win.x + priv->pointer.x); | ||
2693 | 1984 | } | ||
2694 | 1985 | else if (priv->overlay.x + priv->overlay.width >= priv->trough.width) | ||
2695 | 1986 | { | ||
2696 | 1987 | if (priv->state & OS_STATE_DETACHED) | ||
2697 | 1988 | update_tail (scrollbar); | ||
2698 | 1989 | |||
2699 | 1990 | if (!(priv->state & OS_STATE_CONNECTED)) | ||
2700 | 1991 | check_connection (scrollbar); | ||
2701 | 1992 | |||
2702 | 1993 | priv->slide_initial_slider_position = priv->trough.width - MAX (priv->overlay.width, priv->slider.width); | ||
2703 | 1994 | priv->slide_initial_coordinate = MIN (event->x_root, (priv->thumb_win.x + priv->trough.width - | ||
2704 | 1995 | priv->slider.width + priv->pointer.x)); | ||
2705 | 1996 | } | ||
2706 | 1997 | } | ||
2707 | 1803 | } | 1998 | } |
2708 | 1804 | 1999 | ||
2709 | 1805 | return FALSE; | 2000 | return FALSE; |
2710 | @@ -1836,11 +2031,9 @@ | |||
2711 | 1836 | scrollbar = OS_SCROLLBAR (user_data); | 2031 | scrollbar = OS_SCROLLBAR (user_data); |
2712 | 1837 | priv = scrollbar->priv; | 2032 | priv = scrollbar->priv; |
2713 | 1838 | 2033 | ||
2715 | 1839 | /* Stop the paging animation if it's running. */ | 2034 | /* Stop the scrolling animation if it's running. */ |
2716 | 1840 | os_animation_stop (priv->animation, NULL); | 2035 | os_animation_stop (priv->animation, NULL); |
2717 | 1841 | 2036 | ||
2718 | 1842 | priv->event |= OS_EVENT_VALUE_CHANGED; | ||
2719 | 1843 | |||
2720 | 1844 | delta = get_wheel_delta (scrollbar, event->direction); | 2037 | delta = get_wheel_delta (scrollbar, event->direction); |
2721 | 1845 | 2038 | ||
2722 | 1846 | gtk_adjustment_set_value (priv->adjustment, | 2039 | gtk_adjustment_set_value (priv->adjustment, |
2723 | @@ -1849,6 +2042,25 @@ | |||
2724 | 1849 | (gtk_adjustment_get_upper (priv->adjustment) - | 2042 | (gtk_adjustment_get_upper (priv->adjustment) - |
2725 | 1850 | gtk_adjustment_get_page_size (priv->adjustment)))); | 2043 | gtk_adjustment_get_page_size (priv->adjustment)))); |
2726 | 1851 | 2044 | ||
2727 | 2045 | /* Deal with simultaneous events. */ | ||
2728 | 2046 | if (priv->event & OS_EVENT_BUTTON_PRESS) | ||
2729 | 2047 | { | ||
2730 | 2048 | priv->event &= ~(OS_EVENT_MOTION_NOTIFY); | ||
2731 | 2049 | |||
2732 | 2050 | /* we need to update the slide values | ||
2733 | 2051 | * with the current position. */ | ||
2734 | 2052 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | ||
2735 | 2053 | { | ||
2736 | 2054 | priv->slide_initial_slider_position = MIN (priv->slider.y, priv->overlay.y); | ||
2737 | 2055 | priv->slide_initial_coordinate = event->y_root; | ||
2738 | 2056 | } | ||
2739 | 2057 | else | ||
2740 | 2058 | { | ||
2741 | 2059 | priv->slide_initial_slider_position = MIN (priv->slider.x, priv->overlay.x); | ||
2742 | 2060 | priv->slide_initial_coordinate = event->x_root; | ||
2743 | 2061 | } | ||
2744 | 2062 | } | ||
2745 | 2063 | |||
2746 | 1852 | return FALSE; | 2064 | return FALSE; |
2747 | 1853 | } | 2065 | } |
2748 | 1854 | 2066 | ||
2749 | @@ -1863,31 +2075,28 @@ | |||
2750 | 1863 | priv = scrollbar->priv; | 2075 | priv = scrollbar->priv; |
2751 | 1864 | 2076 | ||
2752 | 1865 | priv->event = OS_EVENT_NONE; | 2077 | priv->event = OS_EVENT_NONE; |
2757 | 1866 | 2078 | priv->hidable_thumb = TRUE; | |
2758 | 1867 | priv->detached_scroll = FALSE; | 2079 | |
2759 | 1868 | 2080 | /* Remove running hide timeout, if there is one. */ | |
2760 | 1869 | os_pager_set_detached (priv->pager, FALSE); | 2081 | if (priv->source_hide_thumb_id != 0) |
2761 | 2082 | { | ||
2762 | 2083 | g_source_remove (priv->source_hide_thumb_id); | ||
2763 | 2084 | priv->source_hide_thumb_id = 0; | ||
2764 | 2085 | } | ||
2765 | 2086 | |||
2766 | 2087 | /* This could hardly still be running, | ||
2767 | 2088 | * but it is not impossible. */ | ||
2768 | 2089 | if (priv->source_show_thumb_id != 0) | ||
2769 | 2090 | { | ||
2770 | 2091 | g_source_remove (priv->source_show_thumb_id); | ||
2771 | 2092 | priv->source_show_thumb_id = 0; | ||
2772 | 2093 | } | ||
2773 | 2094 | |||
2774 | 2095 | os_bar_set_detached (priv->bar, FALSE, TRUE); | ||
2775 | 1870 | } | 2096 | } |
2776 | 1871 | 2097 | ||
2777 | 1872 | /* Toplevel functions. */ | 2098 | /* Toplevel functions. */ |
2778 | 1873 | 2099 | ||
2779 | 1874 | /* Store the position of the toplevel window. */ | ||
2780 | 1875 | static void | ||
2781 | 1876 | store_toplevel_position (OsScrollbar *scrollbar) | ||
2782 | 1877 | { | ||
2783 | 1878 | OsScrollbarPrivate *priv; | ||
2784 | 1879 | gint x_pos, y_pos; | ||
2785 | 1880 | |||
2786 | 1881 | priv = scrollbar->priv; | ||
2787 | 1882 | |||
2788 | 1883 | /* In reality, I'm storing widget's window, not the toplevel. | ||
2789 | 1884 | * Is that the same with gdk_window_get_origin? */ | ||
2790 | 1885 | gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos); | ||
2791 | 1886 | |||
2792 | 1887 | priv->win_x = x_pos + priv->thumb_all.x; | ||
2793 | 1888 | priv->win_y = y_pos + priv->thumb_all.y; | ||
2794 | 1889 | } | ||
2795 | 1890 | |||
2796 | 1891 | static gboolean | 2100 | static gboolean |
2797 | 1892 | toplevel_configure_event_cb (GtkWidget *widget, | 2101 | toplevel_configure_event_cb (GtkWidget *widget, |
2798 | 1893 | GdkEventConfigure *event, | 2102 | GdkEventConfigure *event, |
2799 | @@ -1902,7 +2111,7 @@ | |||
2800 | 1902 | * and the configure-event happens after | 2111 | * and the configure-event happens after |
2801 | 1903 | * the PropertyNotify _NET_ACTIVE_WINDOW event, | 2112 | * the PropertyNotify _NET_ACTIVE_WINDOW event, |
2802 | 1904 | * see if the mouse pointer is over this window, if TRUE, | 2113 | * see if the mouse pointer is over this window, if TRUE, |
2804 | 1905 | * proceed with pager_set_state_from_pointer. */ | 2114 | * proceed with bar_set_state_from_pointer (). */ |
2805 | 1906 | if (!is_insensitive (scrollbar) && | 2115 | if (!is_insensitive (scrollbar) && |
2806 | 1907 | (current_time > end_time) && | 2116 | (current_time > end_time) && |
2807 | 1908 | gtk_widget_get_mapped (GTK_WIDGET (scrollbar))) | 2117 | gtk_widget_get_mapped (GTK_WIDGET (scrollbar))) |
2808 | @@ -1932,34 +2141,67 @@ | |||
2809 | 1932 | /* When the window is resized (maximize/restore), | 2141 | /* When the window is resized (maximize/restore), |
2810 | 1933 | * check the position of the pointer | 2142 | * check the position of the pointer |
2811 | 1934 | * and set the state accordingly. */ | 2143 | * and set the state accordingly. */ |
2813 | 1935 | pager_set_state_from_pointer (scrollbar, x, y); | 2144 | bar_set_state_from_pointer (scrollbar, x, y); |
2814 | 1936 | } | 2145 | } |
2815 | 1937 | } | 2146 | } |
2816 | 1938 | else | 2147 | else |
2817 | 1939 | { | 2148 | { |
2820 | 1940 | priv->can_deactivate_pager = FALSE; | 2149 | priv->deactivable_bar = FALSE; |
2821 | 1941 | os_pager_set_active (priv->pager, TRUE, TRUE); | 2150 | os_bar_set_active (priv->bar, TRUE, TRUE); |
2822 | 1942 | } | 2151 | } |
2823 | 1943 | } | 2152 | } |
2824 | 1944 | 2153 | ||
2825 | 1945 | if (current_time > end_time) | 2154 | if (current_time > end_time) |
2826 | 1946 | gtk_widget_hide (priv->thumb); | 2155 | gtk_widget_hide (priv->thumb); |
2827 | 1947 | 2156 | ||
2829 | 1948 | priv->lock_position = FALSE; | 2157 | priv->state &= ~(OS_STATE_LOCKED); |
2830 | 1949 | 2158 | ||
2832 | 1950 | calc_layout_pager (scrollbar, gtk_adjustment_get_value (priv->adjustment)); | 2159 | calc_layout_bar (scrollbar, gtk_adjustment_get_value (priv->adjustment)); |
2833 | 1951 | calc_layout_slider (scrollbar, gtk_adjustment_get_value (priv->adjustment)); | 2160 | calc_layout_slider (scrollbar, gtk_adjustment_get_value (priv->adjustment)); |
2834 | 1952 | 2161 | ||
2836 | 1953 | store_toplevel_position (scrollbar); | 2162 | calc_thumb_window_position (scrollbar); |
2837 | 1954 | 2163 | ||
2838 | 1955 | return FALSE; | 2164 | return FALSE; |
2839 | 1956 | } | 2165 | } |
2840 | 1957 | 2166 | ||
2841 | 2167 | /* widget's window functions. */ | ||
2842 | 2168 | |||
2843 | 2169 | /* Move the thumb in the proximity area. */ | ||
2844 | 2170 | static void | ||
2845 | 2171 | adjust_thumb_position (OsScrollbar *scrollbar, | ||
2846 | 2172 | gdouble event_x, | ||
2847 | 2173 | gdouble event_y) | ||
2848 | 2174 | { | ||
2849 | 2175 | OsScrollbarPrivate *priv; | ||
2850 | 2176 | gint x, y, x_pos, y_pos; | ||
2851 | 2177 | |||
2852 | 2178 | priv = scrollbar->priv; | ||
2853 | 2179 | |||
2854 | 2180 | gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos); | ||
2855 | 2181 | |||
2856 | 2182 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | ||
2857 | 2183 | { | ||
2858 | 2184 | x = priv->thumb_all.x; | ||
2859 | 2185 | y = CLAMP (event_y - priv->slider.height / 2, | ||
2860 | 2186 | priv->thumb_all.y, | ||
2861 | 2187 | priv->thumb_all.y + priv->thumb_all.height - priv->slider.height); | ||
2862 | 2188 | } | ||
2863 | 2189 | else | ||
2864 | 2190 | { | ||
2865 | 2191 | x = CLAMP (event_x - priv->slider.width / 2, | ||
2866 | 2192 | priv->thumb_all.x, | ||
2867 | 2193 | priv->thumb_all.x + priv->thumb_all.width - priv->slider.width); | ||
2868 | 2194 | y = priv->thumb_all.y; | ||
2869 | 2195 | } | ||
2870 | 2196 | |||
2871 | 2197 | move_thumb (scrollbar, x_pos + x, y_pos + y); | ||
2872 | 2198 | } | ||
2873 | 2199 | |||
2874 | 1958 | /* Checks if the pointer is in the proximity area. */ | 2200 | /* Checks if the pointer is in the proximity area. */ |
2875 | 1959 | static gboolean | 2201 | static gboolean |
2876 | 1960 | check_proximity (OsScrollbar *scrollbar, | 2202 | check_proximity (OsScrollbar *scrollbar, |
2879 | 1961 | gint x, | 2203 | gint x, |
2880 | 1962 | gint y) | 2204 | gint y) |
2881 | 1963 | { | 2205 | { |
2882 | 1964 | OsScrollbarPrivate *priv; | 2206 | OsScrollbarPrivate *priv; |
2883 | 1965 | 2207 | ||
2884 | @@ -1968,28 +2210,28 @@ | |||
2885 | 1968 | switch (priv->side) | 2210 | switch (priv->side) |
2886 | 1969 | { | 2211 | { |
2887 | 1970 | case OS_SIDE_RIGHT: | 2212 | case OS_SIDE_RIGHT: |
2892 | 1971 | return (x >= priv->pager_all.x + priv->pager_all.width - PROXIMITY_SIZE && | 2213 | return (x >= priv->bar_all.x + priv->bar_all.width - PROXIMITY_SIZE && |
2893 | 1972 | x <= priv->pager_all.x + priv->pager_all.width) && | 2214 | x <= priv->bar_all.x + priv->bar_all.width) && |
2894 | 1973 | (y >= priv->pager_all.y + priv->overlay.y && | 2215 | (y >= priv->bar_all.y && |
2895 | 1974 | y <= priv->pager_all.y + priv->overlay.y + priv->overlay.height); | 2216 | y <= priv->bar_all.y + priv->bar_all.height); |
2896 | 1975 | break; | 2217 | break; |
2897 | 1976 | case OS_SIDE_BOTTOM: | 2218 | case OS_SIDE_BOTTOM: |
2902 | 1977 | return (y >= priv->pager_all.y + priv->pager_all.height - PROXIMITY_SIZE && | 2219 | return (y >= priv->bar_all.y + priv->bar_all.height - PROXIMITY_SIZE && |
2903 | 1978 | y <= priv->pager_all.y + priv->pager_all.height) && | 2220 | y <= priv->bar_all.y + priv->bar_all.height) && |
2904 | 1979 | (x >= priv->pager_all.x + priv->overlay.x && | 2221 | (x >= priv->bar_all.x && |
2905 | 1980 | x <= priv->pager_all.x + priv->overlay.x + priv->overlay.width); | 2222 | x <= priv->bar_all.x + priv->bar_all.width); |
2906 | 1981 | break; | 2223 | break; |
2907 | 1982 | case OS_SIDE_LEFT: | 2224 | case OS_SIDE_LEFT: |
2912 | 1983 | return (x <= priv->pager_all.x + priv->pager_all.width + PROXIMITY_SIZE && | 2225 | return (x <= priv->bar_all.x + priv->bar_all.width + PROXIMITY_SIZE && |
2913 | 1984 | x >= priv->pager_all.x) && | 2226 | x >= priv->bar_all.x) && |
2914 | 1985 | (y >= priv->pager_all.y + priv->overlay.y && | 2227 | (y >= priv->bar_all.y && |
2915 | 1986 | y <= priv->pager_all.y + priv->overlay.y + priv->overlay.height); | 2228 | y <= priv->bar_all.y + priv->bar_all.height); |
2916 | 1987 | break; | 2229 | break; |
2917 | 1988 | case OS_SIDE_TOP: | 2230 | case OS_SIDE_TOP: |
2922 | 1989 | return (y <= priv->pager_all.y + priv->pager_all.height + PROXIMITY_SIZE && | 2231 | return (y <= priv->bar_all.y + priv->bar_all.height + PROXIMITY_SIZE && |
2923 | 1990 | y >= priv->pager_all.y) && | 2232 | y >= priv->bar_all.y) && |
2924 | 1991 | (x >= priv->pager_all.x + priv->overlay.x && | 2233 | (x >= priv->bar_all.x && |
2925 | 1992 | x <= priv->pager_all.x + priv->overlay.x + priv->overlay.width); | 2234 | x <= priv->bar_all.x + priv->bar_all.width); |
2926 | 1993 | break; | 2235 | break; |
2927 | 1994 | default: | 2236 | default: |
2928 | 1995 | break; | 2237 | break; |
2929 | @@ -1998,6 +2240,64 @@ | |||
2930 | 1998 | return FALSE; | 2240 | return FALSE; |
2931 | 1999 | } | 2241 | } |
2932 | 2000 | 2242 | ||
2933 | 2243 | /* Callback that shows the thumb if it's the case. */ | ||
2934 | 2244 | static gboolean | ||
2935 | 2245 | show_thumb_cb (gpointer user_data) | ||
2936 | 2246 | { | ||
2937 | 2247 | OsScrollbar *scrollbar; | ||
2938 | 2248 | OsScrollbarPrivate *priv; | ||
2939 | 2249 | |||
2940 | 2250 | scrollbar = OS_SCROLLBAR (user_data); | ||
2941 | 2251 | priv = scrollbar->priv; | ||
2942 | 2252 | |||
2943 | 2253 | if (!priv->hidable_thumb) | ||
2944 | 2254 | { | ||
2945 | 2255 | gtk_widget_show (priv->thumb); | ||
2946 | 2256 | |||
2947 | 2257 | update_tail (scrollbar); | ||
2948 | 2258 | } | ||
2949 | 2259 | |||
2950 | 2260 | priv->source_show_thumb_id = 0; | ||
2951 | 2261 | |||
2952 | 2262 | return FALSE; | ||
2953 | 2263 | } | ||
2954 | 2264 | |||
2955 | 2265 | /* Adds a timeout to reveal the thumb. */ | ||
2956 | 2266 | static void | ||
2957 | 2267 | show_thumb (OsScrollbar *scrollbar) | ||
2958 | 2268 | { | ||
2959 | 2269 | OsScrollbarPrivate *priv; | ||
2960 | 2270 | |||
2961 | 2271 | priv = scrollbar->priv; | ||
2962 | 2272 | |||
2963 | 2273 | /* Just update the tail if the thumb is already mapped. */ | ||
2964 | 2274 | if (gtk_widget_get_mapped (priv->thumb)) | ||
2965 | 2275 | { | ||
2966 | 2276 | update_tail (scrollbar); | ||
2967 | 2277 | return; | ||
2968 | 2278 | } | ||
2969 | 2279 | |||
2970 | 2280 | if (priv->state & OS_STATE_INTERNAL) | ||
2971 | 2281 | { | ||
2972 | 2282 | /* If the scrollbar is close to one edge of the screen, | ||
2973 | 2283 | * show it immediately, ignoring the timeout, | ||
2974 | 2284 | * to preserve Fitts' law. */ | ||
2975 | 2285 | if (priv->source_show_thumb_id != 0) | ||
2976 | 2286 | { | ||
2977 | 2287 | g_source_remove (priv->source_show_thumb_id); | ||
2978 | 2288 | priv->source_show_thumb_id = 0; | ||
2979 | 2289 | } | ||
2980 | 2290 | |||
2981 | 2291 | gtk_widget_show (priv->thumb); | ||
2982 | 2292 | |||
2983 | 2293 | update_tail (scrollbar); | ||
2984 | 2294 | } | ||
2985 | 2295 | else if (priv->source_show_thumb_id == 0) | ||
2986 | 2296 | priv->source_show_thumb_id = g_timeout_add (TIMEOUT_THUMB_SHOW, | ||
2987 | 2297 | show_thumb_cb, | ||
2988 | 2298 | scrollbar); | ||
2989 | 2299 | } | ||
2990 | 2300 | |||
2991 | 2001 | /* Filter function applied to the toplevel window. */ | 2301 | /* Filter function applied to the toplevel window. */ |
2992 | 2002 | #ifdef USE_GTK3 | 2302 | #ifdef USE_GTK3 |
2993 | 2003 | typedef enum | 2303 | typedef enum |
2994 | @@ -2025,10 +2325,10 @@ | |||
2995 | 2025 | 2325 | ||
2996 | 2026 | xev = gdkxevent; | 2326 | xev = gdkxevent; |
2997 | 2027 | 2327 | ||
2999 | 2028 | g_return_val_if_fail (OS_IS_PAGER (priv->pager), GDK_FILTER_CONTINUE); | 2328 | g_return_val_if_fail (OS_IS_BAR (priv->bar), GDK_FILTER_CONTINUE); |
3000 | 2029 | g_return_val_if_fail (OS_IS_THUMB (priv->thumb), GDK_FILTER_CONTINUE); | 2329 | g_return_val_if_fail (OS_IS_THUMB (priv->thumb), GDK_FILTER_CONTINUE); |
3001 | 2030 | 2330 | ||
3003 | 2031 | if (!priv->fullsize) | 2331 | if (!(priv->state & OS_STATE_FULLSIZE)) |
3004 | 2032 | { | 2332 | { |
3005 | 2033 | OsXEvent os_xevent; | 2333 | OsXEvent os_xevent; |
3006 | 2034 | gdouble event_x, event_y; | 2334 | gdouble event_x, event_y; |
3007 | @@ -2092,101 +2392,72 @@ | |||
3008 | 2092 | 2392 | ||
3009 | 2093 | if (os_xevent == OS_XEVENT_BUTTON_PRESS) | 2393 | if (os_xevent == OS_XEVENT_BUTTON_PRESS) |
3010 | 2094 | { | 2394 | { |
3012 | 2095 | priv->toplevel_button_press = TRUE; | 2395 | priv->window_button_press = TRUE; |
3013 | 2396 | |||
3014 | 2397 | if (priv->source_show_thumb_id != 0) | ||
3015 | 2398 | { | ||
3016 | 2399 | g_source_remove (priv->source_show_thumb_id); | ||
3017 | 2400 | priv->source_show_thumb_id = 0; | ||
3018 | 2401 | } | ||
3019 | 2402 | |||
3020 | 2096 | gtk_widget_hide (priv->thumb); | 2403 | gtk_widget_hide (priv->thumb); |
3021 | 2097 | } | 2404 | } |
3022 | 2098 | 2405 | ||
3024 | 2099 | if (priv->toplevel_button_press && os_xevent == OS_XEVENT_BUTTON_RELEASE) | 2406 | if (priv->window_button_press && os_xevent == OS_XEVENT_BUTTON_RELEASE) |
3025 | 2100 | { | 2407 | { |
3027 | 2101 | priv->toplevel_button_press = FALSE; | 2408 | priv->window_button_press = FALSE; |
3028 | 2102 | 2409 | ||
3029 | 2103 | /* Proximity area. */ | 2410 | /* Proximity area. */ |
3089 | 2104 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 2411 | if (check_proximity (scrollbar, event_x, event_y)) |
3090 | 2105 | { | 2412 | { |
3091 | 2106 | if (check_proximity (scrollbar, event_x, event_y)) | 2413 | priv->hidable_thumb = FALSE; |
3092 | 2107 | { | 2414 | |
3093 | 2108 | priv->can_hide = FALSE; | 2415 | if (priv->state & OS_STATE_LOCKED) |
3094 | 2109 | 2416 | return GDK_FILTER_CONTINUE; | |
3095 | 2110 | if (priv->lock_position) | 2417 | |
3096 | 2111 | return GDK_FILTER_CONTINUE; | 2418 | adjust_thumb_position (scrollbar, event_x, event_y); |
3097 | 2112 | 2419 | ||
3098 | 2113 | if (priv->overlay.height > priv->slider.height) | 2420 | gtk_widget_show (priv->thumb); |
3099 | 2114 | { | 2421 | |
3100 | 2115 | gint x, y, x_pos, y_pos; | 2422 | update_tail (scrollbar); |
3042 | 2116 | |||
3043 | 2117 | gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos); | ||
3044 | 2118 | |||
3045 | 2119 | x = priv->thumb_all.x; | ||
3046 | 2120 | y = CLAMP (event_y - priv->slider.height / 2, | ||
3047 | 2121 | priv->thumb_all.y + priv->overlay.y, | ||
3048 | 2122 | priv->thumb_all.y + priv->overlay.y + priv->overlay.height - priv->slider.height); | ||
3049 | 2123 | |||
3050 | 2124 | move_thumb (scrollbar, x_pos + x, y_pos + y); | ||
3051 | 2125 | } | ||
3052 | 2126 | else | ||
3053 | 2127 | { | ||
3054 | 2128 | move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y); | ||
3055 | 2129 | } | ||
3056 | 2130 | |||
3057 | 2131 | gtk_widget_show (priv->thumb); | ||
3058 | 2132 | } | ||
3059 | 2133 | } | ||
3060 | 2134 | else | ||
3061 | 2135 | { | ||
3062 | 2136 | if (check_proximity (scrollbar, event_x, event_y)) | ||
3063 | 2137 | { | ||
3064 | 2138 | priv->can_hide = FALSE; | ||
3065 | 2139 | |||
3066 | 2140 | if (priv->lock_position) | ||
3067 | 2141 | return GDK_FILTER_CONTINUE; | ||
3068 | 2142 | |||
3069 | 2143 | if (priv->overlay.width > priv->slider.width) | ||
3070 | 2144 | { | ||
3071 | 2145 | gint x, y, x_pos, y_pos; | ||
3072 | 2146 | |||
3073 | 2147 | gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos); | ||
3074 | 2148 | |||
3075 | 2149 | x = CLAMP (event_x - priv->slider.width / 2, | ||
3076 | 2150 | priv->thumb_all.x + priv->overlay.x, | ||
3077 | 2151 | priv->thumb_all.x + priv->overlay.x + priv->overlay.width - priv->slider.width); | ||
3078 | 2152 | y = priv->thumb_all.y; | ||
3079 | 2153 | |||
3080 | 2154 | move_thumb (scrollbar, x_pos + x, y_pos + y); | ||
3081 | 2155 | } | ||
3082 | 2156 | else | ||
3083 | 2157 | { | ||
3084 | 2158 | move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y); | ||
3085 | 2159 | } | ||
3086 | 2160 | |||
3087 | 2161 | gtk_widget_show (priv->thumb); | ||
3088 | 2162 | } | ||
3101 | 2163 | } | 2423 | } |
3102 | 2164 | } | 2424 | } |
3103 | 2165 | 2425 | ||
3104 | 2166 | if (os_xevent == OS_XEVENT_LEAVE) | 2426 | if (os_xevent == OS_XEVENT_LEAVE) |
3105 | 2167 | { | 2427 | { |
3107 | 2168 | /* Never deactivate the pager in an active window. */ | 2428 | priv->window_button_press = FALSE; |
3108 | 2429 | |||
3109 | 2430 | /* Never deactivate the bar in an active window. */ | ||
3110 | 2169 | if (!priv->active_window) | 2431 | if (!priv->active_window) |
3111 | 2170 | { | 2432 | { |
3131 | 2171 | priv->can_deactivate_pager = TRUE; | 2433 | priv->deactivable_bar = TRUE; |
3132 | 2172 | 2434 | ||
3133 | 2173 | if (priv->source_deactivate_pager_id != 0) | 2435 | if (priv->source_deactivate_bar_id != 0) |
3134 | 2174 | g_source_remove (priv->source_deactivate_pager_id); | 2436 | g_source_remove (priv->source_deactivate_bar_id); |
3135 | 2175 | 2437 | ||
3136 | 2176 | priv->source_deactivate_pager_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE, | 2438 | priv->source_deactivate_bar_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE, |
3137 | 2177 | deactivate_pager_cb, | 2439 | deactivate_bar_cb, |
3138 | 2178 | scrollbar); | 2440 | scrollbar); |
3139 | 2179 | } | 2441 | } |
3140 | 2180 | 2442 | ||
3141 | 2181 | priv->toplevel_button_press = FALSE; | 2443 | if (gtk_widget_get_mapped (priv->thumb) && |
3142 | 2182 | priv->can_hide = TRUE; | 2444 | !(priv->event & OS_EVENT_BUTTON_PRESS)) |
3143 | 2183 | 2445 | { | |
3144 | 2184 | if (priv->source_hide_thumb_id != 0) | 2446 | priv->hidable_thumb = TRUE; |
3145 | 2185 | g_source_remove (priv->source_hide_thumb_id); | 2447 | |
3146 | 2186 | 2448 | if (priv->source_hide_thumb_id != 0) | |
3147 | 2187 | priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE, | 2449 | g_source_remove (priv->source_hide_thumb_id); |
3148 | 2188 | hide_thumb_cb, | 2450 | |
3149 | 2189 | scrollbar); | 2451 | priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE, |
3150 | 2452 | hide_thumb_cb, | ||
3151 | 2453 | scrollbar); | ||
3152 | 2454 | } | ||
3153 | 2455 | |||
3154 | 2456 | if (priv->source_show_thumb_id != 0) | ||
3155 | 2457 | { | ||
3156 | 2458 | g_source_remove (priv->source_show_thumb_id); | ||
3157 | 2459 | priv->source_show_thumb_id = 0; | ||
3158 | 2460 | } | ||
3159 | 2190 | 2461 | ||
3160 | 2191 | if (priv->source_unlock_thumb_id != 0) | 2462 | if (priv->source_unlock_thumb_id != 0) |
3161 | 2192 | g_source_remove (priv->source_unlock_thumb_id); | 2463 | g_source_remove (priv->source_unlock_thumb_id); |
3162 | @@ -2197,107 +2468,47 @@ | |||
3163 | 2197 | } | 2468 | } |
3164 | 2198 | 2469 | ||
3165 | 2199 | /* Get the motion_notify_event trough XEvent. */ | 2470 | /* Get the motion_notify_event trough XEvent. */ |
3167 | 2200 | if (!priv->toplevel_button_press && os_xevent == OS_XEVENT_MOTION) | 2471 | if (!priv->window_button_press && os_xevent == OS_XEVENT_MOTION) |
3168 | 2201 | { | 2472 | { |
3169 | 2202 | /* React to motion_notify_event | 2473 | /* React to motion_notify_event |
3170 | 2203 | * and set the state accordingly. */ | 2474 | * and set the state accordingly. */ |
3171 | 2204 | if (!is_insensitive (scrollbar) && !priv->active_window) | 2475 | if (!is_insensitive (scrollbar) && !priv->active_window) |
3173 | 2205 | pager_set_state_from_pointer (scrollbar, event_x, event_y); | 2476 | bar_set_state_from_pointer (scrollbar, event_x, event_y); |
3174 | 2206 | 2477 | ||
3175 | 2207 | /* Proximity area. */ | 2478 | /* Proximity area. */ |
3177 | 2208 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 2479 | if (check_proximity (scrollbar, event_x, event_y)) |
3178 | 2209 | { | 2480 | { |
3225 | 2210 | if (check_proximity (scrollbar, event_x, event_y)) | 2481 | priv->hidable_thumb = FALSE; |
3226 | 2211 | { | 2482 | |
3227 | 2212 | priv->can_hide = FALSE; | 2483 | if (priv->source_hide_thumb_id != 0) |
3228 | 2213 | 2484 | { | |
3229 | 2214 | if (priv->source_hide_thumb_id != 0) | 2485 | g_source_remove (priv->source_hide_thumb_id); |
3230 | 2215 | { | 2486 | priv->source_hide_thumb_id = 0; |
3231 | 2216 | g_source_remove (priv->source_hide_thumb_id); | 2487 | } |
3232 | 2217 | priv->source_hide_thumb_id = 0; | 2488 | |
3233 | 2218 | } | 2489 | if (priv->state & OS_STATE_LOCKED) |
3234 | 2219 | 2490 | return GDK_FILTER_CONTINUE; | |
3235 | 2220 | if (priv->lock_position) | 2491 | |
3236 | 2221 | return GDK_FILTER_CONTINUE; | 2492 | adjust_thumb_position (scrollbar, event_x, event_y); |
3237 | 2222 | 2493 | ||
3238 | 2223 | if (priv->overlay.height > priv->slider.height) | 2494 | show_thumb (scrollbar); |
3193 | 2224 | { | ||
3194 | 2225 | gint x, y, x_pos, y_pos; | ||
3195 | 2226 | |||
3196 | 2227 | gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos); | ||
3197 | 2228 | |||
3198 | 2229 | x = priv->thumb_all.x; | ||
3199 | 2230 | y = CLAMP (event_y - priv->slider.height / 2, | ||
3200 | 2231 | priv->thumb_all.y + priv->overlay.y, | ||
3201 | 2232 | priv->thumb_all.y + priv->overlay.y + priv->overlay.height - priv->slider.height); | ||
3202 | 2233 | |||
3203 | 2234 | move_thumb (scrollbar, x_pos + x, y_pos + y); | ||
3204 | 2235 | } | ||
3205 | 2236 | else | ||
3206 | 2237 | { | ||
3207 | 2238 | move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y); | ||
3208 | 2239 | } | ||
3209 | 2240 | |||
3210 | 2241 | os_pager_set_detached (priv->pager, FALSE); | ||
3211 | 2242 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); | ||
3212 | 2243 | gtk_widget_show (priv->thumb); | ||
3213 | 2244 | } | ||
3214 | 2245 | else | ||
3215 | 2246 | { | ||
3216 | 2247 | priv->can_hide = TRUE; | ||
3217 | 2248 | priv->lock_position = FALSE; | ||
3218 | 2249 | |||
3219 | 2250 | if (gtk_widget_get_mapped (priv->thumb) && | ||
3220 | 2251 | priv->source_hide_thumb_id == 0) | ||
3221 | 2252 | priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_PROXIMITY_HIDE, | ||
3222 | 2253 | hide_thumb_cb, | ||
3223 | 2254 | scrollbar); | ||
3224 | 2255 | } | ||
3239 | 2256 | } | 2495 | } |
3240 | 2257 | else | 2496 | else |
3241 | 2258 | { | 2497 | { |
3243 | 2259 | if (check_proximity (scrollbar, event_x, event_y)) | 2498 | priv->state &= ~(OS_STATE_LOCKED); |
3244 | 2499 | |||
3245 | 2500 | if (priv->source_show_thumb_id != 0) | ||
3246 | 2260 | { | 2501 | { |
3279 | 2261 | priv->can_hide = FALSE; | 2502 | g_source_remove (priv->source_show_thumb_id); |
3280 | 2262 | 2503 | priv->source_show_thumb_id = 0; | |
3249 | 2263 | if (priv->source_hide_thumb_id != 0) | ||
3250 | 2264 | { | ||
3251 | 2265 | g_source_remove (priv->source_hide_thumb_id); | ||
3252 | 2266 | priv->source_hide_thumb_id = 0; | ||
3253 | 2267 | } | ||
3254 | 2268 | |||
3255 | 2269 | if (priv->lock_position) | ||
3256 | 2270 | return GDK_FILTER_CONTINUE; | ||
3257 | 2271 | |||
3258 | 2272 | if (priv->overlay.width > priv->slider.width) | ||
3259 | 2273 | { | ||
3260 | 2274 | gint x, y, x_pos, y_pos; | ||
3261 | 2275 | |||
3262 | 2276 | gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos); | ||
3263 | 2277 | |||
3264 | 2278 | x = CLAMP (event_x - priv->slider.width / 2, | ||
3265 | 2279 | priv->thumb_all.x + priv->overlay.x, | ||
3266 | 2280 | priv->thumb_all.x + priv->overlay.x + priv->overlay.width - priv->slider.width); | ||
3267 | 2281 | y = priv->thumb_all.y; | ||
3268 | 2282 | |||
3269 | 2283 | move_thumb (scrollbar, x_pos + x, y_pos + y); | ||
3270 | 2284 | } | ||
3271 | 2285 | else | ||
3272 | 2286 | { | ||
3273 | 2287 | move_thumb (scrollbar, priv->win_x + priv->slider.x, priv->win_y); | ||
3274 | 2288 | } | ||
3275 | 2289 | |||
3276 | 2290 | os_pager_set_detached (priv->pager, FALSE); | ||
3277 | 2291 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); | ||
3278 | 2292 | gtk_widget_show (priv->thumb); | ||
3281 | 2293 | } | 2504 | } |
3283 | 2294 | else | 2505 | |
3284 | 2506 | if (gtk_widget_get_mapped (priv->thumb) && | ||
3285 | 2507 | !(priv->event & OS_EVENT_BUTTON_PRESS)) | ||
3286 | 2295 | { | 2508 | { |
3289 | 2296 | priv->can_hide = TRUE; | 2509 | priv->hidable_thumb = TRUE; |
3288 | 2297 | priv->lock_position = FALSE; | ||
3290 | 2298 | 2510 | ||
3293 | 2299 | if (gtk_widget_get_mapped (priv->thumb) && | 2511 | if (priv->source_hide_thumb_id == 0) |
3292 | 2300 | priv->source_hide_thumb_id == 0) | ||
3294 | 2301 | priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_PROXIMITY_HIDE, | 2512 | priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_PROXIMITY_HIDE, |
3295 | 2302 | hide_thumb_cb, | 2513 | hide_thumb_cb, |
3296 | 2303 | scrollbar); | 2514 | scrollbar); |
3297 | @@ -2325,120 +2536,79 @@ | |||
3298 | 2325 | 2536 | ||
3299 | 2326 | xev = gdkxevent; | 2537 | xev = gdkxevent; |
3300 | 2327 | 2538 | ||
3302 | 2328 | g_return_val_if_fail (OS_IS_PAGER (priv->pager), GDK_FILTER_CONTINUE); | 2539 | g_return_val_if_fail (OS_IS_BAR (priv->bar), GDK_FILTER_CONTINUE); |
3303 | 2329 | g_return_val_if_fail (OS_IS_THUMB (priv->thumb), GDK_FILTER_CONTINUE); | 2540 | g_return_val_if_fail (OS_IS_THUMB (priv->thumb), GDK_FILTER_CONTINUE); |
3304 | 2330 | 2541 | ||
3306 | 2331 | if (!priv->fullsize) | 2542 | if (!(priv->state & OS_STATE_FULLSIZE)) |
3307 | 2332 | { | 2543 | { |
3308 | 2333 | if (xev->type == ButtonPress) | 2544 | if (xev->type == ButtonPress) |
3309 | 2334 | { | 2545 | { |
3311 | 2335 | priv->toplevel_button_press = TRUE; | 2546 | priv->window_button_press = TRUE; |
3312 | 2547 | |||
3313 | 2548 | if (priv->source_show_thumb_id != 0) | ||
3314 | 2549 | { | ||
3315 | 2550 | g_source_remove (priv->source_show_thumb_id); | ||
3316 | 2551 | priv->source_show_thumb_id = 0; | ||
3317 | 2552 | } | ||
3318 | 2553 | |||
3319 | 2336 | gtk_widget_hide (priv->thumb); | 2554 | gtk_widget_hide (priv->thumb); |
3320 | 2337 | } | 2555 | } |
3321 | 2338 | 2556 | ||
3323 | 2339 | if (priv->toplevel_button_press && xev->type == ButtonRelease) | 2557 | if (priv->window_button_press && xev->type == ButtonRelease) |
3324 | 2340 | { | 2558 | { |
3326 | 2341 | priv->toplevel_button_press = FALSE; | 2559 | priv->window_button_press = FALSE; |
3327 | 2342 | 2560 | ||
3328 | 2343 | /* Proximity area. */ | 2561 | /* Proximity area. */ |
3400 | 2344 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 2562 | if (check_proximity (scrollbar, xev->xbutton.x, xev->xbutton.y)) |
3401 | 2345 | { | 2563 | { |
3402 | 2346 | if (check_proximity (scrollbar, xev->xbutton.x, xev->xbutton.y)) | 2564 | priv->hidable_thumb = FALSE; |
3403 | 2347 | { | 2565 | |
3404 | 2348 | priv->can_hide = FALSE; | 2566 | if (priv->state & OS_STATE_LOCKED) |
3405 | 2349 | 2567 | return GDK_FILTER_CONTINUE; | |
3406 | 2350 | if (priv->source_hide_thumb_id != 0) | 2568 | |
3407 | 2351 | { | 2569 | adjust_thumb_position (scrollbar, xev->xbutton.x, xev->xbutton.y); |
3408 | 2352 | g_source_remove (priv->source_hide_thumb_id); | 2570 | |
3409 | 2353 | priv->source_hide_thumb_id = 0; | 2571 | gtk_widget_show (priv->thumb); |
3410 | 2354 | } | 2572 | |
3411 | 2355 | 2573 | update_tail (scrollbar); | |
3341 | 2356 | if (priv->lock_position) | ||
3342 | 2357 | return GDK_FILTER_CONTINUE; | ||
3343 | 2358 | |||
3344 | 2359 | if (priv->overlay.height > priv->slider.height) | ||
3345 | 2360 | { | ||
3346 | 2361 | gint x, y, x_pos, y_pos; | ||
3347 | 2362 | |||
3348 | 2363 | gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos); | ||
3349 | 2364 | |||
3350 | 2365 | x = priv->thumb_all.x; | ||
3351 | 2366 | y = CLAMP (xev->xbutton.y - priv->slider.height / 2, | ||
3352 | 2367 | priv->thumb_all.y + priv->overlay.y, | ||
3353 | 2368 | priv->thumb_all.y + priv->overlay.y + priv->overlay.height - priv->slider.height); | ||
3354 | 2369 | |||
3355 | 2370 | move_thumb (scrollbar, x_pos + x, y_pos + y); | ||
3356 | 2371 | } | ||
3357 | 2372 | else | ||
3358 | 2373 | { | ||
3359 | 2374 | move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y); | ||
3360 | 2375 | } | ||
3361 | 2376 | |||
3362 | 2377 | gtk_widget_show (priv->thumb); | ||
3363 | 2378 | } | ||
3364 | 2379 | } | ||
3365 | 2380 | else | ||
3366 | 2381 | { | ||
3367 | 2382 | if (check_proximity (scrollbar, xev->xbutton.x, xev->xbutton.y)) | ||
3368 | 2383 | { | ||
3369 | 2384 | priv->can_hide = FALSE; | ||
3370 | 2385 | |||
3371 | 2386 | if (priv->source_hide_thumb_id != 0) | ||
3372 | 2387 | { | ||
3373 | 2388 | g_source_remove (priv->source_hide_thumb_id); | ||
3374 | 2389 | priv->source_hide_thumb_id = 0; | ||
3375 | 2390 | } | ||
3376 | 2391 | |||
3377 | 2392 | if (priv->lock_position) | ||
3378 | 2393 | return GDK_FILTER_CONTINUE; | ||
3379 | 2394 | |||
3380 | 2395 | if (priv->overlay.width > priv->slider.width) | ||
3381 | 2396 | { | ||
3382 | 2397 | gint x, y, x_pos, y_pos; | ||
3383 | 2398 | |||
3384 | 2399 | gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos); | ||
3385 | 2400 | |||
3386 | 2401 | x = CLAMP (xev->xbutton.x - priv->slider.width / 2, | ||
3387 | 2402 | priv->thumb_all.x + priv->overlay.x, | ||
3388 | 2403 | priv->thumb_all.x + priv->overlay.x + priv->overlay.width - priv->slider.width); | ||
3389 | 2404 | y = priv->thumb_all.y; | ||
3390 | 2405 | |||
3391 | 2406 | move_thumb (scrollbar, x_pos + x, y_pos + y); | ||
3392 | 2407 | } | ||
3393 | 2408 | else | ||
3394 | 2409 | { | ||
3395 | 2410 | move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y); | ||
3396 | 2411 | } | ||
3397 | 2412 | |||
3398 | 2413 | gtk_widget_show (priv->thumb); | ||
3399 | 2414 | } | ||
3412 | 2415 | } | 2574 | } |
3413 | 2416 | } | 2575 | } |
3414 | 2417 | 2576 | ||
3415 | 2418 | if (xev->type == LeaveNotify) | 2577 | if (xev->type == LeaveNotify) |
3416 | 2419 | { | 2578 | { |
3418 | 2420 | /* Never deactivate the pager in an active window. */ | 2579 | priv->window_button_press = FALSE; |
3419 | 2580 | |||
3420 | 2581 | /* Never deactivate the bar in an active window. */ | ||
3421 | 2421 | if (!priv->active_window) | 2582 | if (!priv->active_window) |
3422 | 2422 | { | 2583 | { |
3442 | 2423 | priv->can_deactivate_pager = TRUE; | 2584 | priv->deactivable_bar = TRUE; |
3443 | 2424 | 2585 | ||
3444 | 2425 | if (priv->source_deactivate_pager_id != 0) | 2586 | if (priv->source_deactivate_bar_id != 0) |
3445 | 2426 | g_source_remove (priv->source_deactivate_pager_id); | 2587 | g_source_remove (priv->source_deactivate_bar_id); |
3446 | 2427 | 2588 | ||
3447 | 2428 | priv->source_deactivate_pager_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE, | 2589 | priv->source_deactivate_bar_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE, |
3448 | 2429 | deactivate_pager_cb, | 2590 | deactivate_bar_cb, |
3449 | 2430 | scrollbar); | 2591 | scrollbar); |
3450 | 2431 | } | 2592 | } |
3451 | 2432 | 2593 | ||
3452 | 2433 | priv->toplevel_button_press = FALSE; | 2594 | if (gtk_widget_get_mapped (priv->thumb) && |
3453 | 2434 | priv->can_hide = TRUE; | 2595 | !(priv->event & OS_EVENT_BUTTON_PRESS)) |
3454 | 2435 | 2596 | { | |
3455 | 2436 | if (priv->source_hide_thumb_id != 0) | 2597 | priv->hidable_thumb = TRUE; |
3456 | 2437 | g_source_remove (priv->source_hide_thumb_id); | 2598 | |
3457 | 2438 | 2599 | if (priv->source_hide_thumb_id != 0) | |
3458 | 2439 | priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE, | 2600 | g_source_remove (priv->source_hide_thumb_id); |
3459 | 2440 | hide_thumb_cb, | 2601 | |
3460 | 2441 | scrollbar); | 2602 | priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE, |
3461 | 2603 | hide_thumb_cb, | ||
3462 | 2604 | scrollbar); | ||
3463 | 2605 | } | ||
3464 | 2606 | |||
3465 | 2607 | if (priv->source_show_thumb_id != 0) | ||
3466 | 2608 | { | ||
3467 | 2609 | g_source_remove (priv->source_show_thumb_id); | ||
3468 | 2610 | priv->source_show_thumb_id = 0; | ||
3469 | 2611 | } | ||
3470 | 2442 | 2612 | ||
3471 | 2443 | if (priv->source_unlock_thumb_id != 0) | 2613 | if (priv->source_unlock_thumb_id != 0) |
3472 | 2444 | g_source_remove (priv->source_unlock_thumb_id); | 2614 | g_source_remove (priv->source_unlock_thumb_id); |
3473 | @@ -2449,95 +2619,47 @@ | |||
3474 | 2449 | } | 2619 | } |
3475 | 2450 | 2620 | ||
3476 | 2451 | /* Get the motion_notify_event trough XEvent. */ | 2621 | /* Get the motion_notify_event trough XEvent. */ |
3478 | 2452 | if (!priv->toplevel_button_press && xev->type == MotionNotify) | 2622 | if (!priv->window_button_press && xev->type == MotionNotify) |
3479 | 2453 | { | 2623 | { |
3480 | 2454 | /* React to motion_notify_event | 2624 | /* React to motion_notify_event |
3481 | 2455 | * and set the state accordingly. */ | 2625 | * and set the state accordingly. */ |
3482 | 2456 | if (!is_insensitive (scrollbar) && !priv->active_window) | 2626 | if (!is_insensitive (scrollbar) && !priv->active_window) |
3484 | 2457 | pager_set_state_from_pointer (scrollbar, xev->xmotion.x, xev->xmotion.y); | 2627 | bar_set_state_from_pointer (scrollbar, xev->xmotion.x, xev->xmotion.y); |
3485 | 2458 | 2628 | ||
3486 | 2459 | /* Proximity area. */ | 2629 | /* Proximity area. */ |
3488 | 2460 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 2630 | if (check_proximity (scrollbar, xev->xmotion.x, xev->xmotion.y)) |
3489 | 2461 | { | 2631 | { |
3530 | 2462 | if (check_proximity (scrollbar, xev->xmotion.x, xev->xmotion.y)) | 2632 | priv->hidable_thumb = FALSE; |
3531 | 2463 | { | 2633 | |
3532 | 2464 | priv->can_hide = FALSE; | 2634 | if (priv->source_hide_thumb_id != 0) |
3533 | 2465 | 2635 | { | |
3534 | 2466 | if (priv->lock_position) | 2636 | g_source_remove (priv->source_hide_thumb_id); |
3535 | 2467 | return GDK_FILTER_CONTINUE; | 2637 | priv->source_hide_thumb_id = 0; |
3536 | 2468 | 2638 | } | |
3537 | 2469 | if (priv->overlay.height > priv->slider.height) | 2639 | |
3538 | 2470 | { | 2640 | if (priv->state & OS_STATE_LOCKED) |
3539 | 2471 | gint x, y, x_pos, y_pos; | 2641 | return GDK_FILTER_CONTINUE; |
3540 | 2472 | 2642 | ||
3541 | 2473 | gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos); | 2643 | adjust_thumb_position (scrollbar, xev->xmotion.x, xev->xmotion.y); |
3542 | 2474 | 2644 | ||
3543 | 2475 | x = priv->thumb_all.x; | 2645 | show_thumb (scrollbar); |
3504 | 2476 | y = CLAMP (xev->xmotion.y - priv->slider.height / 2, | ||
3505 | 2477 | priv->thumb_all.y + priv->overlay.y, | ||
3506 | 2478 | priv->thumb_all.y + priv->overlay.y + priv->overlay.height - priv->slider.height); | ||
3507 | 2479 | |||
3508 | 2480 | move_thumb (scrollbar, x_pos + x, y_pos + y); | ||
3509 | 2481 | } | ||
3510 | 2482 | else | ||
3511 | 2483 | { | ||
3512 | 2484 | move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y); | ||
3513 | 2485 | } | ||
3514 | 2486 | |||
3515 | 2487 | os_pager_set_detached (priv->pager, FALSE); | ||
3516 | 2488 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); | ||
3517 | 2489 | gtk_widget_show (priv->thumb); | ||
3518 | 2490 | } | ||
3519 | 2491 | else | ||
3520 | 2492 | { | ||
3521 | 2493 | priv->can_hide = TRUE; | ||
3522 | 2494 | priv->lock_position = FALSE; | ||
3523 | 2495 | |||
3524 | 2496 | if (gtk_widget_get_mapped (priv->thumb) && | ||
3525 | 2497 | priv->source_hide_thumb_id == 0) | ||
3526 | 2498 | priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_PROXIMITY_HIDE, | ||
3527 | 2499 | hide_thumb_cb, | ||
3528 | 2500 | scrollbar); | ||
3529 | 2501 | } | ||
3544 | 2502 | } | 2646 | } |
3545 | 2503 | else | 2647 | else |
3546 | 2504 | { | 2648 | { |
3548 | 2505 | if (check_proximity (scrollbar, xev->xmotion.x, xev->xmotion.y)) | 2649 | priv->state &= ~(OS_STATE_LOCKED); |
3549 | 2650 | |||
3550 | 2651 | if (priv->source_show_thumb_id != 0) | ||
3551 | 2506 | { | 2652 | { |
3578 | 2507 | priv->can_hide = FALSE; | 2653 | g_source_remove (priv->source_show_thumb_id); |
3579 | 2508 | 2654 | priv->source_show_thumb_id = 0; | |
3554 | 2509 | if (priv->lock_position) | ||
3555 | 2510 | return GDK_FILTER_CONTINUE; | ||
3556 | 2511 | |||
3557 | 2512 | if (priv->overlay.width > priv->slider.width) | ||
3558 | 2513 | { | ||
3559 | 2514 | gint x, y, x_pos, y_pos; | ||
3560 | 2515 | |||
3561 | 2516 | gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos); | ||
3562 | 2517 | |||
3563 | 2518 | x = CLAMP (xev->xmotion.x - priv->slider.width / 2, | ||
3564 | 2519 | priv->thumb_all.x + priv->overlay.x, | ||
3565 | 2520 | priv->thumb_all.x + priv->overlay.x + priv->overlay.width - priv->slider.width); | ||
3566 | 2521 | y = priv->thumb_all.y; | ||
3567 | 2522 | |||
3568 | 2523 | move_thumb (scrollbar, x_pos + x, y_pos + y); | ||
3569 | 2524 | } | ||
3570 | 2525 | else | ||
3571 | 2526 | { | ||
3572 | 2527 | move_thumb (scrollbar, priv->win_x + priv->slider.x, priv->win_y); | ||
3573 | 2528 | } | ||
3574 | 2529 | |||
3575 | 2530 | os_pager_set_detached (priv->pager, FALSE); | ||
3576 | 2531 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); | ||
3577 | 2532 | gtk_widget_show (priv->thumb); | ||
3580 | 2533 | } | 2655 | } |
3582 | 2534 | else | 2656 | |
3583 | 2657 | if (gtk_widget_get_mapped (priv->thumb) && | ||
3584 | 2658 | !(priv->event & OS_EVENT_BUTTON_PRESS)) | ||
3585 | 2535 | { | 2659 | { |
3588 | 2536 | priv->can_hide = TRUE; | 2660 | priv->hidable_thumb = TRUE; |
3587 | 2537 | priv->lock_position = FALSE; | ||
3589 | 2538 | 2661 | ||
3592 | 2539 | if (gtk_widget_get_mapped (priv->thumb) && | 2662 | if (priv->source_hide_thumb_id == 0) |
3591 | 2540 | priv->source_hide_thumb_id == 0) | ||
3593 | 2541 | priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_PROXIMITY_HIDE, | 2663 | priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_PROXIMITY_HIDE, |
3594 | 2542 | hide_thumb_cb, | 2664 | hide_thumb_cb, |
3595 | 2543 | scrollbar); | 2665 | scrollbar); |
3596 | @@ -2550,6 +2672,44 @@ | |||
3597 | 2550 | } | 2672 | } |
3598 | 2551 | #endif | 2673 | #endif |
3599 | 2552 | 2674 | ||
3600 | 2675 | /* Add the window filter function. */ | ||
3601 | 2676 | static void | ||
3602 | 2677 | add_window_filter (OsScrollbar *scrollbar) | ||
3603 | 2678 | { | ||
3604 | 2679 | OsScrollbarPrivate *priv; | ||
3605 | 2680 | |||
3606 | 2681 | priv = scrollbar->priv; | ||
3607 | 2682 | |||
3608 | 2683 | /* Don't add duplicated filters. */ | ||
3609 | 2684 | if (!priv->filter.running && | ||
3610 | 2685 | gtk_widget_get_realized (GTK_WIDGET (scrollbar))) | ||
3611 | 2686 | { | ||
3612 | 2687 | priv->filter.running = TRUE; | ||
3613 | 2688 | gdk_window_add_filter (gtk_widget_get_window (GTK_WIDGET (scrollbar)), | ||
3614 | 2689 | window_filter_func, | ||
3615 | 2690 | scrollbar); | ||
3616 | 2691 | } | ||
3617 | 2692 | } | ||
3618 | 2693 | |||
3619 | 2694 | /* Remove the window filter function. */ | ||
3620 | 2695 | static void | ||
3621 | 2696 | remove_window_filter (OsScrollbar *scrollbar) | ||
3622 | 2697 | { | ||
3623 | 2698 | OsScrollbarPrivate *priv; | ||
3624 | 2699 | |||
3625 | 2700 | priv = scrollbar->priv; | ||
3626 | 2701 | |||
3627 | 2702 | /* Remove only if the filter is running. */ | ||
3628 | 2703 | if (priv->filter.running && | ||
3629 | 2704 | gtk_widget_get_realized (GTK_WIDGET (scrollbar))) | ||
3630 | 2705 | { | ||
3631 | 2706 | priv->filter.running = FALSE; | ||
3632 | 2707 | gdk_window_remove_filter (gtk_widget_get_window (GTK_WIDGET (scrollbar)), | ||
3633 | 2708 | window_filter_func, | ||
3634 | 2709 | scrollbar); | ||
3635 | 2710 | } | ||
3636 | 2711 | } | ||
3637 | 2712 | |||
3638 | 2553 | G_DEFINE_TYPE (OsScrollbar, os_scrollbar, GTK_TYPE_SCROLLBAR); | 2713 | G_DEFINE_TYPE (OsScrollbar, os_scrollbar, GTK_TYPE_SCROLLBAR); |
3639 | 2554 | 2714 | ||
3640 | 2555 | static void | 2715 | static void |
3641 | @@ -2634,27 +2794,34 @@ | |||
3642 | 2634 | 2794 | ||
3643 | 2635 | priv->event = OS_EVENT_NONE; | 2795 | priv->event = OS_EVENT_NONE; |
3644 | 2636 | 2796 | ||
3645 | 2797 | priv->state = OS_STATE_NONE; | ||
3646 | 2798 | |||
3647 | 2799 | priv->side = OS_SIDE_RIGHT; | ||
3648 | 2800 | |||
3649 | 2801 | priv->filter.proximity = FALSE; | ||
3650 | 2802 | priv->filter.running = FALSE; | ||
3651 | 2803 | |||
3652 | 2637 | priv->active_window = FALSE; | 2804 | priv->active_window = FALSE; |
3664 | 2638 | priv->can_deactivate_pager = TRUE; | 2805 | priv->deactivable_bar = TRUE; |
3665 | 2639 | priv->can_hide = TRUE; | 2806 | priv->hidable_thumb = TRUE; |
3666 | 2640 | priv->detached_scroll = FALSE; | 2807 | priv->window_button_press = FALSE; |
3667 | 2641 | priv->filter = FALSE; | 2808 | |
3668 | 2642 | priv->fullsize = FALSE; | 2809 | priv->pointer.x = 0; |
3669 | 2643 | priv->internal = FALSE; | 2810 | priv->pointer.y = 0; |
3670 | 2644 | priv->lock_position = FALSE; | 2811 | priv->thumb_win.x = 0; |
3671 | 2645 | priv->proximity = FALSE; | 2812 | priv->thumb_win.y = 0; |
3672 | 2646 | priv->toplevel_button_press = FALSE; | 2813 | |
3673 | 2647 | priv->side = OS_SIDE_RIGHT; | 2814 | priv->source_deactivate_bar_id = 0; |
3663 | 2648 | priv->source_deactivate_pager_id = 0; | ||
3674 | 2649 | priv->source_hide_thumb_id = 0; | 2815 | priv->source_hide_thumb_id = 0; |
3675 | 2816 | priv->source_show_thumb_id = 0; | ||
3676 | 2650 | priv->source_unlock_thumb_id = 0; | 2817 | priv->source_unlock_thumb_id = 0; |
3677 | 2651 | 2818 | ||
3679 | 2652 | priv->pager = os_pager_new (); | 2819 | priv->bar = os_bar_new (); |
3680 | 2653 | 2820 | ||
3681 | 2654 | priv->window_group = gtk_window_group_new (); | 2821 | priv->window_group = gtk_window_group_new (); |
3682 | 2655 | 2822 | ||
3685 | 2656 | priv->animation = os_animation_new (RATE_PAGING, MAX_DURATION_PAGING, | 2823 | priv->animation = os_animation_new (RATE_ANIMATION, MAX_DURATION_SCROLLING, |
3686 | 2657 | paging_cb, NULL, scrollbar); | 2824 | scrolling_cb, scrolling_end_cb, scrollbar); |
3687 | 2658 | priv->value = 0; | 2825 | priv->value = 0; |
3688 | 2659 | 2826 | ||
3689 | 2660 | g_signal_connect (G_OBJECT (scrollbar), "notify::adjustment", | 2827 | g_signal_connect (G_OBJECT (scrollbar), "notify::adjustment", |
3690 | @@ -2673,10 +2840,10 @@ | |||
3691 | 2673 | scrollbar = OS_SCROLLBAR (object); | 2840 | scrollbar = OS_SCROLLBAR (object); |
3692 | 2674 | priv = scrollbar->priv; | 2841 | priv = scrollbar->priv; |
3693 | 2675 | 2842 | ||
3695 | 2676 | if (priv->source_deactivate_pager_id != 0) | 2843 | if (priv->source_deactivate_bar_id != 0) |
3696 | 2677 | { | 2844 | { |
3699 | 2678 | g_source_remove (priv->source_deactivate_pager_id); | 2845 | g_source_remove (priv->source_deactivate_bar_id); |
3700 | 2679 | priv->source_deactivate_pager_id = 0; | 2846 | priv->source_deactivate_bar_id = 0; |
3701 | 2680 | } | 2847 | } |
3702 | 2681 | 2848 | ||
3703 | 2682 | if (priv->source_hide_thumb_id != 0) | 2849 | if (priv->source_hide_thumb_id != 0) |
3704 | @@ -2711,10 +2878,10 @@ | |||
3705 | 2711 | priv->animation = NULL; | 2878 | priv->animation = NULL; |
3706 | 2712 | } | 2879 | } |
3707 | 2713 | 2880 | ||
3709 | 2714 | if (priv->pager != NULL) | 2881 | if (priv->bar != NULL) |
3710 | 2715 | { | 2882 | { |
3713 | 2716 | g_object_unref (priv->pager); | 2883 | g_object_unref (priv->bar); |
3714 | 2717 | priv->pager = NULL; | 2884 | priv->bar = NULL; |
3715 | 2718 | } | 2885 | } |
3716 | 2719 | 2886 | ||
3717 | 2720 | if (priv->window_group != NULL) | 2887 | if (priv->window_group != NULL) |
3718 | @@ -2767,8 +2934,7 @@ | |||
3719 | 2767 | *minimal_width = *natural_width = 0; | 2934 | *minimal_width = *natural_width = 0; |
3720 | 2768 | else | 2935 | else |
3721 | 2769 | { | 2936 | { |
3724 | 2770 | /* Smaller than 35 pixels the thumb looks weird. */ | 2937 | *minimal_width = MIN_THUMB_HEIGHT; |
3723 | 2771 | *minimal_width = 35; | ||
3725 | 2772 | *natural_width = THUMB_HEIGHT; | 2938 | *natural_width = THUMB_HEIGHT; |
3726 | 2773 | } | 2939 | } |
3727 | 2774 | } | 2940 | } |
3728 | @@ -2788,8 +2954,7 @@ | |||
3729 | 2788 | *minimal_height = *natural_height = 0; | 2954 | *minimal_height = *natural_height = 0; |
3730 | 2789 | else | 2955 | else |
3731 | 2790 | { | 2956 | { |
3734 | 2791 | /* Smaller than 35 pixels the thumb looks weird. */ | 2957 | *minimal_height = MIN_THUMB_HEIGHT; |
3733 | 2792 | *minimal_height = 35; | ||
3735 | 2793 | *natural_height = THUMB_HEIGHT; | 2958 | *natural_height = THUMB_HEIGHT; |
3736 | 2794 | } | 2959 | } |
3737 | 2795 | } | 2960 | } |
3738 | @@ -2823,10 +2988,10 @@ | |||
3739 | 2823 | gdk_screen_get_active_window (gtk_widget_get_screen (widget))) | 2988 | gdk_screen_get_active_window (gtk_widget_get_screen (widget))) |
3740 | 2824 | { | 2989 | { |
3741 | 2825 | /* Stops potential running timeout. */ | 2990 | /* Stops potential running timeout. */ |
3743 | 2826 | if (priv->source_deactivate_pager_id != 0) | 2991 | if (priv->source_deactivate_bar_id != 0) |
3744 | 2827 | { | 2992 | { |
3747 | 2828 | g_source_remove (priv->source_deactivate_pager_id); | 2993 | g_source_remove (priv->source_deactivate_bar_id); |
3748 | 2829 | priv->source_deactivate_pager_id = 0; | 2994 | priv->source_deactivate_bar_id = 0; |
3749 | 2830 | } | 2995 | } |
3750 | 2831 | 2996 | ||
3751 | 2832 | priv->active_window = TRUE; | 2997 | priv->active_window = TRUE; |
3752 | @@ -2846,29 +3011,24 @@ | |||
3753 | 2846 | * for example when switching notebook page, | 3011 | * for example when switching notebook page, |
3754 | 2847 | * check the position of the pointer | 3012 | * check the position of the pointer |
3755 | 2848 | * and set the state accordingly. */ | 3013 | * and set the state accordingly. */ |
3757 | 2849 | pager_set_state_from_pointer (scrollbar, x, y); | 3014 | bar_set_state_from_pointer (scrollbar, x, y); |
3758 | 2850 | } | 3015 | } |
3759 | 2851 | else | 3016 | else |
3760 | 2852 | { | 3017 | { |
3761 | 2853 | /* On map-event of an active window, | 3018 | /* On map-event of an active window, |
3765 | 2854 | * the pager should be active. */ | 3019 | * the bar should be active. */ |
3766 | 2855 | priv->can_deactivate_pager = FALSE; | 3020 | priv->deactivable_bar = FALSE; |
3767 | 2856 | os_pager_set_active (priv->pager, TRUE, FALSE); | 3021 | os_bar_set_active (priv->bar, TRUE, FALSE); |
3768 | 2857 | } | 3022 | } |
3769 | 2858 | } | 3023 | } |
3770 | 2859 | 3024 | ||
3773 | 2860 | if (priv->fullsize == FALSE) | 3025 | if (!(priv->state & OS_STATE_FULLSIZE)) |
3774 | 2861 | os_pager_show (priv->pager); | 3026 | os_bar_show (priv->bar); |
3775 | 2862 | 3027 | ||
3776 | 2863 | if (!is_insensitive (scrollbar)) | 3028 | if (!is_insensitive (scrollbar)) |
3777 | 2864 | { | 3029 | { |
3785 | 2865 | priv->proximity = TRUE; | 3030 | priv->filter.proximity = TRUE; |
3786 | 2866 | 3031 | add_window_filter (scrollbar); | |
3780 | 2867 | if (gtk_widget_get_realized (widget) && priv->filter == FALSE) | ||
3781 | 2868 | { | ||
3782 | 2869 | priv->filter = TRUE; | ||
3783 | 2870 | gdk_window_add_filter (gtk_widget_get_window (widget), window_filter_func, scrollbar); | ||
3784 | 2871 | } | ||
3787 | 2872 | } | 3032 | } |
3788 | 2873 | } | 3033 | } |
3789 | 2874 | 3034 | ||
3790 | @@ -2889,20 +3049,17 @@ | |||
3791 | 2889 | gdk_window_get_events (gtk_widget_get_window (widget)) | | 3049 | gdk_window_get_events (gtk_widget_get_window (widget)) | |
3792 | 2890 | GDK_POINTER_MOTION_MASK); | 3050 | GDK_POINTER_MOTION_MASK); |
3793 | 2891 | 3051 | ||
3799 | 2892 | if (priv->filter == FALSE && priv->proximity == TRUE) | 3052 | if (priv->filter.proximity) |
3800 | 2893 | { | 3053 | add_window_filter (scrollbar); |
3796 | 2894 | priv->filter = TRUE; | ||
3797 | 2895 | gdk_window_add_filter (gtk_widget_get_window (widget), window_filter_func, scrollbar); | ||
3798 | 2896 | } | ||
3801 | 2897 | 3054 | ||
3802 | 2898 | g_signal_connect (G_OBJECT (gtk_widget_get_toplevel (widget)), "configure-event", | 3055 | g_signal_connect (G_OBJECT (gtk_widget_get_toplevel (widget)), "configure-event", |
3803 | 2899 | G_CALLBACK (toplevel_configure_event_cb), scrollbar); | 3056 | G_CALLBACK (toplevel_configure_event_cb), scrollbar); |
3804 | 2900 | 3057 | ||
3810 | 2901 | calc_layout_pager (scrollbar, gtk_adjustment_get_value (priv->adjustment)); | 3058 | calc_layout_bar (scrollbar, gtk_adjustment_get_value (priv->adjustment)); |
3811 | 2902 | 3059 | ||
3812 | 2903 | os_pager_set_parent (priv->pager, widget); | 3060 | os_bar_set_parent (priv->bar, widget); |
3813 | 2904 | 3061 | ||
3814 | 2905 | store_toplevel_position (scrollbar); | 3062 | calc_thumb_window_position (scrollbar); |
3815 | 2906 | } | 3063 | } |
3816 | 2907 | 3064 | ||
3817 | 2908 | static void | 3065 | static void |
3818 | @@ -2965,7 +3122,7 @@ | |||
3819 | 2965 | scrollbar = OS_SCROLLBAR (widget); | 3122 | scrollbar = OS_SCROLLBAR (widget); |
3820 | 2966 | priv = scrollbar->priv; | 3123 | priv = scrollbar->priv; |
3821 | 2967 | 3124 | ||
3823 | 2968 | /* Get the side, then move thumb and pager accordingly. */ | 3125 | /* Get the side, then move thumb and bar accordingly. */ |
3824 | 2969 | retrieve_side (scrollbar); | 3126 | retrieve_side (scrollbar); |
3825 | 2970 | 3127 | ||
3826 | 2971 | priv->trough.x = allocation->x; | 3128 | priv->trough.x = allocation->x; |
3827 | @@ -2973,7 +3130,7 @@ | |||
3828 | 2973 | priv->trough.width = allocation->width; | 3130 | priv->trough.width = allocation->width; |
3829 | 2974 | priv->trough.height = allocation->height; | 3131 | priv->trough.height = allocation->height; |
3830 | 2975 | 3132 | ||
3832 | 2976 | priv->pager_all = *allocation; | 3133 | priv->bar_all = *allocation; |
3833 | 2977 | priv->thumb_all = *allocation; | 3134 | priv->thumb_all = *allocation; |
3834 | 2978 | 3135 | ||
3835 | 2979 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 3136 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
3836 | @@ -2986,16 +3143,16 @@ | |||
3837 | 2986 | } | 3143 | } |
3838 | 2987 | 3144 | ||
3839 | 2988 | if (priv->side == OS_SIDE_RIGHT) | 3145 | if (priv->side == OS_SIDE_RIGHT) |
3841 | 2989 | priv->pager_all.x = allocation->x - PAGER_SIZE; | 3146 | priv->bar_all.x = allocation->x - BAR_SIZE; |
3842 | 2990 | 3147 | ||
3844 | 2991 | priv->pager_all.width = PAGER_SIZE; | 3148 | priv->bar_all.width = BAR_SIZE; |
3845 | 2992 | 3149 | ||
3846 | 2993 | priv->thumb_all.width = THUMB_WIDTH; | 3150 | priv->thumb_all.width = THUMB_WIDTH; |
3847 | 2994 | 3151 | ||
3848 | 2995 | if (priv->side == OS_SIDE_RIGHT) | 3152 | if (priv->side == OS_SIDE_RIGHT) |
3850 | 2996 | priv->thumb_all.x = allocation->x - priv->pager_all.width; | 3153 | priv->thumb_all.x = allocation->x - priv->bar_all.width; |
3851 | 2997 | else | 3154 | else |
3853 | 2998 | priv->thumb_all.x = allocation->x + priv->pager_all.width - priv->thumb_all.width; | 3155 | priv->thumb_all.x = allocation->x + priv->bar_all.width - priv->thumb_all.width; |
3854 | 2999 | 3156 | ||
3855 | 3000 | allocation->width = 0; | 3157 | allocation->width = 0; |
3856 | 3001 | } | 3158 | } |
3857 | @@ -3009,32 +3166,32 @@ | |||
3858 | 3009 | } | 3166 | } |
3859 | 3010 | 3167 | ||
3860 | 3011 | if (priv->side == OS_SIDE_BOTTOM) | 3168 | if (priv->side == OS_SIDE_BOTTOM) |
3862 | 3012 | priv->pager_all.y = allocation->y - PAGER_SIZE; | 3169 | priv->bar_all.y = allocation->y - BAR_SIZE; |
3863 | 3013 | 3170 | ||
3865 | 3014 | priv->pager_all.height = PAGER_SIZE; | 3171 | priv->bar_all.height = BAR_SIZE; |
3866 | 3015 | 3172 | ||
3867 | 3016 | priv->thumb_all.height = THUMB_WIDTH; | 3173 | priv->thumb_all.height = THUMB_WIDTH; |
3868 | 3017 | 3174 | ||
3869 | 3018 | if (priv->side == OS_SIDE_BOTTOM) | 3175 | if (priv->side == OS_SIDE_BOTTOM) |
3871 | 3019 | priv->thumb_all.y = allocation->y - priv->pager_all.height; | 3176 | priv->thumb_all.y = allocation->y - priv->bar_all.height; |
3872 | 3020 | else | 3177 | else |
3874 | 3021 | priv->thumb_all.y = allocation->y + priv->pager_all.height - priv->thumb_all.height; | 3178 | priv->thumb_all.y = allocation->y + priv->bar_all.height - priv->thumb_all.height; |
3875 | 3022 | 3179 | ||
3876 | 3023 | allocation->height = 0; | 3180 | allocation->height = 0; |
3877 | 3024 | } | 3181 | } |
3878 | 3025 | 3182 | ||
3879 | 3026 | if (priv->adjustment != NULL) | 3183 | if (priv->adjustment != NULL) |
3880 | 3027 | { | 3184 | { |
3882 | 3028 | calc_layout_pager (scrollbar, gtk_adjustment_get_value (priv->adjustment)); | 3185 | calc_layout_bar (scrollbar, gtk_adjustment_get_value (priv->adjustment)); |
3883 | 3029 | calc_layout_slider (scrollbar, gtk_adjustment_get_value (priv->adjustment)); | 3186 | calc_layout_slider (scrollbar, gtk_adjustment_get_value (priv->adjustment)); |
3884 | 3030 | } | 3187 | } |
3885 | 3031 | 3188 | ||
3887 | 3032 | os_pager_size_allocate (priv->pager, priv->pager_all); | 3189 | os_bar_size_allocate (priv->bar, priv->bar_all); |
3888 | 3033 | 3190 | ||
3890 | 3034 | move_pager (scrollbar); | 3191 | move_bar (scrollbar); |
3891 | 3035 | 3192 | ||
3892 | 3036 | if (gtk_widget_get_realized (widget)) | 3193 | if (gtk_widget_get_realized (widget)) |
3894 | 3037 | store_toplevel_position (scrollbar); | 3194 | calc_thumb_window_position (scrollbar); |
3895 | 3038 | 3195 | ||
3896 | 3039 | gtk_widget_set_allocation (widget, allocation); | 3196 | gtk_widget_set_allocation (widget, allocation); |
3897 | 3040 | } | 3197 | } |
3898 | @@ -3047,15 +3204,10 @@ | |||
3899 | 3047 | 3204 | ||
3900 | 3048 | priv = scrollbar->priv; | 3205 | priv = scrollbar->priv; |
3901 | 3049 | 3206 | ||
3911 | 3050 | priv->proximity = FALSE; | 3207 | priv->filter.proximity = FALSE; |
3912 | 3051 | 3208 | remove_window_filter (scrollbar); | |
3913 | 3052 | if (gtk_widget_get_realized (GTK_WIDGET (scrollbar)) && priv->filter == TRUE) | 3209 | |
3914 | 3053 | { | 3210 | os_bar_set_active (priv->bar, FALSE, FALSE); |
3906 | 3054 | priv->filter = FALSE; | ||
3907 | 3055 | gdk_window_remove_filter (gtk_widget_get_window (GTK_WIDGET (scrollbar)), window_filter_func, scrollbar); | ||
3908 | 3056 | } | ||
3909 | 3057 | |||
3910 | 3058 | os_pager_set_active (priv->pager, FALSE, FALSE); | ||
3915 | 3059 | 3211 | ||
3916 | 3060 | gtk_widget_hide (priv->thumb); | 3212 | gtk_widget_hide (priv->thumb); |
3917 | 3061 | } | 3213 | } |
3918 | @@ -3068,16 +3220,11 @@ | |||
3919 | 3068 | 3220 | ||
3920 | 3069 | priv = scrollbar->priv; | 3221 | priv = scrollbar->priv; |
3921 | 3070 | 3222 | ||
3929 | 3071 | priv->proximity = TRUE; | 3223 | priv->filter.proximity = TRUE; |
3930 | 3072 | 3224 | add_window_filter (scrollbar); | |
3924 | 3073 | if (gtk_widget_get_realized (GTK_WIDGET (scrollbar)) && priv->filter == FALSE) | ||
3925 | 3074 | { | ||
3926 | 3075 | priv->filter = TRUE; | ||
3927 | 3076 | gdk_window_add_filter (gtk_widget_get_window (GTK_WIDGET (scrollbar)), window_filter_func, scrollbar); | ||
3928 | 3077 | } | ||
3931 | 3078 | 3225 | ||
3932 | 3079 | if (priv->active_window) | 3226 | if (priv->active_window) |
3934 | 3080 | os_pager_set_active (priv->pager, TRUE, FALSE); | 3227 | os_bar_set_active (priv->bar, TRUE, FALSE); |
3935 | 3081 | else | 3228 | else |
3936 | 3082 | { | 3229 | { |
3937 | 3083 | gint x, y; | 3230 | gint x, y; |
3938 | @@ -3087,7 +3234,7 @@ | |||
3939 | 3087 | /* When the window is unfocused, | 3234 | /* When the window is unfocused, |
3940 | 3088 | * check the position of the pointer | 3235 | * check the position of the pointer |
3941 | 3089 | * and set the state accordingly. */ | 3236 | * and set the state accordingly. */ |
3943 | 3090 | pager_set_state_from_pointer (scrollbar, x, y); | 3237 | bar_set_state_from_pointer (scrollbar, x, y); |
3944 | 3091 | } | 3238 | } |
3945 | 3092 | } | 3239 | } |
3946 | 3093 | 3240 | ||
3947 | @@ -3150,17 +3297,12 @@ | |||
3948 | 3150 | 3297 | ||
3949 | 3151 | GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->unmap (widget); | 3298 | GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->unmap (widget); |
3950 | 3152 | 3299 | ||
3954 | 3153 | priv->proximity = FALSE; | 3300 | os_bar_hide (priv->bar); |
3952 | 3154 | |||
3953 | 3155 | os_pager_hide (priv->pager); | ||
3955 | 3156 | 3301 | ||
3956 | 3157 | gtk_widget_hide (priv->thumb); | 3302 | gtk_widget_hide (priv->thumb); |
3957 | 3158 | 3303 | ||
3963 | 3159 | if (gtk_widget_get_realized (widget) && priv->filter == TRUE) | 3304 | priv->filter.proximity = FALSE; |
3964 | 3160 | { | 3305 | remove_window_filter (scrollbar); |
3960 | 3161 | priv->filter = FALSE; | ||
3961 | 3162 | gdk_window_remove_filter (gtk_widget_get_window (widget), window_filter_func, scrollbar); | ||
3962 | 3163 | } | ||
3965 | 3164 | } | 3306 | } |
3966 | 3165 | 3307 | ||
3967 | 3166 | static void | 3308 | static void |
3968 | @@ -3172,17 +3314,17 @@ | |||
3969 | 3172 | scrollbar = OS_SCROLLBAR (widget); | 3314 | scrollbar = OS_SCROLLBAR (widget); |
3970 | 3173 | priv = scrollbar->priv; | 3315 | priv = scrollbar->priv; |
3971 | 3174 | 3316 | ||
3973 | 3175 | os_pager_hide (priv->pager); | 3317 | os_bar_hide (priv->bar); |
3974 | 3176 | 3318 | ||
3975 | 3177 | gtk_widget_hide (priv->thumb); | 3319 | gtk_widget_hide (priv->thumb); |
3976 | 3178 | 3320 | ||
3978 | 3179 | priv->filter = FALSE; | 3321 | priv->filter.running = FALSE; |
3979 | 3180 | gdk_window_remove_filter (gtk_widget_get_window (widget), window_filter_func, scrollbar); | 3322 | gdk_window_remove_filter (gtk_widget_get_window (widget), window_filter_func, scrollbar); |
3980 | 3181 | 3323 | ||
3981 | 3182 | g_signal_handlers_disconnect_by_func (G_OBJECT (gtk_widget_get_toplevel (widget)), | 3324 | g_signal_handlers_disconnect_by_func (G_OBJECT (gtk_widget_get_toplevel (widget)), |
3982 | 3183 | G_CALLBACK (toplevel_configure_event_cb), scrollbar); | 3325 | G_CALLBACK (toplevel_configure_event_cb), scrollbar); |
3983 | 3184 | 3326 | ||
3985 | 3185 | os_pager_set_parent (priv->pager, NULL); | 3327 | os_bar_set_parent (priv->bar, NULL); |
3986 | 3186 | 3328 | ||
3987 | 3187 | GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->unrealize (widget); | 3329 | GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->unrealize (widget); |
3988 | 3188 | } | 3330 | } |
3989 | 3189 | 3331 | ||
3990 | === modified file 'os/os-thumb.c' | |||
3991 | --- os/os-thumb.c 2011-10-05 12:24:21 +0000 | |||
3992 | +++ os/os-thumb.c 2011-10-12 17:16:23 +0000 | |||
3993 | @@ -29,9 +29,6 @@ | |||
3994 | 29 | #include <math.h> | 29 | #include <math.h> |
3995 | 30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
3996 | 31 | 31 | ||
3997 | 32 | /* Rate of the fade-out. */ | ||
3998 | 33 | #define RATE_FADE_OUT 30 | ||
3999 | 34 | |||
4000 | 35 | /* Duration of the fade-out. */ | 32 | /* Duration of the fade-out. */ |
4001 | 36 | #define DURATION_FADE_OUT 2000 | 33 | #define DURATION_FADE_OUT 2000 |
4002 | 37 | 34 | ||
4003 | @@ -57,14 +54,12 @@ | |||
4004 | 57 | GtkOrientation orientation; | 54 | GtkOrientation orientation; |
4005 | 58 | GtkWidget *grabbed_widget; | 55 | GtkWidget *grabbed_widget; |
4006 | 59 | OsAnimation *animation; | 56 | OsAnimation *animation; |
4009 | 60 | OsEvent event; | 57 | OsCoordinate pointer; |
4010 | 61 | gboolean can_rgba; | 58 | OsCoordinate pointer_root; |
4011 | 59 | OsEventFlags event; | ||
4012 | 60 | gboolean rgba; | ||
4013 | 62 | gboolean detached; | 61 | gboolean detached; |
4019 | 63 | gboolean use_tolerance; | 62 | gboolean tolerance; |
4015 | 64 | gint pointer_x; | ||
4016 | 65 | gint pointer_y; | ||
4017 | 66 | gint pointer_x_root; | ||
4018 | 67 | gint pointer_y_root; | ||
4020 | 68 | guint32 source_id; | 63 | guint32 source_id; |
4021 | 69 | }; | 64 | }; |
4022 | 70 | 65 | ||
4023 | @@ -192,12 +187,17 @@ | |||
4024 | 192 | 187 | ||
4025 | 193 | priv->event = OS_EVENT_NONE; | 188 | priv->event = OS_EVENT_NONE; |
4026 | 194 | 189 | ||
4028 | 195 | priv->can_rgba = FALSE; | 190 | priv->pointer.x = 0; |
4029 | 191 | priv->pointer.y = 0; | ||
4030 | 192 | priv->pointer_root.x = 0; | ||
4031 | 193 | priv->pointer_root.y = 0; | ||
4032 | 194 | |||
4033 | 195 | priv->rgba = FALSE; | ||
4034 | 196 | priv->detached = FALSE; | 196 | priv->detached = FALSE; |
4036 | 197 | priv->use_tolerance = FALSE; | 197 | priv->tolerance = FALSE; |
4037 | 198 | 198 | ||
4038 | 199 | priv->source_id = 0; | 199 | priv->source_id = 0; |
4040 | 200 | priv->animation = os_animation_new (RATE_FADE_OUT, DURATION_FADE_OUT, | 200 | priv->animation = os_animation_new (RATE_ANIMATION, DURATION_FADE_OUT, |
4041 | 201 | fade_out_cb, NULL, thumb); | 201 | fade_out_cb, NULL, thumb); |
4042 | 202 | 202 | ||
4043 | 203 | gtk_window_set_skip_pager_hint (GTK_WINDOW (thumb), TRUE); | 203 | gtk_window_set_skip_pager_hint (GTK_WINDOW (thumb), TRUE); |
4044 | @@ -237,19 +237,20 @@ | |||
4045 | 237 | 237 | ||
4046 | 238 | if (event->type == GDK_BUTTON_PRESS) | 238 | if (event->type == GDK_BUTTON_PRESS) |
4047 | 239 | { | 239 | { |
4049 | 240 | if (event->button == 1) | 240 | if (event->button == 1 || |
4050 | 241 | event->button == 2) | ||
4051 | 241 | { | 242 | { |
4052 | 242 | gtk_grab_add (widget); | 243 | gtk_grab_add (widget); |
4053 | 243 | 244 | ||
4058 | 244 | priv->pointer_x = event->x; | 245 | priv->pointer.x = event->x; |
4059 | 245 | priv->pointer_y = event->y; | 246 | priv->pointer.y = event->y; |
4060 | 246 | priv->pointer_x_root = event->x_root; | 247 | priv->pointer_root.x = event->x_root; |
4061 | 247 | priv->pointer_y_root = event->y_root; | 248 | priv->pointer_root.y = event->y_root; |
4062 | 248 | 249 | ||
4063 | 249 | priv->event |= OS_EVENT_BUTTON_PRESS; | 250 | priv->event |= OS_EVENT_BUTTON_PRESS; |
4064 | 250 | priv->event &= ~(OS_EVENT_MOTION_NOTIFY); | 251 | priv->event &= ~(OS_EVENT_MOTION_NOTIFY); |
4065 | 251 | 252 | ||
4067 | 252 | priv->use_tolerance = TRUE; | 253 | priv->tolerance = TRUE; |
4068 | 253 | 254 | ||
4069 | 254 | gtk_widget_queue_draw (widget); | 255 | gtk_widget_queue_draw (widget); |
4070 | 255 | } | 256 | } |
4071 | @@ -273,7 +274,8 @@ | |||
4072 | 273 | 274 | ||
4073 | 274 | if (event->type == GDK_BUTTON_RELEASE) | 275 | if (event->type == GDK_BUTTON_RELEASE) |
4074 | 275 | { | 276 | { |
4076 | 276 | if (event->button == 1) | 277 | if (event->button == 1 || |
4077 | 278 | event->button == 2) | ||
4078 | 277 | { | 279 | { |
4079 | 278 | gtk_grab_remove (widget); | 280 | gtk_grab_remove (widget); |
4080 | 279 | 281 | ||
4081 | @@ -295,7 +297,7 @@ | |||
4082 | 295 | thumb = OS_THUMB (widget); | 297 | thumb = OS_THUMB (widget); |
4083 | 296 | priv = thumb->priv; | 298 | priv = thumb->priv; |
4084 | 297 | 299 | ||
4086 | 298 | priv->can_rgba = FALSE; | 300 | priv->rgba = FALSE; |
4087 | 299 | 301 | ||
4088 | 300 | if (gdk_screen_is_composited (gtk_widget_get_screen (widget))) | 302 | if (gdk_screen_is_composited (gtk_widget_get_screen (widget))) |
4089 | 301 | { | 303 | { |
4090 | @@ -313,7 +315,7 @@ | |||
4091 | 313 | if (gdk_visual_get_depth (visual) == 32 && (red_mask == 0xff0000 && | 315 | if (gdk_visual_get_depth (visual) == 32 && (red_mask == 0xff0000 && |
4092 | 314 | green_mask == 0x00ff00 && | 316 | green_mask == 0x00ff00 && |
4093 | 315 | blue_mask == 0x0000ff)) | 317 | blue_mask == 0x0000ff)) |
4095 | 316 | priv->can_rgba = TRUE; | 318 | priv->rgba = TRUE; |
4096 | 317 | } | 319 | } |
4097 | 318 | 320 | ||
4098 | 319 | gtk_widget_queue_draw (widget); | 321 | gtk_widget_queue_draw (widget); |
4099 | @@ -631,7 +633,7 @@ | |||
4100 | 631 | thumb = OS_THUMB (widget); | 633 | thumb = OS_THUMB (widget); |
4101 | 632 | priv = thumb->priv; | 634 | priv = thumb->priv; |
4102 | 633 | 635 | ||
4104 | 634 | radius = priv->can_rgba ? THUMB_RADIUS : 0; | 636 | radius = priv->rgba ? THUMB_RADIUS : 0; |
4105 | 635 | 637 | ||
4106 | 636 | #ifdef USE_GTK3 | 638 | #ifdef USE_GTK3 |
4107 | 637 | width = gtk_widget_get_allocated_width (widget); | 639 | width = gtk_widget_get_allocated_width (widget); |
4108 | @@ -690,8 +692,8 @@ | |||
4109 | 690 | if ((priv->event & OS_EVENT_BUTTON_PRESS) && | 692 | if ((priv->event & OS_EVENT_BUTTON_PRESS) && |
4110 | 691 | !(priv->event & OS_EVENT_MOTION_NOTIFY)) | 693 | !(priv->event & OS_EVENT_MOTION_NOTIFY)) |
4111 | 692 | { | 694 | { |
4114 | 693 | if ((priv->orientation == GTK_ORIENTATION_VERTICAL && (priv->pointer_y < height / 2)) || | 695 | if ((priv->orientation == GTK_ORIENTATION_VERTICAL && (priv->pointer.y < height / 2)) || |
4115 | 694 | (priv->orientation == GTK_ORIENTATION_HORIZONTAL && (priv->pointer_x < width / 2))) | 696 | (priv->orientation == GTK_ORIENTATION_HORIZONTAL && (priv->pointer.x < width / 2))) |
4116 | 695 | { | 697 | { |
4117 | 696 | pattern_add_gdk_rgba_stop (pat, 0.0, &bg_arrow_down, 0.6); | 698 | pattern_add_gdk_rgba_stop (pat, 0.0, &bg_arrow_down, 0.6); |
4118 | 697 | pattern_add_gdk_rgba_stop (pat, 0.49, &bg_arrow_down, 0.1); | 699 | pattern_add_gdk_rgba_stop (pat, 0.49, &bg_arrow_down, 0.1); |
4119 | @@ -850,7 +852,7 @@ | |||
4120 | 850 | os_animation_stop (priv->animation, NULL); | 852 | os_animation_stop (priv->animation, NULL); |
4121 | 851 | } | 853 | } |
4122 | 852 | 854 | ||
4124 | 853 | priv->use_tolerance = FALSE; | 855 | priv->tolerance = FALSE; |
4125 | 854 | 856 | ||
4126 | 855 | return FALSE; | 857 | return FALSE; |
4127 | 856 | } | 858 | } |
4128 | @@ -906,11 +908,11 @@ | |||
4129 | 906 | * see code few lines below. */ | 908 | * see code few lines below. */ |
4130 | 907 | if (!(priv->event & OS_EVENT_MOTION_NOTIFY)) | 909 | if (!(priv->event & OS_EVENT_MOTION_NOTIFY)) |
4131 | 908 | { | 910 | { |
4135 | 909 | if (!priv->use_tolerance || | 911 | if (!priv->tolerance || |
4136 | 910 | (abs (priv->pointer_x - event->x) > TOLERANCE_FADE || | 912 | (abs (priv->pointer.x - event->x) > TOLERANCE_FADE || |
4137 | 911 | abs (priv->pointer_y - event->y) > TOLERANCE_FADE)) | 913 | abs (priv->pointer.y - event->y) > TOLERANCE_FADE)) |
4138 | 912 | { | 914 | { |
4140 | 913 | priv->use_tolerance = FALSE; | 915 | priv->tolerance = FALSE; |
4141 | 914 | priv->source_id = g_timeout_add (TIMEOUT_FADE_OUT, | 916 | priv->source_id = g_timeout_add (TIMEOUT_FADE_OUT, |
4142 | 915 | timeout_fade_out_cb, | 917 | timeout_fade_out_cb, |
4143 | 916 | thumb); | 918 | thumb); |
4144 | @@ -920,8 +922,8 @@ | |||
4145 | 920 | if (priv->event & OS_EVENT_BUTTON_PRESS && | 922 | if (priv->event & OS_EVENT_BUTTON_PRESS && |
4146 | 921 | !(priv->event & OS_EVENT_MOTION_NOTIFY)) | 923 | !(priv->event & OS_EVENT_MOTION_NOTIFY)) |
4147 | 922 | { | 924 | { |
4150 | 923 | if (abs (priv->pointer_x_root - event->x_root) <= TOLERANCE_MOTION && | 925 | if (abs (priv->pointer_root.x - event->x_root) <= TOLERANCE_MOTION && |
4151 | 924 | abs (priv->pointer_y_root - event->y_root) <= TOLERANCE_MOTION) | 926 | abs (priv->pointer_root.y - event->y_root) <= TOLERANCE_MOTION) |
4152 | 925 | return FALSE; | 927 | return FALSE; |
4153 | 926 | 928 | ||
4154 | 927 | priv->event |= OS_EVENT_MOTION_NOTIFY; | 929 | priv->event |= OS_EVENT_MOTION_NOTIFY; |
4155 | @@ -977,6 +979,13 @@ | |||
4156 | 977 | /* If started, stop the fade-out. */ | 979 | /* If started, stop the fade-out. */ |
4157 | 978 | os_animation_stop (priv->animation, fade_out_stop_cb); | 980 | os_animation_stop (priv->animation, fade_out_stop_cb); |
4158 | 979 | 981 | ||
4159 | 982 | if (priv->event & OS_EVENT_MOTION_NOTIFY) | ||
4160 | 983 | { | ||
4161 | 984 | priv->event &= ~(OS_EVENT_MOTION_NOTIFY); | ||
4162 | 985 | |||
4163 | 986 | gtk_widget_queue_draw (widget); | ||
4164 | 987 | } | ||
4165 | 988 | |||
4166 | 980 | return FALSE; | 989 | return FALSE; |
4167 | 981 | } | 990 | } |
4168 | 982 | 991 | ||
4169 | @@ -991,7 +1000,7 @@ | |||
4170 | 991 | 1000 | ||
4171 | 992 | priv->event = OS_EVENT_NONE; | 1001 | priv->event = OS_EVENT_NONE; |
4172 | 993 | 1002 | ||
4174 | 994 | priv->use_tolerance = FALSE; | 1003 | priv->tolerance = FALSE; |
4175 | 995 | 1004 | ||
4176 | 996 | if (priv->grabbed_widget != NULL && gtk_widget_get_mapped (priv->grabbed_widget)) | 1005 | if (priv->grabbed_widget != NULL && gtk_widget_get_mapped (priv->grabbed_widget)) |
4177 | 997 | gtk_grab_add (priv->grabbed_widget); | 1006 | gtk_grab_add (priv->grabbed_widget); |
I do :)