1443
1458
/* filter function applied to the toplevel window */
1460
static GdkFilterReturn
1461
toplevel_filter_func (GdkXEvent *gdkxevent,
1465
OsScrollbar *scrollbar;
1466
OsScrollbarPrivate *priv;
1469
g_return_val_if_fail (OS_SCROLLBAR (user_data), GDK_FILTER_CONTINUE);
1471
scrollbar = OS_SCROLLBAR (user_data);
1473
priv = scrollbar->priv;
1476
g_return_val_if_fail (priv->pager != NULL, GDK_FILTER_CONTINUE);
1477
g_return_val_if_fail (priv->thumb != NULL, GDK_FILTER_CONTINUE);
1479
if (!priv->fullsize)
1481
if (xev->type == GenericEvent)
1483
XIDeviceEvent *xiev;
1485
xiev = xev->xcookie.data;
1487
if (xiev->evtype == XI_ButtonPress)
1489
priv->toplevel_button_press = TRUE;
1490
gtk_widget_hide (priv->thumb);
1493
if (priv->toplevel_button_press && xiev->evtype == XI_ButtonRelease)
1495
priv->toplevel_button_press = FALSE;
1497
/* proximity area */
1498
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
1500
if ((priv->thumb_all.x - xiev->event_x <= PROXIMITY_WIDTH &&
1501
priv->thumb_all.x - xiev->event_x >= 0) &&
1502
(xiev->event_y >= priv->thumb_all.y + priv->overlay.y &&
1503
xiev->event_y <= priv->thumb_all.y + priv->overlay.y + priv->overlay.height))
1505
priv->can_hide = FALSE;
1507
if (priv->lock_position)
1508
return GDK_FILTER_CONTINUE;
1510
if (priv->overlay.height > priv->slider.height)
1512
gint x, y, x_pos, y_pos;
1514
gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos);
1516
x = priv->thumb_all.x;
1517
y = CLAMP (xiev->event_y - priv->slider.height / 2,
1518
priv->thumb_all.y + priv->overlay.y,
1519
priv->thumb_all.y + priv->overlay.y + priv->overlay.height - priv->slider.height);
1521
move_thumb (scrollbar, x_pos + x, y_pos + y);
1525
move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y);
1528
gtk_widget_show (GTK_WIDGET (priv->thumb));
1533
if ((priv->thumb_all.y - xiev->event_y <= PROXIMITY_WIDTH &&
1534
priv->thumb_all.y - xiev->event_y >= 0) &&
1535
(xiev->event_x >= priv->thumb_all.x + priv->overlay.x &&
1536
xiev->event_x <= priv->thumb_all.x + priv->overlay.x + priv->overlay.width))
1538
priv->can_hide = FALSE;
1540
if (priv->lock_position)
1541
return GDK_FILTER_CONTINUE;
1543
if (priv->overlay.width > priv->slider.width)
1545
gint x, y, x_pos, y_pos;
1547
gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos);
1549
x = CLAMP (xiev->event_x - priv->slider.width / 2,
1550
priv->thumb_all.x + priv->overlay.x,
1551
priv->thumb_all.x + priv->overlay.x + priv->overlay.width - priv->slider.width);
1552
y = priv->thumb_all.y;
1554
move_thumb (scrollbar, x_pos + x, y_pos + y);
1558
move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y);
1561
gtk_widget_show (GTK_WIDGET (priv->thumb));
1566
/* after a scroll-event, without motion,
1567
* pager becomes inactive because the timeout in
1568
* leave-notify-event starts,
1569
* this call checks the pointer after the scroll-event,
1570
* since it enters the window,
1571
* then sets the state accordingly. */
1572
if (!priv->active_window && xiev->evtype == XI_Enter)
1574
XIEnterEvent *xiee = xev->xcookie.data;
1576
pager_set_state_from_pointer (scrollbar, xiee->event_x, xiee->event_y);
1579
if (xiev->evtype == XI_Leave)
1581
/* never deactivate the pager in an active window. */
1582
if (!priv->active_window)
1584
priv->can_deactivate_pager = TRUE;
1586
if (priv->source_deactivate_pager_id != 0)
1587
g_source_remove (priv->source_deactivate_pager_id);
1589
priv->source_deactivate_pager_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE,
1590
deactivate_pager_cb,
1594
priv->toplevel_button_press = FALSE;
1595
priv->can_hide = TRUE;
1597
if (priv->source_hide_thumb_id != 0)
1598
g_source_remove (priv->source_hide_thumb_id);
1600
priv->source_hide_thumb_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE,
1604
if (priv->source_unlock_thumb_id != 0)
1605
g_source_remove (priv->source_unlock_thumb_id);
1607
priv->source_unlock_thumb_id = g_timeout_add (TIMEOUT_TOPLEVEL_HIDE,
1612
/* get the motion_notify_event trough XEvent */
1613
if (!priv->toplevel_button_press && xiev->evtype == XI_Motion)
1615
/* react to motion_notify_event
1616
* and set the state accordingly. */
1617
if (!priv->active_window)
1618
pager_set_state_from_pointer (scrollbar, xiev->event_x, xiev->event_y);
1620
/* proximity area */
1621
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
1623
if ((priv->thumb_all.x - xiev->event_x <= PROXIMITY_WIDTH &&
1624
priv->thumb_all.x - xiev->event_x >= 0) &&
1625
(xiev->event_y >= priv->thumb_all.y + priv->overlay.y &&
1626
xiev->event_y <= priv->thumb_all.y + priv->overlay.y + priv->overlay.height))
1628
priv->can_hide = FALSE;
1630
if (priv->lock_position)
1631
return GDK_FILTER_CONTINUE;
1633
if (priv->overlay.height > priv->slider.height)
1635
gint x, y, x_pos, y_pos;
1637
gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos);
1639
x = priv->thumb_all.x;
1640
y = CLAMP (xiev->event_y - priv->slider.height / 2,
1641
priv->thumb_all.y + priv->overlay.y,
1642
priv->thumb_all.y + priv->overlay.y + priv->overlay.height - priv->slider.height);
1644
move_thumb (scrollbar, x_pos + x, y_pos + y);
1648
move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y);
1651
os_pager_set_detached (OS_PAGER (priv->pager), FALSE);
1652
os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE);
1653
gtk_widget_show (GTK_WIDGET (priv->thumb));
1657
priv->can_hide = TRUE;
1658
priv->lock_position = FALSE;
1659
hide_thumb (scrollbar);
1664
if ((priv->thumb_all.y - xiev->event_y <= PROXIMITY_WIDTH &&
1665
priv->thumb_all.y - xiev->event_y >= 0) &&
1666
(xiev->event_x >= priv->thumb_all.x + priv->overlay.x &&
1667
xiev->event_x <= priv->thumb_all.x + priv->overlay.x + priv->overlay.width))
1669
priv->can_hide = FALSE;
1671
if (priv->lock_position)
1672
return GDK_FILTER_CONTINUE;
1674
if (priv->overlay.width > priv->slider.width)
1676
gint x, y, x_pos, y_pos;
1678
gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (scrollbar)), &x_pos, &y_pos);
1680
x = CLAMP (xiev->event_x - priv->slider.width / 2,
1681
priv->thumb_all.x + priv->overlay.x,
1682
priv->thumb_all.x + priv->overlay.x + priv->overlay.width - priv->slider.width);
1683
y = priv->thumb_all.y;
1685
move_thumb (scrollbar, x_pos + x, y_pos + y);
1689
move_thumb (scrollbar, priv->win_x + priv->slider.x, priv->win_y);
1692
os_pager_set_detached (OS_PAGER (priv->pager), FALSE);
1693
os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE);
1694
gtk_widget_show (GTK_WIDGET (priv->thumb));
1698
priv->can_hide = TRUE;
1699
priv->lock_position = FALSE;
1700
hide_thumb (scrollbar);
1707
return GDK_FILTER_CONTINUE;
1444
1710
static GdkFilterReturn
1445
1711
toplevel_filter_func (GdkXEvent *gdkxevent,
1446
1712
GdkEvent *event,
1691
1958
gobject_class = G_OBJECT_CLASS (class);
1692
1959
widget_class = GTK_WIDGET_CLASS (class);
1694
widget_class->expose_event = os_scrollbar_expose_event;
1695
widget_class->grab_notify = os_scrollbar_grab_notify;
1696
widget_class->hide = os_scrollbar_hide;
1697
widget_class->map = os_scrollbar_map;
1698
widget_class->realize = os_scrollbar_realize;
1699
widget_class->show = os_scrollbar_show;
1700
widget_class->size_allocate = os_scrollbar_size_allocate;
1701
widget_class->size_request = os_scrollbar_size_request;
1702
widget_class->unmap = os_scrollbar_unmap;
1703
widget_class->unrealize = os_scrollbar_unrealize;
1962
widget_class->draw = os_scrollbar_draw;
1963
widget_class->get_preferred_width = os_scrollbar_get_preferred_width;
1964
widget_class->get_preferred_height = os_scrollbar_get_preferred_height;
1966
widget_class->expose_event = os_scrollbar_expose_event;
1968
widget_class->grab_notify = os_scrollbar_grab_notify;
1969
widget_class->hide = os_scrollbar_hide;
1970
widget_class->map = os_scrollbar_map;
1971
widget_class->realize = os_scrollbar_realize;
1972
widget_class->show = os_scrollbar_show;
1973
widget_class->size_allocate = os_scrollbar_size_allocate;
1975
widget_class->size_request = os_scrollbar_size_request;
1977
widget_class->unmap = os_scrollbar_unmap;
1978
widget_class->unrealize = os_scrollbar_unrealize;
1705
1980
gobject_class->dispose = os_scrollbar_dispose;
1706
1981
gobject_class->finalize = os_scrollbar_finalize;