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