Merge lp:~cimi/overlay-scrollbar/proximity-separate-function into lp:overlay-scrollbar
- proximity-separate-function
- Merge into trunk
Proposed by
Andrea Cimitan
Status: | Superseded |
---|---|
Proposed branch: | lp:~cimi/overlay-scrollbar/proximity-separate-function |
Merge into: | lp:overlay-scrollbar |
Diff against target: |
969 lines (+176/-208) 4 files modified
os/os-pager.c (+1/-1) os/os-private.h (+4/-4) os/os-scrollbar.c (+169/-195) os/os-thumb.c (+2/-8) |
To merge this branch: | bzr merge lp:~cimi/overlay-scrollbar/proximity-separate-function |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ayatana Scrollbar Team | Pending | ||
Review via email:
|
This proposal has been superseded by a proposal from 2011-06-15.
Commit message
Description of the change
fork of lp:~cimi/ayatana-scrollbar/various-namings-and-refactoring, this branch contains a separate proximity function that can be easily extended to support scrollbars on other sides of the scrolled window
To post a comment you must log in.
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'os/os-pager.c' |
2 | --- os/os-pager.c 2011-06-12 23:21:09 +0000 |
3 | +++ os/os-pager.c 2011-06-15 13:28:34 +0000 |
4 | @@ -315,7 +315,7 @@ |
5 | * |
6 | * Returns: the new #OsPager instance. |
7 | */ |
8 | -GObject* |
9 | +OsPager* |
10 | os_pager_new (void) |
11 | { |
12 | return g_object_new (OS_TYPE_PAGER, NULL); |
13 | |
14 | === modified file 'os/os-private.h' |
15 | --- os/os-private.h 2011-06-10 10:32:53 +0000 |
16 | +++ os/os-private.h 2011-06-15 13:28:34 +0000 |
17 | @@ -30,9 +30,9 @@ |
18 | #pragma GCC visibility push(hidden) |
19 | #endif /* __GNUC__ */ |
20 | |
21 | -/* Default size of the thumb in pixels. */ |
22 | -#define DEFAULT_THUMB_WIDTH 17 |
23 | -#define DEFAULT_THUMB_HEIGHT 69 |
24 | +/* Size of the thumb in pixels. */ |
25 | +#define THUMB_WIDTH 17 |
26 | +#define THUMB_HEIGHT 69 |
27 | |
28 | G_BEGIN_DECLS |
29 | |
30 | @@ -208,7 +208,7 @@ |
31 | |
32 | GType os_pager_get_type (void) G_GNUC_CONST; |
33 | |
34 | -GObject* os_pager_new (void); |
35 | +OsPager* os_pager_new (void); |
36 | |
37 | void os_pager_hide (OsPager *overlay); |
38 | |
39 | |
40 | === modified file 'os/os-scrollbar.c' |
41 | --- os/os-scrollbar.c 2011-06-14 17:20:10 +0000 |
42 | +++ os/os-scrollbar.c 2011-06-15 13:28:34 +0000 |
43 | @@ -32,14 +32,14 @@ |
44 | #include <X11/extensions/XInput2.h> |
45 | #include "math.h" |
46 | |
47 | -/* Default size of the pager in pixels. */ |
48 | -#define DEFAULT_PAGER_WIDTH 3 |
49 | +/* Size of the pager in pixels. */ |
50 | +#define PAGER_SIZE 3 |
51 | |
52 | -/* Default thumb allocation shift in pixels. */ |
53 | +/* Thumb allocation shift in pixels. */ |
54 | #define THUMB_ALLOCATION_SHIFT -3 |
55 | |
56 | -/* Width of the proximity effect in pixels. */ |
57 | -#define PROXIMITY_WIDTH 30 |
58 | +/* Size of the proximity effect in pixels. */ |
59 | +#define PROXIMITY_SIZE 30 |
60 | |
61 | /* Timeout assumed for PropertyNotify _NET_ACTIVE_WINDOW event. */ |
62 | #define TIMEOUT_PRESENT_WINDOW 400 |
63 | @@ -50,18 +50,26 @@ |
64 | /* Timeout before hiding in ms, after leaving the toplevel. */ |
65 | #define TIMEOUT_TOPLEVEL_HIDE 200 |
66 | |
67 | +typedef enum |
68 | +{ |
69 | + OS_SIDE_TOP, |
70 | + OS_SIDE_BOTTOM, |
71 | + OS_SIDE_LEFT, |
72 | + OS_SIDE_RIGHT |
73 | +} OsSide; |
74 | + |
75 | struct _OsScrollbarPrivate |
76 | { |
77 | GdkRectangle trough; |
78 | GdkRectangle overlay; |
79 | GdkRectangle slider; |
80 | - GtkAllocation overlay_all; |
81 | + GtkAllocation pager_all; |
82 | GtkAllocation thumb_all; |
83 | - GObject *pager; |
84 | GtkWidget *thumb; |
85 | GtkAdjustment *adjustment; |
86 | GtkOrientation orientation; |
87 | GtkWindowGroup *window_group; |
88 | + OsPager *pager; |
89 | gboolean button_press_event; |
90 | gboolean enter_notify_event; |
91 | gboolean motion_notify_event; |
92 | @@ -137,74 +145,56 @@ |
93 | |
94 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
95 | { |
96 | - gint y, bottom, top, height; |
97 | - |
98 | - top = priv->trough.y; |
99 | - bottom = priv->trough.y + priv->trough.height; |
100 | - |
101 | - /* overlay height is the fraction (page_size / |
102 | - * total_adjustment_range) times the trough height in pixels |
103 | - */ |
104 | + gint y, trough_length, height; |
105 | + |
106 | + trough_length = priv->trough.height; |
107 | |
108 | if (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment) != 0) |
109 | - height = ((bottom - top) * (gtk_adjustment_get_page_size (priv->adjustment) / |
110 | - (gtk_adjustment_get_upper (priv->adjustment) - |
111 | - gtk_adjustment_get_lower (priv->adjustment)))); |
112 | + height = (trough_length * (gtk_adjustment_get_page_size (priv->adjustment) / |
113 | + (gtk_adjustment_get_upper (priv->adjustment) - |
114 | + gtk_adjustment_get_lower (priv->adjustment)))); |
115 | else |
116 | height = gtk_range_get_min_slider_size (GTK_RANGE (scrollbar)); |
117 | |
118 | height = MAX (height, gtk_range_get_min_slider_size (GTK_RANGE (scrollbar))); |
119 | |
120 | - height = MIN (height, priv->trough.height); |
121 | - |
122 | - y = top; |
123 | - |
124 | if (gtk_adjustment_get_upper (priv->adjustment) - |
125 | gtk_adjustment_get_lower (priv->adjustment) - |
126 | gtk_adjustment_get_page_size (priv->adjustment) != 0) |
127 | - y += (bottom - top - height) * ((adjustment_value - gtk_adjustment_get_lower (priv->adjustment)) / |
128 | + y = (trough_length - height) * ((adjustment_value - gtk_adjustment_get_lower (priv->adjustment)) / |
129 | (gtk_adjustment_get_upper (priv->adjustment) - |
130 | gtk_adjustment_get_lower (priv->adjustment) - |
131 | gtk_adjustment_get_page_size (priv->adjustment))); |
132 | |
133 | - y = CLAMP (y, top, bottom); |
134 | + y = CLAMP (y, 0, trough_length); |
135 | |
136 | priv->overlay.y = y; |
137 | priv->overlay.height = height; |
138 | } |
139 | else |
140 | { |
141 | - gint x, left, right, width; |
142 | - |
143 | - left = priv->trough.x; |
144 | - right = priv->trough.x + priv->trough.width; |
145 | - |
146 | - /* overlay width is the fraction (page_size / |
147 | - * total_adjustment_range) times the trough width in pixels |
148 | - */ |
149 | + gint x, trough_length, width; |
150 | + |
151 | + trough_length = priv->trough.width; |
152 | |
153 | if (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment) != 0) |
154 | - width = ((right - left) * (gtk_adjustment_get_page_size (priv->adjustment) / |
155 | - (gtk_adjustment_get_upper (priv->adjustment) - |
156 | - gtk_adjustment_get_lower (priv->adjustment)))); |
157 | + width = (trough_length * (gtk_adjustment_get_page_size (priv->adjustment) / |
158 | + (gtk_adjustment_get_upper (priv->adjustment) - |
159 | + gtk_adjustment_get_lower (priv->adjustment)))); |
160 | else |
161 | width = gtk_range_get_min_slider_size (GTK_RANGE (scrollbar)); |
162 | |
163 | width = MAX (width, gtk_range_get_min_slider_size (GTK_RANGE (scrollbar))); |
164 | |
165 | - width = MIN (width, priv->trough.width); |
166 | - |
167 | - x = left; |
168 | - |
169 | if (gtk_adjustment_get_upper (priv->adjustment) - |
170 | gtk_adjustment_get_lower (priv->adjustment) - |
171 | gtk_adjustment_get_page_size (priv->adjustment) != 0) |
172 | - x += (right - left - width) * ((adjustment_value - gtk_adjustment_get_lower (priv->adjustment)) / |
173 | + x = (trough_length - width) * ((adjustment_value - gtk_adjustment_get_lower (priv->adjustment)) / |
174 | (gtk_adjustment_get_upper (priv->adjustment) - |
175 | gtk_adjustment_get_lower (priv->adjustment) - |
176 | gtk_adjustment_get_page_size (priv->adjustment))); |
177 | |
178 | - x = CLAMP (x, left, right); |
179 | + x = CLAMP (x, 0, trough_length); |
180 | |
181 | priv->overlay.x = x; |
182 | priv->overlay.width = width; |
183 | @@ -222,52 +212,40 @@ |
184 | |
185 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
186 | { |
187 | - gint y, bottom, top, height; |
188 | - |
189 | - top = priv->trough.y; |
190 | - bottom = priv->trough.y + priv->trough.height; |
191 | - |
192 | + gint y, trough_length, height; |
193 | + |
194 | + trough_length = priv->trough.height; |
195 | height = priv->slider.height; |
196 | |
197 | - height = MIN (height, priv->trough.height); |
198 | - |
199 | - y = top; |
200 | - |
201 | if (gtk_adjustment_get_upper (priv->adjustment) - |
202 | gtk_adjustment_get_lower (priv->adjustment) - |
203 | gtk_adjustment_get_page_size (priv->adjustment) != 0) |
204 | - y += (bottom - top - height) * ((adjustment_value - gtk_adjustment_get_lower (priv->adjustment)) / |
205 | + y = (trough_length - height) * ((adjustment_value - gtk_adjustment_get_lower (priv->adjustment)) / |
206 | (gtk_adjustment_get_upper (priv->adjustment) - |
207 | gtk_adjustment_get_lower (priv->adjustment) - |
208 | gtk_adjustment_get_page_size (priv->adjustment))); |
209 | |
210 | - y = CLAMP (y, top, bottom); |
211 | + y = CLAMP (y, 0, trough_length); |
212 | |
213 | priv->slider.y = y; |
214 | priv->slider.height = height; |
215 | } |
216 | else |
217 | { |
218 | - gint x, left, right, width; |
219 | - |
220 | - left = priv->trough.x; |
221 | - right = priv->trough.x + priv->trough.width; |
222 | - |
223 | + gint x, trough_length, width; |
224 | + |
225 | + trough_length = priv->trough.width; |
226 | width = priv->slider.width; |
227 | |
228 | - width = MIN (width, priv->trough.width); |
229 | - |
230 | - x = left; |
231 | - |
232 | if (gtk_adjustment_get_upper (priv->adjustment) - |
233 | gtk_adjustment_get_lower (priv->adjustment) - |
234 | gtk_adjustment_get_page_size (priv->adjustment) != 0) |
235 | - x += (right - left - width) * ((adjustment_value - gtk_adjustment_get_lower (priv->adjustment)) / |
236 | + x = (trough_length - width) * ((adjustment_value - gtk_adjustment_get_lower (priv->adjustment)) / |
237 | (gtk_adjustment_get_upper (priv->adjustment) - |
238 | gtk_adjustment_get_lower (priv->adjustment) - |
239 | gtk_adjustment_get_page_size (priv->adjustment))); |
240 | |
241 | - x = CLAMP (x, left, right); |
242 | + x = CLAMP (x, 0, trough_length); |
243 | |
244 | priv->slider.x = x; |
245 | priv->slider.width = width; |
246 | @@ -333,7 +311,7 @@ |
247 | priv = scrollbar->priv; |
248 | |
249 | if (priv->pager != NULL && priv->can_deactivate_pager) |
250 | - os_pager_set_active (OS_PAGER (priv->pager), FALSE, TRUE); |
251 | + os_pager_set_active (priv->pager, FALSE, TRUE); |
252 | } |
253 | |
254 | /* timeout before deactivating the pager */ |
255 | @@ -365,7 +343,7 @@ |
256 | if (priv->can_hide) |
257 | { |
258 | priv->value_changed_event = FALSE; |
259 | - gtk_widget_hide (GTK_WIDGET (priv->thumb)); |
260 | + gtk_widget_hide (priv->thumb); |
261 | } |
262 | } |
263 | |
264 | @@ -398,7 +376,7 @@ |
265 | { |
266 | mask.x = 0; |
267 | mask.y = priv->overlay.y; |
268 | - mask.width = DEFAULT_PAGER_WIDTH; |
269 | + mask.width = priv->pager_all.width; |
270 | mask.height = priv->overlay.height; |
271 | } |
272 | else |
273 | @@ -406,10 +384,10 @@ |
274 | mask.x = priv->overlay.x; |
275 | mask.y = 0; |
276 | mask.width = priv->overlay.width; |
277 | - mask.height = DEFAULT_PAGER_WIDTH; |
278 | + mask.height = priv->pager_all.height; |
279 | } |
280 | |
281 | - os_pager_move_resize (OS_PAGER (priv->pager), mask); |
282 | + os_pager_move_resize (priv->pager, mask); |
283 | } |
284 | |
285 | /* sanitize x coordinate of thumb window */ |
286 | @@ -463,7 +441,7 @@ |
287 | |
288 | if (priv->orientation == GTK_ORIENTATION_VERTICAL && |
289 | (n_monitor != gdk_screen_get_monitor_at_point (screen, x - 1 + priv->slider.width, y) || |
290 | - (x - 1 + priv->slider.width) >= screen_width)) |
291 | + x - 1 + priv->slider.width >= screen_width)) |
292 | { |
293 | priv->internal = TRUE; |
294 | return MAX (x - priv->slider.width, screen_width - priv->slider.width); |
295 | @@ -526,7 +504,7 @@ |
296 | |
297 | if (priv->orientation == GTK_ORIENTATION_HORIZONTAL && |
298 | (n_monitor != gdk_screen_get_monitor_at_point (screen, x, y - 1 + priv->slider.height) || |
299 | - (y - 1 + priv->slider.height) >= screen_height)) |
300 | + y - 1 + priv->slider.height >= screen_height)) |
301 | { |
302 | priv->internal = TRUE; |
303 | return MAX (y - priv->slider.height, screen_height - priv->slider.height); |
304 | @@ -707,19 +685,19 @@ |
305 | * hidden a pager that is meant to be hidden/shown. |
306 | * I don't want to see pagers reappearing because |
307 | * of a change in the adjustment of an invisible pager or viceversa. */ |
308 | - if ((gtk_adjustment_get_upper (adjustment) - gtk_adjustment_get_lower (adjustment)) > |
309 | + if (gtk_adjustment_get_upper (adjustment) - gtk_adjustment_get_lower (adjustment) > |
310 | gtk_adjustment_get_page_size (adjustment)) |
311 | { |
312 | priv->fullsize = FALSE; |
313 | if (priv->proximity != FALSE) |
314 | - os_pager_show (OS_PAGER (priv->pager)); |
315 | + os_pager_show (priv->pager); |
316 | } |
317 | else |
318 | { |
319 | priv->fullsize = TRUE; |
320 | if (priv->proximity != FALSE) |
321 | { |
322 | - os_pager_hide (OS_PAGER (priv->pager)); |
323 | + os_pager_hide (priv->pager); |
324 | |
325 | gtk_widget_hide (priv->thumb); |
326 | } |
327 | @@ -729,7 +707,7 @@ |
328 | calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment)); |
329 | |
330 | if (!priv->motion_notify_event && !priv->enter_notify_event) |
331 | - gtk_widget_hide (GTK_WIDGET (priv->thumb)); |
332 | + gtk_widget_hide (priv->thumb); |
333 | |
334 | move_pager (scrollbar); |
335 | } |
336 | @@ -748,20 +726,20 @@ |
337 | calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment)); |
338 | |
339 | if (!priv->motion_notify_event && !priv->enter_notify_event) |
340 | - gtk_widget_hide (GTK_WIDGET (priv->thumb)); |
341 | + gtk_widget_hide (priv->thumb); |
342 | |
343 | - if (gtk_widget_get_mapped (GTK_WIDGET (priv->thumb))) |
344 | + if (gtk_widget_get_mapped (priv->thumb)) |
345 | { |
346 | /* if we're dragging the thumb, it can't be detached. */ |
347 | if (priv->motion_notify_event) |
348 | { |
349 | - os_pager_set_detached (OS_PAGER (priv->pager), FALSE); |
350 | + os_pager_set_detached (priv->pager, FALSE); |
351 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); |
352 | } |
353 | else |
354 | { |
355 | gint x_pos, y_pos; |
356 | - gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (priv->thumb)), &x_pos, &y_pos); |
357 | + gdk_window_get_origin (gtk_widget_get_window (priv->thumb), &x_pos, &y_pos); |
358 | |
359 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
360 | { |
361 | @@ -771,11 +749,11 @@ |
362 | |
363 | mask.x = 0; |
364 | mask.y = y_pos + priv->slider.height / 2 - priv->win_y; |
365 | - mask.width = DEFAULT_PAGER_WIDTH; |
366 | + mask.width = priv->pager_all.width; |
367 | mask.height = priv->overlay.y - mask.y; |
368 | |
369 | - os_pager_connect (OS_PAGER (priv->pager), mask); |
370 | - os_pager_set_detached (OS_PAGER (priv->pager), TRUE); |
371 | + os_pager_connect (priv->pager, mask); |
372 | + os_pager_set_detached (priv->pager, TRUE); |
373 | |
374 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); |
375 | } |
376 | @@ -785,17 +763,17 @@ |
377 | |
378 | mask.x = 0; |
379 | mask.y = priv->overlay.y + priv->overlay.height; |
380 | - mask.width = DEFAULT_PAGER_WIDTH; |
381 | + mask.width = priv->pager_all.width; |
382 | mask.height = y_pos + priv->slider.height / 2 - priv->win_y - mask.y; |
383 | |
384 | - os_pager_connect (OS_PAGER (priv->pager), mask); |
385 | - os_pager_set_detached (OS_PAGER (priv->pager), TRUE); |
386 | + os_pager_connect (priv->pager, mask); |
387 | + os_pager_set_detached (priv->pager, TRUE); |
388 | |
389 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); |
390 | } |
391 | else |
392 | { |
393 | - os_pager_set_detached (OS_PAGER (priv->pager), FALSE); |
394 | + os_pager_set_detached (priv->pager, FALSE); |
395 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); |
396 | } |
397 | } |
398 | @@ -808,10 +786,10 @@ |
399 | mask.x = x_pos + priv->slider.width / 2 - priv->win_x; |
400 | mask.y = 0; |
401 | mask.width = priv->overlay.x - mask.x; |
402 | - mask.height = DEFAULT_PAGER_WIDTH; |
403 | + mask.height = priv->pager_all.height; |
404 | |
405 | - os_pager_connect (OS_PAGER (priv->pager), mask); |
406 | - os_pager_set_detached (OS_PAGER (priv->pager), TRUE); |
407 | + os_pager_connect (priv->pager, mask); |
408 | + os_pager_set_detached (priv->pager, TRUE); |
409 | |
410 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); |
411 | } |
412 | @@ -822,14 +800,14 @@ |
413 | mask.x = priv->overlay.y + priv->overlay.height; |
414 | mask.y = 0; |
415 | mask.width = x_pos + priv->slider.width / 2 - priv->win_x - mask.x; |
416 | - mask.height = DEFAULT_PAGER_WIDTH; |
417 | + mask.height = priv->pager_all.height; |
418 | |
419 | - os_pager_connect (OS_PAGER (priv->pager), mask); |
420 | - os_pager_set_detached (OS_PAGER (priv->pager), TRUE); |
421 | + os_pager_connect (priv->pager, mask); |
422 | + os_pager_set_detached (priv->pager, TRUE); |
423 | } |
424 | else |
425 | { |
426 | - os_pager_set_detached (OS_PAGER (priv->pager), FALSE); |
427 | + os_pager_set_detached (priv->pager, FALSE); |
428 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); |
429 | } |
430 | } |
431 | @@ -860,12 +838,12 @@ |
432 | (y > allocation.y && y < allocation.y + allocation.height)) |
433 | { |
434 | priv->can_deactivate_pager = FALSE; |
435 | - os_pager_set_active (OS_PAGER (priv->pager), TRUE, TRUE); |
436 | + os_pager_set_active (priv->pager, TRUE, TRUE); |
437 | } |
438 | else |
439 | { |
440 | priv->can_deactivate_pager = TRUE; |
441 | - os_pager_set_active (OS_PAGER (priv->pager), FALSE, TRUE); |
442 | + os_pager_set_active (priv->pager, FALSE, TRUE); |
443 | } |
444 | } |
445 | |
446 | @@ -899,7 +877,7 @@ |
447 | priv->active_window = TRUE; |
448 | |
449 | priv->can_deactivate_pager = FALSE; |
450 | - os_pager_set_active (OS_PAGER (priv->pager), TRUE, TRUE); |
451 | + os_pager_set_active (priv->pager, TRUE, TRUE); |
452 | } |
453 | else if (priv->active_window) |
454 | { |
455 | @@ -938,7 +916,7 @@ |
456 | { |
457 | /* if the pointer is outside of the window, set it inactive. */ |
458 | priv->can_deactivate_pager = TRUE; |
459 | - os_pager_set_active (OS_PAGER (priv->pager), FALSE, TRUE); |
460 | + os_pager_set_active (priv->pager, FALSE, TRUE); |
461 | } |
462 | |
463 | if ((current_time > end_time) && priv->thumb != NULL) |
464 | @@ -1196,7 +1174,7 @@ |
465 | |
466 | /* immediately set the pager to be active. */ |
467 | priv->can_deactivate_pager = FALSE; |
468 | - os_pager_set_active (OS_PAGER (priv->pager), TRUE, FALSE); |
469 | + os_pager_set_active (priv->pager, TRUE, FALSE); |
470 | |
471 | xid = GDK_WINDOW_XID (gtk_widget_get_window (widget)); |
472 | xid_parent = GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (scrollbar))); |
473 | @@ -1267,7 +1245,6 @@ |
474 | gdouble frac; |
475 | gdouble value; |
476 | gint trough_length; |
477 | - gint trough_start; |
478 | gint slider_length; |
479 | |
480 | priv = scrollbar->priv; |
481 | @@ -1275,21 +1252,18 @@ |
482 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
483 | { |
484 | trough_length = priv->trough.height; |
485 | - trough_start = priv->trough.y; |
486 | slider_length = MAX (priv->slider.height, priv->overlay.height); |
487 | } |
488 | else |
489 | { |
490 | trough_length = priv->trough.width; |
491 | - trough_start = priv->trough.y; |
492 | slider_length = MAX (priv->slider.width, priv->overlay.width); |
493 | } |
494 | |
495 | if (trough_length == slider_length) |
496 | frac = 1.0; |
497 | else |
498 | - frac = (MAX (0, coord - trough_start) / |
499 | - (gdouble) (trough_length - slider_length)); |
500 | + frac = (MAX (0, coord) / (gdouble) (trough_length - slider_length)); |
501 | |
502 | value = gtk_adjustment_get_lower (priv->adjustment) + frac * (gtk_adjustment_get_upper (priv->adjustment) - |
503 | gtk_adjustment_get_lower (priv->adjustment) - |
504 | @@ -1357,7 +1331,7 @@ |
505 | } |
506 | |
507 | /* FIXME(Cimi) seems useless. */ |
508 | - capture_movement (scrollbar, event->x_root, event->y_root); |
509 | +// capture_movement (scrollbar, event->x_root, event->y_root); |
510 | priv->value_changed_event = FALSE; |
511 | } |
512 | |
513 | @@ -1379,9 +1353,9 @@ |
514 | priv->slide_initial_slider_position = 0; |
515 | priv->slide_initial_coordinate = MAX (event->y_root, priv->win_y + priv->pointer_y); |
516 | } |
517 | - else if (priv->overlay.y + priv->overlay.height >= priv->trough.y + priv->trough.height) |
518 | + else if (priv->overlay.y + priv->overlay.height >= priv->trough.height) |
519 | { |
520 | - priv->slide_initial_slider_position = priv->trough.y + priv->trough.height - priv->overlay.height; |
521 | + priv->slide_initial_slider_position = priv->trough.height - priv->overlay.height; |
522 | priv->slide_initial_coordinate = MAX (event->y_root, priv->win_y + priv->pointer_y); |
523 | } |
524 | } |
525 | @@ -1405,9 +1379,9 @@ |
526 | priv->slide_initial_slider_position = 0; |
527 | priv->slide_initial_coordinate = MAX (event->x_root, priv->win_x + priv->pointer_x); |
528 | } |
529 | - else if (priv->overlay.x + priv->overlay.width >= priv->trough.x + priv->trough.width) |
530 | + else if (priv->overlay.x + priv->overlay.width >= priv->trough.width) |
531 | { |
532 | - priv->slide_initial_slider_position = priv->trough.x + priv->trough.width - priv->overlay.width; |
533 | + priv->slide_initial_slider_position = priv->trough.width - priv->overlay.width; |
534 | priv->slide_initial_coordinate = MAX (event->x_root, priv->win_x + priv->pointer_x); |
535 | } |
536 | } |
537 | @@ -1482,7 +1456,7 @@ |
538 | priv->motion_notify_event = FALSE; |
539 | priv->enter_notify_event = FALSE; |
540 | |
541 | - os_pager_set_detached (OS_PAGER (priv->pager), FALSE); |
542 | + os_pager_set_detached (priv->pager, FALSE); |
543 | } |
544 | |
545 | /* toplevel functions */ |
546 | @@ -1492,24 +1466,16 @@ |
547 | store_toplevel_position (OsScrollbar *scrollbar) |
548 | { |
549 | OsScrollbarPrivate *priv; |
550 | - gint win_x, win_y; |
551 | + gint x_pos, y_pos; |
552 | |
553 | priv = scrollbar->priv; |
554 | |
555 | /* In reality, I'm storing widget's window, not the toplevel. |
556 | * Is that the same with gdk_window_get_origin? */ |
557 | - gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &win_x, &win_y); |
558 | + gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos); |
559 | |
560 | - if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
561 | - { |
562 | - priv->win_x = win_x + priv->thumb_all.x; |
563 | - priv->win_y = win_y + priv->thumb_all.y; |
564 | - } |
565 | - else |
566 | - { |
567 | - priv->win_x = win_x + priv->thumb_all.x; |
568 | - priv->win_y = win_y + priv->thumb_all.y; |
569 | - } |
570 | + priv->win_x = x_pos + priv->thumb_all.x; |
571 | + priv->win_y = y_pos + priv->thumb_all.y; |
572 | } |
573 | |
574 | static gboolean |
575 | @@ -1560,12 +1526,12 @@ |
576 | else |
577 | { |
578 | priv->can_deactivate_pager = FALSE; |
579 | - os_pager_set_active (OS_PAGER (priv->pager), TRUE, TRUE); |
580 | + os_pager_set_active (priv->pager, TRUE, TRUE); |
581 | } |
582 | } |
583 | |
584 | if (current_time > end_time) |
585 | - gtk_widget_hide (GTK_WIDGET (priv->thumb)); |
586 | + gtk_widget_hide (priv->thumb); |
587 | |
588 | priv->lock_position = FALSE; |
589 | |
590 | @@ -1577,6 +1543,41 @@ |
591 | return FALSE; |
592 | } |
593 | |
594 | +/* checks if the pointer is in the proximity area. */ |
595 | +static gboolean |
596 | +check_proximity (OsScrollbar *scrollbar, |
597 | + gint x, |
598 | + gint y, |
599 | + OsSide side) |
600 | +{ |
601 | + OsScrollbarPrivate *priv; |
602 | + |
603 | + priv = scrollbar->priv; |
604 | + |
605 | + switch (side) |
606 | + { |
607 | + case OS_SIDE_RIGHT: |
608 | + return (x >= priv->pager_all.x + priv->pager_all.width - PROXIMITY_SIZE && |
609 | + x <= priv->pager_all.x + priv->pager_all.width) && |
610 | + (y >= priv->pager_all.y + priv->overlay.y && |
611 | + y <= priv->pager_all.y + priv->overlay.y + priv->overlay.height); |
612 | + break; |
613 | + case OS_SIDE_BOTTOM: |
614 | + return (y >= priv->pager_all.y + priv->pager_all.height - PROXIMITY_SIZE && |
615 | + y <= priv->pager_all.y + priv->pager_all.height) && |
616 | + (x >= priv->pager_all.x + priv->overlay.x && |
617 | + x <= priv->pager_all.x + priv->overlay.x + priv->overlay.width); |
618 | + break; |
619 | + case OS_SIDE_LEFT: |
620 | + case OS_SIDE_TOP: |
621 | + /* FIXME not implemented yet. |
622 | + * Add support for different scrollbar positions here. */ |
623 | + break; |
624 | + } |
625 | + |
626 | + return FALSE; |
627 | +} |
628 | + |
629 | /* filter function applied to the toplevel window */ |
630 | #ifdef USE_GTK3 |
631 | static GdkFilterReturn |
632 | @@ -1591,8 +1592,8 @@ |
633 | g_return_val_if_fail (OS_SCROLLBAR (user_data), GDK_FILTER_CONTINUE); |
634 | |
635 | scrollbar = OS_SCROLLBAR (user_data); |
636 | - |
637 | priv = scrollbar->priv; |
638 | + |
639 | xev = gdkxevent; |
640 | |
641 | g_return_val_if_fail (priv->pager != NULL, GDK_FILTER_CONTINUE); |
642 | @@ -1619,10 +1620,7 @@ |
643 | /* proximity area */ |
644 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
645 | { |
646 | - if ((priv->overlay_all.x + DEFAULT_PAGER_WIDTH - xiev->event_x <= PROXIMITY_WIDTH && |
647 | - priv->overlay_all.x + DEFAULT_PAGER_WIDTH - xiev->event_x >= 0) && |
648 | - (xiev->event_y >= priv->overlay_all.y + priv->overlay.y && |
649 | - xiev->event_y <= priv->overlay_all.y + priv->overlay.y + priv->overlay.height)) |
650 | + if (check_proximity (scrollbar, xiev->event_x, xiev->event_y, OS_SIDE_RIGHT)) |
651 | { |
652 | priv->can_hide = FALSE; |
653 | |
654 | @@ -1647,15 +1645,12 @@ |
655 | move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y); |
656 | } |
657 | |
658 | - gtk_widget_show (GTK_WIDGET (priv->thumb)); |
659 | + gtk_widget_show (priv->thumb); |
660 | } |
661 | } |
662 | else |
663 | { |
664 | - if ((priv->overlay_all.y + DEFAULT_PAGER_WIDTH - xiev->event_y <= PROXIMITY_WIDTH && |
665 | - priv->overlay_all.y + DEFAULT_PAGER_WIDTH - xiev->event_y >= 0) && |
666 | - (xiev->event_x >= priv->overlay_all.x + priv->overlay.x && |
667 | - xiev->event_x <= priv->overlay_all.x + priv->overlay.x + priv->overlay.width)) |
668 | + if (check_proximity (scrollbar, xiev->event_x, xiev->event_y, OS_SIDE_BOTTOM)) |
669 | { |
670 | priv->can_hide = FALSE; |
671 | |
672 | @@ -1680,7 +1675,7 @@ |
673 | move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y); |
674 | } |
675 | |
676 | - gtk_widget_show (GTK_WIDGET (priv->thumb)); |
677 | + gtk_widget_show (priv->thumb); |
678 | } |
679 | } |
680 | } |
681 | @@ -1746,10 +1741,7 @@ |
682 | /* proximity area */ |
683 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
684 | { |
685 | - if ((priv->overlay_all.x + DEFAULT_PAGER_WIDTH - xiev->event_x <= PROXIMITY_WIDTH && |
686 | - priv->overlay_all.x + DEFAULT_PAGER_WIDTH - xiev->event_x >= 0) && |
687 | - (xiev->event_y >= priv->overlay_all.y + priv->overlay.y && |
688 | - xiev->event_y <= priv->overlay_all.y + priv->overlay.y + priv->overlay.height)) |
689 | + if (check_proximity (scrollbar, xiev->event_x, xiev->event_y, OS_SIDE_RIGHT)) |
690 | { |
691 | priv->can_hide = FALSE; |
692 | |
693 | @@ -1774,9 +1766,9 @@ |
694 | move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y); |
695 | } |
696 | |
697 | - os_pager_set_detached (OS_PAGER (priv->pager), FALSE); |
698 | + os_pager_set_detached (priv->pager, FALSE); |
699 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); |
700 | - gtk_widget_show (GTK_WIDGET (priv->thumb)); |
701 | + gtk_widget_show (priv->thumb); |
702 | } |
703 | else |
704 | { |
705 | @@ -1787,10 +1779,7 @@ |
706 | } |
707 | else |
708 | { |
709 | - if ((priv->overlay_all.y + DEFAULT_PAGER_WIDTH - xiev->event_y <= PROXIMITY_WIDTH && |
710 | - priv->overlay_all.y + DEFAULT_PAGER_WIDTH - xiev->event_y >= 0) && |
711 | - (xiev->event_x >= priv->overlay_all.x + priv->overlay.x && |
712 | - xiev->event_x <= priv->overlay_all.x + priv->overlay.x + priv->overlay.width)) |
713 | + if (check_proximity (scrollbar, xiev->event_x, xiev->event_y, OS_SIDE_BOTTOM)) |
714 | { |
715 | priv->can_hide = FALSE; |
716 | |
717 | @@ -1815,9 +1804,9 @@ |
718 | move_thumb (scrollbar, priv->win_x + priv->slider.x, priv->win_y); |
719 | } |
720 | |
721 | - os_pager_set_detached (OS_PAGER (priv->pager), FALSE); |
722 | + os_pager_set_detached (priv->pager, FALSE); |
723 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); |
724 | - gtk_widget_show (GTK_WIDGET (priv->thumb)); |
725 | + gtk_widget_show (priv->thumb); |
726 | } |
727 | else |
728 | { |
729 | @@ -1845,8 +1834,8 @@ |
730 | g_return_val_if_fail (OS_SCROLLBAR (user_data), GDK_FILTER_CONTINUE); |
731 | |
732 | scrollbar = OS_SCROLLBAR (user_data); |
733 | - |
734 | priv = scrollbar->priv; |
735 | + |
736 | xev = gdkxevent; |
737 | |
738 | g_return_val_if_fail (priv->pager != NULL, GDK_FILTER_CONTINUE); |
739 | @@ -1867,10 +1856,7 @@ |
740 | /* proximity area */ |
741 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
742 | { |
743 | - if ((priv->overlay_all.x + DEFAULT_PAGER_WIDTH - xev->xbutton.x <= PROXIMITY_WIDTH && |
744 | - priv->overlay_all.x + DEFAULT_PAGER_WIDTH - xev->xbutton.x >= 0) && |
745 | - (xev->xbutton.y >= priv->overlay_all.y + priv->overlay.y && |
746 | - xev->xbutton.y <= priv->overlay_all.y + priv->overlay.y + priv->overlay.height)) |
747 | + if (check_proximity (scrollbar, xev->xbutton.x, xev->xbutton.y, OS_SIDE_RIGHT)) |
748 | { |
749 | priv->can_hide = FALSE; |
750 | |
751 | @@ -1895,15 +1881,12 @@ |
752 | move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y); |
753 | } |
754 | |
755 | - gtk_widget_show (GTK_WIDGET (priv->thumb)); |
756 | + gtk_widget_show (priv->thumb); |
757 | } |
758 | } |
759 | else |
760 | { |
761 | - if ((priv->overlay_all.y + DEFAULT_PAGER_WIDTH - xev->xbutton.y <= PROXIMITY_WIDTH && |
762 | - priv->overlay_all.y + DEFAULT_PAGER_WIDTH - xev->xbutton.y >= 0) && |
763 | - (xev->xbutton.x >= priv->overlay_all.x + priv->overlay.x && |
764 | - xev->xbutton.x <= priv->overlay_all.x + priv->overlay.x + priv->overlay.width)) |
765 | + if (check_proximity (scrollbar, xev->xbutton.x, xev->xbutton.y, OS_SIDE_BOTTOM)) |
766 | { |
767 | priv->can_hide = FALSE; |
768 | |
769 | @@ -1928,7 +1911,7 @@ |
770 | move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y); |
771 | } |
772 | |
773 | - gtk_widget_show (GTK_WIDGET (priv->thumb)); |
774 | + gtk_widget_show (priv->thumb); |
775 | } |
776 | } |
777 | } |
778 | @@ -1991,10 +1974,7 @@ |
779 | /* proximity area */ |
780 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
781 | { |
782 | - if ((priv->overlay_all.x + DEFAULT_PAGER_WIDTH - xev->xmotion.x <= PROXIMITY_WIDTH && |
783 | - priv->overlay_all.x + DEFAULT_PAGER_WIDTH - xev->xmotion.x >= 0) && |
784 | - (xev->xmotion.y >= priv->overlay_all.y + priv->overlay.y && |
785 | - xev->xmotion.y <= priv->overlay_all.y + priv->overlay.y + priv->overlay.height)) |
786 | + if (check_proximity (scrollbar, xev->xmotion.x, xev->xmotion.y, OS_SIDE_RIGHT)) |
787 | { |
788 | priv->can_hide = FALSE; |
789 | |
790 | @@ -2019,9 +1999,9 @@ |
791 | move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y); |
792 | } |
793 | |
794 | - os_pager_set_detached (OS_PAGER (priv->pager), FALSE); |
795 | + os_pager_set_detached (priv->pager, FALSE); |
796 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); |
797 | - gtk_widget_show (GTK_WIDGET (priv->thumb)); |
798 | + gtk_widget_show (priv->thumb); |
799 | } |
800 | else |
801 | { |
802 | @@ -2032,10 +2012,7 @@ |
803 | } |
804 | else |
805 | { |
806 | - if ((priv->overlay_all.y + DEFAULT_PAGER_WIDTH - xev->xmotion.y <= PROXIMITY_WIDTH && |
807 | - priv->overlay_all.y + DEFAULT_PAGER_WIDTH - xev->xmotion.y >= 0) && |
808 | - (xev->xmotion.x >= priv->overlay_all.x + priv->overlay.x && |
809 | - xev->xmotion.x <= priv->overlay_all.x + priv->overlay.x + priv->overlay.width)) |
810 | + if (check_proximity (scrollbar, xev->xmotion.x, xev->xmotion.y, OS_SIDE_BOTTOM)) |
811 | { |
812 | priv->can_hide = FALSE; |
813 | |
814 | @@ -2060,9 +2037,9 @@ |
815 | move_thumb (scrollbar, priv->win_x + priv->slider.x, priv->win_y); |
816 | } |
817 | |
818 | - os_pager_set_detached (OS_PAGER (priv->pager), FALSE); |
819 | + os_pager_set_detached (priv->pager, FALSE); |
820 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); |
821 | - gtk_widget_show (GTK_WIDGET (priv->thumb)); |
822 | + gtk_widget_show (priv->thumb); |
823 | } |
824 | else |
825 | { |
826 | @@ -2347,11 +2324,11 @@ |
827 | /* on map-event of an active window, |
828 | * the pager should be active. */ |
829 | priv->can_deactivate_pager = FALSE; |
830 | - os_pager_set_active (OS_PAGER (priv->pager), TRUE, FALSE); |
831 | + os_pager_set_active (priv->pager, TRUE, FALSE); |
832 | } |
833 | |
834 | if (priv->fullsize == FALSE) |
835 | - os_pager_show (OS_PAGER (priv->pager)); |
836 | + os_pager_show (priv->pager); |
837 | |
838 | if (gtk_widget_get_realized (widget) && priv->filter == FALSE) |
839 | { |
840 | @@ -2388,7 +2365,7 @@ |
841 | |
842 | calc_layout_pager (scrollbar, gtk_adjustment_get_value (priv->adjustment)); |
843 | |
844 | - os_pager_set_parent (OS_PAGER (priv->pager), widget); |
845 | + os_pager_set_parent (priv->pager, widget); |
846 | |
847 | store_toplevel_position (scrollbar); |
848 | } |
849 | @@ -2403,46 +2380,43 @@ |
850 | os_scrollbar_size_allocate (GtkWidget *widget, |
851 | GdkRectangle *allocation) |
852 | { |
853 | - GdkRectangle rect; |
854 | OsScrollbar *scrollbar; |
855 | OsScrollbarPrivate *priv; |
856 | |
857 | scrollbar = OS_SCROLLBAR (widget); |
858 | priv = scrollbar->priv; |
859 | |
860 | - priv->trough.x = 0; |
861 | - priv->trough.y = 0; |
862 | + priv->trough.x = allocation->x; |
863 | + priv->trough.y = allocation->y; |
864 | priv->trough.width = allocation->width; |
865 | priv->trough.height = allocation->height; |
866 | |
867 | - priv->overlay_all = *allocation; |
868 | + priv->pager_all = *allocation; |
869 | priv->thumb_all = *allocation; |
870 | |
871 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
872 | { |
873 | - priv->slider.width = DEFAULT_THUMB_WIDTH; |
874 | - priv->slider.height = DEFAULT_THUMB_HEIGHT; |
875 | - priv->overlay_all.x = allocation->x - DEFAULT_PAGER_WIDTH; |
876 | + priv->slider.width = THUMB_WIDTH; |
877 | + priv->slider.height = THUMB_HEIGHT; |
878 | + |
879 | + priv->pager_all.x = allocation->x - PAGER_SIZE; |
880 | + priv->pager_all.width = PAGER_SIZE; |
881 | + |
882 | priv->thumb_all.x = allocation->x + THUMB_ALLOCATION_SHIFT; |
883 | - |
884 | - rect.x = priv->overlay_all.x; |
885 | - rect.y = priv->overlay_all.y; |
886 | - rect.width = DEFAULT_PAGER_WIDTH; |
887 | - rect.height = priv->overlay_all.height; |
888 | + priv->thumb_all.width = THUMB_WIDTH; |
889 | |
890 | allocation->width = 0; |
891 | } |
892 | else |
893 | { |
894 | - priv->slider.width = DEFAULT_THUMB_HEIGHT; |
895 | - priv->slider.height = DEFAULT_THUMB_WIDTH; |
896 | - priv->overlay_all.y = allocation->y - DEFAULT_PAGER_WIDTH; |
897 | + priv->slider.width = THUMB_HEIGHT; |
898 | + priv->slider.height = THUMB_WIDTH; |
899 | + |
900 | + priv->pager_all.y = allocation->y - PAGER_SIZE; |
901 | + priv->pager_all.height = PAGER_SIZE; |
902 | + |
903 | priv->thumb_all.y = allocation->y + THUMB_ALLOCATION_SHIFT; |
904 | - |
905 | - rect.x = priv->overlay_all.x; |
906 | - rect.y = priv->overlay_all.y; |
907 | - rect.width = priv->overlay_all.width; |
908 | - rect.height = DEFAULT_PAGER_WIDTH; |
909 | + priv->thumb_all.height = THUMB_HEIGHT; |
910 | |
911 | allocation->height = 0; |
912 | } |
913 | @@ -2453,7 +2427,7 @@ |
914 | calc_layout_slider (scrollbar, gtk_adjustment_get_value (priv->adjustment)); |
915 | } |
916 | |
917 | - os_pager_size_allocate (OS_PAGER (priv->pager), rect); |
918 | + os_pager_size_allocate (priv->pager, priv->pager_all); |
919 | |
920 | move_pager (scrollbar); |
921 | |
922 | @@ -2496,7 +2470,7 @@ |
923 | |
924 | priv->proximity = FALSE; |
925 | |
926 | - os_pager_hide (OS_PAGER (priv->pager)); |
927 | + os_pager_hide (priv->pager); |
928 | |
929 | gtk_widget_hide (priv->thumb); |
930 | |
931 | @@ -2517,7 +2491,7 @@ |
932 | scrollbar = OS_SCROLLBAR (widget); |
933 | priv = scrollbar->priv; |
934 | |
935 | - os_pager_hide (OS_PAGER (priv->pager)); |
936 | + os_pager_hide (priv->pager); |
937 | |
938 | gtk_widget_hide (priv->thumb); |
939 | |
940 | @@ -2527,7 +2501,7 @@ |
941 | g_signal_handlers_disconnect_by_func (G_OBJECT (gtk_widget_get_toplevel (widget)), |
942 | G_CALLBACK (toplevel_configure_event_cb), scrollbar); |
943 | |
944 | - os_pager_set_parent (OS_PAGER (priv->pager), NULL); |
945 | + os_pager_set_parent (priv->pager, NULL); |
946 | |
947 | window_group_list = gtk_window_group_list_windows (priv->window_group); |
948 | |
949 | |
950 | === modified file 'os/os-thumb.c' |
951 | --- os/os-thumb.c 2011-06-09 11:19:20 +0000 |
952 | +++ os/os-thumb.c 2011-06-15 13:28:34 +0000 |
953 | @@ -828,15 +828,9 @@ |
954 | { |
955 | priv->orientation = g_value_get_enum (value); |
956 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
957 | - { |
958 | - gtk_window_resize (GTK_WINDOW (object), DEFAULT_THUMB_WIDTH, |
959 | - DEFAULT_THUMB_HEIGHT); |
960 | - } |
961 | + gtk_window_resize (GTK_WINDOW (object), THUMB_WIDTH, THUMB_HEIGHT); |
962 | else |
963 | - { |
964 | - gtk_window_resize (GTK_WINDOW (object), DEFAULT_THUMB_HEIGHT, |
965 | - DEFAULT_THUMB_WIDTH); |
966 | - } |
967 | + gtk_window_resize (GTK_WINDOW (object), THUMB_HEIGHT, THUMB_WIDTH); |
968 | break; |
969 | } |
970 |