Merge lp:~azzar1/overlay-scrollbar/fix-907837 into lp:overlay-scrollbar

Proposed by Andrea Azzarone
Status: Merged
Approved by: Brandon Schaefer
Approved revision: 366
Merged at revision: 368
Proposed branch: lp:~azzar1/overlay-scrollbar/fix-907837
Merge into: lp:overlay-scrollbar
Diff against target: 140 lines (+87/-3)
1 file modified
os/os-scrollbar.c (+87/-3)
To merge this branch: bzr merge lp:~azzar1/overlay-scrollbar/fix-907837
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+142986@code.launchpad.net

Commit message

Add resizing to the overlay scrollbars.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

LGTM. Works, and I can't see any problems with it.

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-11-30 07:51:59 +0000
3+++ os/os-scrollbar.c 2013-01-11 21:05:24 +0000
4@@ -124,6 +124,8 @@
5 OsWindowFilter filter;
6 gboolean active_window;
7 gboolean allow_resize;
8+ gboolean allow_resize_paned;
9+ gboolean resizing_paned;
10 #ifdef USE_GTK3
11 gboolean deactivable_bar;
12 #endif
13@@ -687,6 +689,8 @@
14 priv->orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget));
15 swap_thumb (GTK_SCROLLBAR (widget), os_thumb_new (priv->orientation));
16
17+ priv->resizing_paned = FALSE;
18+
19 /* Connect to adjustment and orientation signals. */
20 g_signal_connect (G_OBJECT (widget), "notify::adjustment",
21 G_CALLBACK (notify_adjustment_cb), NULL);
22@@ -2163,12 +2167,57 @@
23 }
24 /* We're in the 'no action taken' area.
25 * Skip this event. */
26- return FALSE;
27+ if (!priv->allow_resize_paned)
28+ return FALSE;
29 }
30
31 /* We're in the 'SCROLLING' area.
32 * Continue processing the event. */
33 }
34+
35+ if (priv->allow_resize_paned &&
36+ !(priv->event & OS_EVENT_MOTION_NOTIFY))
37+ {
38+ if (((priv->side == OS_SIDE_RIGHT || priv->side == OS_SIDE_LEFT) && f_x > 0.5 * f_y) ||
39+ ((priv->side == OS_SIDE_BOTTOM || priv->side == OS_SIDE_TOP) && f_y > 0.5 * f_x))
40+ {
41+ /* We're either in the 'RESIZE' or in the 'no action taken' area. */
42+ if (((priv->side == OS_SIDE_RIGHT || priv->side == OS_SIDE_LEFT) && f_x > TOLERANCE_DRAG) ||
43+ ((priv->side == OS_SIDE_BOTTOM || priv->side == OS_SIDE_TOP) && f_y > TOLERANCE_DRAG))
44+ {
45+ /* We're in the 'RESIZE' area. */
46+ GtkPaned *paned = GTK_PANED (gtk_widget_get_ancestor (GTK_WIDGET (scrollbar), GTK_TYPE_PANED));
47+
48+ if (!paned)
49+ return FALSE;
50+
51+ GdkWindow *handle_window = gtk_paned_get_handle_window (paned);
52+
53+ GdkEventButton *fwd_event = (GdkEventButton*) gdk_event_new (GDK_BUTTON_PRESS);
54+
55+ fwd_event->window = handle_window;
56+ fwd_event->time = event->time;
57+ fwd_event->x = 1;
58+ fwd_event->y = 1;
59+ fwd_event->state = event->state;
60+ fwd_event->button = 1;
61+ fwd_event->x_root = event->x_root;
62+ fwd_event->y_root = event->y_root;
63+ fwd_event->device = event->device;
64+
65+ gdk_event_put ((GdkEvent*) fwd_event);
66+
67+ priv->resizing_paned = TRUE;
68+
69+ gtk_widget_hide (widget);
70+ }
71+
72+ /* We're in the 'no action taken' area.
73+ * Skip this event. */
74+ return FALSE;
75+ }
76+
77+ }
78
79 if (!(priv->event & OS_EVENT_MOTION_NOTIFY))
80 {
81@@ -3026,7 +3075,7 @@
82 if (priv->state & OS_STATE_LOCKED)
83 return GDK_FILTER_CONTINUE;
84
85- if (!is_touch_mode (GTK_WIDGET (scrollbar), sourceid))
86+ if (!is_touch_mode (GTK_WIDGET (scrollbar), sourceid) && !priv->resizing_paned)
87 show_thumb (scrollbar);
88 }
89 }
90@@ -3103,7 +3152,7 @@
91 if (priv->state & OS_STATE_LOCKED)
92 return GDK_FILTER_CONTINUE;
93
94- if (!is_touch_mode (GTK_WIDGET (scrollbar), sourceid))
95+ if (!is_touch_mode (GTK_WIDGET (scrollbar), sourceid) && !priv->resizing_paned)
96 show_thumb (scrollbar);
97 }
98 else
99@@ -3579,6 +3628,41 @@
100 default:
101 break;
102 }
103+
104+ GtkPaned *paned = GTK_PANED (gtk_widget_get_ancestor (GTK_WIDGET (scrollbar), GTK_TYPE_PANED));
105+ if (!paned)
106+ return;
107+
108+ GdkWindow *handle_window = gtk_paned_get_handle_window (paned);
109+
110+ gdk_window_get_origin (handle_window, &x, &y);
111+
112+ priv->allow_resize_paned = FALSE;
113+ priv->resizing_paned = FALSE;
114+
115+ /* Check if the thumb is next to a paned handle,
116+ * if that's the case, set the allow_resize_paned gboolean. */
117+ switch (priv->side)
118+ {
119+ case OS_SIDE_RIGHT:
120+ if (x + gdk_window_get_width (handle_window) - x_pos <= THUMB_WIDTH)
121+ priv->allow_resize_paned = TRUE;
122+ break;
123+ case OS_SIDE_BOTTOM:
124+ if (y + gdk_window_get_height (handle_window) - y_pos <= THUMB_WIDTH)
125+ priv->allow_resize_paned = TRUE;
126+ break;
127+ case OS_SIDE_LEFT:
128+ if (x_pos - x <= THUMB_WIDTH)
129+ priv->allow_resize_paned = TRUE;
130+ break;
131+ case OS_SIDE_TOP:
132+ if (y_pos - y <= THUMB_WIDTH)
133+ priv->allow_resize_paned = TRUE;
134+ break;
135+ default:
136+ break;
137+ }
138 }
139
140 static void

Subscribers

People subscribed via source and target branches