[mutter] remote-desktop/session: Handle unable to transform coordinate gracefully
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] remote-desktop/session: Handle unable to transform coordinate gracefully
- Date: Fri, 12 Mar 2021 15:43:46 +0000 (UTC)
commit 688280f82d69d2c2102ab0519098d9201d9a827b
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Sat Jan 30 23:52:00 2021 +0100
remote-desktop/session: Handle unable to transform coordinate gracefully
There may be a race between the ability to turn stream relative input
coordinates and turning them into screen coordinates, due to the future
scenario where the entity backing a stream is created and managed ad-hoc
depending on PipeWire stream negotiations.
When an input event is sent during this time, drop it.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
src/backends/meta-remote-desktop-session.c | 52 +++++++++++++++++---------
src/backends/meta-screen-cast-area-stream.c | 4 +-
src/backends/meta-screen-cast-monitor-stream.c | 4 +-
src/backends/meta-screen-cast-stream.c | 10 ++---
src/backends/meta-screen-cast-stream.h | 20 +++++-----
src/backends/meta-screen-cast-window-stream.c | 3 +-
6 files changed, 57 insertions(+), 36 deletions(-)
---
diff --git a/src/backends/meta-remote-desktop-session.c b/src/backends/meta-remote-desktop-session.c
index 4429c35670..1f83ff709e 100644
--- a/src/backends/meta-remote-desktop-session.c
+++ b/src/backends/meta-remote-desktop-session.c
@@ -678,11 +678,17 @@ handle_notify_pointer_motion_absolute (MetaDBusRemoteDesktopSession *skeleton,
return TRUE;
}
- meta_screen_cast_stream_transform_position (stream, x, y, &abs_x, &abs_y);
-
- clutter_virtual_input_device_notify_absolute_motion (session->virtual_pointer,
- CLUTTER_CURRENT_TIME,
- abs_x, abs_y);
+ if (meta_screen_cast_stream_transform_position (stream, x, y, &abs_x, &abs_y))
+ {
+ clutter_virtual_input_device_notify_absolute_motion (session->virtual_pointer,
+ CLUTTER_CURRENT_TIME,
+ abs_x, abs_y);
+ }
+ else
+ {
+ meta_topic (META_DEBUG_REMOTE_DESKTOP,
+ "Dropping early absolute pointer motion (%f, %f)", x, y);
+ }
meta_dbus_remote_desktop_session_complete_notify_pointer_motion_absolute (skeleton,
invocation);
@@ -731,12 +737,18 @@ handle_notify_touch_down (MetaDBusRemoteDesktopSession *skeleton,
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);
+ if (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);
+ }
+ else
+ {
+ meta_topic (META_DEBUG_REMOTE_DESKTOP,
+ "Dropping early touch down (%f, %f)", x, y);
+ }
meta_dbus_remote_desktop_session_complete_notify_touch_down (skeleton,
invocation);
@@ -786,12 +798,18 @@ handle_notify_touch_motion (MetaDBusRemoteDesktopSession *skeleton,
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);
+ if (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);
+ }
+ else
+ {
+ meta_topic (META_DEBUG_REMOTE_DESKTOP,
+ "Dropping early touch motion (%f, %f)", x, y);
+ }
meta_dbus_remote_desktop_session_complete_notify_touch_motion (skeleton,
invocation);
diff --git a/src/backends/meta-screen-cast-area-stream.c b/src/backends/meta-screen-cast-area-stream.c
index 9dd59fbfe6..23d8c98280 100644
--- a/src/backends/meta-screen-cast-area-stream.c
+++ b/src/backends/meta-screen-cast-area-stream.c
@@ -148,7 +148,7 @@ meta_screen_cast_area_stream_set_parameters (MetaScreenCastStream *stream,
area_stream->area.height));
}
-static void
+static gboolean
meta_screen_cast_area_stream_transform_position (MetaScreenCastStream *stream,
double stream_x,
double stream_y,
@@ -160,6 +160,8 @@ meta_screen_cast_area_stream_transform_position (MetaScreenCastStream *stream,
*x = area_stream->area.x + (int) roundf (stream_x / area_stream->scale);
*y = area_stream->area.y + (int) roundf (stream_y / area_stream->scale);
+
+ return TRUE;
}
static void
diff --git a/src/backends/meta-screen-cast-monitor-stream.c b/src/backends/meta-screen-cast-monitor-stream.c
index d3ad20b3c1..c7123a19b0 100644
--- a/src/backends/meta-screen-cast-monitor-stream.c
+++ b/src/backends/meta-screen-cast-monitor-stream.c
@@ -184,7 +184,7 @@ meta_screen_cast_monitor_stream_set_parameters (MetaScreenCastStream *stream,
logical_monitor_layout.height));
}
-static void
+static gboolean
meta_screen_cast_monitor_stream_transform_position (MetaScreenCastStream *stream,
double stream_x,
double stream_y,
@@ -200,6 +200,8 @@ meta_screen_cast_monitor_stream_transform_position (MetaScreenCastStream *stream
*x = logical_monitor_layout.x + stream_x;
*y = logical_monitor_layout.y + stream_y;
+
+ return TRUE;
}
static void
diff --git a/src/backends/meta-screen-cast-stream.c b/src/backends/meta-screen-cast-stream.c
index fed1560fe4..b8ab5abd57 100644
--- a/src/backends/meta-screen-cast-stream.c
+++ b/src/backends/meta-screen-cast-stream.c
@@ -177,18 +177,16 @@ meta_screen_cast_stream_get_src (MetaScreenCastStream *stream)
return priv->src;
}
-void
+gboolean
meta_screen_cast_stream_transform_position (MetaScreenCastStream *stream,
double stream_x,
double stream_y,
double *x,
double *y)
{
- META_SCREEN_CAST_STREAM_GET_CLASS (stream)->transform_position (stream,
- stream_x,
- stream_y,
- x,
- y);
+ MetaScreenCastStreamClass *klass = META_SCREEN_CAST_STREAM_GET_CLASS (stream);
+
+ return klass->transform_position (stream, stream_x, stream_y, x, y);
}
MetaScreenCastCursorMode
diff --git a/src/backends/meta-screen-cast-stream.h b/src/backends/meta-screen-cast-stream.h
index d121c15c1e..3424def20c 100644
--- a/src/backends/meta-screen-cast-stream.h
+++ b/src/backends/meta-screen-cast-stream.h
@@ -43,11 +43,11 @@ struct _MetaScreenCastStreamClass
GError **error);
void (* set_parameters) (MetaScreenCastStream *stream,
GVariantBuilder *parameters_builder);
- void (* transform_position) (MetaScreenCastStream *stream,
- double stream_x,
- double stream_y,
- double *x,
- double *y);
+ gboolean (* transform_position) (MetaScreenCastStream *stream,
+ double stream_x,
+ double stream_y,
+ double *x,
+ double *y);
};
MetaScreenCastSession * meta_screen_cast_stream_get_session (MetaScreenCastStream *stream);
@@ -61,11 +61,11 @@ char * meta_screen_cast_stream_get_object_path (MetaScreenCastStream *stream);
MetaScreenCastStreamSrc * meta_screen_cast_stream_get_src (MetaScreenCastStream *stream);
-void meta_screen_cast_stream_transform_position (MetaScreenCastStream *stream,
- double stream_x,
- double stream_y,
- double *x,
- double *y);
+gboolean meta_screen_cast_stream_transform_position (MetaScreenCastStream *stream,
+ double stream_x,
+ double stream_y,
+ double *x,
+ double *y);
MetaScreenCastCursorMode meta_screen_cast_stream_get_cursor_mode (MetaScreenCastStream *stream);
diff --git a/src/backends/meta-screen-cast-window-stream.c b/src/backends/meta-screen-cast-window-stream.c
index 4c235d150e..6f42a446e8 100644
--- a/src/backends/meta-screen-cast-window-stream.c
+++ b/src/backends/meta-screen-cast-window-stream.c
@@ -128,7 +128,7 @@ meta_screen_cast_window_stream_set_parameters (MetaScreenCastStream *stream,
window_stream->logical_height));
}
-static void
+static gboolean
meta_screen_cast_window_stream_transform_position (MetaScreenCastStream *stream,
double stream_x,
double stream_y,
@@ -145,6 +145,7 @@ meta_screen_cast_window_stream_transform_position (MetaScreenCastStream *stream,
stream_y,
x,
y);
+ return TRUE;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]