1984
1985
if (priv->event & OS_EVENT_BUTTON_PRESS)
1990
f_x = abs (priv->pointer.x - event->x);
1991
f_y = abs (priv->pointer.y - event->y);
1988
1993
/* Use tolerance at the first calls to this motion notify event. */
1989
1994
if (!(priv->event & OS_EVENT_MOTION_NOTIFY) &&
1990
abs (priv->pointer.x - event->x) <= TOLERANCE_MOTION &&
1991
abs (priv->pointer.y - event->y) <= TOLERANCE_MOTION)
1995
f_x <= TOLERANCE_MOTION &&
1996
f_y <= TOLERANCE_MOTION)
1999
/* The scrollbar allows resize, and a scrolling is not started yet.
2000
* Decide if the user will start a window resize or a normal scroll. */
2001
if (priv->allow_resize &&
2002
!(priv->event & OS_EVENT_MOTION_NOTIFY))
2004
/* Trying to draw the area of interest,
2005
* in the case of a vertical scrollbar.
2006
* Everything is reflected for horizontal scrollbars.
2023
* The diagonal lines are inclined differently, using 0.5 * f_y.
2025
if (((priv->side == OS_SIDE_RIGHT || priv->side == OS_SIDE_LEFT) && f_x > 0.5 * f_y) ||
2026
((priv->side == OS_SIDE_BOTTOM || priv->side == OS_SIDE_TOP) && f_y > 0.5 * f_x))
2028
/* We're either in the 'RESIZE' or in the 'no action taken' area. */
2029
if (((priv->side == OS_SIDE_RIGHT || priv->side == OS_SIDE_LEFT) && f_x > TOLERANCE_DRAG) ||
2030
((priv->side == OS_SIDE_BOTTOM || priv->side == OS_SIDE_TOP) && f_y > TOLERANCE_DRAG))
2032
/* We're in the 'RESIZE' area.
2033
* Set the right resize type and hide the thumb. */
2034
GdkWindowEdge window_edge;
2040
window_edge = GDK_WINDOW_EDGE_EAST;
2042
case OS_SIDE_BOTTOM:
2043
window_edge = GDK_WINDOW_EDGE_SOUTH;
2046
window_edge = GDK_WINDOW_EDGE_WEST;
2049
window_edge = GDK_WINDOW_EDGE_NORTH;
2053
gdk_window_begin_resize_drag (gtk_widget_get_window (gtk_widget_get_toplevel (GTK_WIDGET (scrollbar))),
2059
gtk_widget_hide (widget);
2061
/* We're in the 'no action taken' area.
2062
* Skip this event. */
2066
/* We're in the 'SCROLLING' area.
2067
* Continue processing the event. */
1994
2070
if (!(priv->event & OS_EVENT_MOTION_NOTIFY))
1996
2072
/* Check if we can consider the thumb movement connected with the overlay. */
1997
2073
check_connection (scrollbar);
2075
/* It is a scrolling event, set the flag. */
1999
2076
priv->event |= OS_EVENT_MOTION_NOTIFY;
3398
/* Retrieve if the thumb can resize its toplevel window. */
3400
retrieve_resizability (OsScrollbar *scrollbar)
3402
GdkWindow *scrollbar_window;
3403
GdkWindow *toplevel_window;
3404
OsScrollbarPrivate *priv;
3408
priv = scrollbar->priv;
3410
/* By default, they don't allow resize. */
3411
priv->allow_resize = FALSE;
3413
scrollbar_window = gtk_widget_get_window (GTK_WIDGET (scrollbar));
3415
if (!scrollbar_window)
3418
toplevel_window = gtk_widget_get_window (gtk_widget_get_toplevel (GTK_WIDGET (scrollbar)));
3420
gdk_window_get_origin (toplevel_window, &x, &y);
3422
gdk_window_get_root_coords (scrollbar_window,
3423
priv->thumb_all.x, priv->thumb_all.y,
3426
/* Check if the thumb is next to a window edge,
3427
* if that's the case, set the allow_resize gboolean. */
3431
if (x + gdk_window_get_width (toplevel_window) - x_pos <= THUMB_WIDTH)
3432
priv->allow_resize = TRUE;
3434
case OS_SIDE_BOTTOM:
3435
if (y + gdk_window_get_height (toplevel_window) - y_pos <= THUMB_WIDTH)
3436
priv->allow_resize = TRUE;
3439
if (x_pos - x <= THUMB_WIDTH)
3440
priv->allow_resize = TRUE;
3443
if (y_pos - y <= THUMB_WIDTH)
3444
priv->allow_resize = TRUE;
3322
3452
os_scrollbar_size_allocate (GtkWidget *widget,
3323
3453
GdkRectangle *allocation)