=== modified file 'os/os-private.h' --- os/os-private.h 2012-02-22 21:37:28 +0000 +++ os/os-private.h 2012-09-07 06:28:38 +0000 @@ -38,6 +38,9 @@ #define THUMB_WIDTH 21 #define THUMB_HEIGHT 68 +/* Number of pixel to allow normal window resizing above and below the thumb */ +#define RESIZE_ZONE 16 + /* Number of tolerance pixels on drag, while intercepting a motion-notify-event. */ #define TOLERANCE_DRAG 9 === modified file 'os/os-scrollbar.c' --- os/os-scrollbar.c 2012-03-21 11:41:13 +0000 +++ os/os-scrollbar.c 2012-09-07 06:57:30 +0000 @@ -2520,29 +2520,33 @@ { OsScrollbarPrivate *priv; gint x, y, x_pos, y_pos; + GdkWindow *p_thumb_window; + gint x_pos_t, y_pos_t; priv = scrollbar->priv; gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos); - if (priv->state & OS_STATE_LOCKED) - { - gint x_pos_t, y_pos_t; - - gdk_window_get_origin (gtk_widget_get_window (priv->thumb), &x_pos_t, &y_pos_t); - - /* If the pointer is moving in the area of the proximity - * at the left of the thumb (so, not vertically intercepting the thumb), - * unlock it. Viceversa for the horizontal orientation. - * The flag OS_STATE_LOCKED is set only for a mapped thumb, - * so we can freely ask for its position and do our calculations. */ - if ((priv->side == OS_SIDE_RIGHT && x_pos + event_x <= x_pos_t) || - (priv->side == OS_SIDE_BOTTOM && y_pos + event_y <= y_pos_t) || - (priv->side == OS_SIDE_LEFT && x_pos + event_x >= x_pos_t + priv->thumb_all.width) || - (priv->side == OS_SIDE_TOP && y_pos + event_y >= y_pos_t + priv->thumb_all.height)) - priv->state &= ~(OS_STATE_LOCKED); - else - return; + p_thumb_window = gtk_widget_get_window (priv->thumb); + if (p_thumb_window) + { + gdk_window_get_origin (p_thumb_window, &x_pos_t, &y_pos_t); + + if (priv->state & OS_STATE_LOCKED) + { + /* If the pointer is moving in the area of the proximity + * at the left of the thumb (so, not vertically intercepting the thumb), + * unlock it. Viceversa for the horizontal orientation. + * The flag OS_STATE_LOCKED is set only for a mapped thumb, + * so we can freely ask for its position and do our calculations. */ + if ((priv->side == OS_SIDE_RIGHT && x_pos + event_x <= x_pos_t) || + (priv->side == OS_SIDE_BOTTOM && y_pos + event_y <= y_pos_t) || + (priv->side == OS_SIDE_LEFT && x_pos + event_x >= x_pos_t + priv->thumb_all.width) || + (priv->side == OS_SIDE_TOP && y_pos + event_y >= y_pos_t + priv->thumb_all.height)) + priv->state &= ~(OS_STATE_LOCKED); + else + return; + } } /* Calculate priv->thumb_win.x and priv->thumb_win.y @@ -2557,27 +2561,36 @@ if (priv->orientation == GTK_ORIENTATION_VERTICAL) { x = priv->thumb_all.x; + y = event_y; - if (priv->overlay.height > priv->slider.height) + if ( p_thumb_window && + (y_pos + y) < (y_pos_t + priv->slider.height + RESIZE_ZONE) && + (y_pos + y + RESIZE_ZONE) > y_pos_t) + { + /* Adjust thumb position only if the mouse ponter is outside the resize zone */ + y = y_pos_t - y_pos; + } + else if (priv->overlay.height > priv->slider.height) { /* Overlay (bar) is longer than the slider (thumb). * The thumb is locked within the overlay, * until the mouse is on the middle of page up or page down buttons. */ - if (event_y < priv->thumb_all.y + priv->overlay.y + priv->slider.height / 4) + if (y < priv->thumb_all.y + priv->overlay.y + priv->slider.height / 4) { /* Align to page up. */ - y = event_y - priv->slider.height / 4; + y -= priv->slider.height / 4; } - else if (event_y > priv->thumb_all.y + priv->overlay.y + priv->overlay.height - priv->slider.height / 4) + else if (y > priv->thumb_all.y + priv->overlay.y + priv->overlay.height - priv->slider.height / 4) { /* Align to page down. */ - y = event_y - priv->slider.height * 3 / 4; + y -= priv->slider.height * 3 / 4; } else { /* Lock within the overlay. */ - y = CLAMP (event_y - priv->slider.height / 2, + y -= priv->slider.height / 2; + y = CLAMP (y, priv->thumb_all.y + priv->overlay.y, priv->thumb_all.y + priv->overlay.y + priv->overlay.height - priv->slider.height); } @@ -2588,15 +2601,15 @@ * The thumb is locked to its natural position (priv->slider.y), * until the mouse is on the middle of page up or page down buttons. */ - if (event_y < priv->thumb_all.y + priv->slider.y + priv->slider.height / 4) + if (y < priv->thumb_all.y + priv->slider.y + priv->slider.height / 4) { /* Align to page up. */ - y = event_y - priv->slider.height / 4; + y -= priv->slider.height / 4; } - else if (event_y > priv->thumb_all.y + priv->slider.y + priv->slider.height - priv->slider.height / 4) + else if (y > priv->thumb_all.y + priv->slider.y + priv->slider.height - priv->slider.height / 4) { /* Align to page down. */ - y = event_y - priv->slider.height * 3 / 4; + y -= priv->slider.height * 3 / 4; } else { @@ -2610,31 +2623,39 @@ else { y = priv->thumb_all.y; + x = event_x; - if (priv->overlay.width > priv->slider.width) + if ( p_thumb_window && + (x_pos + x) < (x_pos_t + priv->slider.width + RESIZE_ZONE) && + (x_pos + x + RESIZE_ZONE) > x_pos_t) + { + /* Adjust thumb position only if the mouse ponter is outside the resize zone */ + x = x_pos_t - x_pos; + } + else if (priv->overlay.width > priv->slider.width) { /* Overlay (bar) is longer than the slider (thumb). * The thumb is locked within the overlay, * until the mouse is on the middle of page up or page down buttons. */ - if (event_x < priv->thumb_all.x + priv->overlay.x + priv->slider.width / 4) + if (x < priv->thumb_all.x + priv->overlay.x + priv->slider.width / 4) { /* Align to page up. */ - x = event_x - priv->slider.width / 4; + x -= - priv->slider.width / 4; } - else if (event_x > priv->thumb_all.x + priv->overlay.x + priv->overlay.width - priv->slider.width / 4) + else if (x > priv->thumb_all.x + priv->overlay.x + priv->overlay.width - priv->slider.width / 4) { /* Align to page down. */ - x = event_x - priv->slider.width * 3 / 4; + x -= priv->slider.width * 3 / 4; } else { /* Lock within the overlay. */ - x = CLAMP (event_x - priv->slider.width / 2, + x -= priv->slider.width / 2; + x = CLAMP (x, priv->thumb_all.x + priv->overlay.x, priv->thumb_all.x + priv->overlay.x + priv->overlay.width - priv->slider.width); } - } else { @@ -2758,6 +2779,8 @@ priv = scrollbar->priv; + priv->hidable_thumb = FALSE; + /* Just update the tail if the thumb is already mapped. */ if (gtk_widget_get_mapped (priv->thumb)) { @@ -2901,10 +2924,6 @@ /* Proximity area. */ if (check_proximity (scrollbar, event_x, event_y)) { - priv->hidable_thumb = FALSE; - - adjust_thumb_position (scrollbar, event_x, event_y); - if (priv->state & OS_STATE_LOCKED) return GDK_FILTER_CONTINUE; @@ -2967,20 +2986,22 @@ /* Proximity area. */ if (check_proximity (scrollbar, event_x, event_y)) { - priv->hidable_thumb = FALSE; - if (priv->source_hide_thumb_id != 0) { g_source_remove (priv->source_hide_thumb_id); priv->source_hide_thumb_id = 0; } - adjust_thumb_position (scrollbar, event_x, event_y); - - if (priv->state & OS_STATE_LOCKED) - return GDK_FILTER_CONTINUE; - - show_thumb (scrollbar); + /* Thumb is not moved with the mouse if not clicked */ + if (!gtk_widget_get_visible(priv->thumb)) + { + adjust_thumb_position (scrollbar, event_x, event_y); + + if (priv->state & OS_STATE_LOCKED) + return GDK_FILTER_CONTINUE; + + show_thumb (scrollbar); + } } else {