[mutter] wayland/pointer: Send high-resolution scroll data
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] wayland/pointer: Send high-resolution scroll data
- Date: Thu, 14 Jul 2022 23:14:24 +0000 (UTC)
commit 9dd6268d13d5757a51f0ff6181998df766bdba9f
Author: José Expósito <jose exposito89 gmail com>
Date: Mon Sep 20 19:53:46 2021 +0200
wayland/pointer: Send high-resolution scroll data
Upgrade the seat protocol to version 8 and change the scroll handler to
support new clients.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1962>
src/wayland/meta-wayland-pointer.c | 64 ++++++++++++++++++++++++++++++-------
src/wayland/meta-wayland-versions.h | 2 +-
2 files changed, 53 insertions(+), 13 deletions(-)
---
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index 81a16fe6ef..94e76677b6 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -730,8 +730,10 @@ handle_scroll_event (MetaWaylandPointer *pointer,
struct wl_resource *resource;
wl_fixed_t x_value = 0, y_value = 0;
int x_discrete = 0, y_discrete = 0;
+ int32_t x_value120 = 0, y_value120 = 0;
enum wl_pointer_axis_source source = -1;
MetaWaylandPointerClient *client;
+ gboolean is_discrete_event = FALSE, is_value120_event = FALSE;
if (clutter_event_is_pointer_emulated (event))
return;
@@ -759,21 +761,25 @@ handle_scroll_event (MetaWaylandPointer *pointer,
switch (clutter_event_get_scroll_direction (event))
{
case CLUTTER_SCROLL_UP:
+ is_discrete_event = TRUE;
y_value = -DEFAULT_AXIS_STEP_DISTANCE;
y_discrete = -1;
break;
case CLUTTER_SCROLL_DOWN:
+ is_discrete_event = TRUE;
y_value = DEFAULT_AXIS_STEP_DISTANCE;
y_discrete = 1;
break;
case CLUTTER_SCROLL_LEFT:
+ is_discrete_event = TRUE;
x_value = -DEFAULT_AXIS_STEP_DISTANCE;
x_discrete = -1;
break;
case CLUTTER_SCROLL_RIGHT:
+ is_discrete_event = TRUE;
x_value = DEFAULT_AXIS_STEP_DISTANCE;
x_discrete = 1;
break;
@@ -788,6 +794,13 @@ handle_scroll_event (MetaWaylandPointer *pointer,
clutter_event_get_scroll_delta (event, &dx, &dy);
x_value = wl_fixed_from_double (dx) * factor;
y_value = wl_fixed_from_double (dy) * factor;
+
+ is_value120_event = (source == WL_POINTER_AXIS_SOURCE_WHEEL);
+ if (is_value120_event)
+ {
+ x_value120 = (int32_t) (dx * 120);
+ y_value120 = (int32_t) (dy * 120);
+ }
}
break;
@@ -798,18 +811,32 @@ handle_scroll_event (MetaWaylandPointer *pointer,
wl_resource_for_each (resource, &client->pointer_resources)
{
int client_version = wl_resource_get_version (resource);
+ gboolean send_axis_x = TRUE, send_axis_y = TRUE;
if (client_version >= WL_POINTER_AXIS_SOURCE_SINCE_VERSION)
wl_pointer_send_axis_source (resource, source);
/* X axis */
- if (x_discrete != 0 &&
- client_version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION)
- wl_pointer_send_axis_discrete (resource,
- WL_POINTER_AXIS_HORIZONTAL_SCROLL,
- x_discrete);
+ if (client_version >= WL_POINTER_AXIS_VALUE120_SINCE_VERSION)
+ {
+ if (is_value120_event && x_value120 != 0)
+ wl_pointer_send_axis_value120 (resource,
+ WL_POINTER_AXIS_HORIZONTAL_SCROLL,
+ x_value120);
+
+ send_axis_x = !is_discrete_event;
+ }
+ else if (client_version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION)
+ {
+ if (is_discrete_event && x_discrete != 0)
+ wl_pointer_send_axis_discrete (resource,
+ WL_POINTER_AXIS_HORIZONTAL_SCROLL,
+ x_discrete);
+
+ send_axis_x = !is_value120_event;
+ }
- if (x_value)
+ if (x_value && send_axis_x)
wl_pointer_send_axis (resource, clutter_event_get_time (event),
WL_POINTER_AXIS_HORIZONTAL_SCROLL, x_value);
@@ -819,13 +846,26 @@ handle_scroll_event (MetaWaylandPointer *pointer,
clutter_event_get_time (event),
WL_POINTER_AXIS_HORIZONTAL_SCROLL);
/* Y axis */
- if (y_discrete != 0 &&
- client_version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION)
- wl_pointer_send_axis_discrete (resource,
- WL_POINTER_AXIS_VERTICAL_SCROLL,
- y_discrete);
+ if (client_version >= WL_POINTER_AXIS_VALUE120_SINCE_VERSION)
+ {
+ if (is_value120_event && y_value120 != 0)
+ wl_pointer_send_axis_value120 (resource,
+ WL_POINTER_AXIS_VERTICAL_SCROLL,
+ y_value120);
+
+ send_axis_y = !is_discrete_event;
+ }
+ else if (client_version >= WL_POINTER_AXIS_DISCRETE_SINCE_VERSION)
+ {
+ if (is_discrete_event && y_discrete != 0)
+ wl_pointer_send_axis_discrete (resource,
+ WL_POINTER_AXIS_VERTICAL_SCROLL,
+ y_discrete);
+
+ send_axis_y = !is_value120_event;
+ }
- if (y_value)
+ if (y_value && send_axis_y)
wl_pointer_send_axis (resource, clutter_event_get_time (event),
WL_POINTER_AXIS_VERTICAL_SCROLL, y_value);
diff --git a/src/wayland/meta-wayland-versions.h b/src/wayland/meta-wayland-versions.h
index bb6b2c40d2..ee7602814a 100644
--- a/src/wayland/meta-wayland-versions.h
+++ b/src/wayland/meta-wayland-versions.h
@@ -38,7 +38,7 @@
#define META_WL_COMPOSITOR_VERSION 5
#define META_WL_DATA_DEVICE_MANAGER_VERSION 3
#define META_XDG_WM_BASE_VERSION 4
-#define META_WL_SEAT_VERSION 5
+#define META_WL_SEAT_VERSION 8
#define META_WL_OUTPUT_VERSION 2
#define META_XSERVER_VERSION 1
#define META_GTK_SHELL1_VERSION 5
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]