Merge lp:~cimi/overlay-scrollbar/support-different-placement into lp:overlay-scrollbar
- support-different-placement
- Merge into trunk
Proposed by
Andrea Cimitan
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ted Gould | ||||
Approved revision: | 271 | ||||
Merged at revision: | 272 | ||||
Proposed branch: | lp:~cimi/overlay-scrollbar/support-different-placement | ||||
Merge into: | lp:overlay-scrollbar | ||||
Diff against target: |
621 lines (+281/-72) 4 files modified
configure.ac (+2/-2) os/os-scrollbar.c (+278/-65) os/os-utils.c (+0/-5) tests/test-os.c (+1/-0) |
||||
To merge this branch: | bzr merge lp:~cimi/overlay-scrollbar/support-different-placement | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ted Gould (community) | Approve | ||
Review via email: mp+66183@code.launchpad.net |
Commit message
Description of the change
Support different scrollbar layout, didn't test the qdata yet
To post a comment you must log in.
- 269. By Andrea Cimitan
-
This should fix multimonitor support
- 270. By Andrea Cimitan
-
Merged trunk
- 271. By Andrea Cimitan
-
Initialize side
Revision history for this message
Ted Gould (ted) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'configure.ac' | |||
2 | --- configure.ac 2011-06-17 02:48:41 +0000 | |||
3 | +++ configure.ac 2011-06-29 10:01:21 +0000 | |||
4 | @@ -71,9 +71,9 @@ | |||
5 | 71 | 71 | ||
6 | 72 | AC_ARG_WITH([gtk], | 72 | AC_ARG_WITH([gtk], |
7 | 73 | [AS_HELP_STRING([--with-gtk], | 73 | [AS_HELP_STRING([--with-gtk], |
9 | 74 | [Which version of gtk to use @<:@default=2@:>@])], | 74 | [Which version of gtk to use @<:@default=3@:>@])], |
10 | 75 | [], | 75 | [], |
12 | 76 | [with_gtk=2]) | 76 | [with_gtk=3]) |
13 | 77 | AS_IF([test "x$with_gtk" = x3], | 77 | AS_IF([test "x$with_gtk" = x3], |
14 | 78 | [PKG_CHECK_MODULES(DEPS, glib-2.0 >= $glib_req gtk+-3.0 >= $gtk3_req cairo >= $cairo_req) | 78 | [PKG_CHECK_MODULES(DEPS, glib-2.0 >= $glib_req gtk+-3.0 >= $gtk3_req cairo >= $cairo_req) |
15 | 79 | AC_SUBST(DEPS_CFLAGS) | 79 | AC_SUBST(DEPS_CFLAGS) |
16 | 80 | 80 | ||
17 | === modified file 'os/os-scrollbar.c' | |||
18 | --- os/os-scrollbar.c 2011-06-28 23:04:55 +0000 | |||
19 | +++ os/os-scrollbar.c 2011-06-29 10:01:21 +0000 | |||
20 | @@ -35,9 +35,6 @@ | |||
21 | 35 | /* Size of the pager in pixels. */ | 35 | /* Size of the pager in pixels. */ |
22 | 36 | #define PAGER_SIZE 3 | 36 | #define PAGER_SIZE 3 |
23 | 37 | 37 | ||
24 | 38 | /* Thumb allocation shift in pixels. */ | ||
25 | 39 | #define THUMB_ALLOCATION_SHIFT -3 | ||
26 | 40 | |||
27 | 41 | /* Size of the proximity effect in pixels. */ | 38 | /* Size of the proximity effect in pixels. */ |
28 | 42 | #define PROXIMITY_SIZE 30 | 39 | #define PROXIMITY_SIZE 30 |
29 | 43 | 40 | ||
30 | @@ -61,6 +58,15 @@ | |||
31 | 61 | OS_SIDE_RIGHT | 58 | OS_SIDE_RIGHT |
32 | 62 | } OsSide; | 59 | } OsSide; |
33 | 63 | 60 | ||
34 | 61 | typedef enum | ||
35 | 62 | { | ||
36 | 63 | OS_STRUT_SIDE_NONE = 0, | ||
37 | 64 | OS_STRUT_SIDE_TOP = 1, | ||
38 | 65 | OS_STRUT_SIDE_BOTTOM = 2, | ||
39 | 66 | OS_STRUT_SIDE_LEFT = 4, | ||
40 | 67 | OS_STRUT_SIDE_RIGHT = 8 | ||
41 | 68 | } OsStrutSide; | ||
42 | 69 | |||
43 | 64 | struct _OsScrollbarPrivate | 70 | struct _OsScrollbarPrivate |
44 | 65 | { | 71 | { |
45 | 66 | GdkRectangle trough; | 72 | GdkRectangle trough; |
46 | @@ -73,6 +79,7 @@ | |||
47 | 73 | GtkOrientation orientation; | 79 | GtkOrientation orientation; |
48 | 74 | GtkWindowGroup *window_group; | 80 | GtkWindowGroup *window_group; |
49 | 75 | OsPager *pager; | 81 | OsPager *pager; |
50 | 82 | OsSide side; | ||
51 | 76 | gboolean button_press_event; | 83 | gboolean button_press_event; |
52 | 77 | gboolean enter_notify_event; | 84 | gboolean enter_notify_event; |
53 | 78 | gboolean motion_notify_event; | 85 | gboolean motion_notify_event; |
54 | @@ -102,6 +109,7 @@ | |||
55 | 102 | static Atom unity_net_workarea_region_atom = None; | 109 | static Atom unity_net_workarea_region_atom = None; |
56 | 103 | static GList *os_root_list = NULL; | 110 | static GList *os_root_list = NULL; |
57 | 104 | static cairo_region_t *os_workarea = NULL; | 111 | static cairo_region_t *os_workarea = NULL; |
58 | 112 | static GQuark os_quark_placement = 0; | ||
59 | 105 | 113 | ||
60 | 106 | static void swap_adjustment (OsScrollbar *scrollbar, GtkAdjustment *adjustment); | 114 | static void swap_adjustment (OsScrollbar *scrollbar, GtkAdjustment *adjustment); |
61 | 107 | static void swap_thumb (OsScrollbar *scrollbar, GtkWidget *thumb); | 115 | static void swap_thumb (OsScrollbar *scrollbar, GtkWidget *thumb); |
62 | @@ -409,14 +417,16 @@ | |||
63 | 409 | GdkScreen *screen; | 417 | GdkScreen *screen; |
64 | 410 | OsScrollbarPrivate *priv; | 418 | OsScrollbarPrivate *priv; |
65 | 411 | cairo_rectangle_int_t rect; | 419 | cairo_rectangle_int_t rect; |
67 | 412 | gint screen_width, n_monitor; | 420 | gint screen_x, screen_width, n_monitor, monitor_x; |
68 | 413 | 421 | ||
69 | 414 | priv = scrollbar->priv; | 422 | priv = scrollbar->priv; |
70 | 415 | 423 | ||
71 | 416 | /* the x - 1 coordinate shift is done | 424 | /* the x - 1 coordinate shift is done |
72 | 417 | * to calculate monitor boundaries. */ | 425 | * to calculate monitor boundaries. */ |
73 | 426 | monitor_x = priv->side == OS_SIDE_LEFT ? x : x - 1; | ||
74 | 427 | |||
75 | 418 | screen = gtk_widget_get_screen (GTK_WIDGET (scrollbar)); | 428 | screen = gtk_widget_get_screen (GTK_WIDGET (scrollbar)); |
77 | 419 | n_monitor = gdk_screen_get_monitor_at_point (screen, x - 1, y); | 429 | n_monitor = gdk_screen_get_monitor_at_point (screen, monitor_x, y); |
78 | 420 | #ifdef USE_GTK3 | 430 | #ifdef USE_GTK3 |
79 | 421 | gdk_screen_get_monitor_geometry (screen, n_monitor, &rect); | 431 | gdk_screen_get_monitor_geometry (screen, n_monitor, &rect); |
80 | 422 | #else | 432 | #else |
81 | @@ -428,42 +438,108 @@ | |||
82 | 428 | rect.height = gdk_rect.height; | 438 | rect.height = gdk_rect.height; |
83 | 429 | #endif | 439 | #endif |
84 | 430 | 440 | ||
88 | 431 | if (cairo_region_is_empty (os_workarea)) | 441 | screen_x = rect.x; |
89 | 432 | screen_width = rect.x + rect.width; | 442 | screen_width = rect.x + rect.width; |
90 | 433 | else | 443 | |
91 | 444 | if (!cairo_region_is_empty (os_workarea)) | ||
92 | 434 | { | 445 | { |
93 | 435 | cairo_region_t *monitor_workarea; | 446 | cairo_region_t *monitor_workarea; |
94 | 447 | cairo_region_t *struts_region; | ||
95 | 436 | cairo_rectangle_int_t tmp_rect; | 448 | cairo_rectangle_int_t tmp_rect; |
96 | 437 | gint i, x, width; | 449 | gint i, x, width; |
97 | 438 | 450 | ||
98 | 439 | x = rect.x; | 451 | x = rect.x; |
100 | 440 | width = rect.width; | 452 | width = rect.x + rect.width; |
101 | 441 | 453 | ||
102 | 454 | /* full monitor region */ | ||
103 | 442 | monitor_workarea = cairo_region_create_rectangle (&rect); | 455 | monitor_workarea = cairo_region_create_rectangle (&rect); |
104 | 456 | struts_region = cairo_region_copy (monitor_workarea); | ||
105 | 443 | 457 | ||
106 | 458 | /* workarea region for current monitor */ | ||
107 | 444 | cairo_region_intersect (monitor_workarea, os_workarea); | 459 | cairo_region_intersect (monitor_workarea, os_workarea); |
108 | 445 | 460 | ||
110 | 446 | for (i = 0; i < cairo_region_num_rectangles (monitor_workarea); i++) | 461 | /* struts region for current monitor */ |
111 | 462 | cairo_region_subtract (struts_region, monitor_workarea); | ||
112 | 463 | |||
113 | 464 | for (i = 0; i < cairo_region_num_rectangles (struts_region); i++) | ||
114 | 447 | { | 465 | { |
121 | 448 | cairo_region_get_rectangle (monitor_workarea, i, &tmp_rect); | 466 | OsStrutSide strut_side; |
122 | 449 | 467 | gint count; | |
123 | 450 | if (tmp_rect.x > x) | 468 | |
124 | 451 | x = tmp_rect.x; | 469 | cairo_region_get_rectangle (struts_region, i, &tmp_rect); |
125 | 452 | if (tmp_rect.x + tmp_rect.width < width) | 470 | |
126 | 453 | width = tmp_rect.x + tmp_rect.width; | 471 | strut_side = OS_STRUT_SIDE_NONE; |
127 | 472 | count = 0; | ||
128 | 473 | |||
129 | 474 | /* determine which side the strut is on */ | ||
130 | 475 | if (tmp_rect.y == rect.y) | ||
131 | 476 | { | ||
132 | 477 | strut_side |= OS_STRUT_SIDE_TOP; | ||
133 | 478 | count++; | ||
134 | 479 | } | ||
135 | 480 | |||
136 | 481 | if (tmp_rect.x == rect.x) | ||
137 | 482 | { | ||
138 | 483 | strut_side |= OS_STRUT_SIDE_LEFT; | ||
139 | 484 | count++; | ||
140 | 485 | } | ||
141 | 486 | |||
142 | 487 | if (tmp_rect.x + tmp_rect.width == rect.x + rect.width) | ||
143 | 488 | { | ||
144 | 489 | strut_side |= OS_STRUT_SIDE_RIGHT; | ||
145 | 490 | count++; | ||
146 | 491 | } | ||
147 | 492 | |||
148 | 493 | if (tmp_rect.y + tmp_rect.height == rect.y + rect.height) | ||
149 | 494 | { | ||
150 | 495 | strut_side |= OS_STRUT_SIDE_BOTTOM; | ||
151 | 496 | count++; | ||
152 | 497 | } | ||
153 | 498 | |||
154 | 499 | /* handle multiple sides */ | ||
155 | 500 | if (count >= 2) | ||
156 | 501 | { | ||
157 | 502 | if (tmp_rect.width > tmp_rect.height) | ||
158 | 503 | strut_side &= ~(OS_STRUT_SIDE_LEFT | OS_STRUT_SIDE_RIGHT); | ||
159 | 504 | else if (tmp_rect.width < tmp_rect.height) | ||
160 | 505 | strut_side &= ~(OS_STRUT_SIDE_TOP | OS_STRUT_SIDE_BOTTOM); | ||
161 | 506 | } | ||
162 | 507 | |||
163 | 508 | /* get the monitor boundaries using the strut */ | ||
164 | 509 | if (strut_side & OS_STRUT_SIDE_LEFT) | ||
165 | 510 | { | ||
166 | 511 | if (tmp_rect.x + tmp_rect.width > x) | ||
167 | 512 | x = tmp_rect.x + tmp_rect.width; | ||
168 | 513 | } | ||
169 | 514 | |||
170 | 515 | if (strut_side & OS_STRUT_SIDE_RIGHT) | ||
171 | 516 | { | ||
172 | 517 | if (tmp_rect.x < width) | ||
173 | 518 | width = tmp_rect.x; | ||
174 | 519 | } | ||
175 | 454 | } | 520 | } |
176 | 455 | 521 | ||
178 | 456 | screen_width = x + width; | 522 | screen_x = x; |
179 | 523 | screen_width = width; | ||
180 | 457 | 524 | ||
181 | 458 | cairo_region_destroy (monitor_workarea); | 525 | cairo_region_destroy (monitor_workarea); |
190 | 459 | } | 526 | cairo_region_destroy (struts_region); |
191 | 460 | 527 | } | |
192 | 461 | if (priv->orientation == GTK_ORIENTATION_VERTICAL && | 528 | |
193 | 462 | (n_monitor != gdk_screen_get_monitor_at_point (screen, x - 1 + priv->slider.width, y) || | 529 | if (priv->side == OS_SIDE_RIGHT && |
194 | 463 | x - 1 + priv->slider.width >= screen_width)) | 530 | (n_monitor != gdk_screen_get_monitor_at_point (screen, monitor_x + priv->thumb_all.width, y) || |
195 | 464 | { | 531 | monitor_x + priv->thumb_all.width >= screen_width)) |
196 | 465 | priv->internal = TRUE; | 532 | { |
197 | 466 | return MAX (x - priv->slider.width, screen_width - priv->slider.width); | 533 | priv->internal = TRUE; |
198 | 534 | return MAX (x - priv->thumb_all.width, screen_width - priv->thumb_all.width); | ||
199 | 535 | } | ||
200 | 536 | |||
201 | 537 | if (priv->side == OS_SIDE_LEFT && | ||
202 | 538 | (n_monitor != gdk_screen_get_monitor_at_point (screen, monitor_x - priv->thumb_all.width, y) || | ||
203 | 539 | monitor_x - priv->thumb_all.width <= screen_x)) | ||
204 | 540 | { | ||
205 | 541 | priv->internal = TRUE; | ||
206 | 542 | return MAX (x, screen_x); | ||
207 | 467 | } | 543 | } |
208 | 468 | 544 | ||
209 | 469 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 545 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
210 | @@ -484,14 +560,16 @@ | |||
211 | 484 | GdkScreen *screen; | 560 | GdkScreen *screen; |
212 | 485 | OsScrollbarPrivate *priv; | 561 | OsScrollbarPrivate *priv; |
213 | 486 | cairo_rectangle_int_t rect; | 562 | cairo_rectangle_int_t rect; |
215 | 487 | gint screen_height, n_monitor; | 563 | gint screen_y, screen_height, n_monitor, monitor_y; |
216 | 488 | 564 | ||
217 | 489 | priv = scrollbar->priv; | 565 | priv = scrollbar->priv; |
218 | 490 | 566 | ||
219 | 491 | /* the y - 1 coordinate shift is done | 567 | /* the y - 1 coordinate shift is done |
220 | 492 | * to calculate monitor boundaries. */ | 568 | * to calculate monitor boundaries. */ |
221 | 569 | monitor_y = priv->side == OS_SIDE_TOP ? y : y - 1; | ||
222 | 570 | |||
223 | 493 | screen = gtk_widget_get_screen (GTK_WIDGET (scrollbar)); | 571 | screen = gtk_widget_get_screen (GTK_WIDGET (scrollbar)); |
225 | 494 | n_monitor = gdk_screen_get_monitor_at_point (screen, x, y - 1); | 572 | n_monitor = gdk_screen_get_monitor_at_point (screen, x, monitor_y); |
226 | 495 | #ifdef USE_GTK3 | 573 | #ifdef USE_GTK3 |
227 | 496 | gdk_screen_get_monitor_geometry (screen, n_monitor, &rect); | 574 | gdk_screen_get_monitor_geometry (screen, n_monitor, &rect); |
228 | 497 | #else | 575 | #else |
229 | @@ -503,42 +581,108 @@ | |||
230 | 503 | rect.height = gdk_rect.height; | 581 | rect.height = gdk_rect.height; |
231 | 504 | #endif | 582 | #endif |
232 | 505 | 583 | ||
236 | 506 | if (cairo_region_is_empty (os_workarea)) | 584 | screen_y = rect.y; |
237 | 507 | screen_height = rect.y + rect.height; | 585 | screen_height = rect.y + rect.height; |
238 | 508 | else | 586 | |
239 | 587 | if (!cairo_region_is_empty (os_workarea)) | ||
240 | 509 | { | 588 | { |
241 | 510 | cairo_region_t *monitor_workarea; | 589 | cairo_region_t *monitor_workarea; |
242 | 590 | cairo_region_t *struts_region; | ||
243 | 511 | cairo_rectangle_int_t tmp_rect; | 591 | cairo_rectangle_int_t tmp_rect; |
244 | 512 | gint i, y, height; | 592 | gint i, y, height; |
245 | 513 | 593 | ||
246 | 514 | y = rect.y; | 594 | y = rect.y; |
248 | 515 | height = rect.height; | 595 | height = rect.y + rect.height; |
249 | 516 | 596 | ||
250 | 597 | /* full monitor region */ | ||
251 | 517 | monitor_workarea = cairo_region_create_rectangle (&rect); | 598 | monitor_workarea = cairo_region_create_rectangle (&rect); |
252 | 599 | struts_region = cairo_region_copy (monitor_workarea); | ||
253 | 518 | 600 | ||
254 | 601 | /* workarea region for current monitor */ | ||
255 | 519 | cairo_region_intersect (monitor_workarea, os_workarea); | 602 | cairo_region_intersect (monitor_workarea, os_workarea); |
256 | 520 | 603 | ||
258 | 521 | for (i = 0; i < cairo_region_num_rectangles (monitor_workarea); i++) | 604 | /* struts region for current monitor */ |
259 | 605 | cairo_region_subtract (struts_region, monitor_workarea); | ||
260 | 606 | |||
261 | 607 | for (i = 0; i < cairo_region_num_rectangles (struts_region); i++) | ||
262 | 522 | { | 608 | { |
269 | 523 | cairo_region_get_rectangle (monitor_workarea, i, &tmp_rect); | 609 | OsStrutSide strut_side; |
270 | 524 | 610 | gint count; | |
271 | 525 | if (tmp_rect.y > y) | 611 | |
272 | 526 | y = tmp_rect.y; | 612 | cairo_region_get_rectangle (struts_region, i, &tmp_rect); |
273 | 527 | if (tmp_rect.y + tmp_rect.height < height) | 613 | |
274 | 528 | height = tmp_rect.y + tmp_rect.height; | 614 | strut_side = OS_STRUT_SIDE_NONE; |
275 | 615 | count = 0; | ||
276 | 616 | |||
277 | 617 | /* determine which side the strut is on */ | ||
278 | 618 | if (tmp_rect.y == rect.y) | ||
279 | 619 | { | ||
280 | 620 | strut_side |= OS_STRUT_SIDE_TOP; | ||
281 | 621 | count++; | ||
282 | 622 | } | ||
283 | 623 | |||
284 | 624 | if (tmp_rect.x == rect.x) | ||
285 | 625 | { | ||
286 | 626 | strut_side |= OS_STRUT_SIDE_LEFT; | ||
287 | 627 | count++; | ||
288 | 628 | } | ||
289 | 629 | |||
290 | 630 | if (tmp_rect.x + tmp_rect.width == rect.x + rect.width) | ||
291 | 631 | { | ||
292 | 632 | strut_side |= OS_STRUT_SIDE_RIGHT; | ||
293 | 633 | count++; | ||
294 | 634 | } | ||
295 | 635 | |||
296 | 636 | if (tmp_rect.y + tmp_rect.height == rect.y + rect.height) | ||
297 | 637 | { | ||
298 | 638 | strut_side |= OS_STRUT_SIDE_BOTTOM; | ||
299 | 639 | count++; | ||
300 | 640 | } | ||
301 | 641 | |||
302 | 642 | /* handle multiple sides */ | ||
303 | 643 | if (count >= 2) | ||
304 | 644 | { | ||
305 | 645 | if (tmp_rect.width > tmp_rect.height) | ||
306 | 646 | strut_side &= ~(OS_STRUT_SIDE_LEFT | OS_STRUT_SIDE_RIGHT); | ||
307 | 647 | else if (tmp_rect.width < tmp_rect.height) | ||
308 | 648 | strut_side &= ~(OS_STRUT_SIDE_TOP | OS_STRUT_SIDE_BOTTOM); | ||
309 | 649 | } | ||
310 | 650 | |||
311 | 651 | /* get the monitor boundaries using the strut */ | ||
312 | 652 | if (strut_side & OS_STRUT_SIDE_TOP) | ||
313 | 653 | { | ||
314 | 654 | if (tmp_rect.y + tmp_rect.height > y) | ||
315 | 655 | y = tmp_rect.y + tmp_rect.height; | ||
316 | 656 | } | ||
317 | 657 | |||
318 | 658 | if (strut_side & OS_STRUT_SIDE_BOTTOM) | ||
319 | 659 | { | ||
320 | 660 | if (tmp_rect.y < height) | ||
321 | 661 | height = tmp_rect.y; | ||
322 | 662 | } | ||
323 | 529 | } | 663 | } |
324 | 530 | 664 | ||
326 | 531 | screen_height = y + height; | 665 | screen_y = y; |
327 | 666 | screen_height = height; | ||
328 | 532 | 667 | ||
329 | 533 | cairo_region_destroy (monitor_workarea); | 668 | cairo_region_destroy (monitor_workarea); |
338 | 534 | } | 669 | cairo_region_destroy (struts_region); |
339 | 535 | 670 | } | |
340 | 536 | if (priv->orientation == GTK_ORIENTATION_HORIZONTAL && | 671 | |
341 | 537 | (n_monitor != gdk_screen_get_monitor_at_point (screen, x, y - 1 + priv->slider.height) || | 672 | if (priv->side == OS_SIDE_BOTTOM && |
342 | 538 | y - 1 + priv->slider.height >= screen_height)) | 673 | (n_monitor != gdk_screen_get_monitor_at_point (screen, x, monitor_y + priv->thumb_all.height) || |
343 | 539 | { | 674 | monitor_y + priv->thumb_all.height >= screen_height)) |
344 | 540 | priv->internal = TRUE; | 675 | { |
345 | 541 | return MAX (y - priv->slider.height, screen_height - priv->slider.height); | 676 | priv->internal = TRUE; |
346 | 677 | return MAX (y - priv->thumb_all.height, screen_height - priv->thumb_all.height); | ||
347 | 678 | } | ||
348 | 679 | |||
349 | 680 | if (priv->side == OS_SIDE_TOP && | ||
350 | 681 | (n_monitor != gdk_screen_get_monitor_at_point (screen, x, monitor_y - priv->thumb_all.height) || | ||
351 | 682 | monitor_y - priv->thumb_all.height <= screen_y)) | ||
352 | 683 | { | ||
353 | 684 | priv->internal = TRUE; | ||
354 | 685 | return MAX (y, screen_y); | ||
355 | 542 | } | 686 | } |
356 | 543 | 687 | ||
357 | 544 | if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) | 688 | if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) |
358 | @@ -1580,14 +1724,13 @@ | |||
359 | 1580 | static gboolean | 1724 | static gboolean |
360 | 1581 | check_proximity (OsScrollbar *scrollbar, | 1725 | check_proximity (OsScrollbar *scrollbar, |
361 | 1582 | gint x, | 1726 | gint x, |
364 | 1583 | gint y, | 1727 | gint y) |
363 | 1584 | OsSide side) | ||
365 | 1585 | { | 1728 | { |
366 | 1586 | OsScrollbarPrivate *priv; | 1729 | OsScrollbarPrivate *priv; |
367 | 1587 | 1730 | ||
368 | 1588 | priv = scrollbar->priv; | 1731 | priv = scrollbar->priv; |
369 | 1589 | 1732 | ||
371 | 1590 | switch (side) | 1733 | switch (priv->side) |
372 | 1591 | { | 1734 | { |
373 | 1592 | case OS_SIDE_RIGHT: | 1735 | case OS_SIDE_RIGHT: |
374 | 1593 | return (x >= priv->pager_all.x + priv->pager_all.width - PROXIMITY_SIZE && | 1736 | return (x >= priv->pager_all.x + priv->pager_all.width - PROXIMITY_SIZE && |
375 | @@ -1602,9 +1745,16 @@ | |||
376 | 1602 | x <= priv->pager_all.x + priv->overlay.x + priv->overlay.width); | 1745 | x <= priv->pager_all.x + priv->overlay.x + priv->overlay.width); |
377 | 1603 | break; | 1746 | break; |
378 | 1604 | case OS_SIDE_LEFT: | 1747 | case OS_SIDE_LEFT: |
379 | 1748 | return (x <= priv->pager_all.x + priv->pager_all.width + PROXIMITY_SIZE && | ||
380 | 1749 | x >= priv->pager_all.x) && | ||
381 | 1750 | (y >= priv->pager_all.y + priv->overlay.y && | ||
382 | 1751 | y <= priv->pager_all.y + priv->overlay.y + priv->overlay.height); | ||
383 | 1752 | break; | ||
384 | 1605 | case OS_SIDE_TOP: | 1753 | case OS_SIDE_TOP: |
387 | 1606 | /* FIXME not implemented yet. | 1754 | return (y <= priv->pager_all.y + priv->pager_all.height + PROXIMITY_SIZE && |
388 | 1607 | * Add support for different scrollbar positions here. */ | 1755 | y >= priv->pager_all.y) && |
389 | 1756 | (x >= priv->pager_all.x + priv->overlay.x && | ||
390 | 1757 | x <= priv->pager_all.x + priv->overlay.x + priv->overlay.width); | ||
391 | 1608 | break; | 1758 | break; |
392 | 1609 | default: | 1759 | default: |
393 | 1610 | break; | 1760 | break; |
394 | @@ -1655,7 +1805,7 @@ | |||
395 | 1655 | /* proximity area */ | 1805 | /* proximity area */ |
396 | 1656 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 1806 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
397 | 1657 | { | 1807 | { |
399 | 1658 | if (check_proximity (scrollbar, xiev->event_x, xiev->event_y, OS_SIDE_RIGHT)) | 1808 | if (check_proximity (scrollbar, xiev->event_x, xiev->event_y)) |
400 | 1659 | { | 1809 | { |
401 | 1660 | priv->can_hide = FALSE; | 1810 | priv->can_hide = FALSE; |
402 | 1661 | 1811 | ||
403 | @@ -1685,7 +1835,7 @@ | |||
404 | 1685 | } | 1835 | } |
405 | 1686 | else | 1836 | else |
406 | 1687 | { | 1837 | { |
408 | 1688 | if (check_proximity (scrollbar, xiev->event_x, xiev->event_y, OS_SIDE_BOTTOM)) | 1838 | if (check_proximity (scrollbar, xiev->event_x, xiev->event_y)) |
409 | 1689 | { | 1839 | { |
410 | 1690 | priv->can_hide = FALSE; | 1840 | priv->can_hide = FALSE; |
411 | 1691 | 1841 | ||
412 | @@ -1776,7 +1926,7 @@ | |||
413 | 1776 | /* proximity area */ | 1926 | /* proximity area */ |
414 | 1777 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 1927 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
415 | 1778 | { | 1928 | { |
417 | 1779 | if (check_proximity (scrollbar, xiev->event_x, xiev->event_y, OS_SIDE_RIGHT)) | 1929 | if (check_proximity (scrollbar, xiev->event_x, xiev->event_y)) |
418 | 1780 | { | 1930 | { |
419 | 1781 | priv->can_hide = FALSE; | 1931 | priv->can_hide = FALSE; |
420 | 1782 | 1932 | ||
421 | @@ -1820,7 +1970,7 @@ | |||
422 | 1820 | } | 1970 | } |
423 | 1821 | else | 1971 | else |
424 | 1822 | { | 1972 | { |
426 | 1823 | if (check_proximity (scrollbar, xiev->event_x, xiev->event_y, OS_SIDE_BOTTOM)) | 1973 | if (check_proximity (scrollbar, xiev->event_x, xiev->event_y)) |
427 | 1824 | { | 1974 | { |
428 | 1825 | priv->can_hide = FALSE; | 1975 | priv->can_hide = FALSE; |
429 | 1826 | 1976 | ||
430 | @@ -1903,7 +2053,7 @@ | |||
431 | 1903 | /* proximity area */ | 2053 | /* proximity area */ |
432 | 1904 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 2054 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
433 | 1905 | { | 2055 | { |
435 | 1906 | if (check_proximity (scrollbar, xev->xbutton.x, xev->xbutton.y, OS_SIDE_RIGHT)) | 2056 | if (check_proximity (scrollbar, xev->xbutton.x, xev->xbutton.y)) |
436 | 1907 | { | 2057 | { |
437 | 1908 | priv->can_hide = FALSE; | 2058 | priv->can_hide = FALSE; |
438 | 1909 | 2059 | ||
439 | @@ -1933,7 +2083,7 @@ | |||
440 | 1933 | } | 2083 | } |
441 | 1934 | else | 2084 | else |
442 | 1935 | { | 2085 | { |
444 | 1936 | if (check_proximity (scrollbar, xev->xbutton.x, xev->xbutton.y, OS_SIDE_BOTTOM)) | 2086 | if (check_proximity (scrollbar, xev->xbutton.x, xev->xbutton.y)) |
445 | 1937 | { | 2087 | { |
446 | 1938 | priv->can_hide = FALSE; | 2088 | priv->can_hide = FALSE; |
447 | 1939 | 2089 | ||
448 | @@ -2021,7 +2171,7 @@ | |||
449 | 2021 | /* proximity area */ | 2171 | /* proximity area */ |
450 | 2022 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 2172 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
451 | 2023 | { | 2173 | { |
453 | 2024 | if (check_proximity (scrollbar, xev->xmotion.x, xev->xmotion.y, OS_SIDE_RIGHT)) | 2174 | if (check_proximity (scrollbar, xev->xmotion.x, xev->xmotion.y)) |
454 | 2025 | { | 2175 | { |
455 | 2026 | priv->can_hide = FALSE; | 2176 | priv->can_hide = FALSE; |
456 | 2027 | 2177 | ||
457 | @@ -2065,7 +2215,7 @@ | |||
458 | 2065 | } | 2215 | } |
459 | 2066 | else | 2216 | else |
460 | 2067 | { | 2217 | { |
462 | 2068 | if (check_proximity (scrollbar, xev->xmotion.x, xev->xmotion.y, OS_SIDE_BOTTOM)) | 2218 | if (check_proximity (scrollbar, xev->xmotion.x, xev->xmotion.y)) |
463 | 2069 | { | 2219 | { |
464 | 2070 | priv->can_hide = FALSE; | 2220 | priv->can_hide = FALSE; |
465 | 2071 | 2221 | ||
466 | @@ -2183,6 +2333,9 @@ | |||
467 | 2183 | gdk_window_set_events (root, gdk_window_get_events (root) | | 2333 | gdk_window_set_events (root, gdk_window_get_events (root) | |
468 | 2184 | GDK_PROPERTY_CHANGE_MASK); | 2334 | GDK_PROPERTY_CHANGE_MASK); |
469 | 2185 | gdk_window_add_filter (root, root_filter_func, NULL); | 2335 | gdk_window_add_filter (root, root_filter_func, NULL); |
470 | 2336 | |||
471 | 2337 | /* initialize the quark */ | ||
472 | 2338 | os_quark_placement = g_quark_from_string ("os_quark_placement"); | ||
473 | 2186 | } | 2339 | } |
474 | 2187 | else | 2340 | else |
475 | 2188 | { | 2341 | { |
476 | @@ -2204,6 +2357,7 @@ | |||
477 | 2204 | priv->lock_position = FALSE; | 2357 | priv->lock_position = FALSE; |
478 | 2205 | priv->proximity = FALSE; | 2358 | priv->proximity = FALSE; |
479 | 2206 | priv->toplevel_button_press = FALSE; | 2359 | priv->toplevel_button_press = FALSE; |
480 | 2360 | priv->side = OS_SIDE_RIGHT; | ||
481 | 2207 | priv->source_deactivate_pager_id = 0; | 2361 | priv->source_deactivate_pager_id = 0; |
482 | 2208 | priv->source_hide_thumb_id = 0; | 2362 | priv->source_hide_thumb_id = 0; |
483 | 2209 | priv->source_unlock_thumb_id = 0; | 2363 | priv->source_unlock_thumb_id = 0; |
484 | @@ -2453,6 +2607,50 @@ | |||
485 | 2453 | GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->show (widget); | 2607 | GTK_WIDGET_CLASS (g_type_class_peek (GTK_TYPE_WIDGET))->show (widget); |
486 | 2454 | } | 2608 | } |
487 | 2455 | 2609 | ||
488 | 2610 | /* retrieve the side of the scrollbar */ | ||
489 | 2611 | static void | ||
490 | 2612 | retrieve_side (OsScrollbar *scrollbar) | ||
491 | 2613 | { | ||
492 | 2614 | GtkCornerType corner; | ||
493 | 2615 | OsScrollbarPrivate *priv; | ||
494 | 2616 | |||
495 | 2617 | priv = scrollbar->priv; | ||
496 | 2618 | |||
497 | 2619 | corner = GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (scrollbar), os_quark_placement)); | ||
498 | 2620 | |||
499 | 2621 | if (GTK_SCROLLED_WINDOW (gtk_widget_get_parent (GTK_WIDGET (scrollbar)))) | ||
500 | 2622 | corner = gtk_scrolled_window_get_placement (GTK_SCROLLED_WINDOW (gtk_widget_get_parent (GTK_WIDGET (scrollbar)))); | ||
501 | 2623 | |||
502 | 2624 | /* GtkCornerType to OsSide */ | ||
503 | 2625 | if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) | ||
504 | 2626 | { | ||
505 | 2627 | if (corner == GTK_CORNER_TOP_LEFT || | ||
506 | 2628 | corner == GTK_CORNER_TOP_RIGHT) | ||
507 | 2629 | priv->side = OS_SIDE_BOTTOM; | ||
508 | 2630 | else | ||
509 | 2631 | priv->side = OS_SIDE_TOP; | ||
510 | 2632 | } | ||
511 | 2633 | else | ||
512 | 2634 | { | ||
513 | 2635 | if (gtk_widget_get_direction (GTK_WIDGET (scrollbar)) == GTK_TEXT_DIR_LTR) | ||
514 | 2636 | { | ||
515 | 2637 | if (corner == GTK_CORNER_TOP_LEFT || | ||
516 | 2638 | corner == GTK_CORNER_BOTTOM_LEFT) | ||
517 | 2639 | priv->side = OS_SIDE_RIGHT; | ||
518 | 2640 | else | ||
519 | 2641 | priv->side = OS_SIDE_LEFT; | ||
520 | 2642 | } | ||
521 | 2643 | else | ||
522 | 2644 | { | ||
523 | 2645 | if (corner == GTK_CORNER_TOP_RIGHT || | ||
524 | 2646 | corner == GTK_CORNER_BOTTOM_RIGHT) | ||
525 | 2647 | priv->side = OS_SIDE_RIGHT; | ||
526 | 2648 | else | ||
527 | 2649 | priv->side = OS_SIDE_LEFT; | ||
528 | 2650 | } | ||
529 | 2651 | } | ||
530 | 2652 | } | ||
531 | 2653 | |||
532 | 2456 | static void | 2654 | static void |
533 | 2457 | os_scrollbar_size_allocate (GtkWidget *widget, | 2655 | os_scrollbar_size_allocate (GtkWidget *widget, |
534 | 2458 | GdkRectangle *allocation) | 2656 | GdkRectangle *allocation) |
535 | @@ -2463,6 +2661,9 @@ | |||
536 | 2463 | scrollbar = OS_SCROLLBAR (widget); | 2661 | scrollbar = OS_SCROLLBAR (widget); |
537 | 2464 | priv = scrollbar->priv; | 2662 | priv = scrollbar->priv; |
538 | 2465 | 2663 | ||
539 | 2664 | /* get the side, then move thumb and pager accordingly. */ | ||
540 | 2665 | retrieve_side (scrollbar); | ||
541 | 2666 | |||
542 | 2466 | priv->trough.x = allocation->x; | 2667 | priv->trough.x = allocation->x; |
543 | 2467 | priv->trough.y = allocation->y; | 2668 | priv->trough.y = allocation->y; |
544 | 2468 | priv->trough.width = allocation->width; | 2669 | priv->trough.width = allocation->width; |
545 | @@ -2480,12 +2681,18 @@ | |||
546 | 2480 | os_thumb_resize (OS_THUMB (priv->thumb), priv->slider.width, priv->slider.height); | 2681 | os_thumb_resize (OS_THUMB (priv->thumb), priv->slider.width, priv->slider.height); |
547 | 2481 | } | 2682 | } |
548 | 2482 | 2683 | ||
550 | 2483 | priv->pager_all.x = allocation->x - PAGER_SIZE; | 2684 | if (priv->side == OS_SIDE_RIGHT) |
551 | 2685 | priv->pager_all.x = allocation->x - PAGER_SIZE; | ||
552 | 2686 | |||
553 | 2484 | priv->pager_all.width = PAGER_SIZE; | 2687 | priv->pager_all.width = PAGER_SIZE; |
554 | 2485 | 2688 | ||
555 | 2486 | priv->thumb_all.x = allocation->x + THUMB_ALLOCATION_SHIFT; | ||
556 | 2487 | priv->thumb_all.width = THUMB_WIDTH; | 2689 | priv->thumb_all.width = THUMB_WIDTH; |
557 | 2488 | 2690 | ||
558 | 2691 | if (priv->side == OS_SIDE_RIGHT) | ||
559 | 2692 | priv->thumb_all.x = allocation->x - priv->pager_all.width; | ||
560 | 2693 | else | ||
561 | 2694 | priv->thumb_all.x = allocation->x + priv->pager_all.width - priv->thumb_all.width; | ||
562 | 2695 | |||
563 | 2489 | allocation->width = 0; | 2696 | allocation->width = 0; |
564 | 2490 | } | 2697 | } |
565 | 2491 | else | 2698 | else |
566 | @@ -2497,11 +2704,17 @@ | |||
567 | 2497 | os_thumb_resize (OS_THUMB (priv->thumb), priv->slider.width, priv->slider.height); | 2704 | os_thumb_resize (OS_THUMB (priv->thumb), priv->slider.width, priv->slider.height); |
568 | 2498 | } | 2705 | } |
569 | 2499 | 2706 | ||
571 | 2500 | priv->pager_all.y = allocation->y - PAGER_SIZE; | 2707 | if (priv->side == OS_SIDE_BOTTOM) |
572 | 2708 | priv->pager_all.y = allocation->y - PAGER_SIZE; | ||
573 | 2709 | |||
574 | 2501 | priv->pager_all.height = PAGER_SIZE; | 2710 | priv->pager_all.height = PAGER_SIZE; |
575 | 2502 | 2711 | ||
578 | 2503 | priv->thumb_all.y = allocation->y + THUMB_ALLOCATION_SHIFT; | 2712 | priv->thumb_all.height = THUMB_WIDTH; |
579 | 2504 | priv->thumb_all.height = THUMB_HEIGHT; | 2713 | |
580 | 2714 | if (priv->side == OS_SIDE_BOTTOM) | ||
581 | 2715 | priv->thumb_all.y = allocation->y - priv->pager_all.height; | ||
582 | 2716 | else | ||
583 | 2717 | priv->thumb_all.y = allocation->y + priv->pager_all.height - priv->thumb_all.height; | ||
584 | 2505 | 2718 | ||
585 | 2506 | allocation->height = 0; | 2719 | allocation->height = 0; |
586 | 2507 | } | 2720 | } |
587 | 2508 | 2721 | ||
588 | === modified file 'os/os-utils.c' | |||
589 | --- os/os-utils.c 2011-06-09 12:45:39 +0000 | |||
590 | +++ os/os-utils.c 2011-06-29 10:01:21 +0000 | |||
591 | @@ -41,7 +41,6 @@ | |||
592 | 41 | "firefox-bin", | 41 | "firefox-bin", |
593 | 42 | "gnucash", | 42 | "gnucash", |
594 | 43 | "gvim", | 43 | "gvim", |
595 | 44 | "meld", | ||
596 | 45 | "pgadmin3", | 44 | "pgadmin3", |
597 | 46 | "soffice", | 45 | "soffice", |
598 | 47 | "synaptic", | 46 | "synaptic", |
599 | @@ -65,10 +64,6 @@ | |||
600 | 65 | } | 64 | } |
601 | 66 | g_module_close (module); | 65 | g_module_close (module); |
602 | 67 | 66 | ||
603 | 68 | /* Black list RTL languages, not supported yet */ | ||
604 | 69 | if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) | ||
605 | 70 | return TRUE; | ||
606 | 71 | |||
607 | 72 | for (i = 0; i < nr_programs; i++) | 67 | for (i = 0; i < nr_programs; i++) |
608 | 73 | if (g_strcmp0 (blacklist[i], program) == 0) | 68 | if (g_strcmp0 (blacklist[i], program) == 0) |
609 | 74 | return TRUE; | 69 | return TRUE; |
610 | 75 | 70 | ||
611 | === modified file 'tests/test-os.c' | |||
612 | --- tests/test-os.c 2011-03-02 15:29:56 +0000 | |||
613 | +++ tests/test-os.c 2011-06-29 10:01:21 +0000 | |||
614 | @@ -270,6 +270,7 @@ | |||
615 | 270 | text_view0 = gtk_text_view_new (); | 270 | text_view0 = gtk_text_view_new (); |
616 | 271 | gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window_text0), text_view0); | 271 | gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window_text0), text_view0); |
617 | 272 | gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window_text0), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | 272 | gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window_text0), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
618 | 273 | gtk_scrolled_window_set_placement (GTK_SCROLLED_WINDOW (scrolled_window_text0), GTK_CORNER_BOTTOM_RIGHT); | ||
619 | 273 | 274 | ||
620 | 274 | /* text_buffer0 */ | 275 | /* text_buffer0 */ |
621 | 275 | text_buffer0 = gtk_text_view_get_buffer(GTK_TEXT_VIEW (text_view0)); | 276 | text_buffer0 = gtk_text_view_get_buffer(GTK_TEXT_VIEW (text_view0)); |
Need to initialize side.