Merge lp:~ayatana-scrollbar-team/overlay-scrollbar/use-backdrop-state-flag-instead-root-filter into lp:overlay-scrollbar
- use-backdrop-state-flag-instead-root-filter
- Merge into trunk
Proposed by
Andrea Cimitan
Status: | Merged |
---|---|
Approved by: | Ted Gould |
Approved revision: | 346 |
Merged at revision: | 346 |
Proposed branch: | lp:~ayatana-scrollbar-team/overlay-scrollbar/use-backdrop-state-flag-instead-root-filter |
Merge into: | lp:overlay-scrollbar |
Diff against target: |
386 lines (+117/-87) 1 file modified
os/os-scrollbar.c (+117/-87) |
To merge this branch: | bzr merge lp:~ayatana-scrollbar-team/overlay-scrollbar/use-backdrop-state-flag-instead-root-filter |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ted Gould (community) | Approve | ||
Review via email: mp+104789@code.launchpad.net |
Commit message
Description of the change
Try removing code not needed with latest gtk3
To post a comment you must log in.
Revision history for this message
Andrea Cimitan (cimi) wrote : | # |
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 'os/os-scrollbar.c' | |||
2 | --- os/os-scrollbar.c 2012-04-27 13:49:56 +0000 | |||
3 | +++ os/os-scrollbar.c 2012-05-04 18:27:26 +0000 | |||
4 | @@ -125,7 +125,9 @@ | |||
5 | 125 | OsWindowFilter filter; | 125 | OsWindowFilter filter; |
6 | 126 | gboolean active_window; | 126 | gboolean active_window; |
7 | 127 | gboolean allow_resize; | 127 | gboolean allow_resize; |
8 | 128 | #ifdef USE_GTK3 | ||
9 | 128 | gboolean deactivable_bar; | 129 | gboolean deactivable_bar; |
10 | 130 | #endif | ||
11 | 129 | gboolean hidable_thumb; | 131 | gboolean hidable_thumb; |
12 | 130 | gboolean window_button_press; /* FIXME(Cimi) to replace with X11 input events. */ | 132 | gboolean window_button_press; /* FIXME(Cimi) to replace with X11 input events. */ |
13 | 131 | gdouble value; | 133 | gdouble value; |
14 | @@ -573,6 +575,7 @@ | |||
15 | 573 | return value; | 575 | return value; |
16 | 574 | } | 576 | } |
17 | 575 | 577 | ||
18 | 578 | #ifdef USE_GTK3 | ||
19 | 576 | /* Deactivate the bar if it's the case. */ | 579 | /* Deactivate the bar if it's the case. */ |
20 | 577 | static void | 580 | static void |
21 | 578 | deactivate_bar (GtkScrollbar *scrollbar) | 581 | deactivate_bar (GtkScrollbar *scrollbar) |
22 | @@ -602,6 +605,7 @@ | |||
23 | 602 | 605 | ||
24 | 603 | return FALSE; | 606 | return FALSE; |
25 | 604 | } | 607 | } |
26 | 608 | #endif | ||
27 | 605 | 609 | ||
28 | 606 | /* Get the private struct. */ | 610 | /* Get the private struct. */ |
29 | 607 | static OsScrollbarPrivate* | 611 | static OsScrollbarPrivate* |
30 | @@ -647,7 +651,9 @@ | |||
31 | 647 | 651 | ||
32 | 648 | /* Initialize struct variables. */ | 652 | /* Initialize struct variables. */ |
33 | 649 | qdata->side = OS_SIDE_RIGHT; | 653 | qdata->side = OS_SIDE_RIGHT; |
34 | 654 | #ifdef USE_GTK3 | ||
35 | 650 | qdata->deactivable_bar = TRUE; | 655 | qdata->deactivable_bar = TRUE; |
36 | 656 | #endif | ||
37 | 651 | qdata->hidable_thumb = TRUE; | 657 | qdata->hidable_thumb = TRUE; |
38 | 652 | qdata->fine_scroll_multiplier = 1.0; | 658 | qdata->fine_scroll_multiplier = 1.0; |
39 | 653 | qdata->bar = os_bar_new (); | 659 | qdata->bar = os_bar_new (); |
40 | @@ -1480,6 +1486,7 @@ | |||
41 | 1480 | move_bar (scrollbar); | 1486 | move_bar (scrollbar); |
42 | 1481 | } | 1487 | } |
43 | 1482 | 1488 | ||
44 | 1489 | #ifdef USE_GTK3 | ||
45 | 1483 | /* Bar functions. */ | 1490 | /* Bar functions. */ |
46 | 1484 | 1491 | ||
47 | 1485 | /* Set the state of the bar checking mouse position. */ | 1492 | /* Set the state of the bar checking mouse position. */ |
48 | @@ -1509,89 +1516,10 @@ | |||
49 | 1509 | os_bar_set_active (priv->bar, FALSE, TRUE); | 1516 | os_bar_set_active (priv->bar, FALSE, TRUE); |
50 | 1510 | } | 1517 | } |
51 | 1511 | } | 1518 | } |
52 | 1519 | #endif | ||
53 | 1512 | 1520 | ||
54 | 1513 | /* Root window functions. */ | 1521 | /* Root window functions. */ |
55 | 1514 | 1522 | ||
56 | 1515 | /* React on active window changes. */ | ||
57 | 1516 | static void | ||
58 | 1517 | root_gfunc (gpointer data, | ||
59 | 1518 | gpointer user_data) | ||
60 | 1519 | { | ||
61 | 1520 | GtkScrollbar *scrollbar; | ||
62 | 1521 | OsScrollbarPrivate *priv; | ||
63 | 1522 | |||
64 | 1523 | scrollbar = GTK_SCROLLBAR (data); | ||
65 | 1524 | priv = get_private (GTK_WIDGET (scrollbar)); | ||
66 | 1525 | |||
67 | 1526 | OS_DCHECK (scrollbar != NULL); | ||
68 | 1527 | |||
69 | 1528 | /* Return if the scrollbar is insensitive. */ | ||
70 | 1529 | if (is_insensitive (scrollbar)) | ||
71 | 1530 | return; | ||
72 | 1531 | |||
73 | 1532 | if (gtk_widget_get_mapped (GTK_WIDGET (scrollbar))) | ||
74 | 1533 | { | ||
75 | 1534 | if (gtk_widget_get_window (gtk_widget_get_toplevel (GTK_WIDGET (scrollbar))) == | ||
76 | 1535 | gdk_screen_get_active_window (gtk_widget_get_screen (GTK_WIDGET (scrollbar)))) | ||
77 | 1536 | { | ||
78 | 1537 | /* Stops potential running timeout. */ | ||
79 | 1538 | if (priv->source_deactivate_bar_id != 0) | ||
80 | 1539 | { | ||
81 | 1540 | g_source_remove (priv->source_deactivate_bar_id); | ||
82 | 1541 | priv->source_deactivate_bar_id = 0; | ||
83 | 1542 | } | ||
84 | 1543 | |||
85 | 1544 | priv->active_window = TRUE; | ||
86 | 1545 | |||
87 | 1546 | priv->deactivable_bar = FALSE; | ||
88 | 1547 | os_bar_set_active (priv->bar, TRUE, TRUE); | ||
89 | 1548 | } | ||
90 | 1549 | else if (priv->active_window) | ||
91 | 1550 | { | ||
92 | 1551 | GdkWindow *parent; | ||
93 | 1552 | GdkWindow *window; | ||
94 | 1553 | const gint64 current_time = g_get_monotonic_time (); | ||
95 | 1554 | const gint64 end_time = priv->present_time + TIMEOUT_PRESENT_WINDOW * 1000; | ||
96 | 1555 | |||
97 | 1556 | priv->active_window = FALSE; | ||
98 | 1557 | |||
99 | 1558 | /* Loop through parent windows until it reaches | ||
100 | 1559 | * either an unknown GdkWindow (NULL), | ||
101 | 1560 | * or the toplevel window. */ | ||
102 | 1561 | window = gtk_widget_get_window (GTK_WIDGET (scrollbar)); | ||
103 | 1562 | parent = window_at_pointer (window, NULL, NULL); | ||
104 | 1563 | while (parent != NULL) | ||
105 | 1564 | { | ||
106 | 1565 | if (window == parent) | ||
107 | 1566 | break; | ||
108 | 1567 | |||
109 | 1568 | parent = gdk_window_get_parent (parent); | ||
110 | 1569 | } | ||
111 | 1570 | |||
112 | 1571 | if (parent != NULL) | ||
113 | 1572 | { | ||
114 | 1573 | gint x, y; | ||
115 | 1574 | |||
116 | 1575 | window_get_pointer (window, &x, &y, NULL); | ||
117 | 1576 | |||
118 | 1577 | /* When the window is unfocused, | ||
119 | 1578 | * check the position of the pointer | ||
120 | 1579 | * and set the state accordingly. */ | ||
121 | 1580 | bar_set_state_from_pointer (scrollbar, x, y); | ||
122 | 1581 | } | ||
123 | 1582 | else | ||
124 | 1583 | { | ||
125 | 1584 | /* If the pointer is outside of the window, set it inactive. */ | ||
126 | 1585 | priv->deactivable_bar = TRUE; | ||
127 | 1586 | os_bar_set_active (priv->bar, FALSE, TRUE); | ||
128 | 1587 | } | ||
129 | 1588 | |||
130 | 1589 | if ((current_time > end_time) && priv->thumb != NULL) | ||
131 | 1590 | gtk_widget_hide (priv->thumb); | ||
132 | 1591 | } | ||
133 | 1592 | } | ||
134 | 1593 | } | ||
135 | 1594 | |||
136 | 1595 | /* Filter function applied to the root window. */ | 1523 | /* Filter function applied to the root window. */ |
137 | 1596 | static GdkFilterReturn | 1524 | static GdkFilterReturn |
138 | 1597 | root_filter_func (GdkXEvent *gdkxevent, | 1525 | root_filter_func (GdkXEvent *gdkxevent, |
139 | @@ -1604,11 +1532,7 @@ | |||
140 | 1604 | 1532 | ||
141 | 1605 | if (xev->type == PropertyNotify) | 1533 | if (xev->type == PropertyNotify) |
142 | 1606 | { | 1534 | { |
148 | 1607 | if (xev->xproperty.atom == net_active_window_atom) | 1535 | if (xev->xproperty.atom == unity_net_workarea_region_atom) |
144 | 1608 | { | ||
145 | 1609 | g_slist_foreach (os_root_list, root_gfunc, NULL); | ||
146 | 1610 | } | ||
147 | 1611 | else if (xev->xproperty.atom == unity_net_workarea_region_atom) | ||
149 | 1612 | { | 1536 | { |
150 | 1613 | calc_workarea (xev->xany.display, xev->xany.window); | 1537 | calc_workarea (xev->xany.display, xev->xany.window); |
151 | 1614 | } | 1538 | } |
152 | @@ -1914,7 +1838,9 @@ | |||
153 | 1914 | 1838 | ||
154 | 1915 | priv->event |= OS_EVENT_ENTER_NOTIFY; | 1839 | priv->event |= OS_EVENT_ENTER_NOTIFY; |
155 | 1916 | 1840 | ||
156 | 1841 | #ifdef USE_GTK3 | ||
157 | 1917 | priv->deactivable_bar = FALSE; | 1842 | priv->deactivable_bar = FALSE; |
158 | 1843 | #endif | ||
159 | 1918 | priv->hidable_thumb = FALSE; | 1844 | priv->hidable_thumb = FALSE; |
160 | 1919 | 1845 | ||
161 | 1920 | if (priv->state & OS_STATE_INTERNAL) | 1846 | if (priv->state & OS_STATE_INTERNAL) |
162 | @@ -1986,6 +1912,7 @@ | |||
163 | 1986 | * not interacting with the thumb. */ | 1912 | * not interacting with the thumb. */ |
164 | 1987 | if (!(priv->event & OS_EVENT_BUTTON_PRESS)) | 1913 | if (!(priv->event & OS_EVENT_BUTTON_PRESS)) |
165 | 1988 | { | 1914 | { |
166 | 1915 | #ifdef USE_GTK3 | ||
167 | 1989 | /* Never deactivate the bar in an active window. */ | 1916 | /* Never deactivate the bar in an active window. */ |
168 | 1990 | if (!priv->active_window) | 1917 | if (!priv->active_window) |
169 | 1991 | { | 1918 | { |
170 | @@ -1998,6 +1925,7 @@ | |||
171 | 1998 | deactivate_bar_cb, | 1925 | deactivate_bar_cb, |
172 | 1999 | scrollbar); | 1926 | scrollbar); |
173 | 2000 | } | 1927 | } |
174 | 1928 | #endif | ||
175 | 2001 | 1929 | ||
176 | 2002 | priv->event &= ~(OS_EVENT_ENTER_NOTIFY); | 1930 | priv->event &= ~(OS_EVENT_ENTER_NOTIFY); |
177 | 2003 | 1931 | ||
178 | @@ -2029,9 +1957,11 @@ | |||
179 | 2029 | scrollbar = GTK_SCROLLBAR (user_data); | 1957 | scrollbar = GTK_SCROLLBAR (user_data); |
180 | 2030 | priv = get_private (GTK_WIDGET (scrollbar)); | 1958 | priv = get_private (GTK_WIDGET (scrollbar)); |
181 | 2031 | 1959 | ||
182 | 1960 | #ifdef USE_GTK3 | ||
183 | 2032 | /* Immediately set the bar to be active. */ | 1961 | /* Immediately set the bar to be active. */ |
184 | 2033 | priv->deactivable_bar = FALSE; | 1962 | priv->deactivable_bar = FALSE; |
185 | 2034 | os_bar_set_active (priv->bar, TRUE, FALSE); | 1963 | os_bar_set_active (priv->bar, TRUE, FALSE); |
186 | 1964 | #endif | ||
187 | 2035 | 1965 | ||
188 | 2036 | xid = GDK_WINDOW_XID (gtk_widget_get_window (widget)); | 1966 | xid = GDK_WINDOW_XID (gtk_widget_get_window (widget)); |
189 | 2037 | xid_parent = GDK_WINDOW_XID (gtk_widget_get_window (gtk_widget_get_toplevel (GTK_WIDGET (scrollbar)))); | 1967 | xid_parent = GDK_WINDOW_XID (gtk_widget_get_window (gtk_widget_get_toplevel (GTK_WIDGET (scrollbar)))); |
190 | @@ -2566,6 +2496,7 @@ | |||
191 | 2566 | const gint64 current_time = g_get_monotonic_time (); | 2496 | const gint64 current_time = g_get_monotonic_time (); |
192 | 2567 | const gint64 end_time = priv->present_time + TIMEOUT_PRESENT_WINDOW * 1000; | 2497 | const gint64 end_time = priv->present_time + TIMEOUT_PRESENT_WINDOW * 1000; |
193 | 2568 | 2498 | ||
194 | 2499 | #ifdef USE_GTK3 | ||
195 | 2569 | /* If the widget is mapped, is not insentitive | 2500 | /* If the widget is mapped, is not insentitive |
196 | 2570 | * and the configure-event happens after | 2501 | * and the configure-event happens after |
197 | 2571 | * the PropertyNotify _NET_ACTIVE_WINDOW event, | 2502 | * the PropertyNotify _NET_ACTIVE_WINDOW event, |
198 | @@ -2609,6 +2540,7 @@ | |||
199 | 2609 | os_bar_set_active (priv->bar, TRUE, TRUE); | 2540 | os_bar_set_active (priv->bar, TRUE, TRUE); |
200 | 2610 | } | 2541 | } |
201 | 2611 | } | 2542 | } |
202 | 2543 | #endif | ||
203 | 2612 | 2544 | ||
204 | 2613 | if (current_time > end_time) | 2545 | if (current_time > end_time) |
205 | 2614 | gtk_widget_hide (priv->thumb); | 2546 | gtk_widget_hide (priv->thumb); |
206 | @@ -3027,6 +2959,7 @@ | |||
207 | 3027 | { | 2959 | { |
208 | 3028 | priv->window_button_press = FALSE; | 2960 | priv->window_button_press = FALSE; |
209 | 3029 | 2961 | ||
210 | 2962 | #ifdef USE_GTK3 | ||
211 | 3030 | /* Never deactivate the bar in an active window. */ | 2963 | /* Never deactivate the bar in an active window. */ |
212 | 3031 | if (!priv->active_window) | 2964 | if (!priv->active_window) |
213 | 3032 | { | 2965 | { |
214 | @@ -3039,6 +2972,7 @@ | |||
215 | 3039 | deactivate_bar_cb, | 2972 | deactivate_bar_cb, |
216 | 3040 | scrollbar); | 2973 | scrollbar); |
217 | 3041 | } | 2974 | } |
218 | 2975 | #endif | ||
219 | 3042 | 2976 | ||
220 | 3043 | if (gtk_widget_get_mapped (priv->thumb) && | 2977 | if (gtk_widget_get_mapped (priv->thumb) && |
221 | 3044 | !(priv->event & OS_EVENT_BUTTON_PRESS)) | 2978 | !(priv->event & OS_EVENT_BUTTON_PRESS)) |
222 | @@ -3070,10 +3004,12 @@ | |||
223 | 3070 | /* Get the motion_notify_event trough XEvent. */ | 3004 | /* Get the motion_notify_event trough XEvent. */ |
224 | 3071 | if (!priv->window_button_press && os_xevent == OS_XEVENT_MOTION) | 3005 | if (!priv->window_button_press && os_xevent == OS_XEVENT_MOTION) |
225 | 3072 | { | 3006 | { |
226 | 3007 | #ifdef USE_GTK3 | ||
227 | 3073 | /* React to motion_notify_event | 3008 | /* React to motion_notify_event |
228 | 3074 | * and set the state accordingly. */ | 3009 | * and set the state accordingly. */ |
229 | 3075 | if (!is_insensitive (scrollbar) && !priv->active_window) | 3010 | if (!is_insensitive (scrollbar) && !priv->active_window) |
230 | 3076 | bar_set_state_from_pointer (scrollbar, event_x, event_y); | 3011 | bar_set_state_from_pointer (scrollbar, event_x, event_y); |
231 | 3012 | #endif | ||
232 | 3077 | 3013 | ||
233 | 3078 | /* Proximity area. */ | 3014 | /* Proximity area. */ |
234 | 3079 | if (check_proximity (scrollbar, event_x, event_y)) | 3015 | if (check_proximity (scrollbar, event_x, event_y)) |
235 | @@ -3335,6 +3271,15 @@ | |||
236 | 3335 | (* pre_hijacked_scrollbar_hide) (widget); | 3271 | (* pre_hijacked_scrollbar_hide) (widget); |
237 | 3336 | } | 3272 | } |
238 | 3337 | 3273 | ||
239 | 3274 | #ifdef USE_GTK3 | ||
240 | 3275 | /* Return TRUE if the widget is in backdrop window. */ | ||
241 | 3276 | static gboolean | ||
242 | 3277 | is_backdrop_window (GtkWidget *widget) | ||
243 | 3278 | { | ||
244 | 3279 | return (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_BACKDROP) != 0; | ||
245 | 3280 | } | ||
246 | 3281 | #endif | ||
247 | 3282 | |||
248 | 3338 | static void | 3283 | static void |
249 | 3339 | hijacked_scrollbar_map (GtkWidget *widget) | 3284 | hijacked_scrollbar_map (GtkWidget *widget) |
250 | 3340 | { | 3285 | { |
251 | @@ -3348,9 +3293,9 @@ | |||
252 | 3348 | 3293 | ||
253 | 3349 | (* widget_class_map) (widget); | 3294 | (* widget_class_map) (widget); |
254 | 3350 | 3295 | ||
255 | 3296 | #ifdef USE_GTK3 | ||
256 | 3351 | /* On map, check for the active window. */ | 3297 | /* On map, check for the active window. */ |
259 | 3352 | if (gtk_widget_get_window (gtk_widget_get_toplevel (widget)) == | 3298 | if (!is_backdrop_window (GTK_WIDGET (scrollbar))) |
258 | 3353 | gdk_screen_get_active_window (gtk_widget_get_screen (widget))) | ||
260 | 3354 | { | 3299 | { |
261 | 3355 | /* Stops potential running timeout. */ | 3300 | /* Stops potential running timeout. */ |
262 | 3356 | if (priv->source_deactivate_bar_id != 0) | 3301 | if (priv->source_deactivate_bar_id != 0) |
263 | @@ -3386,6 +3331,7 @@ | |||
264 | 3386 | os_bar_set_active (priv->bar, TRUE, FALSE); | 3331 | os_bar_set_active (priv->bar, TRUE, FALSE); |
265 | 3387 | } | 3332 | } |
266 | 3388 | } | 3333 | } |
267 | 3334 | #endif | ||
268 | 3389 | 3335 | ||
269 | 3390 | if (!(priv->state & OS_STATE_FULLSIZE)) | 3336 | if (!(priv->state & OS_STATE_FULLSIZE)) |
270 | 3391 | os_bar_show (priv->bar); | 3337 | os_bar_show (priv->bar); |
271 | @@ -3653,7 +3599,9 @@ | |||
272 | 3653 | priv->filter.proximity = FALSE; | 3599 | priv->filter.proximity = FALSE; |
273 | 3654 | remove_window_filter (scrollbar); | 3600 | remove_window_filter (scrollbar); |
274 | 3655 | 3601 | ||
275 | 3602 | #ifdef USE_GTK3 | ||
276 | 3656 | os_bar_set_active (priv->bar, FALSE, FALSE); | 3603 | os_bar_set_active (priv->bar, FALSE, FALSE); |
277 | 3604 | #endif | ||
278 | 3657 | 3605 | ||
279 | 3658 | gtk_widget_hide (priv->thumb); | 3606 | gtk_widget_hide (priv->thumb); |
280 | 3659 | } | 3607 | } |
281 | @@ -3675,6 +3623,7 @@ | |||
282 | 3675 | add_window_filter (scrollbar); | 3623 | add_window_filter (scrollbar); |
283 | 3676 | } | 3624 | } |
284 | 3677 | 3625 | ||
285 | 3626 | #ifdef USE_GTK3 | ||
286 | 3678 | if (priv->active_window) | 3627 | if (priv->active_window) |
287 | 3679 | os_bar_set_active (priv->bar, TRUE, FALSE); | 3628 | os_bar_set_active (priv->bar, TRUE, FALSE); |
288 | 3680 | else if (gtk_widget_get_realized (GTK_WIDGET (scrollbar))) | 3629 | else if (gtk_widget_get_realized (GTK_WIDGET (scrollbar))) |
289 | @@ -3688,9 +3637,86 @@ | |||
290 | 3688 | * and set the state accordingly. */ | 3637 | * and set the state accordingly. */ |
291 | 3689 | bar_set_state_from_pointer (scrollbar, x, y); | 3638 | bar_set_state_from_pointer (scrollbar, x, y); |
292 | 3690 | } | 3639 | } |
293 | 3640 | #endif | ||
294 | 3691 | } | 3641 | } |
295 | 3692 | 3642 | ||
296 | 3693 | #ifdef USE_GTK3 | 3643 | #ifdef USE_GTK3 |
297 | 3644 | /* React on active window changes. */ | ||
298 | 3645 | static void | ||
299 | 3646 | backdrop_state_flag_changed (GtkScrollbar *scrollbar) | ||
300 | 3647 | { | ||
301 | 3648 | OsScrollbarPrivate *priv; | ||
302 | 3649 | |||
303 | 3650 | priv = get_private (GTK_WIDGET (scrollbar)); | ||
304 | 3651 | |||
305 | 3652 | OS_DCHECK (scrollbar != NULL); | ||
306 | 3653 | |||
307 | 3654 | /* Return if the scrollbar is insensitive. */ | ||
308 | 3655 | if (is_insensitive (scrollbar)) | ||
309 | 3656 | return; | ||
310 | 3657 | |||
311 | 3658 | if (gtk_widget_get_mapped (GTK_WIDGET (scrollbar))) | ||
312 | 3659 | { | ||
313 | 3660 | if (!is_backdrop_window (GTK_WIDGET (scrollbar))) | ||
314 | 3661 | { | ||
315 | 3662 | /* Stops potential running timeout. */ | ||
316 | 3663 | if (priv->source_deactivate_bar_id != 0) | ||
317 | 3664 | { | ||
318 | 3665 | g_source_remove (priv->source_deactivate_bar_id); | ||
319 | 3666 | priv->source_deactivate_bar_id = 0; | ||
320 | 3667 | } | ||
321 | 3668 | |||
322 | 3669 | priv->active_window = TRUE; | ||
323 | 3670 | |||
324 | 3671 | priv->deactivable_bar = FALSE; | ||
325 | 3672 | os_bar_set_active (priv->bar, TRUE, TRUE); | ||
326 | 3673 | } | ||
327 | 3674 | else if (priv->active_window) | ||
328 | 3675 | { | ||
329 | 3676 | GdkWindow *parent; | ||
330 | 3677 | GdkWindow *window; | ||
331 | 3678 | const gint64 current_time = g_get_monotonic_time (); | ||
332 | 3679 | const gint64 end_time = priv->present_time + TIMEOUT_PRESENT_WINDOW * 1000; | ||
333 | 3680 | |||
334 | 3681 | priv->active_window = FALSE; | ||
335 | 3682 | |||
336 | 3683 | /* Loop through parent windows until it reaches | ||
337 | 3684 | * either an unknown GdkWindow (NULL), | ||
338 | 3685 | * or the toplevel window. */ | ||
339 | 3686 | window = gtk_widget_get_window (GTK_WIDGET (scrollbar)); | ||
340 | 3687 | parent = window_at_pointer (window, NULL, NULL); | ||
341 | 3688 | while (parent != NULL) | ||
342 | 3689 | { | ||
343 | 3690 | if (window == parent) | ||
344 | 3691 | break; | ||
345 | 3692 | |||
346 | 3693 | parent = gdk_window_get_parent (parent); | ||
347 | 3694 | } | ||
348 | 3695 | |||
349 | 3696 | if (parent != NULL) | ||
350 | 3697 | { | ||
351 | 3698 | gint x, y; | ||
352 | 3699 | |||
353 | 3700 | window_get_pointer (window, &x, &y, NULL); | ||
354 | 3701 | |||
355 | 3702 | /* When the window is unfocused, | ||
356 | 3703 | * check the position of the pointer | ||
357 | 3704 | * and set the state accordingly. */ | ||
358 | 3705 | bar_set_state_from_pointer (scrollbar, x, y); | ||
359 | 3706 | } | ||
360 | 3707 | else | ||
361 | 3708 | { | ||
362 | 3709 | /* If the pointer is outside of the window, set it inactive. */ | ||
363 | 3710 | priv->deactivable_bar = TRUE; | ||
364 | 3711 | os_bar_set_active (priv->bar, FALSE, TRUE); | ||
365 | 3712 | } | ||
366 | 3713 | |||
367 | 3714 | if ((current_time > end_time) && priv->thumb != NULL) | ||
368 | 3715 | gtk_widget_hide (priv->thumb); | ||
369 | 3716 | } | ||
370 | 3717 | } | ||
371 | 3718 | } | ||
372 | 3719 | |||
373 | 3694 | static void | 3720 | static void |
374 | 3695 | hijacked_scrollbar_state_flags_changed (GtkWidget *widget, | 3721 | hijacked_scrollbar_state_flags_changed (GtkWidget *widget, |
375 | 3696 | GtkStateFlags flags) | 3722 | GtkStateFlags flags) |
376 | @@ -3699,6 +3725,10 @@ | |||
377 | 3699 | 3725 | ||
378 | 3700 | scrollbar = GTK_SCROLLBAR (widget); | 3726 | scrollbar = GTK_SCROLLBAR (widget); |
379 | 3701 | 3727 | ||
380 | 3728 | if ((flags & GTK_STATE_FLAG_BACKDROP) != | ||
381 | 3729 | (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_BACKDROP)) | ||
382 | 3730 | backdrop_state_flag_changed (scrollbar); | ||
383 | 3731 | |||
384 | 3702 | /* Only set the new state if the right bit changed. */ | 3732 | /* Only set the new state if the right bit changed. */ |
385 | 3703 | if ((flags & GTK_STATE_FLAG_INSENSITIVE) != | 3733 | if ((flags & GTK_STATE_FLAG_INSENSITIVE) != |
386 | 3704 | (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_INSENSITIVE)) | 3734 | (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_INSENSITIVE)) |
I know the #ifdef are ugly, but gtk+2 doesn't have backdrop state flag...