[gnome-flashback] backends: move GPU ownership from the monitor manager to the backend
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] backends: move GPU ownership from the monitor manager to the backend
- Date: Sat, 11 Jul 2020 18:41:49 +0000 (UTC)
commit a3061fd60002f9ec9cb6702dd28161dcf21399ee
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Tue Jul 7 20:45:20 2020 +0300
backends: move GPU ownership from the monitor manager to the backend
Based on mutter commit:
https://gitlab.gnome.org/GNOME/mutter/-/commit/5c500ad4021941abed48
backends/gf-backend-private.h | 6 ++++
backends/gf-backend-x11-cm.c | 12 ++++++-
backends/gf-backend.c | 62 +++++++++++++++++++++++++++++++++++
backends/gf-crtc-xrandr.c | 7 +++-
backends/gf-gpu-private.h | 26 +++++++--------
backends/gf-gpu-xrandr-private.h | 12 +++----
backends/gf-gpu-xrandr.c | 9 +++--
backends/gf-gpu.c | 37 +++++++++++----------
backends/gf-monitor-manager-private.h | 8 -----
backends/gf-monitor-manager-xrandr.c | 43 ++++++++++++++----------
backends/gf-monitor-manager.c | 45 ++++++++++++++-----------
backends/gf-monitor-tiled-private.h | 7 ++--
backends/gf-monitor-tiled.c | 30 ++++++++---------
backends/gf-monitor.c | 7 ++--
backends/gf-output-xrandr.c | 9 +++--
15 files changed, 212 insertions(+), 108 deletions(-)
---
diff --git a/backends/gf-backend-private.h b/backends/gf-backend-private.h
index 5bfa1df..427085e 100644
--- a/backends/gf-backend-private.h
+++ b/backends/gf-backend-private.h
@@ -28,6 +28,7 @@
#include "gf-backend.h"
#include "gf-monitor-manager-private.h"
+#include "gf-monitor-manager-types-private.h"
#include "gf-orientation-manager-private.h"
#include "gf-settings-private.h"
@@ -49,6 +50,11 @@ GfSettings *gf_backend_get_settings (GfBackend *backend);
void gf_backend_monitors_changed (GfBackend *backend);
+void gf_backend_add_gpu (GfBackend *self,
+ GfGpu *gpu);
+
+GList *gf_backend_get_gpus (GfBackend *self);
+
G_END_DECLS
#endif
diff --git a/backends/gf-backend-x11-cm.c b/backends/gf-backend-x11-cm.c
index ed8aada..dcd5d3a 100644
--- a/backends/gf-backend-x11-cm.c
+++ b/backends/gf-backend-x11-cm.c
@@ -21,6 +21,7 @@
#include "config.h"
#include "gf-backend-x11-cm-private.h"
+#include "gf-gpu-xrandr-private.h"
#include "gf-monitor-manager-xrandr-private.h"
struct _GfBackendX11Cm
@@ -69,6 +70,15 @@ gf_backend_x11_cm_class_init (GfBackendX11CmClass *x11_cm_class)
}
static void
-gf_backend_x11_cm_init (GfBackendX11Cm *x11_cm)
+gf_backend_x11_cm_init (GfBackendX11Cm *self)
{
+ GfGpuXrandr *gpu_xrandr;
+
+ /*
+ * The X server deals with multiple GPUs for us, so we just see what the X
+ * server gives us as one single GPU, even though it may actually be backed
+ * by multiple.
+ */
+ gpu_xrandr = gf_gpu_xrandr_new (GF_BACKEND_X11 (self));
+ gf_backend_add_gpu (GF_BACKEND (self), GF_GPU (gpu_xrandr));
}
diff --git a/backends/gf-backend.c b/backends/gf-backend.c
index 1b930f3..639d430 100644
--- a/backends/gf-backend.c
+++ b/backends/gf-backend.c
@@ -28,6 +28,7 @@
#include <gio/gio.h>
#include "gf-backend-x11-cm-private.h"
+#include "gf-gpu-private.h"
#include "gf-orientation-manager-private.h"
#include "gf-settings-private.h"
@@ -37,8 +38,19 @@ typedef struct
GfOrientationManager *orientation_manager;
GfMonitorManager *monitor_manager;
+
+ GList *gpus;
} GfBackendPrivate;
+enum
+{
+ GPU_ADDED,
+
+ LAST_SIGNAL
+};
+
+static guint backend_signals[LAST_SIGNAL] = { 0 };
+
static void
initable_iface_init (GInitableIface *initable_iface);
@@ -97,6 +109,20 @@ gf_backend_dispose (GObject *object)
G_OBJECT_CLASS (gf_backend_parent_class)->dispose (object);
}
+static void
+gf_backend_finalize (GObject *object)
+{
+ GfBackend *self;
+ GfBackendPrivate *priv;
+
+ self = GF_BACKEND (object);
+ priv = gf_backend_get_instance_private (self);
+
+ g_list_free_full (priv->gpus, g_object_unref);
+
+ G_OBJECT_CLASS (gf_backend_parent_class)->finalize (object);
+}
+
static void
gf_backend_real_post_init (GfBackend *backend)
{
@@ -115,8 +141,21 @@ gf_backend_class_init (GfBackendClass *backend_class)
object_class = G_OBJECT_CLASS (backend_class);
object_class->dispose = gf_backend_dispose;
+ object_class->finalize = gf_backend_finalize;
backend_class->post_init = gf_backend_real_post_init;
+
+ backend_signals[GPU_ADDED] =
+ g_signal_new ("gpu-added",
+ G_TYPE_FROM_CLASS (backend_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ G_TYPE_NONE,
+ 1,
+ GF_TYPE_GPU);
}
static void
@@ -197,3 +236,26 @@ void
gf_backend_monitors_changed (GfBackend *backend)
{
}
+
+void
+gf_backend_add_gpu (GfBackend *self,
+ GfGpu *gpu)
+{
+ GfBackendPrivate *priv;
+
+ priv = gf_backend_get_instance_private (self);
+
+ priv->gpus = g_list_append (priv->gpus, gpu);
+
+ g_signal_emit (self, backend_signals[GPU_ADDED], 0, gpu);
+}
+
+GList *
+gf_backend_get_gpus (GfBackend *self)
+{
+ GfBackendPrivate *priv;
+
+ priv = gf_backend_get_instance_private (self);
+
+ return priv->gpus;
+}
diff --git a/backends/gf-crtc-xrandr.c b/backends/gf-crtc-xrandr.c
index 09f453d..236bd16 100644
--- a/backends/gf-crtc-xrandr.c
+++ b/backends/gf-crtc-xrandr.c
@@ -27,6 +27,8 @@
#include <X11/Xlib-xcb.h>
+#include "gf-backend-private.h"
+#include "gf-monitor-manager-xrandr-private.h"
#include "gf-output-private.h"
#define ALL_ROTATIONS (RR_Rotate_0 | RR_Rotate_90 | RR_Rotate_180 | RR_Rotate_270)
@@ -184,6 +186,7 @@ gf_crtc_xrandr_set_config (GfCrtc *crtc,
{
GfGpu *gpu;
GfGpuXrandr *gpu_xrandr;
+ GfBackend *backend;
GfMonitorManager *monitor_manager;
GfMonitorManagerXrandr *monitor_manager_xrandr;
Display *xdisplay;
@@ -197,7 +200,9 @@ gf_crtc_xrandr_set_config (GfCrtc *crtc,
gpu = gf_crtc_get_gpu (crtc);
gpu_xrandr = GF_GPU_XRANDR (gpu);
- monitor_manager = gf_gpu_get_monitor_manager (gpu);
+ backend = gf_gpu_get_backend (gpu);
+
+ monitor_manager = gf_backend_get_monitor_manager (backend);
monitor_manager_xrandr = GF_MONITOR_MANAGER_XRANDR (monitor_manager);
xdisplay = gf_monitor_manager_xrandr_get_xdisplay (monitor_manager_xrandr);
diff --git a/backends/gf-gpu-private.h b/backends/gf-gpu-private.h
index a7381f4..e97eedb 100644
--- a/backends/gf-gpu-private.h
+++ b/backends/gf-gpu-private.h
@@ -36,27 +36,27 @@ struct _GfGpuClass
GError **error);
};
-gboolean gf_gpu_read_current (GfGpu *gpu,
- GError **error);
+gboolean gf_gpu_read_current (GfGpu *self,
+ GError **error);
-gboolean gf_gpu_has_hotplug_mode_update (GfGpu *gpu);
+gboolean gf_gpu_has_hotplug_mode_update (GfGpu *self);
-GfMonitorManager *gf_gpu_get_monitor_manager (GfGpu *gpu);
+GfBackend *gf_gpu_get_backend (GfGpu *self);
-GList *gf_gpu_get_outputs (GfGpu *gpu);
+GList *gf_gpu_get_outputs (GfGpu *self);
-GList *gf_gpu_get_crtcs (GfGpu *gpu);
+GList *gf_gpu_get_crtcs (GfGpu *self);
-GList *gf_gpu_get_modes (GfGpu *gpu);
+GList *gf_gpu_get_modes (GfGpu *self);
-void gf_gpu_take_outputs (GfGpu *gpu,
- GList *outputs);
+void gf_gpu_take_outputs (GfGpu *self,
+ GList *outputs);
-void gf_gpu_take_crtcs (GfGpu *gpu,
- GList *crtcs);
+void gf_gpu_take_crtcs (GfGpu *self,
+ GList *crtcs);
-void gf_gpu_take_modes (GfGpu *gpu,
- GList *modes);
+void gf_gpu_take_modes (GfGpu *self,
+ GList *modes);
G_END_DECLS
diff --git a/backends/gf-gpu-xrandr-private.h b/backends/gf-gpu-xrandr-private.h
index 31a5dea..525ea09 100644
--- a/backends/gf-gpu-xrandr-private.h
+++ b/backends/gf-gpu-xrandr-private.h
@@ -22,21 +22,21 @@
#include <glib-object.h>
#include <X11/extensions/Xrandr.h>
+#include "gf-backend-x11-private.h"
#include "gf-gpu-private.h"
-#include "gf-monitor-manager-xrandr-private.h"
G_BEGIN_DECLS
#define GF_TYPE_GPU_XRANDR (gf_gpu_xrandr_get_type ())
G_DECLARE_FINAL_TYPE (GfGpuXrandr, gf_gpu_xrandr, GF, GPU_XRANDR, GfGpu)
-GfGpuXrandr *gf_gpu_xrandr_new (GfMonitorManagerXrandr *monitor_manager_xrandr);
+GfGpuXrandr *gf_gpu_xrandr_new (GfBackendX11 *backend_x11);
-XRRScreenResources *gf_gpu_xrandr_get_resources (GfGpuXrandr *gpu_xrandr);
+XRRScreenResources *gf_gpu_xrandr_get_resources (GfGpuXrandr *self);
-void gf_gpu_xrandr_get_max_screen_size (GfGpuXrandr *gpu_xrandr,
- int *max_width,
- int *max_height);
+void gf_gpu_xrandr_get_max_screen_size (GfGpuXrandr *self,
+ int *max_width,
+ int *max_height);
G_END_DECLS
diff --git a/backends/gf-gpu-xrandr.c b/backends/gf-gpu-xrandr.c
index 341d556..3909e42 100644
--- a/backends/gf-gpu-xrandr.c
+++ b/backends/gf-gpu-xrandr.c
@@ -80,6 +80,7 @@ gf_gpu_xrandr_read_current (GfGpu *gpu,
GError **error)
{
GfGpuXrandr *gpu_xrandr;
+ GfBackend *backend;
GfMonitorManager *monitor_manager;
GfMonitorManagerXrandr *monitor_manager_xrandr;
Display *xdisplay;
@@ -95,7 +96,9 @@ gf_gpu_xrandr_read_current (GfGpu *gpu,
RROutput primary_output;
gpu_xrandr = GF_GPU_XRANDR (gpu);
- monitor_manager = gf_gpu_get_monitor_manager (gpu);
+
+ backend = gf_gpu_get_backend (gpu);
+ monitor_manager = gf_backend_get_monitor_manager (backend);
monitor_manager_xrandr = GF_MONITOR_MANAGER_XRANDR (monitor_manager);
xdisplay = gf_monitor_manager_xrandr_get_xdisplay (monitor_manager_xrandr);
@@ -244,10 +247,10 @@ gf_gpu_xrandr_init (GfGpuXrandr *gpu_xrandr)
}
GfGpuXrandr *
-gf_gpu_xrandr_new (GfMonitorManagerXrandr *monitor_manager_xrandr)
+gf_gpu_xrandr_new (GfBackendX11 *backend_x11)
{
return g_object_new (GF_TYPE_GPU_XRANDR,
- "monitor-manager", monitor_manager_xrandr,
+ "backend", backend_x11,
NULL);
}
diff --git a/backends/gf-gpu.c b/backends/gf-gpu.c
index e4d81e1..3a41e05 100644
--- a/backends/gf-gpu.c
+++ b/backends/gf-gpu.c
@@ -19,22 +19,23 @@
#include "config.h"
#include "gf-gpu-private.h"
+#include "gf-backend-private.h"
#include "gf-output-private.h"
typedef struct
{
- GfMonitorManager *monitor_manager;
+ GfBackend *backend;
- GList *outputs;
- GList *crtcs;
- GList *modes;
+ GList *outputs;
+ GList *crtcs;
+ GList *modes;
} GfGpuPrivate;
enum
{
PROP_0,
- PROP_MONITOR_MANAGER,
+ PROP_BACKEND,
LAST_PROP
};
@@ -73,8 +74,8 @@ gf_gpu_get_property (GObject *object,
switch (property_id)
{
- case PROP_MONITOR_MANAGER:
- g_value_set_object (value, priv->monitor_manager);
+ case PROP_BACKEND:
+ g_value_set_object (value, priv->backend);
break;
default:
@@ -97,8 +98,8 @@ gf_gpu_set_property (GObject *object,
switch (property_id)
{
- case PROP_MONITOR_MANAGER:
- priv->monitor_manager = g_value_get_object (value);
+ case PROP_BACKEND:
+ priv->backend = g_value_get_object (value);
break;
default:
@@ -110,11 +111,11 @@ gf_gpu_set_property (GObject *object,
static void
gf_gpu_install_properties (GObjectClass *object_class)
{
- gpu_properties[PROP_MONITOR_MANAGER] =
- g_param_spec_object ("monitor-manager",
- "GfMonitorManager",
- "GfMonitorManager",
- GF_TYPE_MONITOR_MANAGER,
+ gpu_properties[PROP_BACKEND] =
+ g_param_spec_object ("backend",
+ "GfBackend",
+ "GfBackend",
+ GF_TYPE_BACKEND,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
@@ -187,14 +188,14 @@ gf_gpu_has_hotplug_mode_update (GfGpu *gpu)
return FALSE;
}
-GfMonitorManager *
-gf_gpu_get_monitor_manager (GfGpu *gpu)
+GfBackend *
+gf_gpu_get_backend (GfGpu *self)
{
GfGpuPrivate *priv;
- priv = gf_gpu_get_instance_private (gpu);
+ priv = gf_gpu_get_instance_private (self);
- return priv->monitor_manager;
+ return priv->backend;
}
GList *
diff --git a/backends/gf-monitor-manager-private.h b/backends/gf-monitor-manager-private.h
index 1665f23..4dbe227 100644
--- a/backends/gf-monitor-manager-private.h
+++ b/backends/gf-monitor-manager-private.h
@@ -60,8 +60,6 @@ struct _GfMonitorManager
gint screen_width;
gint screen_height;
- GList *gpus;
-
GList *monitors;
GList *logical_monitors;
@@ -166,12 +164,6 @@ GList *gf_monitor_manager_get_monitors (GfM
GfLogicalMonitor *gf_monitor_manager_get_primary_logical_monitor (GfMonitorManager
*manager);
-void gf_monitor_manager_add_gpu (GfMonitorManager
*manager,
- GfGpu
*gpu);
-
-GList *gf_monitor_manager_get_gpus (GfMonitorManager
*manager);
-
-
gboolean gf_monitor_manager_has_hotplug_mode_update (GfMonitorManager
*manager);
void gf_monitor_manager_read_current_state (GfMonitorManager
*manager);
void gf_monitor_manager_on_hotplug (GfMonitorManager
*manager);
diff --git a/backends/gf-monitor-manager-xrandr.c b/backends/gf-monitor-manager-xrandr.c
index 4659b54..a8076da 100644
--- a/backends/gf-monitor-manager-xrandr.c
+++ b/backends/gf-monitor-manager-xrandr.c
@@ -63,13 +63,6 @@ struct _GfMonitorManagerXrandr
gboolean has_randr15;
GHashTable *tiled_monitor_atoms;
- /*
- * The X server deals with multiple GPUs for us, soe just see what the X
- * server gives us as one single GPU, even though it may actually be backed
- * by multiple.
- */
- GfGpu *gpu;
-
Time last_xrandr_set_timestamp;
gfloat *supported_scales;
@@ -278,6 +271,18 @@ is_output_assignment_changed (GfOutput *output,
return TRUE;
}
+static GfGpu *
+get_gpu (GfMonitorManagerXrandr *self)
+{
+ GfMonitorManager *manager;
+ GfBackend *backend;
+
+ manager = GF_MONITOR_MANAGER (self);
+ backend = gf_monitor_manager_get_backend (manager);
+
+ return GF_GPU (gf_backend_get_gpus (backend)->data);
+}
+
static gboolean
is_assignments_changed (GfMonitorManager *manager,
GfCrtcInfo **crtc_infos,
@@ -286,11 +291,13 @@ is_assignments_changed (GfMonitorManager *manager,
guint n_output_infos)
{
GfMonitorManagerXrandr *manager_xrandr;
+ GfGpu *gpu;
GList *l;
manager_xrandr = GF_MONITOR_MANAGER_XRANDR (manager);
+ gpu = get_gpu (manager_xrandr);
- for (l = gf_gpu_get_crtcs (manager_xrandr->gpu); l; l = l->next)
+ for (l = gf_gpu_get_crtcs (gpu); l; l = l->next)
{
GfCrtc *crtc = l->data;
@@ -298,7 +305,7 @@ is_assignments_changed (GfMonitorManager *manager,
return TRUE;
}
- for (l = gf_gpu_get_outputs (manager_xrandr->gpu); l; l = l->next)
+ for (l = gf_gpu_get_outputs (gpu); l; l = l->next)
{
GfOutput *output = l->data;
@@ -371,11 +378,13 @@ apply_crtc_assignments (GfMonitorManager *manager,
guint n_outputs)
{
GfMonitorManagerXrandr *xrandr;
+ GfGpu *gpu;
gint width, height, width_mm, height_mm;
guint i;
GList *l;
xrandr = GF_MONITOR_MANAGER_XRANDR (manager);
+ gpu = get_gpu (xrandr);
XGrabServer (xrandr->xdisplay);
@@ -430,7 +439,7 @@ apply_crtc_assignments (GfMonitorManager *manager,
}
/* Disable CRTCs not mentioned in the list */
- for (l = gf_gpu_get_crtcs (xrandr->gpu); l; l = l->next)
+ for (l = gf_gpu_get_crtcs (gpu); l; l = l->next)
{
GfCrtc *crtc = l->data;
@@ -540,7 +549,7 @@ apply_crtc_assignments (GfMonitorManager *manager,
}
/* Disable outputs not mentioned in the list */
- for (l = gf_gpu_get_outputs (xrandr->gpu); l; l = l->next)
+ for (l = gf_gpu_get_outputs (gpu); l; l = l->next)
{
GfOutput *output = l->data;
@@ -665,9 +674,6 @@ gf_monitor_manager_xrandr_constructed (GObject *object)
xrandr->xdisplay = gf_backend_x11_get_xdisplay (GF_BACKEND_X11 (backend));
xrandr->xroot = DefaultRootWindow (xrandr->xdisplay);
- xrandr->gpu = GF_GPU (gf_gpu_xrandr_new (xrandr));
- gf_monitor_manager_add_gpu (GF_MONITOR_MANAGER (xrandr), xrandr->gpu);
-
if (XRRQueryExtension (xrandr->xdisplay, &rr_event_base, &rr_error_base))
{
gint major_version;
@@ -718,7 +724,6 @@ gf_monitor_manager_xrandr_finalize (GObject *object)
xrandr = GF_MONITOR_MANAGER_XRANDR (object);
- g_clear_object (&xrandr->gpu);
g_clear_pointer (&xrandr->supported_scales, g_free);
G_OBJECT_CLASS (gf_monitor_manager_xrandr_parent_class)->finalize (object);
@@ -1069,10 +1074,12 @@ gf_monitor_manager_xrandr_get_max_screen_size (GfMonitorManager *manager,
gint *max_height)
{
GfMonitorManagerXrandr *xrandr;
+ GfGpu *gpu;
xrandr = GF_MONITOR_MANAGER_XRANDR (manager);
+ gpu = get_gpu (xrandr);
- gf_gpu_xrandr_get_max_screen_size (GF_GPU_XRANDR (xrandr->gpu),
+ gf_gpu_xrandr_get_max_screen_size (GF_GPU_XRANDR (gpu),
max_width, max_height);
return TRUE;
@@ -1137,6 +1144,7 @@ gf_monitor_manager_xrandr_handle_xevent (GfMonitorManagerXrandr *xrandr,
XEvent *event)
{
GfMonitorManager *manager;
+ GfGpu *gpu;
GfGpuXrandr *gpu_xrandr;
XRRScreenResources *resources;
@@ -1148,7 +1156,8 @@ gf_monitor_manager_xrandr_handle_xevent (GfMonitorManagerXrandr *xrandr,
XRRUpdateConfiguration (event);
gf_monitor_manager_read_current_state (manager);
- gpu_xrandr = GF_GPU_XRANDR (xrandr->gpu);
+ gpu = get_gpu (xrandr);
+ gpu_xrandr = GF_GPU_XRANDR (gpu);
resources = gf_gpu_xrandr_get_resources (gpu_xrandr);
if (!resources)
diff --git a/backends/gf-monitor-manager.c b/backends/gf-monitor-manager.c
index b0dbe6a..c82a602 100644
--- a/backends/gf-monitor-manager.c
+++ b/backends/gf-monitor-manager.c
@@ -996,15 +996,21 @@ is_main_tiled_monitor_output (GfOutput *output)
static void
rebuild_monitors (GfMonitorManager *manager)
{
+ GfMonitorManagerPrivate *priv;
+ GList *gpus;
GList *l;
+ priv = gf_monitor_manager_get_instance_private (manager);
+
if (manager->monitors)
{
g_list_free_full (manager->monitors, g_object_unref);
manager->monitors = NULL;
}
- for (l = manager->gpus; l; l = l->next)
+ gpus = gf_backend_get_gpus (priv->backend);
+
+ for (l = gpus; l; l = l->next)
{
GfGpu *gpu = l->data;
GList *k;
@@ -1019,7 +1025,7 @@ rebuild_monitors (GfMonitorManager *manager)
{
GfMonitorTiled *monitor_tiled;
- monitor_tiled = gf_monitor_tiled_new (gpu, output);
+ monitor_tiled = gf_monitor_tiled_new (gpu, manager, output);
manager->monitors = g_list_append (manager->monitors, monitor_tiled);
}
}
@@ -1038,10 +1044,16 @@ static GList *
combine_gpu_lists (GfMonitorManager *manager,
GList * (*list_getter) (GfGpu *gpu))
{
+ GfMonitorManagerPrivate *priv;
+ GList *gpus;
GList *list = NULL;
GList *l;
- for (l = manager->gpus; l; l = l->next)
+ priv = gf_monitor_manager_get_instance_private (manager);
+
+ gpus = gf_backend_get_gpus (priv->backend);
+
+ for (l = gpus; l; l = l->next)
{
GfGpu *gpu = l->data;
@@ -1935,11 +1947,14 @@ gf_monitor_manager_real_is_lid_closed (GfMonitorManager *manager)
static void
gf_monitor_manager_real_read_current_state (GfMonitorManager *manager)
{
+ GfMonitorManagerPrivate *priv;
GList *l;
+ priv = gf_monitor_manager_get_instance_private (manager);
+
manager->serial++;
- for (l = manager->gpus; l; l = l->next)
+ for (l = gf_backend_get_gpus (priv->backend); l; l = l->next)
{
GfGpu *gpu = l->data;
GError *error = NULL;
@@ -2054,7 +2069,6 @@ gf_monitor_manager_finalize (GObject *object)
manager = GF_MONITOR_MANAGER (object);
- g_list_free_full (manager->gpus, g_object_unref);
g_list_free_full (manager->logical_monitors, g_object_unref);
G_OBJECT_CLASS (gf_monitor_manager_parent_class)->finalize (object);
@@ -2275,25 +2289,18 @@ gf_monitor_manager_get_primary_logical_monitor (GfMonitorManager *manager)
return manager->primary_logical_monitor;
}
-void
-gf_monitor_manager_add_gpu (GfMonitorManager *manager,
- GfGpu *gpu)
-{
- manager->gpus = g_list_append (manager->gpus, gpu);
-}
-
-GList *
-gf_monitor_manager_get_gpus (GfMonitorManager *manager)
-{
- return manager->gpus;
-}
-
gboolean
gf_monitor_manager_has_hotplug_mode_update (GfMonitorManager *manager)
{
+ GfMonitorManagerPrivate *priv;
+ GList *gpus;
GList *l;
- for (l = manager->gpus; l; l = l->next)
+ priv = gf_monitor_manager_get_instance_private (manager);
+
+ gpus = gf_backend_get_gpus (priv->backend);
+
+ for (l = gpus; l; l = l->next)
{
GfGpu *gpu = l->data;
diff --git a/backends/gf-monitor-tiled-private.h b/backends/gf-monitor-tiled-private.h
index de2bddb..58a2ed0 100644
--- a/backends/gf-monitor-tiled-private.h
+++ b/backends/gf-monitor-tiled-private.h
@@ -31,10 +31,11 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GfMonitorTiled, gf_monitor_tiled,
GF, MONITOR_TILED, GfMonitor)
-GfMonitorTiled *gf_monitor_tiled_new (GfGpu *gpu,
- GfOutput *output);
+GfMonitorTiled *gf_monitor_tiled_new (GfGpu *gpu,
+ GfMonitorManager *monitor_manager,
+ GfOutput *output);
-uint32_t gf_monitor_tiled_get_tile_group_id (GfMonitorTiled *monitor_tiled);
+uint32_t gf_monitor_tiled_get_tile_group_id (GfMonitorTiled *monitor_tiled);
G_END_DECLS
diff --git a/backends/gf-monitor-tiled.c b/backends/gf-monitor-tiled.c
index 6398283..704a829 100644
--- a/backends/gf-monitor-tiled.c
+++ b/backends/gf-monitor-tiled.c
@@ -34,15 +34,17 @@ typedef struct
struct _GfMonitorTiled
{
- GfMonitor parent;
+ GfMonitor parent;
- uint32_t tile_group_id;
+ GfMonitorManager *monitor_manager;
+
+ uint32_t tile_group_id;
/* The tile (0, 0) output. */
- GfOutput *origin_output;
+ GfOutput *origin_output;
/* The output enabled even when a non-tiled mode is used. */
- GfOutput *main_output;
+ GfOutput *main_output;
};
G_DEFINE_TYPE (GfMonitorTiled, gf_monitor_tiled, GF_TYPE_MONITOR)
@@ -594,15 +596,12 @@ calculate_tile_coordinate (GfMonitor *monitor,
static void
gf_monitor_tiled_finalize (GObject *object)
{
- GfMonitor *monitor;
- GfGpu *gpu;
- GfMonitorManager *monitor_manager;
+ GfMonitorTiled *self;
- monitor = GF_MONITOR (object);
+ self = GF_MONITOR_TILED (object);
- gpu = gf_monitor_get_gpu (monitor);
- monitor_manager = gf_gpu_get_monitor_manager (gpu);
- gf_monitor_manager_tiled_monitor_removed (monitor_manager, monitor);
+ gf_monitor_manager_tiled_monitor_removed (self->monitor_manager,
+ GF_MONITOR (self));
G_OBJECT_CLASS (gf_monitor_tiled_parent_class)->finalize (object);
}
@@ -719,12 +718,12 @@ gf_monitor_tiled_init (GfMonitorTiled *tiled)
}
GfMonitorTiled *
-gf_monitor_tiled_new (GfGpu *gpu,
- GfOutput *output)
+gf_monitor_tiled_new (GfGpu *gpu,
+ GfMonitorManager *monitor_manager,
+ GfOutput *output)
{
GfMonitorTiled *tiled;
GfMonitor *monitor;
- GfMonitorManager *monitor_manager;
tiled = g_object_new (GF_TYPE_MONITOR_TILED,
"gpu", gpu,
@@ -732,6 +731,8 @@ gf_monitor_tiled_new (GfGpu *gpu,
monitor = GF_MONITOR (tiled);
+ tiled->monitor_manager = monitor_manager;
+
tiled->tile_group_id = output->tile_info.group_id;
gf_monitor_set_winsys_id (monitor, output->winsys_id);
@@ -742,7 +743,6 @@ gf_monitor_tiled_new (GfGpu *gpu,
gf_monitor_generate_spec (monitor);
- monitor_manager = gf_gpu_get_monitor_manager (gpu);
gf_monitor_manager_tiled_monitor_added (monitor_manager, monitor);
generate_modes (tiled);
diff --git a/backends/gf-monitor.c b/backends/gf-monitor.c
index cc983e1..752eb8e 100644
--- a/backends/gf-monitor.c
+++ b/backends/gf-monitor.c
@@ -511,11 +511,13 @@ void
gf_monitor_make_display_name (GfMonitor *monitor)
{
GfMonitorPrivate *priv;
+ GfBackend *backend;
GfMonitorManager *manager;
priv = gf_monitor_get_instance_private (monitor);
- manager = gf_gpu_get_monitor_manager (priv->gpu);
+ backend = gf_gpu_get_backend (priv->gpu);
+ manager = gf_backend_get_monitor_manager (backend);
g_free (priv->display_name);
priv->display_name = make_display_name (monitor, manager);
@@ -1041,7 +1043,8 @@ gf_monitor_calculate_mode_scale (GfMonitor *monitor,
gint global_scaling_factor;
priv = gf_monitor_get_instance_private (monitor);
- monitor_manager = gf_gpu_get_monitor_manager (priv->gpu);
+ backend = gf_gpu_get_backend (priv->gpu);
+ monitor_manager = gf_backend_get_monitor_manager (backend);
backend = gf_monitor_manager_get_backend (monitor_manager);
settings = gf_backend_get_settings (backend);
diff --git a/backends/gf-output-xrandr.c b/backends/gf-output-xrandr.c
index 71ed222..a656fc9 100644
--- a/backends/gf-output-xrandr.c
+++ b/backends/gf-output-xrandr.c
@@ -32,16 +32,19 @@
#include <xcb/randr.h>
#include "gf-crtc-private.h"
+#include "gf-monitor-manager-xrandr-private.h"
static Display *
xdisplay_from_output (GfOutput *output)
{
GfGpu *gpu;
+ GfBackend *backend;
GfMonitorManager *monitor_manager;
GfMonitorManagerXrandr *monitor_manager_xrandr;
gpu = gf_output_get_gpu (output);
- monitor_manager = gf_gpu_get_monitor_manager (gpu);
+ backend = gf_gpu_get_backend (gpu);
+ monitor_manager = gf_backend_get_monitor_manager (backend);
monitor_manager_xrandr = GF_MONITOR_MANAGER_XRANDR (monitor_manager);
return gf_monitor_manager_xrandr_get_xdisplay (monitor_manager_xrandr);
@@ -430,6 +433,7 @@ static void
output_get_tile_info (GfOutput *output)
{
GfGpu *gpu;
+ GfBackend *backend;
GfMonitorManager *monitor_manager;
GfMonitorManagerXrandr *monitor_manager_xrandr;
Display *xdisplay;
@@ -440,7 +444,8 @@ output_get_tile_info (GfOutput *output)
Atom actual_type;
gpu = gf_output_get_gpu (output);
- monitor_manager = gf_gpu_get_monitor_manager (gpu);
+ backend = gf_gpu_get_backend (gpu);
+ monitor_manager = gf_backend_get_monitor_manager (backend);
monitor_manager_xrandr = GF_MONITOR_MANAGER_XRANDR (monitor_manager);
if (!gf_monitor_manager_xrandr_has_randr15 (monitor_manager_xrandr))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]