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
=== modified file 'os/os-scrollbar.c'
--- os/os-scrollbar.c 2012-11-30 07:51:59 +0000
+++ os/os-scrollbar.c 2013-01-11 21:05:24 +0000
@@ -124,6 +124,8 @@
124 OsWindowFilter filter;124 OsWindowFilter filter;
125 gboolean active_window;125 gboolean active_window;
126 gboolean allow_resize;126 gboolean allow_resize;
127 gboolean allow_resize_paned;
128 gboolean resizing_paned;
127#ifdef USE_GTK3129#ifdef USE_GTK3
128 gboolean deactivable_bar;130 gboolean deactivable_bar;
129#endif131#endif
@@ -687,6 +689,8 @@
687 priv->orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget));689 priv->orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget));
688 swap_thumb (GTK_SCROLLBAR (widget), os_thumb_new (priv->orientation));690 swap_thumb (GTK_SCROLLBAR (widget), os_thumb_new (priv->orientation));
689691
692 priv->resizing_paned = FALSE;
693
690 /* Connect to adjustment and orientation signals. */694 /* Connect to adjustment and orientation signals. */
691 g_signal_connect (G_OBJECT (widget), "notify::adjustment",695 g_signal_connect (G_OBJECT (widget), "notify::adjustment",
692 G_CALLBACK (notify_adjustment_cb), NULL);696 G_CALLBACK (notify_adjustment_cb), NULL);
@@ -2163,12 +2167,57 @@
2163 }2167 }
2164 /* We're in the 'no action taken' area.2168 /* We're in the 'no action taken' area.
2165 * Skip this event. */2169 * Skip this event. */
2166 return FALSE;2170 if (!priv->allow_resize_paned)
2171 return FALSE;
2167 }2172 }
21682173
2169 /* We're in the 'SCROLLING' area.2174 /* We're in the 'SCROLLING' area.
2170 * Continue processing the event. */2175 * Continue processing the event. */
2171 }2176 }
2177
2178 if (priv->allow_resize_paned &&
2179 !(priv->event & OS_EVENT_MOTION_NOTIFY))
2180 {
2181 if (((priv->side == OS_SIDE_RIGHT || priv->side == OS_SIDE_LEFT) && f_x > 0.5 * f_y) ||
2182 ((priv->side == OS_SIDE_BOTTOM || priv->side == OS_SIDE_TOP) && f_y > 0.5 * f_x))
2183 {
2184 /* We're either in the 'RESIZE' or in the 'no action taken' area. */
2185 if (((priv->side == OS_SIDE_RIGHT || priv->side == OS_SIDE_LEFT) && f_x > TOLERANCE_DRAG) ||
2186 ((priv->side == OS_SIDE_BOTTOM || priv->side == OS_SIDE_TOP) && f_y > TOLERANCE_DRAG))
2187 {
2188 /* We're in the 'RESIZE' area. */
2189 GtkPaned *paned = GTK_PANED (gtk_widget_get_ancestor (GTK_WIDGET (scrollbar), GTK_TYPE_PANED));
2190
2191 if (!paned)
2192 return FALSE;
2193
2194 GdkWindow *handle_window = gtk_paned_get_handle_window (paned);
2195
2196 GdkEventButton *fwd_event = (GdkEventButton*) gdk_event_new (GDK_BUTTON_PRESS);
2197
2198 fwd_event->window = handle_window;
2199 fwd_event->time = event->time;
2200 fwd_event->x = 1;
2201 fwd_event->y = 1;
2202 fwd_event->state = event->state;
2203 fwd_event->button = 1;
2204 fwd_event->x_root = event->x_root;
2205 fwd_event->y_root = event->y_root;
2206 fwd_event->device = event->device;
2207
2208 gdk_event_put ((GdkEvent*) fwd_event);
2209
2210 priv->resizing_paned = TRUE;
2211
2212 gtk_widget_hide (widget);
2213 }
2214
2215 /* We're in the 'no action taken' area.
2216 * Skip this event. */
2217 return FALSE;
2218 }
2219
2220 }
21722221
2173 if (!(priv->event & OS_EVENT_MOTION_NOTIFY))2222 if (!(priv->event & OS_EVENT_MOTION_NOTIFY))
2174 {2223 {
@@ -3026,7 +3075,7 @@
3026 if (priv->state & OS_STATE_LOCKED)3075 if (priv->state & OS_STATE_LOCKED)
3027 return GDK_FILTER_CONTINUE;3076 return GDK_FILTER_CONTINUE;
30283077
3029 if (!is_touch_mode (GTK_WIDGET (scrollbar), sourceid))3078 if (!is_touch_mode (GTK_WIDGET (scrollbar), sourceid) && !priv->resizing_paned)
3030 show_thumb (scrollbar);3079 show_thumb (scrollbar);
3031 }3080 }
3032 }3081 }
@@ -3103,7 +3152,7 @@
3103 if (priv->state & OS_STATE_LOCKED)3152 if (priv->state & OS_STATE_LOCKED)
3104 return GDK_FILTER_CONTINUE;3153 return GDK_FILTER_CONTINUE;
31053154
3106 if (!is_touch_mode (GTK_WIDGET (scrollbar), sourceid))3155 if (!is_touch_mode (GTK_WIDGET (scrollbar), sourceid) && !priv->resizing_paned)
3107 show_thumb (scrollbar);3156 show_thumb (scrollbar);
3108 }3157 }
3109 else3158 else
@@ -3579,6 +3628,41 @@
3579 default:3628 default:
3580 break;3629 break;
3581 }3630 }
3631
3632 GtkPaned *paned = GTK_PANED (gtk_widget_get_ancestor (GTK_WIDGET (scrollbar), GTK_TYPE_PANED));
3633 if (!paned)
3634 return;
3635
3636 GdkWindow *handle_window = gtk_paned_get_handle_window (paned);
3637
3638 gdk_window_get_origin (handle_window, &x, &y);
3639
3640 priv->allow_resize_paned = FALSE;
3641 priv->resizing_paned = FALSE;
3642
3643 /* Check if the thumb is next to a paned handle,
3644 * if that's the case, set the allow_resize_paned gboolean. */
3645 switch (priv->side)
3646 {
3647 case OS_SIDE_RIGHT:
3648 if (x + gdk_window_get_width (handle_window) - x_pos <= THUMB_WIDTH)
3649 priv->allow_resize_paned = TRUE;
3650 break;
3651 case OS_SIDE_BOTTOM:
3652 if (y + gdk_window_get_height (handle_window) - y_pos <= THUMB_WIDTH)
3653 priv->allow_resize_paned = TRUE;
3654 break;
3655 case OS_SIDE_LEFT:
3656 if (x_pos - x <= THUMB_WIDTH)
3657 priv->allow_resize_paned = TRUE;
3658 break;
3659 case OS_SIDE_TOP:
3660 if (y_pos - y <= THUMB_WIDTH)
3661 priv->allow_resize_paned = TRUE;
3662 break;
3663 default:
3664 break;
3665 }
3582}3666}
35833667
3584static void3668static void

Subscribers

People subscribed via source and target branches