[mutter] remote-desktop: Add smooth scroll event support



commit c459ad79322c1ff7407b1bff36677324d1315fdb
Author: Jonas Ådahl <jadahl gmail com>
Date:   Mon Jan 29 14:40:28 2018 +0800

    remote-desktop: Add smooth scroll event support

 src/backends/meta-remote-desktop-session.c | 42 ++++++++++++++++++++++++++++++
 src/org.gnome.Mutter.RemoteDesktop.xml     | 13 +++++++++
 2 files changed, 55 insertions(+)
---
diff --git a/src/backends/meta-remote-desktop-session.c b/src/backends/meta-remote-desktop-session.c
index eaf6e718b..17786ea57 100644
--- a/src/backends/meta-remote-desktop-session.c
+++ b/src/backends/meta-remote-desktop-session.c
@@ -39,6 +39,11 @@
 
 #define META_REMOTE_DESKTOP_SESSION_DBUS_PATH "/org/gnome/Mutter/RemoteDesktop/Session"
 
+enum _MetaRemoteDesktopNotifyAxisFlags
+{
+  META_REMOTE_DESKTOP_NOTIFY_AXIS_FLAGS_FINISH = 1 << 0,
+} MetaRemoteDesktopNotifyAxisFlags;
+
 struct _MetaRemoteDesktopSession
 {
   MetaDBusRemoteDesktopSessionSkeleton parent;
@@ -376,6 +381,42 @@ handle_notify_pointer_button (MetaDBusRemoteDesktopSession *skeleton,
   return TRUE;
 }
 
+static gboolean
+handle_notify_pointer_axis (MetaDBusRemoteDesktopSession *skeleton,
+                            GDBusMethodInvocation        *invocation,
+                            double                        dx,
+                            double                        dy,
+                            uint32_t                      flags)
+{
+  MetaRemoteDesktopSession *session = META_REMOTE_DESKTOP_SESSION (skeleton);
+  ClutterScrollFinishFlags finish_flags = CLUTTER_SCROLL_FINISHED_NONE;
+
+  if (!check_permission (session, invocation))
+    {
+      g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
+                                             G_DBUS_ERROR_ACCESS_DENIED,
+                                             "Permission denied");
+      return TRUE;
+    }
+
+  if (flags & META_REMOTE_DESKTOP_NOTIFY_AXIS_FLAGS_FINISH)
+    {
+      finish_flags |= (CLUTTER_SCROLL_FINISHED_HORIZONTAL |
+                       CLUTTER_SCROLL_FINISHED_VERTICAL);
+    }
+
+  clutter_virtual_input_device_notify_scroll_continuous (session->virtual_pointer,
+                                                         CLUTTER_CURRENT_TIME,
+                                                         dx, dy,
+                                                         CLUTTER_SCROLL_SOURCE_FINGER,
+                                                         finish_flags);
+
+  meta_dbus_remote_desktop_session_complete_notify_pointer_axis (skeleton,
+                                                                 invocation);
+
+  return TRUE;
+}
+
 static ClutterScrollDirection
 discrete_steps_to_scroll_direction (unsigned int axis,
                                     int          steps)
@@ -480,6 +521,7 @@ meta_remote_desktop_session_init_iface (MetaDBusRemoteDesktopSessionIface *iface
   iface->handle_notify_keyboard_keycode = handle_notify_keyboard_keycode;
   iface->handle_notify_keyboard_keysym = handle_notify_keyboard_keysym;
   iface->handle_notify_pointer_button = handle_notify_pointer_button;
+  iface->handle_notify_pointer_axis = handle_notify_pointer_axis;
   iface->handle_notify_pointer_axis_discrete = handle_notify_pointer_axis_discrete;
   iface->handle_notify_pointer_motion_absolute = handle_notify_pointer_motion_absolute;
 }
diff --git a/src/org.gnome.Mutter.RemoteDesktop.xml b/src/org.gnome.Mutter.RemoteDesktop.xml
index 4af5fe317..47f06a414 100644
--- a/src/org.gnome.Mutter.RemoteDesktop.xml
+++ b/src/org.gnome.Mutter.RemoteDesktop.xml
@@ -87,6 +87,19 @@
       <arg name="state" type="b" direction="in" />
     </method>
 
+    <!--
+       NotifyPointerAxis:
+
+       A smooth pointer axis event notification
+
+       Possible @flags:
+         1: finish - scroll motion was finished (e.g. fingers lifted)
+     -->
+    <method name="NotifyPointerAxis">
+      <arg name="dx" type="d" direction="in" />
+      <arg name="dy" type="d" direction="in" />
+      <arg name="flags" type="u" direction="in" />
+    </method>
     <!--
        NotifyPointerAxisDiscrete:
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]