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 @@ -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 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. -->