Put logical monitor grid lookup API in MetaMonitorManager

Don't falsely assume the screen has anything to do with the monitor
grid, and thus move the related API to MetaMonitorManager.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
Jonas Ådahl 2016-11-30 10:49:00 +08:00
parent 9337d18468
commit 2df4ebff47
6 changed files with 36 additions and 39 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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);

View File

@ -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,

View File

@ -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);

View File

@ -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;