[mutter] screen: Put xinerama monitor index outside of MetaLogicalMonitor
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] screen: Put xinerama monitor index outside of MetaLogicalMonitor
- Date: Wed, 25 Jan 2017 08:32:38 +0000 (UTC)
commit bc5077f623b437e5894047e729e061f3deaa66f8
Author: Jonas Ådahl <jadahl gmail com>
Date: Fri Dec 2 22:09:43 2016 +0800
screen: Put xinerama monitor index outside of MetaLogicalMonitor
Put the monitor xinerama index in a separate struct that is attached to
the logical monitor using g_object_set/get_qdata(). Eventually this
should be moved to some "X11 window manager" object, but lets keep it
in MetaScreen until we have such a thing.
https://bugzilla.gnome.org/show_bug.cgi?id=777732
src/backends/meta-monitor-manager-private.h | 1 -
src/core/screen.c | 55 +++++++++++++++++++++++++-
2 files changed, 52 insertions(+), 4 deletions(-)
---
diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h
index 5bc454a..7e61d0e 100644
--- a/src/backends/meta-monitor-manager-private.h
+++ b/src/backends/meta-monitor-manager-private.h
@@ -216,7 +216,6 @@ struct _MetaLogicalMonitor
GObject parent;
int number;
- int xinerama_index;
MetaRectangle rect;
/* for tiled monitors these are calculated, from untiled just copied */
float refresh_rate;
diff --git a/src/core/screen.c b/src/core/screen.c
index 1661436..123a7e8 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -100,6 +100,13 @@ static guint screen_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (MetaScreen, meta_screen, G_TYPE_OBJECT);
+static GQuark quark_screen_x11_logical_monitor_data = 0;
+
+typedef struct _MetaScreenX11LogicalMonitorData
+{
+ int xinerama_index;
+} MetaScreenX11LogicalMonitorData;
+
static void
meta_screen_set_property (GObject *object,
guint prop_id,
@@ -254,6 +261,9 @@ meta_screen_class_init (MetaScreenClass *klass)
g_object_class_install_property (object_class,
PROP_N_WORKSPACES,
pspec);
+
+ quark_screen_x11_logical_monitor_data =
+ g_quark_from_static_string ("-meta-screen-logical-monitor-x11-data");
}
static void
@@ -338,6 +348,31 @@ set_wm_icon_size_hint (MetaScreen *screen)
#undef N_VALS
}
+static MetaScreenX11LogicalMonitorData *
+get_screen_x11_logical_monitor_data (MetaLogicalMonitor *logical_monitor)
+{
+ return g_object_get_qdata (G_OBJECT (logical_monitor),
+ quark_screen_x11_logical_monitor_data);
+}
+
+static MetaScreenX11LogicalMonitorData *
+ensure_screen_x11_logical_monitor_data (MetaLogicalMonitor *logical_monitor)
+{
+ MetaScreenX11LogicalMonitorData *data;
+
+ data = get_screen_x11_logical_monitor_data (logical_monitor);
+ if (data)
+ return data;
+
+ data = g_new0 (MetaScreenX11LogicalMonitorData, 1);
+ g_object_set_qdata_full (G_OBJECT (logical_monitor),
+ quark_screen_x11_logical_monitor_data,
+ data,
+ g_free);
+
+ return data;
+}
+
static void
meta_screen_ensure_xinerama_indices (MetaScreen *screen)
{
@@ -376,7 +411,13 @@ meta_screen_ensure_xinerama_indices (MetaScreen *screen)
logical_monitor->rect.y == infos[j].y_org &&
logical_monitor->rect.width == infos[j].width &&
logical_monitor->rect.height == infos[j].height)
- logical_monitor->xinerama_index = j;
+ {
+ MetaScreenX11LogicalMonitorData *logical_monitor_data;
+
+ logical_monitor_data =
+ ensure_screen_x11_logical_monitor_data (logical_monitor);
+ logical_monitor_data->xinerama_index = j;
+ }
}
}
@@ -387,11 +428,15 @@ int
meta_screen_logical_monitor_to_xinerama_index (MetaScreen *screen,
MetaLogicalMonitor *logical_monitor)
{
+ MetaScreenX11LogicalMonitorData *logical_monitor_data;
+
g_return_val_if_fail (logical_monitor, -1);
meta_screen_ensure_xinerama_indices (screen);
- return logical_monitor->xinerama_index;
+ logical_monitor_data = get_screen_x11_logical_monitor_data (logical_monitor);
+
+ return logical_monitor_data->xinerama_index;
}
MetaLogicalMonitor *
@@ -411,8 +456,12 @@ meta_screen_xinerama_index_to_logical_monitor (MetaScreen *screen,
for (l = logical_monitors; l; l = l->next)
{
MetaLogicalMonitor *logical_monitor = l->data;
+ MetaScreenX11LogicalMonitorData *logical_monitor_data;
+
+ logical_monitor_data =
+ ensure_screen_x11_logical_monitor_data (logical_monitor);
- if (logical_monitor->xinerama_index == xinerama_index)
+ if (logical_monitor_data->xinerama_index == xinerama_index)
return logical_monitor;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]