[mutter] Move logical monitor neighbor API into monitor manager
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] Move logical monitor neighbor API into monitor manager
- Date: Wed, 25 Jan 2017 08:31:58 +0000 (UTC)
commit a422d6fe08b9267b145200a5139d2f77f1d637e1
Author: Jonas Ådahl <jadahl gmail com>
Date: Thu Dec 1 15:15:52 2016 +0800
Move logical monitor neighbor API into monitor manager
Move the last piece of monitor grid getter API to the monitor manager
away from MetaScreen. The public facing API are still there, but are
thin wrappers around the MetaMonitorManager API.
https://bugzilla.gnome.org/show_bug.cgi?id=777732
src/backends/meta-monitor-manager-private.h | 4 ++
src/backends/meta-monitor-manager.c | 47 +++++++++++++++++++++
src/core/keybindings.c | 8 +++-
src/core/screen-private.h | 4 --
src/core/screen.c | 58 +++++---------------------
src/core/window-private.h | 2 +-
src/core/workspace.c | 18 ++++++---
src/wayland/meta-window-wayland.c | 6 +-
8 files changed, 84 insertions(+), 63 deletions(-)
---
diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h
index 0920da9..a34cc2e 100644
--- a/src/backends/meta-monitor-manager-private.h
+++ b/src/backends/meta-monitor-manager-private.h
@@ -380,6 +380,10 @@ MetaLogicalMonitor *meta_monitor_manager_get_logical_monitor_at (MetaMonitorMana
MetaLogicalMonitor *meta_monitor_manager_get_logical_monitor_from_rect (MetaMonitorManager *manager,
MetaRectangle *rect);
+MetaLogicalMonitor *meta_monitor_manager_get_logical_monitor_neighbor (MetaMonitorManager *manager,
+ MetaLogicalMonitor *logical_monitor,
+ MetaScreenDirection direction);
+
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 da52478..5b5b898 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -1386,6 +1386,53 @@ meta_monitor_manager_get_logical_monitor_from_rect (MetaMonitorManager *manager,
return best_logical_monitor;
}
+MetaLogicalMonitor *
+meta_monitor_manager_get_logical_monitor_neighbor (MetaMonitorManager *manager,
+ MetaLogicalMonitor *logical_monitor,
+ MetaScreenDirection direction)
+{
+ unsigned int i;
+
+ for (i = 0; i < manager->n_logical_monitors; i++)
+ {
+ MetaLogicalMonitor *other = &manager->logical_monitors[i];
+
+ switch (direction)
+ {
+ case META_SCREEN_RIGHT:
+ if (other->rect.x == (logical_monitor->rect.x +
+ logical_monitor->rect.width) &&
+ meta_rectangle_vert_overlap (&other->rect,
+ &logical_monitor->rect))
+ return other;
+ break;
+ case META_SCREEN_LEFT:
+ if (logical_monitor->rect.x == (other->rect.x +
+ other->rect.width) &&
+ meta_rectangle_vert_overlap (&other->rect,
+ &logical_monitor->rect))
+ return other;
+ break;
+ case META_SCREEN_UP:
+ if (logical_monitor->rect.y == (other->rect.y +
+ other->rect.height) &&
+ meta_rectangle_horiz_overlap (&other->rect,
+ &logical_monitor->rect))
+ return other;
+ break;
+ case META_SCREEN_DOWN:
+ if (other->rect.y == (logical_monitor->rect.y +
+ logical_monitor->rect.height) &&
+ meta_rectangle_horiz_overlap (&other->rect,
+ &logical_monitor->rect))
+ return other;
+ break;
+ }
+ }
+
+ return NULL;
+}
+
MetaOutput *
meta_monitor_manager_get_outputs (MetaMonitorManager *manager,
unsigned int *n_outputs)
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 6ee5607..b73c794 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -3154,11 +3154,15 @@ handle_move_to_monitor (MetaDisplay *display,
MetaKeyBinding *binding,
gpointer dummy)
{
+ MetaBackend *backend = meta_get_backend ();
+ MetaMonitorManager *monitor_manager =
+ meta_backend_get_monitor_manager (backend);
gint which = binding->handler->data;
- const MetaLogicalMonitor *current, *new;
+ MetaLogicalMonitor *current, *new;
current = window->monitor;
- new = meta_screen_get_monitor_neighbor (screen, current->number, which);
+ new = meta_monitor_manager_get_logical_monitor_neighbor (monitor_manager,
+ current, which);
if (new == NULL)
return;
diff --git a/src/core/screen-private.h b/src/core/screen-private.h
index 1bc2e24..df14699 100644
--- a/src/core/screen-private.h
+++ b/src/core/screen-private.h
@@ -130,10 +130,6 @@ void meta_screen_hide_tile_preview (MetaScreen *screen);
MetaWindow* meta_screen_get_mouse_window (MetaScreen *screen,
MetaWindow *not_this_one);
-MetaLogicalMonitor * meta_screen_get_monitor_neighbor (MetaScreen *screen,
- int which_monitor,
- MetaScreenDirection dir);
-
void meta_screen_update_workspace_layout (MetaScreen *screen);
void meta_screen_update_workspace_names (MetaScreen *screen);
void meta_screen_queue_workarea_recalc (MetaScreen *screen);
diff --git a/src/core/screen.c b/src/core/screen.c
index eea7f23..4aa2597 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -1415,60 +1415,24 @@ meta_screen_get_monitor_index_for_rect (MetaScreen *screen,
return logical_monitor->number;
}
-MetaLogicalMonitor *
-meta_screen_get_monitor_neighbor (MetaScreen *screen,
- int which_monitor,
- MetaScreenDirection direction)
-{
- 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;
- MetaLogicalMonitor *input;
- MetaLogicalMonitor *current;
-
- logical_monitors =
- meta_monitor_manager_get_logical_monitors (monitor_manager,
- &n_logical_monitors);
- input = &logical_monitors[which_monitor];
-
- for (i = 0; i < n_logical_monitors; i++)
- {
- current = &logical_monitors[i];
-
- if ((direction == META_SCREEN_RIGHT &&
- current->rect.x == input->rect.x + input->rect.width &&
- meta_rectangle_vert_overlap(¤t->rect, &input->rect)) ||
- (direction == META_SCREEN_LEFT &&
- input->rect.x == current->rect.x + current->rect.width &&
- meta_rectangle_vert_overlap(¤t->rect, &input->rect)) ||
- (direction == META_SCREEN_UP &&
- input->rect.y == current->rect.y + current->rect.height &&
- meta_rectangle_horiz_overlap(¤t->rect, &input->rect)) ||
- (direction == META_SCREEN_DOWN &&
- current->rect.y == input->rect.y + input->rect.height &&
- meta_rectangle_horiz_overlap(¤t->rect, &input->rect)))
- {
- return current;
- }
- }
-
- return NULL;
-}
-
int
meta_screen_get_monitor_neighbor_index (MetaScreen *screen,
int which_monitor,
MetaScreenDirection direction)
{
+ MetaBackend *backend = meta_get_backend ();
+ MetaMonitorManager *monitor_manager =
+ meta_backend_get_monitor_manager (backend);
MetaLogicalMonitor *logical_monitor;
+ MetaLogicalMonitor *neighbor;
- logical_monitor = meta_screen_get_monitor_neighbor (screen,
- which_monitor,
- direction);
- return logical_monitor ? logical_monitor->number : -1;
+ logical_monitor =
+ meta_monitor_manager_get_logical_monitor_from_number (monitor_manager,
+ which_monitor);
+ neighbor = meta_monitor_manager_get_logical_monitor_neighbor (monitor_manager,
+ logical_monitor,
+ direction);
+ return neighbor ? neighbor->number : -1;
}
/**
diff --git a/src/core/window-private.h b/src/core/window-private.h
index cd79bde..726e1b1 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -135,7 +135,7 @@ struct _MetaWindow
MetaDisplay *display;
MetaScreen *screen;
guint64 stamp;
- const MetaLogicalMonitor *monitor;
+ MetaLogicalMonitor *monitor;
MetaWorkspace *workspace;
MetaWindowClientType client_type;
MetaWaylandSurface *surface;
diff --git a/src/core/workspace.c b/src/core/workspace.c
index ea465a7..fe56557 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -965,37 +965,43 @@ meta_workspace_set_builtin_struts (MetaWorkspace *workspace,
{
MetaStrut *strut = l->data;
MetaLogicalMonitor *logical_monitor;
- int idx;
logical_monitor =
meta_monitor_manager_get_logical_monitor_from_rect (monitor_manager,
&strut->rect);
- idx = logical_monitor->number;
switch (strut->side)
{
case META_SIDE_TOP:
- if (meta_screen_get_monitor_neighbor (screen, idx, META_SCREEN_UP))
+ if (meta_monitor_manager_get_logical_monitor_neighbor (monitor_manager,
+ logical_monitor,
+ META_SCREEN_UP))
continue;
strut->rect.height += strut->rect.y;
strut->rect.y = 0;
break;
case META_SIDE_BOTTOM:
- if (meta_screen_get_monitor_neighbor (screen, idx, META_SCREEN_DOWN))
+ if (meta_monitor_manager_get_logical_monitor_neighbor (monitor_manager,
+ logical_monitor,
+ META_SCREEN_DOWN))
continue;
strut->rect.height = screen->rect.height - strut->rect.y;
break;
case META_SIDE_LEFT:
- if (meta_screen_get_monitor_neighbor (screen, idx, META_SCREEN_LEFT))
+ if (meta_monitor_manager_get_logical_monitor_neighbor (monitor_manager,
+ logical_monitor,
+ META_SCREEN_LEFT))
continue;
strut->rect.width += strut->rect.x;
strut->rect.x = 0;
break;
case META_SIDE_RIGHT:
- if (meta_screen_get_monitor_neighbor (screen, idx, META_SCREEN_RIGHT))
+ if (meta_monitor_manager_get_logical_monitor_neighbor (monitor_manager,
+ logical_monitor,
+ META_SCREEN_RIGHT))
continue;
strut->rect.width = screen->rect.width - strut->rect.x;
diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c
index f80e01d..04d3c1f 100644
--- a/src/wayland/meta-window-wayland.c
+++ b/src/wayland/meta-window-wayland.c
@@ -339,9 +339,9 @@ meta_window_wayland_update_main_monitor (MetaWindow *window)
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaWindow *toplevel_window;
- const MetaLogicalMonitor *from;
- const MetaLogicalMonitor *to;
- const MetaLogicalMonitor *scaled_new;
+ MetaLogicalMonitor *from;
+ MetaLogicalMonitor *to;
+ MetaLogicalMonitor *scaled_new;
float scale;
MetaRectangle rect;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]