[mutter] remote-desktop: Add touch screen event support
- From: Jonas Ã…dahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] remote-desktop: Add touch screen event support
- Date: Fri, 23 Feb 2018 12:52:14 +0000 (UTC)
commit 03a12f9458c818ed06a65e4640818407be4e9141
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Mon Jan 29 14:44:03 2018 +0800
remote-desktop: Add touch screen event support
src/backends/meta-remote-desktop-session.c | 135 +++++++++++++++++++++++++++++
src/org.gnome.Mutter.RemoteDesktop.xml | 33 +++++++
2 files changed, 168 insertions(+)
---
diff --git a/src/backends/meta-remote-desktop-session.c b/src/backends/meta-remote-desktop-session.c
index 9270c0e5d..821b16724 100644
--- a/src/backends/meta-remote-desktop-session.c
+++ b/src/backends/meta-remote-desktop-session.c
@@ -58,6 +58,7 @@ struct _MetaRemoteDesktopSession
ClutterVirtualInputDevice *virtual_pointer;
ClutterVirtualInputDevice *virtual_keyboard;
+ ClutterVirtualInputDevice *virtual_touchscreen;
};
static void
@@ -102,6 +103,10 @@ meta_remote_desktop_session_start (MetaRemoteDesktopSession *session,
clutter_device_manager_create_virtual_device (device_manager,
CLUTTER_KEYBOARD_DEVICE);
+ session->virtual_touchscreen =
+ clutter_device_manager_create_virtual_device (device_manager,
+ CLUTTER_TOUCHSCREEN_DEVICE);
+
return TRUE;
}
@@ -561,6 +566,133 @@ handle_notify_pointer_motion_absolute (MetaDBusRemoteDesktopSession *skeleton,
return TRUE;
}
+static gboolean
+handle_notify_touch_down (MetaDBusRemoteDesktopSession *skeleton,
+ GDBusMethodInvocation *invocation,
+ const char *stream_path,
+ unsigned int slot,
+ double x,
+ double y)
+{
+ MetaRemoteDesktopSession *session = META_REMOTE_DESKTOP_SESSION (skeleton);
+ MetaScreenCastStream *stream;
+ double abs_x, abs_y;
+
+ 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 (!session->screen_cast_session)
+ {
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
+ G_DBUS_ERROR_FAILED,
+ "No screen cast active");
+ return TRUE;
+ }
+
+ stream = meta_screen_cast_session_get_stream (session->screen_cast_session,
+ stream_path);
+ if (!stream)
+ {
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
+ G_DBUS_ERROR_FAILED,
+ "Unknown stream");
+ return TRUE;
+ }
+
+ meta_screen_cast_stream_transform_position (stream, x, y, &abs_x, &abs_y);
+
+ clutter_virtual_input_device_notify_touch_down (session->virtual_touchscreen,
+ CLUTTER_CURRENT_TIME,
+ slot,
+ abs_x, abs_y);
+
+ meta_dbus_remote_desktop_session_complete_notify_touch_down (skeleton,
+ invocation);
+
+ return TRUE;
+}
+
+static gboolean
+handle_notify_touch_motion (MetaDBusRemoteDesktopSession *skeleton,
+ GDBusMethodInvocation *invocation,
+ const char *stream_path,
+ unsigned int slot,
+ double x,
+ double y)
+{
+ MetaRemoteDesktopSession *session = META_REMOTE_DESKTOP_SESSION (skeleton);
+ MetaScreenCastStream *stream;
+ double abs_x, abs_y;
+
+ 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 (!session->screen_cast_session)
+ {
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
+ G_DBUS_ERROR_FAILED,
+ "No screen cast active");
+ return TRUE;
+ }
+
+ stream = meta_screen_cast_session_get_stream (session->screen_cast_session,
+ stream_path);
+ if (!stream)
+ {
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
+ G_DBUS_ERROR_FAILED,
+ "Unknown stream");
+ return TRUE;
+ }
+
+ meta_screen_cast_stream_transform_position (stream, x, y, &abs_x, &abs_y);
+
+ clutter_virtual_input_device_notify_touch_motion (session->virtual_touchscreen,
+ CLUTTER_CURRENT_TIME,
+ slot,
+ abs_x, abs_y);
+
+ meta_dbus_remote_desktop_session_complete_notify_touch_motion (skeleton,
+ invocation);
+
+ return TRUE;
+}
+
+static gboolean
+handle_notify_touch_up (MetaDBusRemoteDesktopSession *skeleton,
+ GDBusMethodInvocation *invocation,
+ unsigned int slot)
+{
+ MetaRemoteDesktopSession *session = META_REMOTE_DESKTOP_SESSION (skeleton);
+
+ if (!check_permission (session, invocation))
+ {
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
+ G_DBUS_ERROR_ACCESS_DENIED,
+ "Permission denied");
+ return TRUE;
+ }
+
+ clutter_virtual_input_device_notify_touch_up (session->virtual_touchscreen,
+ CLUTTER_CURRENT_TIME,
+ slot);
+
+ meta_dbus_remote_desktop_session_complete_notify_touch_up (skeleton,
+ invocation);
+
+ return TRUE;
+}
+
static void
meta_remote_desktop_session_init_iface (MetaDBusRemoteDesktopSessionIface *iface)
{
@@ -573,6 +705,9 @@ meta_remote_desktop_session_init_iface (MetaDBusRemoteDesktopSessionIface *iface
iface->handle_notify_pointer_axis_discrete = handle_notify_pointer_axis_discrete;
iface->handle_notify_pointer_motion_relative = handle_notify_pointer_motion_relative;
iface->handle_notify_pointer_motion_absolute = handle_notify_pointer_motion_absolute;
+ iface->handle_notify_touch_down = handle_notify_touch_down;
+ iface->handle_notify_touch_motion = handle_notify_touch_motion;
+ iface->handle_notify_touch_up = handle_notify_touch_up;
}
static void
diff --git a/src/org.gnome.Mutter.RemoteDesktop.xml b/src/org.gnome.Mutter.RemoteDesktop.xml
index 4646d2948..dddc59a16 100644
--- a/src/org.gnome.Mutter.RemoteDesktop.xml
+++ b/src/org.gnome.Mutter.RemoteDesktop.xml
@@ -131,6 +131,39 @@
<arg name="y" type="d" direction="in" />
</method>
+ <!--
+ NotifyTouchDown:
+
+ A absolute pointer motion event notification
+ -->
+ <method name="NotifyTouchDown">
+ <arg name="stream" type="s" direction="in" />
+ <arg name="slot" type="u" direction="in" />
+ <arg name="x" type="d" direction="in" />
+ <arg name="y" type="d" direction="in" />
+ </method>
+
+ <!--
+ NotifyTouchMotion:
+
+ A absolute pointer motion event notification
+ -->
+ <method name="NotifyTouchMotion">
+ <arg name="stream" type="s" direction="in" />
+ <arg name="slot" type="u" direction="in" />
+ <arg name="x" type="d" direction="in" />
+ <arg name="y" type="d" direction="in" />
+ </method>
+
+ <!--
+ NotifyTouchUp:
+
+ A absolute pointer motion event notification
+ -->
+ <method name="NotifyTouchUp">
+ <arg name="slot" type="u" direction="in" />
+ </method>
+
</interface>
</node>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]