summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPascal Nowack <Pascal.Nowack@gmx.de>2020-12-15 10:34:43 +0100
committerPascal Nowack <Pascal.Nowack@gmx.de>2021-01-11 10:12:53 +0100
commitf363476229277e4500e1aac25e028cfe794ebdc1 (patch)
tree9df86d4602a2be112902762fc59754f2f94a417b
parent93e938e22fa2cf1c13c3abde49e174f31b3c5f0f (diff)
downloadmutter-f363476229277e4500e1aac25e028cfe794ebdc1.tar.gz
remote-desktop: Allow using custom scroll source for NotifyPointerAxis
Currently, the NotifyPointerAxis method always assumes that the scroll source is CLUTTER_SCROLL_SOURCE_FINGER. This is however not always true and in some cases a remote desktop client needs to submit a PointerAxis event with a custom axis step. This is for example the case with high resolution mouse wheels, where the NotifyPointerAxisDiscrete method is unsuitable. In such cases NotifyPointerAxis needs to be called, but with the intention that the scroll source is still a mouse wheel. To solve this situation, don't assume the scroll source always to be CLUTTER_SCROLL_SOURCE_FINGER. Instead, add further flag options to NotifyPointerAxis, which allow a remote desktop client to choose the scroll source. This way a remote desktop client can choose what scroll source is the most suitable one for the current scroll event. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1636>
-rw-r--r--src/backends/meta-remote-desktop-session.c44
-rw-r--r--src/org.gnome.Mutter.RemoteDesktop.xml9
2 files changed, 51 insertions, 2 deletions
diff --git a/src/backends/meta-remote-desktop-session.c b/src/backends/meta-remote-desktop-session.c
index 27bd58b72..d01b5e6a8 100644
--- a/src/backends/meta-remote-desktop-session.c
+++ b/src/backends/meta-remote-desktop-session.c
@@ -39,9 +39,13 @@
#define META_REMOTE_DESKTOP_SESSION_DBUS_PATH "/org/gnome/Mutter/RemoteDesktop/Session"
-enum _MetaRemoteDesktopNotifyAxisFlags
+typedef enum _MetaRemoteDesktopNotifyAxisFlags
{
+ META_REMOTE_DESKTOP_NOTIFY_AXIS_FLAGS_NONE = 0,
META_REMOTE_DESKTOP_NOTIFY_AXIS_FLAGS_FINISH = 1 << 0,
+ META_REMOTE_DESKTOP_NOTIFY_AXIS_FLAGS_SOURCE_WHEEL = 1 << 1,
+ META_REMOTE_DESKTOP_NOTIFY_AXIS_FLAGS_SOURCE_FINGER = 1 << 2,
+ META_REMOTE_DESKTOP_NOTIFY_AXIS_FLAGS_SOURCE_CONTINUOUS = 1 << 3,
} MetaRemoteDesktopNotifyAxisFlags;
struct _MetaRemoteDesktopSession
@@ -453,6 +457,33 @@ handle_notify_pointer_button (MetaDBusRemoteDesktopSession *skeleton,
}
static gboolean
+clutter_scroll_source_from_axis_flags (MetaRemoteDesktopNotifyAxisFlags axis_flags,
+ ClutterScrollSource *scroll_source)
+{
+ MetaRemoteDesktopNotifyAxisFlags scroll_mask;
+
+ scroll_mask = META_REMOTE_DESKTOP_NOTIFY_AXIS_FLAGS_SOURCE_WHEEL |
+ META_REMOTE_DESKTOP_NOTIFY_AXIS_FLAGS_SOURCE_FINGER |
+ META_REMOTE_DESKTOP_NOTIFY_AXIS_FLAGS_SOURCE_CONTINUOUS;
+
+ switch (axis_flags & scroll_mask)
+ {
+ case META_REMOTE_DESKTOP_NOTIFY_AXIS_FLAGS_SOURCE_WHEEL:
+ *scroll_source = CLUTTER_SCROLL_SOURCE_WHEEL;
+ return TRUE;
+ case META_REMOTE_DESKTOP_NOTIFY_AXIS_FLAGS_NONE:
+ case META_REMOTE_DESKTOP_NOTIFY_AXIS_FLAGS_SOURCE_FINGER:
+ *scroll_source = CLUTTER_SCROLL_SOURCE_FINGER;
+ return TRUE;
+ case META_REMOTE_DESKTOP_NOTIFY_AXIS_FLAGS_SOURCE_CONTINUOUS:
+ *scroll_source = CLUTTER_SCROLL_SOURCE_CONTINUOUS;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
handle_notify_pointer_axis (MetaDBusRemoteDesktopSession *skeleton,
GDBusMethodInvocation *invocation,
double dx,
@@ -461,10 +492,19 @@ handle_notify_pointer_axis (MetaDBusRemoteDesktopSession *skeleton,
{
MetaRemoteDesktopSession *session = META_REMOTE_DESKTOP_SESSION (skeleton);
ClutterScrollFinishFlags finish_flags = CLUTTER_SCROLL_FINISHED_NONE;
+ ClutterScrollSource scroll_source;
if (!meta_remote_desktop_session_check_can_notify (session, invocation))
return TRUE;
+ if (!clutter_scroll_source_from_axis_flags (flags, &scroll_source))
+ {
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
+ G_DBUS_ERROR_FAILED,
+ "Invalid scroll source");
+ return TRUE;
+ }
+
if (flags & META_REMOTE_DESKTOP_NOTIFY_AXIS_FLAGS_FINISH)
{
finish_flags |= (CLUTTER_SCROLL_FINISHED_HORIZONTAL |
@@ -474,7 +514,7 @@ handle_notify_pointer_axis (MetaDBusRemoteDesktopSession *skeleton,
clutter_virtual_input_device_notify_scroll_continuous (session->virtual_pointer,
CLUTTER_CURRENT_TIME,
dx, dy,
- CLUTTER_SCROLL_SOURCE_FINGER,
+ scroll_source,
finish_flags);
meta_dbus_remote_desktop_session_complete_notify_pointer_axis (skeleton,
diff --git a/src/org.gnome.Mutter.RemoteDesktop.xml b/src/org.gnome.Mutter.RemoteDesktop.xml
index a07aefe27..d93413f6d 100644
--- a/src/org.gnome.Mutter.RemoteDesktop.xml
+++ b/src/org.gnome.Mutter.RemoteDesktop.xml
@@ -115,6 +115,15 @@
Possible @flags:
1: finish - scroll motion was finished (e.g. fingers lifted)
+ 2: source_wheel - The scroll event is originated by a mouse wheel.
+ 4: source_finger - The scroll event is originated by one or more fingers on
+ the device (eg. touchpads).
+ 8: source_continuous - The scroll event is originated by the motion of some
+ device (eg. a scroll button is set).
+
+ Maximum one of the @flags 'source_wheel', 'source_finger',
+ 'source_continuous' may be specified.
+ If no source flag is specified, `source_finger` is assumed.
-->
<method name="NotifyPointerAxis">
<arg name="dx" type="d" direction="in" />