[mutter] Put logical monitor grid lookup API in MetaMonitorManager
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] Put logical monitor grid lookup API in MetaMonitorManager
- Date: Wed, 25 Jan 2017 08:31:23 +0000 (UTC)
commit 2df4ebff477453d5748495cec26664d429d63f66
Author: Jonas Ådahl <jadahl gmail com>
Date: Wed Nov 30 10:49:00 2016 +0800
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
src/backends/meta-monitor-manager-private.h | 4 +++
src/backends/meta-monitor-manager.c | 16 +++++++++++
src/core/screen-private.h | 4 ---
src/core/screen.c | 34 +++--------------------
src/core/window.c | 7 +++-
src/wayland/meta-wayland-surface-role-cursor.c | 10 ++++---
6 files changed, 36 insertions(+), 39 deletions(-)
---
diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h
index d576450..c07cc88 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 d2cafb1..aeede6e 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 60c1cd6..a1ebc99 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 341a8b9..0f14d18 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)
@@ -1473,34 +1477,6 @@ meta_screen_get_monitor_index_for_rect (MetaScreen *screen,
}
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,
MetaScreenDirection direction)
diff --git a/src/core/window.c b/src/core/window.c
index 9db1b25..15c312a 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 8937fc2..5b5f9d6 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]