mirror of
https://github.com/brl/mutter.git
synced 2024-12-24 12:02:04 +00:00
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>
This commit is contained in:
parent
93e938e22f
commit
f363476229
@ -39,9 +39,13 @@
|
|||||||
|
|
||||||
#define META_REMOTE_DESKTOP_SESSION_DBUS_PATH "/org/gnome/Mutter/RemoteDesktop/Session"
|
#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_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;
|
} MetaRemoteDesktopNotifyAxisFlags;
|
||||||
|
|
||||||
struct _MetaRemoteDesktopSession
|
struct _MetaRemoteDesktopSession
|
||||||
@ -452,6 +456,33 @@ handle_notify_pointer_button (MetaDBusRemoteDesktopSession *skeleton,
|
|||||||
return TRUE;
|
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
|
static gboolean
|
||||||
handle_notify_pointer_axis (MetaDBusRemoteDesktopSession *skeleton,
|
handle_notify_pointer_axis (MetaDBusRemoteDesktopSession *skeleton,
|
||||||
GDBusMethodInvocation *invocation,
|
GDBusMethodInvocation *invocation,
|
||||||
@ -461,10 +492,19 @@ handle_notify_pointer_axis (MetaDBusRemoteDesktopSession *skeleton,
|
|||||||
{
|
{
|
||||||
MetaRemoteDesktopSession *session = META_REMOTE_DESKTOP_SESSION (skeleton);
|
MetaRemoteDesktopSession *session = META_REMOTE_DESKTOP_SESSION (skeleton);
|
||||||
ClutterScrollFinishFlags finish_flags = CLUTTER_SCROLL_FINISHED_NONE;
|
ClutterScrollFinishFlags finish_flags = CLUTTER_SCROLL_FINISHED_NONE;
|
||||||
|
ClutterScrollSource scroll_source;
|
||||||
|
|
||||||
if (!meta_remote_desktop_session_check_can_notify (session, invocation))
|
if (!meta_remote_desktop_session_check_can_notify (session, invocation))
|
||||||
return TRUE;
|
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)
|
if (flags & META_REMOTE_DESKTOP_NOTIFY_AXIS_FLAGS_FINISH)
|
||||||
{
|
{
|
||||||
finish_flags |= (CLUTTER_SCROLL_FINISHED_HORIZONTAL |
|
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_virtual_input_device_notify_scroll_continuous (session->virtual_pointer,
|
||||||
CLUTTER_CURRENT_TIME,
|
CLUTTER_CURRENT_TIME,
|
||||||
dx, dy,
|
dx, dy,
|
||||||
CLUTTER_SCROLL_SOURCE_FINGER,
|
scroll_source,
|
||||||
finish_flags);
|
finish_flags);
|
||||||
|
|
||||||
meta_dbus_remote_desktop_session_complete_notify_pointer_axis (skeleton,
|
meta_dbus_remote_desktop_session_complete_notify_pointer_axis (skeleton,
|
||||||
|
@ -115,6 +115,15 @@
|
|||||||
|
|
||||||
Possible @flags:
|
Possible @flags:
|
||||||
1: finish - scroll motion was finished (e.g. fingers lifted)
|
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">
|
<method name="NotifyPointerAxis">
|
||||||
<arg name="dx" type="d" direction="in" />
|
<arg name="dx" type="d" direction="in" />
|
||||||
|
Loading…
Reference in New Issue
Block a user