Merge lp:~cimi/overlay-scrollbar/use-enums into lp:overlay-scrollbar

Proposed by Andrea Cimitan
Status: Superseded
Proposed branch: lp:~cimi/overlay-scrollbar/use-enums
Merge into: lp:overlay-scrollbar
Diff against target: 710 lines (+232/-215)
3 files modified
os/os-private.h (+10/-1)
os/os-scrollbar.c (+205/-195)
os/os-thumb.c (+17/-19)
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/use-enums
Reviewer Review Type Date Requested Status
Ayatana Scrollbar Team Pending
Review via email: mp+67203@code.launchpad.net

This proposal has been superseded by a proposal from 2011-07-07.

Description of the change

If you have ideas on namings or other sets of enums to create, just ping me in IRC and not marking as "NEED FIXING" :)
Or they could be handled in separated branches

To post a comment you must log in.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'os/os-private.h'
--- os/os-private.h 2011-06-27 17:03:25 +0000
+++ os/os-private.h 2011-07-07 15:06:32 +0000
@@ -36,6 +36,15 @@
3636
37G_BEGIN_DECLS37G_BEGIN_DECLS
3838
39typedef enum
40{
41 OS_EVENT_NONE = 0,
42 OS_EVENT_BUTTON_PRESS = 1,
43 OS_EVENT_ENTER_NOTIFY = 2,
44 OS_EVENT_MOTION_NOTIFY = 4,
45 OS_EVENT_VALUE_CHANGED = 8
46} OsEvent;
47
39/* os-log.c */48/* os-log.c */
4049
41/* Severity levels. */50/* Severity levels. */
@@ -71,7 +80,7 @@
71 } \80 } \
72 } G_STMT_END81 } G_STMT_END
7382
74/* Macro loggging an error message to stderr and breaking the program execution83/* Macro logging an error message to stderr and breaking the program execution
75 * if the assertion fails. */84 * if the assertion fails. */
76#define OS_CHECK(cond) \85#define OS_CHECK(cond) \
77 G_STMT_START { \86 G_STMT_START { \
7887
=== modified file 'os/os-scrollbar.c'
--- os/os-scrollbar.c 2011-07-05 18:13:09 +0000
+++ os/os-scrollbar.c 2011-07-07 15:06:32 +0000
@@ -91,13 +91,11 @@
91 OsAnimation *animation;91 OsAnimation *animation;
92 OsPager *pager;92 OsPager *pager;
93 OsSide side;93 OsSide side;
94 gboolean button_press_event;94 OsEvent event;
95 gboolean enter_notify_event;
96 gboolean motion_notify_event;
97 gboolean value_changed_event;
98 gboolean active_window;95 gboolean active_window;
99 gboolean can_deactivate_pager;96 gboolean can_deactivate_pager;
100 gboolean can_hide;97 gboolean can_hide;
98 gboolean detached_scroll;
101 gboolean filter;99 gboolean filter;
102 gboolean fullsize;100 gboolean fullsize;
103 gboolean internal;101 gboolean internal;
@@ -368,10 +366,7 @@
368 priv = scrollbar->priv;366 priv = scrollbar->priv;
369367
370 if (priv->can_hide)368 if (priv->can_hide)
371 {369 gtk_widget_hide (priv->thumb);
372 priv->value_changed_event = FALSE;
373 gtk_widget_hide (priv->thumb);
374 }
375}370}
376371
377/* timeout before hiding the thumb */372/* timeout before hiding the thumb */
@@ -773,19 +768,6 @@
773 gtk_adjustment_set_value (priv->adjustment, new_value);768 gtk_adjustment_set_value (priv->adjustment, new_value);
774}769}
775770
776/* stop_func called by the set-scroll animation */
777static void
778set_scroll_stop_cb (gpointer user_data)
779{
780 OsScrollbar *scrollbar;
781 OsScrollbarPrivate *priv;
782
783 scrollbar = OS_SCROLLBAR (user_data);
784 priv = scrollbar->priv;
785
786 priv->value = gtk_adjustment_get_value (priv->adjustment);
787}
788
789/* swap adjustment pointer */771/* swap adjustment pointer */
790static void772static void
791swap_adjustment (OsScrollbar *scrollbar,773swap_adjustment (OsScrollbar *scrollbar,
@@ -933,12 +915,98 @@
933 calc_layout_pager (scrollbar, gtk_adjustment_get_value (adjustment));915 calc_layout_pager (scrollbar, gtk_adjustment_get_value (adjustment));
934 calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment));916 calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment));
935917
936 if (!priv->motion_notify_event && !priv->enter_notify_event)918 if (!(priv->event & OS_EVENT_ENTER_NOTIFY) &&
919 !(priv->event & OS_EVENT_MOTION_NOTIFY))
937 gtk_widget_hide (priv->thumb);920 gtk_widget_hide (priv->thumb);
938921
939 move_pager (scrollbar);922 move_pager (scrollbar);
940}923}
941924
925/* update the visual connection between pager and thumb. */
926static void
927update_visual_connection (OsScrollbar *scrollbar)
928{
929 OsScrollbarPrivate *priv;
930 gint x_pos, y_pos;
931
932 priv = scrollbar->priv;
933
934 gdk_window_get_origin (gtk_widget_get_window (priv->thumb), &x_pos, &y_pos);
935
936 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
937 {
938 if (priv->win_y + priv->overlay.y >= y_pos + priv->slider.height)
939 {
940 GdkRectangle mask;
941
942 mask.x = 0;
943 mask.y = y_pos + priv->slider.height / 2 - priv->win_y;
944 mask.width = priv->pager_all.width;
945 mask.height = priv->overlay.y - mask.y;
946
947 os_pager_connect (priv->pager, mask);
948 os_pager_set_detached (priv->pager, TRUE);
949
950 os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE);
951 }
952 else if (priv->win_y + priv->overlay.y + priv->overlay.height <= y_pos)
953 {
954 GdkRectangle mask;
955
956 mask.x = 0;
957 mask.y = priv->overlay.y + priv->overlay.height;
958 mask.width = priv->pager_all.width;
959 mask.height = y_pos + priv->slider.height / 2 - priv->win_y - mask.y;
960
961 os_pager_connect (priv->pager, mask);
962 os_pager_set_detached (priv->pager, TRUE);
963
964 os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE);
965 }
966 else
967 {
968 os_pager_set_detached (priv->pager, FALSE);
969 os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE);
970 }
971 }
972 else
973 {
974 if (priv->win_x + priv->overlay.x >= x_pos + priv->slider.width)
975 {
976 GdkRectangle mask;
977
978 mask.x = x_pos + priv->slider.width / 2 - priv->win_x;
979 mask.y = 0;
980 mask.width = priv->overlay.x - mask.x;
981 mask.height = priv->pager_all.height;
982
983 os_pager_connect (priv->pager, mask);
984 os_pager_set_detached (priv->pager, TRUE);
985
986 os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE);
987 }
988 else if (priv->win_x + priv->overlay.x + priv->overlay.width <= x_pos)
989 {
990 GdkRectangle mask;
991
992 mask.x = priv->overlay.x + priv->overlay.width;
993 mask.y = 0;
994 mask.width = x_pos + priv->slider.width / 2 - priv->win_x - mask.x;
995 mask.height = priv->pager_all.height;
996
997 os_pager_connect (priv->pager, mask);
998 os_pager_set_detached (priv->pager, TRUE);
999
1000 os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE);
1001 }
1002 else
1003 {
1004 os_pager_set_detached (priv->pager, FALSE);
1005 os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE);
1006 }
1007 }
1008}
1009
942static void1010static void
943adjustment_value_changed_cb (GtkAdjustment *adjustment,1011adjustment_value_changed_cb (GtkAdjustment *adjustment,
944 gpointer user_data)1012 gpointer user_data)
@@ -952,95 +1020,20 @@
952 calc_layout_pager (scrollbar, gtk_adjustment_get_value (adjustment));1020 calc_layout_pager (scrollbar, gtk_adjustment_get_value (adjustment));
953 calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment));1021 calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment));
9541022
955 if (!priv->motion_notify_event && !priv->enter_notify_event)1023 if (!(priv->event & OS_EVENT_ENTER_NOTIFY) &&
1024 !(priv->event & OS_EVENT_MOTION_NOTIFY))
956 gtk_widget_hide (priv->thumb);1025 gtk_widget_hide (priv->thumb);
9571026
958 if (gtk_widget_get_mapped (priv->thumb))1027 if (gtk_widget_get_mapped (priv->thumb))
959 {1028 {
960 /* if we're dragging the thumb, it can't be detached. */1029 /* if we're dragging the thumb, it can't be detached. */
961 if (priv->motion_notify_event)1030 if (priv->event & OS_EVENT_MOTION_NOTIFY)
962 {1031 {
963 os_pager_set_detached (priv->pager, FALSE);1032 os_pager_set_detached (priv->pager, FALSE);
964 os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE);1033 os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE);
965 }1034 }
966 else1035 else
967 {1036 update_visual_connection (scrollbar);
968 gint x_pos, y_pos;
969 gdk_window_get_origin (gtk_widget_get_window (priv->thumb), &x_pos, &y_pos);
970
971 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
972 {
973 if (priv->win_y + priv->overlay.y > y_pos + priv->slider.height)
974 {
975 GdkRectangle mask;
976
977 mask.x = 0;
978 mask.y = y_pos + priv->slider.height / 2 - priv->win_y;
979 mask.width = priv->pager_all.width;
980 mask.height = priv->overlay.y - mask.y;
981
982 os_pager_connect (priv->pager, mask);
983 os_pager_set_detached (priv->pager, TRUE);
984
985 os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE);
986 }
987 else if (priv->win_y + priv->overlay.y + priv->overlay.height < y_pos)
988 {
989 GdkRectangle mask;
990
991 mask.x = 0;
992 mask.y = priv->overlay.y + priv->overlay.height;
993 mask.width = priv->pager_all.width;
994 mask.height = y_pos + priv->slider.height / 2 - priv->win_y - mask.y;
995
996 os_pager_connect (priv->pager, mask);
997 os_pager_set_detached (priv->pager, TRUE);
998
999 os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE);
1000 }
1001 else
1002 {
1003 os_pager_set_detached (priv->pager, FALSE);
1004 os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE);
1005 }
1006 }
1007 else
1008 {
1009 if (priv->win_x + priv->overlay.x > x_pos + priv->slider.width)
1010 {
1011 GdkRectangle mask;
1012
1013 mask.x = x_pos + priv->slider.width / 2 - priv->win_x;
1014 mask.y = 0;
1015 mask.width = priv->overlay.x - mask.x;
1016 mask.height = priv->pager_all.height;
1017
1018 os_pager_connect (priv->pager, mask);
1019 os_pager_set_detached (priv->pager, TRUE);
1020
1021 os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE);
1022 }
1023 else if (priv->win_x + priv->overlay.x + priv->overlay.width < x_pos)
1024 {
1025 GdkRectangle mask;
1026
1027 mask.x = priv->overlay.x + priv->overlay.width;
1028 mask.y = 0;
1029 mask.width = x_pos + priv->slider.width / 2 - priv->win_x - mask.x;
1030 mask.height = priv->pager_all.height;
1031
1032 os_pager_connect (priv->pager, mask);
1033 os_pager_set_detached (priv->pager, TRUE);
1034
1035 os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE);
1036 }
1037 else
1038 {
1039 os_pager_set_detached (priv->pager, FALSE);
1040 os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE);
1041 }
1042 }
1043 }
1044 }1037 }
10451038
1046 move_pager (scrollbar);1039 move_pager (scrollbar);
@@ -1257,8 +1250,10 @@
1257 priv->present_time = g_get_monotonic_time ();1250 priv->present_time = g_get_monotonic_time ();
1258 present_gdk_window_with_timestamp (GTK_WIDGET (scrollbar), event->time);1251 present_gdk_window_with_timestamp (GTK_WIDGET (scrollbar), event->time);
12591252
1260 priv->button_press_event = TRUE;1253 priv->event |= OS_EVENT_BUTTON_PRESS;
1261 priv->motion_notify_event = FALSE;1254 priv->event &= ~(OS_EVENT_MOTION_NOTIFY);
1255
1256 priv->detached_scroll = FALSE;
12621257
1263 if (priv->orientation == GTK_ORIENTATION_VERTICAL)1258 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
1264 {1259 {
@@ -1352,7 +1347,7 @@
13521347
1353 gtk_window_set_transient_for (GTK_WINDOW (widget), NULL);1348 gtk_window_set_transient_for (GTK_WINDOW (widget), NULL);
13541349
1355 if (!priv->motion_notify_event)1350 if (!(priv->event & OS_EVENT_MOTION_NOTIFY) && !priv->detached_scroll)
1356 {1351 {
1357 if (priv->orientation == GTK_ORIENTATION_VERTICAL)1352 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
1358 {1353 {
@@ -1369,11 +1364,10 @@
1369 page_down (scrollbar);1364 page_down (scrollbar);
1370 }1365 }
13711366
1372 priv->value_changed_event = TRUE;1367 priv->event |= OS_EVENT_VALUE_CHANGED;
1373 }1368 }
13741369
1375 priv->button_press_event = FALSE;1370 priv->event &= ~(OS_EVENT_BUTTON_PRESS | OS_EVENT_MOTION_NOTIFY);
1376 priv->motion_notify_event = FALSE;
1377 }1371 }
1378 }1372 }
13791373
@@ -1391,7 +1385,8 @@
1391 scrollbar = OS_SCROLLBAR (user_data);1385 scrollbar = OS_SCROLLBAR (user_data);
1392 priv = scrollbar->priv;1386 priv = scrollbar->priv;
13931387
1394 priv->enter_notify_event = TRUE;1388 priv->event |= OS_EVENT_ENTER_NOTIFY;
1389
1395 priv->can_deactivate_pager = FALSE;1390 priv->can_deactivate_pager = FALSE;
1396 priv->can_hide = FALSE;1391 priv->can_hide = FALSE;
13971392
@@ -1414,7 +1409,7 @@
14141409
1415 /* add the timeouts only if you are1410 /* add the timeouts only if you are
1416 * not interacting with the thumb. */1411 * not interacting with the thumb. */
1417 if (!priv->button_press_event)1412 if (!(priv->event & OS_EVENT_BUTTON_PRESS))
1418 {1413 {
1419 /* never deactivate the pager in an active window. */1414 /* never deactivate the pager in an active window. */
1420 if (!priv->active_window)1415 if (!priv->active_window)
@@ -1586,46 +1581,6 @@
1586 gtk_adjustment_set_value (priv->adjustment, new_value);1581 gtk_adjustment_set_value (priv->adjustment, new_value);
1587}1582}
15881583
1589/* from pointer movement, store the right adjustment value */
1590static void
1591capture_movement_for_animation (OsScrollbar *scrollbar,
1592 gint mouse_x,
1593 gint mouse_y)
1594{
1595 OsScrollbarPrivate *priv;
1596 gint delta;
1597 gint c;
1598 gdouble current_value, old_value, new_value;
1599
1600 priv = scrollbar->priv;
1601
1602 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
1603 delta = mouse_y - priv->slide_initial_coordinate;
1604 else
1605 delta = mouse_x - priv->slide_initial_coordinate;
1606
1607 c = priv->slide_initial_slider_position + delta;
1608
1609 current_value = gtk_adjustment_get_value (priv->adjustment);
1610 old_value = priv->value;
1611 new_value = coord_to_value (scrollbar, c);
1612
1613 /* stop the animation if we are connecting. */
1614 if ((current_value > old_value &&
1615 new_value > current_value) ||
1616 (current_value < old_value &&
1617 new_value < current_value))
1618 {
1619 os_animation_stop (priv->animation, NULL);
1620
1621 gtk_adjustment_set_value (priv->adjustment, new_value);
1622 }
1623
1624 /* update the adjustment value for the reconnect animation:
1625 * set_scroll_cb could be running at that time. */
1626 priv->value = new_value;
1627}
1628
1629static gboolean1584static gboolean
1630thumb_motion_notify_event_cb (GtkWidget *widget,1585thumb_motion_notify_event_cb (GtkWidget *widget,
1631 GdkEventMotion *event,1586 GdkEventMotion *event,
@@ -1637,72 +1592,129 @@
1637 scrollbar = OS_SCROLLBAR (user_data);1592 scrollbar = OS_SCROLLBAR (user_data);
1638 priv = scrollbar->priv;1593 priv = scrollbar->priv;
16391594
1640 if (priv->button_press_event)1595 if (priv->event & OS_EVENT_BUTTON_PRESS)
1641 {1596 {
1642 gint x, y;1597 gint x, y;
16431598
1644 /* reconnect slider and overlay after key press */1599 /* thumb and pager are detached.
1645 if (priv->value_changed_event)1600 * Detached scroll: keep the thumb detached during the scroll,
1601 * update the visual connection when reaching an edge. */
1602 if (priv->event & OS_EVENT_VALUE_CHANGED)
1646 {1603 {
1647 /* return if the mouse movement is small. */1604 /* return if the mouse movement is small. */
1648 if (abs (priv->pointer_x - event->x) <= TOLERANCE_PIXELS &&1605 if (abs (priv->pointer_x - event->x) <= TOLERANCE_PIXELS &&
1649 abs (priv->pointer_y - event->y) <= TOLERANCE_PIXELS)1606 abs (priv->pointer_y - event->y) <= TOLERANCE_PIXELS)
1650 return FALSE;1607 return FALSE;
16511608
1652 if (priv->orientation == GTK_ORIENTATION_VERTICAL)1609 priv->detached_scroll = TRUE;
1653 {
1654 priv->slide_initial_slider_position = event->y_root - priv->win_y - event->y;
1655 priv->slide_initial_coordinate = event->y_root;
1656 }
1657 else
1658 {
1659 priv->slide_initial_slider_position = event->x_root - priv->win_x - event->x;
1660 priv->slide_initial_coordinate = event->x_root;
1661 }
16621610
1663 /* stop the scroll animation if it's running. */1611 /* stop the scroll animation if it's running. */
1664 os_animation_stop (priv->animation, set_scroll_stop_cb);1612 os_animation_stop (priv->animation, NULL);
16651613
1666 /* set the initial adjustment value required for reconnect. */1614 /* limit x and y within the allocation. */
1667 capture_movement_for_animation (scrollbar, event->x_root, event->y_root);
1668
1669 /* animate the reconnect, using the same animation object. */
1670 os_animation_start (priv->animation);
1671
1672 priv->value_changed_event = FALSE;
1673 }
1674
1675 /* only the reconnect animation can be running at that time. */
1676 if (os_animation_is_running (priv->animation))
1677 {
1678 /* update the adjustment value. */
1679 capture_movement_for_animation (scrollbar, event->x_root, event->y_root);
1680
1681 /* limit x and y within the thumb allocation. */
1682 if (priv->orientation == GTK_ORIENTATION_VERTICAL)1615 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
1683 {1616 {
1684 x = priv->win_x;1617 x = priv->win_x;
1685 y = CLAMP (event->y_root - priv->pointer_y,1618 y = CLAMP (event->y_root - priv->pointer_y,
1686 priv->win_y,1619 priv->win_y,
1687 priv->win_y + priv->thumb_all.height);1620 priv->win_y + priv->thumb_all.height - priv->slider.height);
1688 }1621 }
1689 else1622 else
1690 {1623 {
1691 x = CLAMP (event->x_root - priv->pointer_x,1624 x = CLAMP (event->x_root - priv->pointer_x,
1692 priv->win_x,1625 priv->win_x,
1693 priv->win_x + priv->thumb_all.width);1626 priv->win_x + priv->thumb_all.width - priv->slider.width);
1694 y = priv->win_y;1627 y = priv->win_y;
1695 }1628 }
16961629
1630 /* fine scroll while detached,
1631 * do not scroll when hitting an edge. */
1632 if ((priv->orientation == GTK_ORIENTATION_VERTICAL &&
1633 y > priv->win_y &&
1634 y < priv->win_y + priv->thumb_all.height - priv->slider.height) ||
1635 (priv->orientation == GTK_ORIENTATION_HORIZONTAL &&
1636 x > priv->win_x &&
1637 x < priv->win_x + priv->thumb_all.width - priv->slider.width))
1638 capture_movement (scrollbar, event->x_root, event->y_root);
1639
1697 move_thumb (scrollbar, x, y);1640 move_thumb (scrollbar, x, y);
16981641
1699 /* return if the reconnect animation is still running after1642 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
1700 * capture_movement_for_animation. */1643 {
1701 if (os_animation_is_running (priv->animation))1644 if (gtk_adjustment_get_value (priv->adjustment) == 0)
1702 return FALSE;1645 {
1646 update_visual_connection (scrollbar);
1647
1648 if (priv->overlay.height > priv->slider.height)
1649 {
1650 priv->slide_initial_slider_position = 0;
1651 priv->slide_initial_coordinate = MAX (event->y_root, priv->win_y + priv->pointer_y);
1652 }
1653 else
1654 {
1655 priv->slide_initial_slider_position = 0;
1656 priv->slide_initial_coordinate = event->y_root;
1657 }
1658 }
1659 else if (priv->overlay.y + priv->overlay.height >= priv->trough.height)
1660 {
1661 update_visual_connection (scrollbar);
1662
1663 if (priv->overlay.height > priv->slider.height)
1664 {
1665 priv->slide_initial_slider_position = priv->trough.height - priv->overlay.height;
1666 priv->slide_initial_coordinate = MAX (event->y_root, priv->win_y + priv->pointer_y);
1667 }
1668 else
1669 {
1670 priv->slide_initial_slider_position = priv->trough.height - priv->slider.height;
1671 priv->slide_initial_coordinate = event->y_root;
1672 }
1673 }
1674 }
1675 else
1676 {
1677 if (gtk_adjustment_get_value (priv->adjustment) == 0)
1678 {
1679 update_visual_connection (scrollbar);
1680
1681 if (priv->overlay.width > priv->slider.width)
1682 {
1683 priv->slide_initial_slider_position = 0;
1684 priv->slide_initial_coordinate = MAX (event->x_root, priv->win_x + priv->pointer_x);
1685 }
1686 else
1687 {
1688 priv->slide_initial_slider_position = 0;
1689 priv->slide_initial_coordinate = event->x_root;
1690 }
1691 }
1692 else if (priv->overlay.x + priv->overlay.width >= priv->trough.width)
1693 {
1694 update_visual_connection (scrollbar);
1695
1696 if (priv->overlay.width > priv->slider.width)
1697 {
1698 priv->slide_initial_slider_position = priv->trough.width - priv->overlay.width;
1699 priv->slide_initial_coordinate = MAX (event->x_root, priv->win_x + priv->pointer_x);
1700 }
1701 else
1702 {
1703 priv->slide_initial_slider_position = priv->trough.width - priv->slider.width;
1704 priv->slide_initial_coordinate = event->x_root;
1705 }
1706 }
1707 }
1708
1709 return FALSE;
1703 }1710 }
17041711
1705 priv->motion_notify_event = TRUE;1712 OS_DCHECK (!priv->detached_scroll);
1713
1714 /* thumb and pager are connected.
1715 * Normal scroll: keep the thumb in sync with the pager,
1716 * do not update the visual connection. */
1717 priv->event |= OS_EVENT_MOTION_NOTIFY;
17061718
1707 capture_movement (scrollbar, event->x_root, event->y_root);1719 capture_movement (scrollbar, event->x_root, event->y_root);
17081720
@@ -1798,7 +1810,7 @@
1798 scrollbar = OS_SCROLLBAR (user_data);1810 scrollbar = OS_SCROLLBAR (user_data);
1799 priv = scrollbar->priv;1811 priv = scrollbar->priv;
18001812
1801 priv->value_changed_event = TRUE;1813 priv->event |= OS_EVENT_VALUE_CHANGED;
18021814
1803 delta = get_wheel_delta (scrollbar, event->direction);1815 delta = get_wheel_delta (scrollbar, event->direction);
18041816
@@ -1821,9 +1833,9 @@
1821 scrollbar = OS_SCROLLBAR (user_data);1833 scrollbar = OS_SCROLLBAR (user_data);
1822 priv = scrollbar->priv;1834 priv = scrollbar->priv;
18231835
1824 priv->button_press_event = FALSE;1836 priv->event = OS_EVENT_NONE;
1825 priv->motion_notify_event = FALSE;1837
1826 priv->enter_notify_event = FALSE;1838 priv->detached_scroll = FALSE;
18271839
1828 os_pager_set_detached (priv->pager, FALSE);1840 os_pager_set_detached (priv->pager, FALSE);
1829}1841}
@@ -2555,14 +2567,12 @@
2555 os_root_list = g_list_append (os_root_list, scrollbar);2567 os_root_list = g_list_append (os_root_list, scrollbar);
2556 }2568 }
25572569
2558 priv->button_press_event = FALSE;2570 priv->event = OS_EVENT_NONE;
2559 priv->enter_notify_event = FALSE;
2560 priv->motion_notify_event = FALSE;
2561 priv->value_changed_event = FALSE;
25622571
2563 priv->active_window = FALSE;2572 priv->active_window = FALSE;
2564 priv->can_deactivate_pager = TRUE;2573 priv->can_deactivate_pager = TRUE;
2565 priv->can_hide = TRUE;2574 priv->can_hide = TRUE;
2575 priv->detached_scroll = FALSE;
2566 priv->filter = FALSE;2576 priv->filter = FALSE;
2567 priv->fullsize = FALSE;2577 priv->fullsize = FALSE;
2568 priv->internal = FALSE;2578 priv->internal = FALSE;
25692579
=== modified file 'os/os-thumb.c'
--- os/os-thumb.c 2011-06-30 10:52:41 +0000
+++ os/os-thumb.c 2011-07-07 15:06:32 +0000
@@ -56,8 +56,7 @@
56 GtkOrientation orientation;56 GtkOrientation orientation;
57 GtkWidget *grabbed_widget;57 GtkWidget *grabbed_widget;
58 OsAnimation *animation;58 OsAnimation *animation;
59 gboolean button_press_event;59 OsEvent event;
60 gboolean motion_notify_event;
61 gboolean can_rgba;60 gboolean can_rgba;
62 gboolean detached;61 gboolean detached;
63 gboolean use_tolerance;62 gboolean use_tolerance;
@@ -190,8 +189,7 @@
190 OsThumbPrivate);189 OsThumbPrivate);
191 priv = thumb->priv;190 priv = thumb->priv;
192191
193 priv->button_press_event = FALSE;192 priv->event = OS_EVENT_NONE;
194 priv->motion_notify_event = FALSE;
195193
196 priv->can_rgba = FALSE;194 priv->can_rgba = FALSE;
197 priv->detached = FALSE;195 priv->detached = FALSE;
@@ -245,8 +243,8 @@
245 priv->pointer_x = event->x;243 priv->pointer_x = event->x;
246 priv->pointer_y = event->y;244 priv->pointer_y = event->y;
247245
248 priv->button_press_event = TRUE;246 priv->event |= OS_EVENT_BUTTON_PRESS;
249 priv->motion_notify_event = FALSE;247 priv->event &= ~(OS_EVENT_MOTION_NOTIFY);
250248
251 priv->use_tolerance = TRUE;249 priv->use_tolerance = TRUE;
252250
@@ -276,8 +274,7 @@
276 {274 {
277 gtk_grab_remove (widget);275 gtk_grab_remove (widget);
278276
279 priv->button_press_event = FALSE;277 priv->event &= ~(OS_EVENT_BUTTON_PRESS | OS_EVENT_MOTION_NOTIFY);
280 priv->motion_notify_event = FALSE;
281278
282 gtk_widget_queue_draw (widget);279 gtk_widget_queue_draw (widget);
283 }280 }
@@ -687,7 +684,8 @@
687 else684 else
688 pat = cairo_pattern_create_linear (0, 0, width, 0);685 pat = cairo_pattern_create_linear (0, 0, width, 0);
689686
690 if (priv->button_press_event && !priv->motion_notify_event)687 if ((priv->event & OS_EVENT_BUTTON_PRESS) &&
688 !(priv->event & OS_EVENT_MOTION_NOTIFY))
691 {689 {
692 if ((priv->orientation == GTK_ORIENTATION_VERTICAL && (priv->pointer_y < height / 2)) ||690 if ((priv->orientation == GTK_ORIENTATION_VERTICAL && (priv->pointer_y < height / 2)) ||
693 (priv->orientation == GTK_ORIENTATION_HORIZONTAL && (priv->pointer_x < width / 2)))691 (priv->orientation == GTK_ORIENTATION_HORIZONTAL && (priv->pointer_x < width / 2)))
@@ -715,7 +713,7 @@
715 cairo_set_source (cr, pat);713 cairo_set_source (cr, pat);
716 cairo_pattern_destroy (pat);714 cairo_pattern_destroy (pat);
717715
718 if (priv->motion_notify_event)716 if (priv->event & OS_EVENT_MOTION_NOTIFY)
719 {717 {
720 cairo_fill_preserve (cr);718 cairo_fill_preserve (cr);
721 set_source_gdk_rgba (cr, &bg_arrow_down, 0.3);719 set_source_gdk_rgba (cr, &bg_arrow_down, 0.3);
@@ -837,8 +835,8 @@
837 /* If we exit the thumb when a button is pressed,835 /* If we exit the thumb when a button is pressed,
838 * there's no need to stop the animation, it should836 * there's no need to stop the animation, it should
839 * already be stopped.837 * already be stopped.
840 * Stop it only if priv->button_press_event is FALSE. */838 * Stop it only if OS_EVENT_BUTTON_PRESS is not set. */
841 if (!priv->button_press_event)839 if (!(priv->event & OS_EVENT_BUTTON_PRESS))
842 {840 {
843 if (priv->source_id != 0)841 if (priv->source_id != 0)
844 {842 {
@@ -901,9 +899,9 @@
901899
902 /* If you're not dragging, and you're outside900 /* If you're not dragging, and you're outside
903 * the tolerance pixels, enable the fade-out.901 * the tolerance pixels, enable the fade-out.
904 * priv->motion_notify_event is TRUE only on dragging,902 * OS_EVENT_MOTION_NOTIFY is set only on dragging,
905 * see code few lines below. */903 * see code few lines below. */
906 if (!priv->motion_notify_event)904 if (!(priv->event & OS_EVENT_MOTION_NOTIFY))
907 {905 {
908 if (!priv->use_tolerance ||906 if (!priv->use_tolerance ||
909 (abs (priv->pointer_x - event->x) > TOLERANCE_PIXELS ||907 (abs (priv->pointer_x - event->x) > TOLERANCE_PIXELS ||
@@ -916,12 +914,12 @@
916 }914 }
917 }915 }
918916
919 if (priv->button_press_event)917 if (priv->event & OS_EVENT_BUTTON_PRESS)
920 {918 {
921 if (!priv->motion_notify_event)919 if (!(priv->event & OS_EVENT_MOTION_NOTIFY))
922 gtk_widget_queue_draw (widget);920 gtk_widget_queue_draw (widget);
923921
924 priv->motion_notify_event = TRUE;922 priv->event |= OS_EVENT_MOTION_NOTIFY;
925 }923 }
926924
927 return FALSE;925 return FALSE;
@@ -988,8 +986,7 @@
988 thumb = OS_THUMB (widget);986 thumb = OS_THUMB (widget);
989 priv = thumb->priv;987 priv = thumb->priv;
990988
991 priv->button_press_event = FALSE;989 priv->event = OS_EVENT_NONE;
992 priv->motion_notify_event = FALSE;
993990
994 priv->use_tolerance = FALSE;991 priv->use_tolerance = FALSE;
995992
@@ -1155,6 +1152,7 @@
1155 if (priv->detached != detached)1152 if (priv->detached != detached)
1156 {1153 {
1157 priv->detached = detached;1154 priv->detached = detached;
1155
1158 gtk_widget_queue_draw (GTK_WIDGET (thumb));1156 gtk_widget_queue_draw (GTK_WIDGET (thumb));
1159 }1157 }
1160}1158}

Subscribers

People subscribed via source and target branches