Merge lp:~cimi/overlay-scrollbar/new-scrolling-modes into lp:overlay-scrollbar

Proposed by Andrea Cimitan
Status: Merged
Approved by: Ted Gould
Approved revision: 319
Merged at revision: 319
Proposed branch: lp:~cimi/overlay-scrollbar/new-scrolling-modes
Merge into: lp:overlay-scrollbar
Diff against target: 516 lines (+228/-67)
1 file modified
os/os-scrollbar.c (+228/-67)
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/new-scrolling-modes
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+84294@code.launchpad.net

Description of the change

Use modifier keys (right now, control), to allow new scrolling modes.

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-11-30 21:15:01 +0000
+++ os/os-scrollbar.c 2011-12-02 17:10:28 +0000
@@ -46,6 +46,9 @@
46/* Min duration of the scrolling. */46/* Min duration of the scrolling. */
47#define MIN_DURATION_SCROLLING 25047#define MIN_DURATION_SCROLLING 250
4848
49/* Modifier key used to slow down actions. */
50#define MODIFIER_KEY GDK_CONTROL_MASK
51
49/* Timeout assumed for PropertyNotify _NET_ACTIVE_WINDOW event. */52/* Timeout assumed for PropertyNotify _NET_ACTIVE_WINDOW event. */
50#define TIMEOUT_PRESENT_WINDOW 40053#define TIMEOUT_PRESENT_WINDOW 400
5154
@@ -61,6 +64,11 @@
61/* Timeout before hiding in ms, after leaving the toplevel. */64/* Timeout before hiding in ms, after leaving the toplevel. */
62#define TIMEOUT_TOPLEVEL_HIDE 20065#define TIMEOUT_TOPLEVEL_HIDE 200
6366
67typedef enum {
68 OS_SCROLL_PAGE,
69 OS_SCROLL_STEP
70} OsScrollType;
71
64typedef enum72typedef enum
65{73{
66 OS_SIDE_TOP,74 OS_SIDE_TOP,
@@ -74,10 +82,11 @@
74 OS_STATE_NONE = 0,82 OS_STATE_NONE = 0,
75 OS_STATE_CONNECTED = 1,83 OS_STATE_CONNECTED = 1,
76 OS_STATE_DETACHED = 2,84 OS_STATE_DETACHED = 2,
77 OS_STATE_FULLSIZE = 4,85 OS_STATE_FINE_SCROLL = 4,
78 OS_STATE_INTERNAL = 8,86 OS_STATE_FULLSIZE = 8,
79 OS_STATE_LOCKED = 16,87 OS_STATE_INTERNAL = 16,
80 OS_STATE_RECONNECTING = 3288 OS_STATE_LOCKED = 32,
89 OS_STATE_RECONNECTING = 64
81} OsStateFlags;90} OsStateFlags;
8291
83typedef enum92typedef enum
@@ -119,8 +128,9 @@
119 gboolean hidable_thumb;128 gboolean hidable_thumb;
120 gboolean window_button_press; /* FIXME(Cimi) to replace with X11 input events. */129 gboolean window_button_press; /* FIXME(Cimi) to replace with X11 input events. */
121 gdouble value;130 gdouble value;
122 gint slide_initial_slider_position;131 gfloat fine_scroll_multiplier;
123 gint slide_initial_coordinate;132 gfloat slide_initial_slider_position;
133 gfloat slide_initial_coordinate;
124 gint64 present_time;134 gint64 present_time;
125 guint32 source_deactivate_bar_id;135 guint32 source_deactivate_bar_id;
126 guint32 source_hide_thumb_id;136 guint32 source_hide_thumb_id;
@@ -171,6 +181,97 @@
171static void os_scrollbar_dispose (GObject *object);181static void os_scrollbar_dispose (GObject *object);
172static void os_scrollbar_finalize (GObject *object);182static void os_scrollbar_finalize (GObject *object);
173183
184/* Calculate slide_initial_slider_position with more precision. */
185static void
186calc_precise_slide_values (OsScrollbar *scrollbar,
187 gfloat x_coordinate,
188 gfloat y_coordinate)
189{
190 OsScrollbarPrivate *priv;
191 gdouble adjustment_value;
192
193 priv = scrollbar->priv;
194
195 adjustment_value = gtk_adjustment_get_value (priv->adjustment);
196
197 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
198 {
199 gdouble y1, y2, trough_length, height;
200
201 y1 = 0;
202 trough_length = priv->trough.height;
203
204 if (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment) != 0)
205 height = (trough_length * (gtk_adjustment_get_page_size (priv->adjustment) /
206 (gtk_adjustment_get_upper (priv->adjustment) -
207 gtk_adjustment_get_lower (priv->adjustment))));
208 else
209 height = gtk_range_get_min_slider_size (GTK_RANGE (scrollbar));
210
211 height = MAX (height, gtk_range_get_min_slider_size (GTK_RANGE (scrollbar)));
212
213 if (gtk_adjustment_get_upper (priv->adjustment) -
214 gtk_adjustment_get_lower (priv->adjustment) -
215 gtk_adjustment_get_page_size (priv->adjustment) != 0)
216 y1 = (trough_length - height) * ((adjustment_value - gtk_adjustment_get_lower (priv->adjustment)) /
217 (gtk_adjustment_get_upper (priv->adjustment) -
218 gtk_adjustment_get_lower (priv->adjustment) -
219 gtk_adjustment_get_page_size (priv->adjustment)));
220
221 y2 = 0;
222 height = priv->slider.height;
223
224 if (gtk_adjustment_get_upper (priv->adjustment) -
225 gtk_adjustment_get_lower (priv->adjustment) -
226 gtk_adjustment_get_page_size (priv->adjustment) != 0)
227 y2 = (trough_length - height) * ((adjustment_value - gtk_adjustment_get_lower (priv->adjustment)) /
228 (gtk_adjustment_get_upper (priv->adjustment) -
229 gtk_adjustment_get_lower (priv->adjustment) -
230 gtk_adjustment_get_page_size (priv->adjustment)));
231
232 priv->slide_initial_slider_position = CLAMP (MIN (y1, y2), 0, trough_length);
233 priv->slide_initial_coordinate = y_coordinate;
234 }
235 else
236 {
237 gdouble x1, x2, trough_length, width;
238
239 x1 = 0;
240 trough_length = priv->trough.width;
241
242 if (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment) != 0)
243 width = (trough_length * (gtk_adjustment_get_page_size (priv->adjustment) /
244 (gtk_adjustment_get_upper (priv->adjustment) -
245 gtk_adjustment_get_lower (priv->adjustment))));
246 else
247 width = gtk_range_get_min_slider_size (GTK_RANGE (scrollbar));
248
249 width = MAX (width, gtk_range_get_min_slider_size (GTK_RANGE (scrollbar)));
250
251 if (gtk_adjustment_get_upper (priv->adjustment) -
252 gtk_adjustment_get_lower (priv->adjustment) -
253 gtk_adjustment_get_page_size (priv->adjustment) != 0)
254 x1 = (trough_length - width) * ((adjustment_value - gtk_adjustment_get_lower (priv->adjustment)) /
255 (gtk_adjustment_get_upper (priv->adjustment) -
256 gtk_adjustment_get_lower (priv->adjustment) -
257 gtk_adjustment_get_page_size (priv->adjustment)));
258
259 x2 = 0;
260 width = priv->slider.width;
261
262 if (gtk_adjustment_get_upper (priv->adjustment) -
263 gtk_adjustment_get_lower (priv->adjustment) -
264 gtk_adjustment_get_page_size (priv->adjustment) != 0)
265 x2 = (trough_length - width) * ((adjustment_value - gtk_adjustment_get_lower (priv->adjustment)) /
266 (gtk_adjustment_get_upper (priv->adjustment) -
267 gtk_adjustment_get_lower (priv->adjustment) -
268 gtk_adjustment_get_page_size (priv->adjustment)));
269
270 priv->slide_initial_slider_position = CLAMP (MIN (x1, x2), 0, trough_length);
271 priv->slide_initial_coordinate = x_coordinate;
272 }
273}
274
174/* Calculate bar layout info. */275/* Calculate bar layout info. */
175static void276static void
176calc_layout_bar (OsScrollbar *scrollbar,277calc_layout_bar (OsScrollbar *scrollbar,
@@ -393,9 +494,9 @@
393}494}
394495
395/* Traduce coordinates into GtkRange values. */496/* Traduce coordinates into GtkRange values. */
396static gdouble497static inline gdouble
397coord_to_value (OsScrollbar *scrollbar,498coord_to_value (OsScrollbar *scrollbar,
398 gint coord)499 gfloat coord)
399{500{
400 OsScrollbarPrivate *priv;501 OsScrollbarPrivate *priv;
401 gdouble frac;502 gdouble frac;
@@ -1010,6 +1111,24 @@
10101111
1011/* Adjustment functions. */1112/* Adjustment functions. */
10121113
1114/* Calculate fine_scroll_multiplier. */
1115static void
1116calc_fine_scroll_multiplier (OsScrollbar *scrollbar)
1117{
1118 OsScrollbarPrivate *priv;
1119
1120 priv = scrollbar->priv;
1121
1122 /* FIXME(Cimi) Not sure about this calculation...
1123 * However seems to work "enough" well. */
1124 priv->fine_scroll_multiplier = MIN ((priv->orientation == GTK_ORIENTATION_VERTICAL ?
1125 priv->trough.height : priv->trough.width) /
1126 (gtk_adjustment_get_upper (priv->adjustment) -
1127 gtk_adjustment_get_lower (priv->adjustment) -
1128 gtk_adjustment_get_page_size (priv->adjustment)),
1129 1);
1130}
1131
1013static void1132static void
1014adjustment_changed_cb (GtkAdjustment *adjustment,1133adjustment_changed_cb (GtkAdjustment *adjustment,
1015 gpointer user_data)1134 gpointer user_data)
@@ -1046,6 +1165,7 @@
10461165
1047 calc_layout_bar (scrollbar, gtk_adjustment_get_value (adjustment));1166 calc_layout_bar (scrollbar, gtk_adjustment_get_value (adjustment));
1048 calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment));1167 calc_layout_slider (scrollbar, gtk_adjustment_get_value (adjustment));
1168 calc_fine_scroll_multiplier (scrollbar);
10491169
1050 if (!(priv->event & OS_EVENT_ENTER_NOTIFY) &&1170 if (!(priv->event & OS_EVENT_ENTER_NOTIFY) &&
1051 !(priv->event & OS_EVENT_MOTION_NOTIFY))1171 !(priv->event & OS_EVENT_MOTION_NOTIFY))
@@ -1395,7 +1515,9 @@
1395 priv->event |= OS_EVENT_BUTTON_PRESS;1515 priv->event |= OS_EVENT_BUTTON_PRESS;
1396 priv->event &= ~(OS_EVENT_MOTION_NOTIFY);1516 priv->event &= ~(OS_EVENT_MOTION_NOTIFY);
13971517
1398 if (event->button == 2)1518 /* Middle-click or shift+left-click for "jump to" action. */
1519 if (event->button == 2 ||
1520 (event->button == 1 && (event->state & GDK_SHIFT_MASK)))
1399 {1521 {
1400 /* Reconnect the thumb with the bar. */1522 /* Reconnect the thumb with the bar. */
1401 gdouble new_value;1523 gdouble new_value;
@@ -1450,16 +1572,7 @@
1450 }1572 }
1451 }1573 }
14521574
1453 if (priv->orientation == GTK_ORIENTATION_VERTICAL)1575 calc_precise_slide_values (scrollbar, event->x_root, event->y_root);
1454 {
1455 priv->slide_initial_slider_position = MIN (priv->slider.y, priv->overlay.y);
1456 priv->slide_initial_coordinate = event->y_root;
1457 }
1458 else
1459 {
1460 priv->slide_initial_slider_position = MIN (priv->slider.x, priv->overlay.x);
1461 priv->slide_initial_coordinate = event->x_root;
1462 }
14631576
1464 priv->pointer.x = event->x;1577 priv->pointer.x = event->x;
1465 priv->pointer.y = event->y;1578 priv->pointer.y = event->y;
@@ -1469,26 +1582,32 @@
1469 return FALSE;1582 return FALSE;
1470}1583}
14711584
1472/* Page down, with animation. */1585/* Scroll down, with animation. */
1473static void1586static void
1474page_down (OsScrollbar *scrollbar)1587scroll_down (OsScrollbar *scrollbar,
1588 OsScrollType scroll_type)
1475{1589{
1476 OsScrollbarPrivate *priv;1590 OsScrollbarPrivate *priv;
1477 gdouble new_value;1591 gdouble new_value, increment;
1478 gint32 duration;1592 gint32 duration;
14791593
1480 priv = scrollbar->priv;1594 priv = scrollbar->priv;
14811595
1596 /* Either step down or page down. */
1597 if (scroll_type == OS_SCROLL_STEP)
1598 increment = gtk_adjustment_get_step_increment (priv->adjustment);
1599 else
1600 increment = gtk_adjustment_get_page_increment (priv->adjustment);
1601
1482 /* If a scrolling animation is running,1602 /* If a scrolling animation is running,
1483 * stop it and add the new value. */1603 * stop it and add the new value. */
1484 if (os_animation_is_running (priv->animation))1604 if (os_animation_is_running (priv->animation))
1485 {1605 {
1486 os_animation_stop (priv->animation, NULL);1606 os_animation_stop (priv->animation, NULL);
1487 new_value = priv->value + gtk_adjustment_get_page_increment (priv->adjustment);1607 new_value = priv->value + increment;
1488 }1608 }
1489 else1609 else
1490 new_value = gtk_adjustment_get_value (priv->adjustment) +1610 new_value = gtk_adjustment_get_value (priv->adjustment) + increment;
1491 gtk_adjustment_get_page_increment (priv->adjustment);
14921611
1493 priv->value = CLAMP (new_value,1612 priv->value = CLAMP (new_value,
1494 gtk_adjustment_get_lower (priv->adjustment),1613 gtk_adjustment_get_lower (priv->adjustment),
@@ -1499,8 +1618,10 @@
1499 return;1618 return;
15001619
1501 /* Calculate and set the duration. */1620 /* Calculate and set the duration. */
1502 duration = MIN_DURATION_SCROLLING + ((priv->value - gtk_adjustment_get_value (priv->adjustment)) /1621 if (scroll_type == OS_SCROLL_STEP)
1503 gtk_adjustment_get_page_increment (priv->adjustment)) *1622 duration = MIN_DURATION_SCROLLING;
1623 else
1624 duration = MIN_DURATION_SCROLLING + ((priv->value - gtk_adjustment_get_value (priv->adjustment)) / increment) *
1504 (MAX_DURATION_SCROLLING - MIN_DURATION_SCROLLING);1625 (MAX_DURATION_SCROLLING - MIN_DURATION_SCROLLING);
1505 os_animation_set_duration (priv->animation, duration);1626 os_animation_set_duration (priv->animation, duration);
15061627
@@ -1508,26 +1629,32 @@
1508 os_animation_start (priv->animation);1629 os_animation_start (priv->animation);
1509}1630}
15101631
1511/* Page up, with animation. */1632/* Scroll up, with animation. */
1512static void1633static void
1513page_up (OsScrollbar *scrollbar)1634scroll_up (OsScrollbar *scrollbar,
1635 OsScrollType scroll_type)
1514{1636{
1515 OsScrollbarPrivate *priv;1637 OsScrollbarPrivate *priv;
1516 gdouble new_value;1638 gdouble new_value, increment;
1517 gint32 duration;1639 gint32 duration;
15181640
1519 priv = scrollbar->priv;1641 priv = scrollbar->priv;
15201642
1643 /* Either step up or page up. */
1644 if (scroll_type == OS_SCROLL_STEP)
1645 increment = gtk_adjustment_get_step_increment (priv->adjustment);
1646 else
1647 increment = gtk_adjustment_get_page_increment (priv->adjustment);
1648
1521 /* If a scrolling animation is running,1649 /* If a scrolling animation is running,
1522 * stop it and subtract the new value. */1650 * stop it and subtract the new value. */
1523 if (os_animation_is_running (priv->animation))1651 if (os_animation_is_running (priv->animation))
1524 {1652 {
1525 os_animation_stop (priv->animation, NULL);1653 os_animation_stop (priv->animation, NULL);
1526 new_value = priv->value - gtk_adjustment_get_page_increment (priv->adjustment);1654 new_value = priv->value - increment;
1527 }1655 }
1528 else1656 else
1529 new_value = gtk_adjustment_get_value (priv->adjustment) -1657 new_value = gtk_adjustment_get_value (priv->adjustment) - increment;
1530 gtk_adjustment_get_page_increment (priv->adjustment);
15311658
1532 priv->value = CLAMP (new_value,1659 priv->value = CLAMP (new_value,
1533 gtk_adjustment_get_lower (priv->adjustment),1660 gtk_adjustment_get_lower (priv->adjustment),
@@ -1538,9 +1665,11 @@
1538 return;1665 return;
15391666
1540 /* Calculate and set the duration. */1667 /* Calculate and set the duration. */
1541 duration = MIN_DURATION_SCROLLING + ((gtk_adjustment_get_value (priv->adjustment) - priv->value) /1668 if (scroll_type == OS_SCROLL_STEP)
1542 gtk_adjustment_get_page_increment (priv->adjustment)) *1669 duration = MIN_DURATION_SCROLLING;
1543 (MAX_DURATION_SCROLLING - MIN_DURATION_SCROLLING);1670 else
1671 duration = MIN_DURATION_SCROLLING + ((gtk_adjustment_get_value (priv->adjustment) - priv->value) / increment) *
1672 (MAX_DURATION_SCROLLING - MIN_DURATION_SCROLLING);
1544 os_animation_set_duration (priv->animation, duration);1673 os_animation_set_duration (priv->animation, duration);
15451674
1546 /* Start the scrolling animation. */1675 /* Start the scrolling animation. */
@@ -1565,22 +1694,32 @@
15651694
1566 gtk_window_set_transient_for (GTK_WINDOW (widget), NULL);1695 gtk_window_set_transient_for (GTK_WINDOW (widget), NULL);
15671696
1697 /* Don't trigger actions on thumb dragging or jump-to scrolling. */
1568 if (event->button == 1 &&1698 if (event->button == 1 &&
1699 !(event->state & GDK_SHIFT_MASK) &&
1569 !(priv->event & OS_EVENT_MOTION_NOTIFY))1700 !(priv->event & OS_EVENT_MOTION_NOTIFY))
1570 {1701 {
1702 OsScrollType scroll_type;
1703
1704 /* Type of the scroll to perform. */
1705 if (event->state & MODIFIER_KEY)
1706 scroll_type = OS_SCROLL_STEP;
1707 else
1708 scroll_type = OS_SCROLL_PAGE;
1709
1571 if (priv->orientation == GTK_ORIENTATION_VERTICAL)1710 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
1572 {1711 {
1573 if (priv->pointer.y < priv->slider.height / 2)1712 if (priv->pointer.y < priv->slider.height / 2)
1574 page_up (scrollbar);1713 scroll_up (scrollbar, scroll_type);
1575 else1714 else
1576 page_down (scrollbar);1715 scroll_down (scrollbar, scroll_type);
1577 }1716 }
1578 else1717 else
1579 {1718 {
1580 if (priv->pointer.x < priv->slider.width / 2)1719 if (priv->pointer.x < priv->slider.width / 2)
1581 page_up (scrollbar);1720 scroll_up (scrollbar, scroll_type);
1582 else1721 else
1583 page_down (scrollbar);1722 scroll_down (scrollbar, scroll_type);
1584 }1723 }
1585 }1724 }
15861725
@@ -1746,8 +1885,8 @@
1746 gint mouse_y)1885 gint mouse_y)
1747{1886{
1748 OsScrollbarPrivate *priv;1887 OsScrollbarPrivate *priv;
1888 gfloat c;
1749 gint delta;1889 gint delta;
1750 gint c;
1751 gdouble new_value;1890 gdouble new_value;
17521891
1753 priv = scrollbar->priv;1892 priv = scrollbar->priv;
@@ -1757,7 +1896,11 @@
1757 else1896 else
1758 delta = mouse_x - priv->slide_initial_coordinate;1897 delta = mouse_x - priv->slide_initial_coordinate;
17591898
1760 c = priv->slide_initial_slider_position + delta;1899 /* With fine scroll, slow down the scroll. */
1900 if (priv->state & OS_STATE_FINE_SCROLL)
1901 c = priv->slide_initial_slider_position + delta * priv->fine_scroll_multiplier;
1902 else
1903 c = priv->slide_initial_slider_position + delta;
17611904
1762 new_value = coord_to_value (scrollbar, c);1905 new_value = coord_to_value (scrollbar, c);
17631906
@@ -1802,16 +1945,7 @@
1802 if (priv->state & OS_STATE_RECONNECTING)1945 if (priv->state & OS_STATE_RECONNECTING)
1803 {1946 {
1804 /* It's a reconnecting animation. */1947 /* It's a reconnecting animation. */
1805 if (priv->orientation == GTK_ORIENTATION_VERTICAL)1948 calc_precise_slide_values (scrollbar, event->x_root, event->y_root);
1806 {
1807 priv->slide_initial_slider_position = MIN (priv->slider.y, priv->overlay.y);
1808 priv->slide_initial_coordinate = event->y_root;
1809 }
1810 else
1811 {
1812 priv->slide_initial_slider_position = MIN (priv->slider.x, priv->overlay.x);
1813 priv->slide_initial_coordinate = event->x_root;
1814 }
1815 }1949 }
1816 else1950 else
1817 {1951 {
@@ -1820,6 +1954,34 @@
1820 }1954 }
1821 }1955 }
18221956
1957 /* Check for modifier keys. */
1958 if (event->state & MODIFIER_KEY)
1959 {
1960 /* You pressed the modifier key for the first time,
1961 * let's deal with it. */
1962 if (!(priv->state & OS_STATE_FINE_SCROLL))
1963 {
1964 calc_fine_scroll_multiplier (scrollbar);
1965 calc_precise_slide_values (scrollbar, event->x_root, event->y_root);
1966
1967 priv->state |= OS_STATE_FINE_SCROLL;
1968 }
1969
1970 priv->state &= ~(OS_STATE_CONNECTED);
1971 }
1972 else
1973 {
1974 /* You released the modifier key for the first time,
1975 * let's deal with it. */
1976 if (priv->state & OS_STATE_FINE_SCROLL)
1977 {
1978 /* Recalculate slider positions. */
1979 calc_precise_slide_values (scrollbar, event->x_root, event->y_root);
1980
1981 priv->state &= ~(OS_STATE_FINE_SCROLL);
1982 }
1983 }
1984
1823 /* Behave differently when the thumb is connected or not. */1985 /* Behave differently when the thumb is connected or not. */
1824 if (priv->state & OS_STATE_CONNECTED)1986 if (priv->state & OS_STATE_CONNECTED)
1825 {1987 {
@@ -1867,7 +2029,7 @@
1867 }2029 }
1868 else2030 else
1869 {2031 {
1870 /* This is a fine scroll, works subtly different.2032 /* This is a disconnected scroll, works subtly different.
1871 * It has to take care of reconnection,2033 * It has to take care of reconnection,
1872 * and scrolling is not allowed when hitting an edge. */2034 * and scrolling is not allowed when hitting an edge. */
18732035
@@ -1887,7 +2049,7 @@
1887 y = priv->thumb_win.y;2049 y = priv->thumb_win.y;
1888 }2050 }
18892051
1890 /* Fine scroll while detached,2052 /* Disconnected scroll while detached,
1891 * do not scroll when hitting an edge. */2053 * do not scroll when hitting an edge. */
1892 if ((priv->orientation == GTK_ORIENTATION_VERTICAL &&2054 if ((priv->orientation == GTK_ORIENTATION_VERTICAL &&
1893 y > priv->thumb_win.y &&2055 y > priv->thumb_win.y &&
@@ -1905,9 +2067,10 @@
1905 capture_movement (scrollbar, event->x_root, event->y_root);2067 capture_movement (scrollbar, event->x_root, event->y_root);
1906 }2068 }
1907 else if (!os_animation_is_running (priv->animation) &&2069 else if (!os_animation_is_running (priv->animation) &&
1908 !(priv->state & OS_STATE_DETACHED))2070 !(priv->state & OS_STATE_DETACHED) &&
2071 !(priv->state & OS_STATE_FINE_SCROLL))
1909 {2072 {
1910 /* Animate scrolling till reaches the edge. */2073 /* Animate scrolling till reaches the edge. */
1911 if ((priv->orientation == GTK_ORIENTATION_VERTICAL && y <= priv->thumb_win.y) ||2074 if ((priv->orientation == GTK_ORIENTATION_VERTICAL && y <= priv->thumb_win.y) ||
1912 (priv->orientation == GTK_ORIENTATION_HORIZONTAL && x <= priv->thumb_win.x))2075 (priv->orientation == GTK_ORIENTATION_HORIZONTAL && x <= priv->thumb_win.x))
1913 priv->value = gtk_adjustment_get_lower (priv->adjustment);2076 priv->value = gtk_adjustment_get_lower (priv->adjustment);
@@ -2026,7 +2189,12 @@
2026 /* Stop the scrolling animation if it's running. */2189 /* Stop the scrolling animation if it's running. */
2027 os_animation_stop (priv->animation, NULL);2190 os_animation_stop (priv->animation, NULL);
20282191
2029 delta = get_wheel_delta (scrollbar, event->direction);2192 /* Slow down scroll wheel with the modifier key pressed,
2193 * by a 0.2 factor. */
2194 if (event->state & MODIFIER_KEY)
2195 delta = get_wheel_delta (scrollbar, event->direction) * 0.2;
2196 else
2197 delta = get_wheel_delta (scrollbar, event->direction);
20302198
2031 gtk_adjustment_set_value (priv->adjustment,2199 gtk_adjustment_set_value (priv->adjustment,
2032 CLAMP (gtk_adjustment_get_value (priv->adjustment) + delta,2200 CLAMP (gtk_adjustment_get_value (priv->adjustment) + delta,
@@ -2041,16 +2209,7 @@
20412209
2042 /* we need to update the slide values2210 /* we need to update the slide values
2043 * with the current position. */2211 * with the current position. */
2044 if (priv->orientation == GTK_ORIENTATION_VERTICAL)2212 calc_precise_slide_values (scrollbar, event->x_root, event->y_root);
2045 {
2046 priv->slide_initial_slider_position = MIN (priv->slider.y, priv->overlay.y);
2047 priv->slide_initial_coordinate = event->y_root;
2048 }
2049 else
2050 {
2051 priv->slide_initial_slider_position = MIN (priv->slider.x, priv->overlay.x);
2052 priv->slide_initial_coordinate = event->x_root;
2053 }
2054 }2213 }
20552214
2056 return FALSE;2215 return FALSE;
@@ -2793,6 +2952,8 @@
2793 priv->thumb_win.x = 0;2952 priv->thumb_win.x = 0;
2794 priv->thumb_win.y = 0;2953 priv->thumb_win.y = 0;
27952954
2955 priv->fine_scroll_multiplier = 1.0;
2956
2796 priv->source_deactivate_bar_id = 0;2957 priv->source_deactivate_bar_id = 0;
2797 priv->source_hide_thumb_id = 0;2958 priv->source_hide_thumb_id = 0;
2798 priv->source_show_thumb_id = 0;2959 priv->source_show_thumb_id = 0;

Subscribers

People subscribed via source and target branches