Merge lp:~cimi/overlay-scrollbar/fix-motion-after-reconnection into lp:overlay-scrollbar

Proposed by Andrea Cimitan
Status: Merged
Approved by: Ted Gould
Approved revision: 318
Merged at revision: 321
Proposed branch: lp:~cimi/overlay-scrollbar/fix-motion-after-reconnection
Merge into: lp:overlay-scrollbar
Diff against target: 163 lines (+64/-40)
1 file modified
os/os-scrollbar.c (+64/-40)
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/fix-motion-after-reconnection
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+84500@code.launchpad.net

This proposal supersedes a proposal from 2011-12-05.

Description of the change

Fixes motion notify event after reconnection animation ended. Plus add some comments.

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) :
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 2011-12-02 17:04:13 +0000
+++ os/os-scrollbar.c 2011-12-05 16:52:24 +0000
@@ -71,31 +71,31 @@
7171
72typedef enum72typedef enum
73{73{
74 OS_SIDE_TOP,74 OS_SIDE_TOP, /* Scrollbar is at top. */
75 OS_SIDE_BOTTOM,75 OS_SIDE_BOTTOM, /* Scrollbar is at bottom. */
76 OS_SIDE_LEFT,76 OS_SIDE_LEFT, /* Scrollbar is at left. */
77 OS_SIDE_RIGHT77 OS_SIDE_RIGHT /* Scrollbar is at right. */
78} OsSide;78} OsSide;
7979
80typedef enum80typedef enum
81{81{
82 OS_STATE_NONE = 0,82 OS_STATE_NONE = 0, /* No state. */
83 OS_STATE_CONNECTED = 1,83 OS_STATE_CONNECTED = 1, /* Thumb and bar move connected, like a native scrollbar. */
84 OS_STATE_DETACHED = 2,84 OS_STATE_DETACHED = 2, /* The thumb is visually detached from the bar, and you can see the tail. */
85 OS_STATE_FINE_SCROLL = 4,85 OS_STATE_FINE_SCROLL = 4, /* A fine scroll is currently running, the modifier key must be pressed. */
86 OS_STATE_FULLSIZE = 8,86 OS_STATE_FULLSIZE = 8, /* The scrollbar is fullsize, so we hide it. */
87 OS_STATE_INTERNAL = 16,87 OS_STATE_INTERNAL = 16, /* The thumb is touching a strut or a screen edge, it's internal. */
88 OS_STATE_LOCKED = 32,88 OS_STATE_LOCKED = 32, /* Thumb is locked in its position when moving in the proximity area. */
89 OS_STATE_RECONNECTING = 6489 OS_STATE_RECONNECTING = 64 /* The thumb is reconnecting with the bar, there's likely an animation in progress. */
90} OsStateFlags;90} OsStateFlags;
9191
92typedef enum92typedef enum
93{93{
94 OS_STRUT_SIDE_NONE = 0,94 OS_STRUT_SIDE_NONE = 0, /* No strut. */
95 OS_STRUT_SIDE_TOP = 1,95 OS_STRUT_SIDE_TOP = 1, /* Strut at top. */
96 OS_STRUT_SIDE_BOTTOM = 2,96 OS_STRUT_SIDE_BOTTOM = 2, /* Strut at bottom. */
97 OS_STRUT_SIDE_LEFT = 4,97 OS_STRUT_SIDE_LEFT = 4, /* Strut at left. */
98 OS_STRUT_SIDE_RIGHT = 898 OS_STRUT_SIDE_RIGHT = 8 /* Strut at right. */
99} OsStrutSideFlags;99} OsStrutSideFlags;
100100
101typedef struct101typedef struct
@@ -996,10 +996,46 @@
996996
997 priv = scrollbar->priv;997 priv = scrollbar->priv;
998998
999 priv->state &= ~(OS_STATE_RECONNECTING);999 /* Only update the slide values at the end of a reconnection,
10001000 * with the button pressed, otherwise it's not needed. */
1001 check_connection (scrollbar);1001 if ((priv->state & OS_STATE_RECONNECTING) &&
1002}1002 (priv->event & OS_EVENT_BUTTON_PRESS))
1003 {
1004 gint x_pos, y_pos;
1005
1006 gdk_window_get_origin (gtk_widget_get_window (priv->thumb), &x_pos, &y_pos);
1007
1008 calc_precise_slide_values (scrollbar, x_pos + priv->pointer.x, y_pos + priv->pointer.y);
1009 }
1010
1011 /* Check if the thumb can be considered connected after the animation. */
1012 check_connection (scrollbar);
1013
1014 /* Unset OS_STATE_RECONNECTING since the animation ended. */
1015 priv->state &= ~(OS_STATE_RECONNECTING);
1016}
1017
1018/* Stop function called by the scrolling animation. */
1019static void
1020scrolling_stop_cb (gpointer user_data)
1021{
1022 OsScrollbar *scrollbar;
1023 OsScrollbarPrivate *priv;
1024
1025 scrollbar = OS_SCROLLBAR (user_data);
1026
1027 priv = scrollbar->priv;
1028
1029 /* No slide values update here,
1030 * handle them separately! */
1031
1032 /* Check if the thumb can be considered connected after the animation. */
1033 check_connection (scrollbar);
1034
1035 /* Unset OS_STATE_RECONNECTING since the animation ended. */
1036 priv->state &= ~(OS_STATE_RECONNECTING);
1037}
1038
10031039
1004/* Swap adjustment pointer. */1040/* Swap adjustment pointer. */
1005static void1041static void
@@ -1521,29 +1557,17 @@
1521 {1557 {
1522 /* Reconnect the thumb with the bar. */1558 /* Reconnect the thumb with the bar. */
1523 gdouble new_value;1559 gdouble new_value;
1524 gint c, delta;1560 gfloat c;
1525 gint32 duration;1561 gint32 duration;
15261562
1527 if (priv->orientation == GTK_ORIENTATION_VERTICAL)1563 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
1528 {1564 c = event->y_root - priv->thumb_win.y - event->y;
1529 priv->slide_initial_slider_position = event->y_root - priv->thumb_win.y - event->y;
1530 priv->slide_initial_coordinate = event->y_root;
1531
1532 delta = event->y_root - priv->slide_initial_coordinate;
1533 }
1534 else1565 else
1535 {1566 c = event->x_root - priv->thumb_win.x - event->x;
1536 priv->slide_initial_slider_position = event->x_root - priv->thumb_win.x - event->x;
1537 priv->slide_initial_coordinate = event->x_root;
1538
1539 delta = event->x_root - priv->slide_initial_coordinate;
1540 }
1541
1542 c = priv->slide_initial_slider_position + delta;
15431567
1544 /* If a scrolling animation is running,1568 /* If a scrolling animation is running,
1545 * stop it and add the new value. */1569 * stop it and add the new value. */
1546 os_animation_stop (priv->animation, NULL);1570 os_animation_stop (priv->animation, scrolling_stop_cb);
15471571
1548 new_value = coord_to_value (scrollbar, c);1572 new_value = coord_to_value (scrollbar, c);
15491573
@@ -1603,7 +1627,7 @@
1603 * stop it and add the new value. */1627 * stop it and add the new value. */
1604 if (os_animation_is_running (priv->animation))1628 if (os_animation_is_running (priv->animation))
1605 {1629 {
1606 os_animation_stop (priv->animation, NULL);1630 os_animation_stop (priv->animation, scrolling_stop_cb);
1607 new_value = priv->value + increment;1631 new_value = priv->value + increment;
1608 }1632 }
1609 else1633 else
@@ -1650,7 +1674,7 @@
1650 * stop it and subtract the new value. */1674 * stop it and subtract the new value. */
1651 if (os_animation_is_running (priv->animation))1675 if (os_animation_is_running (priv->animation))
1652 {1676 {
1653 os_animation_stop (priv->animation, NULL);1677 os_animation_stop (priv->animation, scrolling_stop_cb);
1654 new_value = priv->value - increment;1678 new_value = priv->value - increment;
1655 }1679 }
1656 else1680 else
@@ -1950,7 +1974,7 @@
1950 else1974 else
1951 {1975 {
1952 /* Stop the paging animation now. */1976 /* Stop the paging animation now. */
1953 os_animation_stop (priv->animation, NULL);1977 os_animation_stop (priv->animation, scrolling_stop_cb);
1954 }1978 }
1955 }1979 }
19561980

Subscribers

People subscribed via source and target branches