From 60fa895ae34652bfce3e3624b8cbb7d28723d9d0 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 13 Jul 2020 12:28:46 +0200 Subject: [PATCH] backends: Move away from meta_cursor_renderer_get_position() We are moving onto relying fully on the seat cursor position. As this focuses (thus far?) on mouse pointers only, use the cursor tracker as a convenient shortcut. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403 --- src/backends/meta-screen-cast-area-stream-src.c | 8 ++++++-- .../meta-screen-cast-monitor-stream-src.c | 8 ++++++-- .../meta-screen-cast-window-stream-src.c | 16 ++++++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/backends/meta-screen-cast-area-stream-src.c b/src/backends/meta-screen-cast-area-stream-src.c index 270bfa2a9..7b1e4cc3d 100644 --- a/src/backends/meta-screen-cast-area-stream-src.c +++ b/src/backends/meta-screen-cast-area-stream-src.c @@ -142,9 +142,11 @@ is_cursor_in_stream (MetaScreenCastAreaStreamSrc *area_src) } else { + MetaCursorTracker *cursor_tracker = + meta_backend_get_cursor_tracker (backend); graphene_point_t cursor_position; - cursor_position = meta_cursor_renderer_get_position (cursor_renderer); + meta_cursor_tracker_get_pointer (cursor_tracker, &cursor_position, NULL); return graphene_rect_contains_point (&area_rect, &cursor_position); } } @@ -504,6 +506,8 @@ meta_screen_cast_area_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc *s MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src); MetaScreenCastAreaStream *area_stream = META_SCREEN_CAST_AREA_STREAM (stream); MetaBackend *backend = get_backend (area_src); + MetaCursorTracker *cursor_tracker = + meta_backend_get_cursor_tracker (backend); MetaCursorRenderer *cursor_renderer = meta_backend_get_cursor_renderer (backend); MetaCursorSprite *cursor_sprite; @@ -524,7 +528,7 @@ meta_screen_cast_area_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc *s area = meta_screen_cast_area_stream_get_area (area_stream); scale = meta_screen_cast_area_stream_get_scale (area_stream); - cursor_position = meta_cursor_renderer_get_position (cursor_renderer); + meta_cursor_tracker_get_pointer (cursor_tracker, &cursor_position, NULL); cursor_position.x -= area->x; cursor_position.y -= area->y; cursor_position.x *= scale; diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c b/src/backends/meta-screen-cast-monitor-stream-src.c index 6c70bbc41..45aff9126 100644 --- a/src/backends/meta-screen-cast-monitor-stream-src.c +++ b/src/backends/meta-screen-cast-monitor-stream-src.c @@ -170,9 +170,11 @@ is_cursor_in_stream (MetaScreenCastMonitorStreamSrc *monitor_src) } else { + MetaCursorTracker *cursor_tracker = + meta_backend_get_cursor_tracker (backend); graphene_point_t cursor_position; - cursor_position = meta_cursor_renderer_get_position (cursor_renderer); + meta_cursor_tracker_get_pointer (cursor_tracker, &cursor_position, NULL); return graphene_rect_contains_point (&logical_monitor_rect, &cursor_position); } @@ -596,6 +598,8 @@ meta_screen_cast_monitor_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc MetaBackend *backend = get_backend (monitor_src); MetaCursorRenderer *cursor_renderer = meta_backend_get_cursor_renderer (backend); + MetaCursorTracker *cursor_tracker = + meta_backend_get_cursor_tracker (backend); MetaCursorSprite *cursor_sprite; MetaMonitor *monitor; MetaLogicalMonitor *logical_monitor; @@ -625,7 +629,7 @@ meta_screen_cast_monitor_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc else view_scale = 1.0; - cursor_position = meta_cursor_renderer_get_position (cursor_renderer); + meta_cursor_tracker_get_pointer (cursor_tracker, &cursor_position, NULL); cursor_position.x -= logical_monitor_rect.origin.x; cursor_position.y -= logical_monitor_rect.origin.y; cursor_position.x *= view_scale; diff --git a/src/backends/meta-screen-cast-window-stream-src.c b/src/backends/meta-screen-cast-window-stream-src.c index 5f0f736af..8a323f845 100644 --- a/src/backends/meta-screen-cast-window-stream-src.c +++ b/src/backends/meta-screen-cast-window-stream-src.c @@ -110,6 +110,8 @@ maybe_draw_cursor_sprite (MetaScreenCastWindowStreamSrc *window_src, MetaBackend *backend = get_backend (window_src); MetaCursorRenderer *cursor_renderer = meta_backend_get_cursor_renderer (backend); + MetaCursorTracker *cursor_tracker = + meta_backend_get_cursor_tracker (backend); MetaCursorSprite *cursor_sprite; CoglTexture *cursor_texture; MetaScreenCastWindow *screen_cast_window; @@ -133,7 +135,7 @@ maybe_draw_cursor_sprite (MetaScreenCastWindowStreamSrc *window_src, return; screen_cast_window = window_src->screen_cast_window; - cursor_position = meta_cursor_renderer_get_position (cursor_renderer); + meta_cursor_tracker_get_pointer (cursor_tracker, &cursor_position, NULL); if (!meta_screen_cast_window_transform_cursor_position (screen_cast_window, cursor_sprite, &cursor_position, @@ -189,6 +191,8 @@ maybe_blit_cursor_sprite (MetaScreenCastWindowStreamSrc *window_src, clutter_backend_get_cogl_context (clutter_get_default_backend ()); MetaCursorRenderer *cursor_renderer = meta_backend_get_cursor_renderer (backend); + MetaCursorTracker *cursor_tracker = + meta_backend_get_cursor_tracker (backend); MetaScreenCastWindow *screen_cast_window; MetaCursorSprite *cursor_sprite; graphene_point_t relative_cursor_position; @@ -209,7 +213,7 @@ maybe_blit_cursor_sprite (MetaScreenCastWindowStreamSrc *window_src, return; screen_cast_window = window_src->screen_cast_window; - cursor_position = meta_cursor_renderer_get_position (cursor_renderer); + meta_cursor_tracker_get_pointer (cursor_tracker, &cursor_position, NULL); if (!meta_screen_cast_window_transform_cursor_position (screen_cast_window, cursor_sprite, &cursor_position, @@ -360,13 +364,15 @@ is_cursor_in_stream (MetaScreenCastWindowStreamSrc *window_src) MetaBackend *backend = get_backend (window_src); MetaCursorRenderer *cursor_renderer = meta_backend_get_cursor_renderer (backend); + MetaCursorTracker *cursor_tracker = + meta_backend_get_cursor_tracker (backend); MetaCursorSprite *cursor_sprite; graphene_point_t cursor_position; MetaScreenCastWindow *screen_cast_window; cursor_sprite = meta_cursor_renderer_get_cursor (cursor_renderer); - cursor_position = meta_cursor_renderer_get_position (cursor_renderer); + meta_cursor_tracker_get_pointer (cursor_tracker, &cursor_position, NULL); screen_cast_window = window_src->screen_cast_window; return meta_screen_cast_window_transform_cursor_position (screen_cast_window, @@ -539,6 +545,8 @@ meta_screen_cast_window_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc MetaBackend *backend = get_backend (window_src); MetaCursorRenderer *cursor_renderer = meta_backend_get_cursor_renderer (backend); + MetaCursorTracker *cursor_tracker = + meta_backend_get_cursor_tracker (backend); MetaScreenCastWindow *screen_cast_window = window_src->screen_cast_window; MetaCursorSprite *cursor_sprite; graphene_point_t cursor_position; @@ -547,7 +555,7 @@ meta_screen_cast_window_stream_src_set_cursor_metadata (MetaScreenCastStreamSrc int x, y; cursor_sprite = meta_cursor_renderer_get_cursor (cursor_renderer); - cursor_position = meta_cursor_renderer_get_position (cursor_renderer); + meta_cursor_tracker_get_pointer (cursor_tracker, &cursor_position, NULL); if (!meta_screen_cast_window_transform_cursor_position (screen_cast_window, cursor_sprite,