[mutter] remote-desktop: Allow using custom scroll source for NotifyPointerAxis
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] remote-desktop: Allow using custom scroll source for NotifyPointerAxis
- Date: Mon, 11 Jan 2021 09:41:25 +0000 (UTC)
commit f363476229277e4500e1aac25e028cfe794ebdc1
Author: Pascal Nowack <Pascal Nowack gmx de>
Date: Tue Dec 15 10:34:43 2020 +0100
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>
src/backends/meta-remote-desktop-session.c | 44 ++++++++++++++++++++++++++++--
src/org.gnome.Mutter.RemoteDesktop.xml | 9 ++++++
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 27bd58b724..d01b5e6a89 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
@@ -452,6 +456,33 @@ handle_notify_pointer_button (MetaDBusRemoteDesktopSession *skeleton,
return TRUE;
}
+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,
@@ -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 a07aefe27c..d93413f6de 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" />
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]