From 86d9cd1a664bb3163a27b2c578658ea43c27e0a2 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Mon, 29 Jun 2020 13:01:55 +0000 Subject: [PATCH] remote-desktop: Check for screencast only when required The portal API requires a screencast session only for absolution motion with remote desktop, other methods including relative motion do not require a screencast session. There is no reason to be more strict than the API actually is, check for a screencast session only when required, like for absolute motion events and touch events. Tested with https://gitlab.gnome.org/snippets/1122 Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1307 (cherry picked from commit b8524504f475c98591c6f04b7dfcab47d023ac8f) --- src/backends/meta-remote-desktop-session.c | 34 +++++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/backends/meta-remote-desktop-session.c b/src/backends/meta-remote-desktop-session.c index a7f128dfa..28191a1e0 100644 --- a/src/backends/meta-remote-desktop-session.c +++ b/src/backends/meta-remote-desktop-session.c @@ -273,14 +273,6 @@ meta_remote_desktop_session_check_can_notify (MetaRemoteDesktopSession *session, return FALSE; } - if (!session->screen_cast_session) - { - g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, - G_DBUS_ERROR_FAILED, - "No screen cast active"); - return FALSE; - } - return TRUE; } @@ -591,6 +583,15 @@ handle_notify_pointer_motion_absolute (MetaDBusRemoteDesktopSession *skeleton, if (!meta_remote_desktop_session_check_can_notify (session, invocation)) 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) @@ -628,6 +629,14 @@ handle_notify_touch_down (MetaDBusRemoteDesktopSession *skeleton, if (!meta_remote_desktop_session_check_can_notify (session, invocation)) 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) @@ -666,6 +675,15 @@ handle_notify_touch_motion (MetaDBusRemoteDesktopSession *skeleton, if (!meta_remote_desktop_session_check_can_notify (session, invocation)) 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)