scrolling.rst 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. .. _scrolling:
  2. ==============================================================================
  3. Scrolling
  4. ==============================================================================
  5. libinput supports three different types of scrolling methods:
  6. :ref:`twofinger_scrolling`, :ref:`edge_scrolling` and
  7. :ref:`button_scrolling`. Some devices support multiple methods, though only
  8. one can be enabled at a time. As a general overview:
  9. - touchpad devices with physical buttons below the touchpad support edge and
  10. two-finger scrolling
  11. - touchpad devices without physical buttons (:ref:`ClickPads <clickpad_softbuttons>`)
  12. support two-finger scrolling and edge scrolling
  13. - pointing sticks provide on-button scrolling by default
  14. - mice and other pointing devices support on-button scrolling but it is not
  15. enabled by default
  16. A device may differ from the above based on its capabilities. See
  17. **libinput_device_config_scroll_set_method()** for documentation on how to
  18. switch methods and **libinput_device_config_scroll_get_methods()** for
  19. documentation on how to query a device for available scroll methods.
  20. .. _horizontal_scrolling:
  21. ------------------------------------------------------------------------------
  22. Horizontal scrolling
  23. ------------------------------------------------------------------------------
  24. Scroll movements provide vertical and horizontal directions, each
  25. scroll event contains both directions where applicable, see
  26. **libinput_event_pointer_get_axis_value()**. libinput does not provide separate
  27. toggles to enable or disable horizontal scrolling. Instead, horizontal
  28. scrolling is always enabled. This is intentional, libinput does not have
  29. enough context to know when horizontal scrolling is appropriate for a given
  30. widget. The task of filtering horizontal movements is up to the caller.
  31. .. _twofinger_scrolling:
  32. ------------------------------------------------------------------------------
  33. Two-finger scrolling
  34. ------------------------------------------------------------------------------
  35. The default on two-finger capable touchpads (almost all modern touchpads are
  36. capable of detecting two fingers). Scrolling is triggered by two fingers
  37. being placed on the surface of the touchpad, then moving those fingers
  38. vertically or horizontally.
  39. .. figure:: twofinger-scrolling.svg
  40. :align: center
  41. Vertical and horizontal two-finger scrolling
  42. For scrolling to trigger, a built-in distance threshold has to be met, but once
  43. engaged, any movement will scroll. In other words: to start scrolling, a
  44. sufficiently large movement is required; once scrolling, tiny amounts of
  45. movements will translate into tiny scroll movements.
  46. Scrolling in both directions at once is possible by meeting the required
  47. distance thresholds to enable each direction separately.
  48. When a scroll gesture remains close to perfectly straight, it will be held to
  49. exact 90-degree angles; but if the gesture moves diagonally, it is free to
  50. scroll in any direction.
  51. Two-finger scrolling requires the touchpad to track both touch points with
  52. reasonable precision. Unfortunately, some so-called "semi-mt" touchpads can
  53. only track the bounding box of the two fingers rather than the actual
  54. position of each finger. In addition, that bounding box usually suffers from
  55. a low resolution, causing jumpy movement during two-finger scrolling.
  56. libinput does not provide two-finger scrolling on those touchpads.
  57. .. _edge_scrolling:
  58. ------------------------------------------------------------------------------
  59. Edge scrolling
  60. ------------------------------------------------------------------------------
  61. On some touchpads, edge scrolling is available, triggered by moving a single
  62. finger along the right edge (vertical scroll) or bottom edge (horizontal
  63. scroll).
  64. .. figure:: edge-scrolling.svg
  65. :align: center
  66. Vertical and horizontal edge scrolling
  67. Due to the layout of the edges, diagonal scrolling is not possible. The
  68. behavior of edge scrolling using both edges at the same time is undefined.
  69. Edge scrolling overlaps with :ref:`clickpad_softbuttons`. A physical click on
  70. a clickpad ends scrolling.
  71. .. _button_scrolling:
  72. ------------------------------------------------------------------------------
  73. On-Button scrolling
  74. ------------------------------------------------------------------------------
  75. On-button scrolling converts the motion of a device into scroll events while
  76. a designated button is held down. For example, Lenovo devices provide a
  77. `pointing stick <http://en.wikipedia.org/wiki/Pointing_stick>`_ that emulates
  78. scroll events when the trackstick's middle mouse button is held down.
  79. .. note:: On-button scrolling is enabled by default for pointing sticks. This
  80. prevents middle-button dragging; all motion events while the middle
  81. button is down are converted to scroll events.
  82. .. figure:: button-scrolling.svg
  83. :align: center
  84. Button scrolling
  85. The button may be changed with
  86. **libinput_device_config_scroll_set_button()** but must be on the same device as
  87. the motion events. Cross-device scrolling is not supported but
  88. for one exception: libinput's :ref:`t440_support` enables the use of the middle
  89. button for button scrolling (even when the touchpad is disabled).
  90. If the scroll button lock is enabled (see
  91. **libinput_device_config_scroll_set_button_lock()**), the button does not
  92. need to be held down. Pressing and releasing the button once enables the
  93. button lock, the button is now considered logically held down. Pressing and
  94. releasing the button a second time logically releases the button. While the
  95. button is logically held down, motion events are converted to scroll events.
  96. If the button is held and used to scroll for longer than a short grace
  97. period, releasing the button does not engage the lock. This allows
  98. hold-to-scroll for short, precise adjustments without accidentally toggling
  99. the lock. A quick click or a brief scroll within the grace period still
  100. engages the lock as normal.
  101. .. _scroll_sources:
  102. ------------------------------------------------------------------------------
  103. Scroll sources
  104. ------------------------------------------------------------------------------
  105. .. note:: Scroll sources are deprecated with libinput 1.19. The scroll
  106. source is now encoded in the event type.
  107. libinput provides a pointer axis *source* for each scroll event. The
  108. source can be obtained with the **libinput_event_pointer_get_axis_source()**
  109. function and is one of **wheel**, **finger**, or **continuous**. The source
  110. information lets a caller decide when to implement kinetic scrolling.
  111. Usually, a caller will process events of source wheel as they come in.
  112. For events of source finger a caller should calculate the velocity of the
  113. scroll motion and upon finger release start a kinetic scrolling motion (i.e.
  114. continue executing a scroll according to some friction factor).
  115. libinput expects the caller to be in charge of widget handling, the source
  116. information is thus enough to provide kinetic scrolling on a per-widget
  117. basis. A caller should cancel kinetic scrolling when the pointer leaves the
  118. current widget or when a key is pressed.
  119. See the **libinput_event_pointer_get_axis_source()** for details on the
  120. behavior of each scroll source.
  121. See also http://who-t.blogspot.com.au/2015/03/libinput-scroll-sources.html
  122. .. _natural_scrolling:
  123. ------------------------------------------------------------------------------
  124. Natural scrolling vs. traditional scrolling
  125. ------------------------------------------------------------------------------
  126. Natural scrolling is the term (probably) coined by Apple for matching
  127. the motion of the scroll device with the direction of the **content**.
  128. In traditional scrolling, moving the wheel down causes the scroll bar
  129. indicators to move down and the content to move up. In natural scrolling,
  130. moving the wheel down causes the content to move down and the scroll bar
  131. indicators to move up. This method of scrolling matches the interaction
  132. with content on touch screens where a movement down also moves the content
  133. down.
  134. libinput supports natural scrolling for all its scroll methods; it can
  135. be enabled with the
  136. **libinput_device_config_scroll_set_natural_scroll_enabled()** function.