Merge lp:~cimi/overlay-scrollbar/hide-thumb-on-selection into lp:overlay-scrollbar

Proposed by Andrea Cimitan
Status: Merged
Approved by: Ted Gould
Approved revision: 220
Merged at revision: 235
Proposed branch: lp:~cimi/overlay-scrollbar/hide-thumb-on-selection
Merge into: lp:overlay-scrollbar
Diff against target: 122 lines (+83/-1)
1 file modified
os/os-scrollbar.c (+83/-1)
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/hide-thumb-on-selection
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Mirco Müller Pending
Review via email: mp+58296@code.launchpad.net

Description of the change

store a gboolean that is set to TRUE when mouse clicking, and FALSE on mouse release

To post a comment you must log in.
213. By Andrea Cimitan

User the filter func for the LeaveNotify, as it is not called when moving in internal gdkwindows

214. By Andrea Cimitan

Moved the leave_notify_event in toplevel_filter_func

215. By Andrea Cimitan

indent

Revision history for this message
Mirco Müller (macslow) wrote :

As a general rule of thumb, I would _always_ initialize variables upon declaration and also always check any pointers (xev, gdkevent) against NULL upon function-entry.

Revision history for this message
Mirco Müller (macslow) wrote :

There's a lot of math going on to check for thresholds/limits. I would put those into functions (or macros) to make the condition-checking (if-statements) more readable and make any potential/later changes to them less tedious and error-prone.

216. By Andrea Cimitan

reverted change in variable name

217. By Andrea Cimitan

ops, I suddenly merged a different branch, now ok

Revision history for this message
Ted Gould (ted) wrote :

top_level_button_press needs to be initialized to FALSE.

review: Needs Fixing
218. By Andrea Cimitan

Initialize toplevel_button_press

219. By Andrea Cimitan

Merged trunk

220. By Andrea Cimitan

should enter leavenotify also when toplevel_button_press is FALSE

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 2011-05-17 17:04:30 +0000
3+++ os/os-scrollbar.c 2011-05-17 17:23:23 +0000
4@@ -65,6 +65,7 @@
5 gboolean active_window;
6 gboolean can_deactivate_pager;
7 gboolean can_hide;
8+ gboolean toplevel_button_press;
9 gboolean filter;
10 gboolean fullsize;
11 gboolean internal;
12@@ -1433,6 +1434,85 @@
13
14 if (!priv->fullsize)
15 {
16+ if (xevent->type == ButtonPress)
17+ {
18+ priv->toplevel_button_press = TRUE;
19+ gtk_widget_hide (priv->thumb);
20+ }
21+
22+ if (priv->toplevel_button_press && xevent->type == ButtonRelease)
23+ {
24+ priv->toplevel_button_press = FALSE;
25+
26+ /* proximity area */
27+ if (priv->orientation == GTK_ORIENTATION_VERTICAL)
28+ {
29+ if ((priv->thumb_all.x - xevent->xbutton.x <= PROXIMITY_WIDTH &&
30+ priv->thumb_all.x - xevent->xbutton.x >= 0) &&
31+ (xevent->xbutton.y >= priv->thumb_all.y + priv->overlay.y &&
32+ xevent->xbutton.y <= priv->thumb_all.y + priv->overlay.y + priv->overlay.height))
33+ {
34+ priv->can_hide = FALSE;
35+
36+ if (priv->lock_position)
37+ return GDK_FILTER_CONTINUE;
38+
39+ if (priv->overlay.height > priv->slider.height)
40+ {
41+ gint x, y, x_pos, y_pos;
42+
43+ gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos);
44+
45+ x = priv->thumb_all.x;
46+ y = CLAMP (xevent->xbutton.y - priv->slider.height / 2,
47+ priv->thumb_all.y + priv->overlay.y,
48+ priv->thumb_all.y + priv->overlay.y + priv->overlay.height - priv->slider.height);
49+
50+ os_scrollbar_move_thumb (scrollbar, x_pos + x, y_pos + y);
51+ }
52+ else
53+ {
54+ os_scrollbar_move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y);
55+ }
56+
57+ gtk_widget_show (GTK_WIDGET (priv->thumb));
58+ }
59+ }
60+ else
61+ {
62+ if ((priv->thumb_all.y - xevent->xbutton.y <= PROXIMITY_WIDTH &&
63+ priv->thumb_all.y - xevent->xbutton.y >= 0) &&
64+ (xevent->xbutton.x >= priv->thumb_all.x + priv->overlay.x &&
65+ xevent->xbutton.x <= priv->thumb_all.x + priv->overlay.x + priv->overlay.width))
66+ {
67+ priv->can_hide = FALSE;
68+
69+ if (priv->lock_position)
70+ return GDK_FILTER_CONTINUE;
71+
72+ if (priv->overlay.width > priv->slider.width)
73+ {
74+ gint x, y, x_pos, y_pos;
75+
76+ gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos);
77+
78+ x = CLAMP (xevent->xbutton.x - priv->slider.width / 2,
79+ priv->thumb_all.x + priv->overlay.x,
80+ priv->thumb_all.x + priv->overlay.x + priv->overlay.width - priv->slider.width);
81+ y = priv->thumb_all.y;
82+
83+ os_scrollbar_move_thumb (scrollbar, x_pos + x, y_pos + y);
84+ }
85+ else
86+ {
87+ os_scrollbar_move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y);
88+ }
89+
90+ gtk_widget_show (GTK_WIDGET (priv->thumb));
91+ }
92+ }
93+ }
94+
95 /* after a scroll-event, without motion,
96 * pager becomes inactive because the timeout in
97 * leave-notify-event starts,
98@@ -1457,6 +1537,7 @@
99 scrollbar);
100 }
101
102+ priv->toplevel_button_press = FALSE;
103 priv->can_hide = TRUE;
104
105 if (priv->source_hide_thumb_id != 0)
106@@ -1475,7 +1556,7 @@
107 }
108
109 /* get the motion_notify_event trough XEvent */
110- if (xevent->type == MotionNotify)
111+ if (!priv->toplevel_button_press && xevent->type == MotionNotify)
112 {
113 /* react to motion_notify_event
114 * and set the state accordingly. */
115@@ -1642,6 +1723,7 @@
116 priv->internal = FALSE;
117 priv->lock_position = FALSE;
118 priv->proximity = FALSE;
119+ priv->toplevel_button_press = FALSE;
120 priv->source_deactivate_pager_id = 0;
121 priv->source_hide_thumb_id = 0;
122 priv->source_unlock_thumb_id = 0;

Subscribers

People subscribed via source and target branches