diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h index d57645080..c07cc88e4 100644 --- a/src/backends/meta-monitor-manager-private.h +++ b/src/backends/meta-monitor-manager-private.h @@ -373,6 +373,10 @@ MetaLogicalMonitor *meta_monitor_manager_get_logical_monitor_from_number (MetaMo MetaLogicalMonitor *meta_monitor_manager_get_primary_logical_monitor (MetaMonitorManager *manager); +MetaLogicalMonitor *meta_monitor_manager_get_logical_monitor_at (MetaMonitorManager *manager, + int x, + int y); + MetaOutput *meta_monitor_manager_get_outputs (MetaMonitorManager *manager, unsigned int *n_outputs); diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index d2cafb1c9..aeede6eaf 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -1329,6 +1329,22 @@ meta_monitor_manager_get_primary_logical_monitor (MetaMonitorManager *manager) return manager->primary_logical_monitor; } +MetaLogicalMonitor * +meta_monitor_manager_get_logical_monitor_at (MetaMonitorManager *manager, + int x, + int y) +{ + unsigned int i; + + for (i = 0; i < manager->n_logical_monitors; i++) + { + if (POINT_IN_RECT (x, y, manager->logical_monitors[i].rect)) + return &manager->logical_monitors[i]; + } + + return NULL; +} + MetaOutput * meta_monitor_manager_get_outputs (MetaMonitorManager *manager, unsigned int *n_outputs) diff --git a/src/core/screen-private.h b/src/core/screen-private.h index 60c1cd655..a1ebc99f0 100644 --- a/src/core/screen-private.h +++ b/src/core/screen-private.h @@ -142,10 +142,6 @@ MetaLogicalMonitor * meta_screen_get_logical_monitor_for_rect (MetaScreen *sc MetaLogicalMonitor * meta_screen_calculate_logical_monitor_for_window (MetaScreen *screen, MetaWindow *window); -MetaLogicalMonitor * meta_screen_get_logical_monitor_for_point (MetaScreen *screen, - int x, - int y); - MetaLogicalMonitor * meta_screen_get_monitor_neighbor (MetaScreen *screen, int which_monitor, MetaScreenDirection dir); diff --git a/src/core/screen.c b/src/core/screen.c index 341a8b979..0f14d18ab 100644 --- a/src/core/screen.c +++ b/src/core/screen.c @@ -1236,9 +1236,13 @@ root_cursor_prepare_at (MetaCursorSprite *cursor_sprite, int y, MetaScreen *screen) { + MetaBackend *backend = meta_get_backend (); + MetaMonitorManager *monitor_manager = + meta_backend_get_monitor_manager (backend); MetaLogicalMonitor *logical_monitor; - logical_monitor = meta_screen_get_logical_monitor_for_point (screen, x, y); + logical_monitor = + meta_monitor_manager_get_logical_monitor_at (monitor_manager, x, y); /* Reload the cursor texture if the scale has changed. */ if (logical_monitor) @@ -1472,34 +1476,6 @@ meta_screen_get_monitor_index_for_rect (MetaScreen *screen, return monitor->number; } -MetaLogicalMonitor * -meta_screen_get_logical_monitor_for_point (MetaScreen *screen, - int x, - int y) -{ - MetaBackend *backend = meta_get_backend (); - MetaMonitorManager *monitor_manager = - meta_backend_get_monitor_manager (backend); - MetaLogicalMonitor *logical_monitors; - unsigned int n_logical_monitors; - unsigned int i; - - logical_monitors = - meta_monitor_manager_get_logical_monitors (monitor_manager, - &n_logical_monitors); - - if (n_logical_monitors == 1) - return &logical_monitors[0]; - - for (i = 0; i < n_logical_monitors; i++) - { - if (POINT_IN_RECT (x, y, logical_monitors[i].rect)) - return &logical_monitors[i]; - } - - return NULL; -} - MetaLogicalMonitor * meta_screen_get_monitor_neighbor (MetaScreen *screen, int which_monitor, diff --git a/src/core/window.c b/src/core/window.c index 9db1b25d3..15c312a75 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -5633,6 +5633,9 @@ update_move (MetaWindow *window, !META_WINDOW_MAXIMIZED (window) && !META_WINDOW_TILED_SIDE_BY_SIDE (window)) { + MetaBackend *backend = meta_get_backend (); + MetaMonitorManager *monitor_manager = + meta_backend_get_monitor_manager (backend); const MetaLogicalMonitor *monitor; MetaRectangle work_area; @@ -5649,8 +5652,8 @@ update_move (MetaWindow *window, * refers to the monitor which contains the largest part of the window, * the latter to the one where the pointer is located. */ - monitor = meta_screen_get_current_logical_monitor_for_pos (window->screen, - x, y); + monitor = meta_monitor_manager_get_logical_monitor_at (monitor_manager, + x, y); meta_window_get_work_area_for_monitor (window, monitor->number, &work_area); diff --git a/src/wayland/meta-wayland-surface-role-cursor.c b/src/wayland/meta-wayland-surface-role-cursor.c index 8937fc203..5b5f9d6c0 100644 --- a/src/wayland/meta-wayland-surface-role-cursor.c +++ b/src/wayland/meta-wayland-surface-role-cursor.c @@ -28,6 +28,7 @@ #include "meta-xwayland.h" #include "screen-private.h" #include "meta-wayland-private.h" +#include "backends/meta-backend-private.h" typedef struct _MetaWaylandSurfaceRoleCursorPrivate MetaWaylandSurfaceRoleCursorPrivate; @@ -96,15 +97,16 @@ cursor_sprite_prepare_at (MetaCursorSprite *cursor_sprite, { MetaWaylandSurfaceRole *role = META_WAYLAND_SURFACE_ROLE (cursor_role); MetaWaylandSurface *surface = meta_wayland_surface_role_get_surface (role); - MetaDisplay *display = meta_get_display (); - MetaScreen *screen = display->screen; if (!meta_xwayland_is_xwayland_surface (surface)) { + MetaBackend *backend = meta_get_backend (); + MetaMonitorManager *monitor_manager = + meta_backend_get_monitor_manager (backend); const MetaLogicalMonitor *logical_monitor; - logical_monitor = meta_screen_get_logical_monitor_for_point (screen, - x, y); + logical_monitor = + meta_monitor_manager_get_logical_monitor_at (monitor_manager, x, y); if (logical_monitor) { float texture_scale;