backends: Move MonitorManager creation to MetaBackend as well
This commit is contained in:
parent
48dc544bef
commit
c44b1d730d
@ -51,6 +51,7 @@ struct _MetaBackendClass
|
|||||||
|
|
||||||
MetaIdleMonitor * (* create_idle_monitor) (MetaBackend *backend,
|
MetaIdleMonitor * (* create_idle_monitor) (MetaBackend *backend,
|
||||||
int device_id);
|
int device_id);
|
||||||
|
MetaMonitorManager * (* create_monitor_manager) (MetaBackend *backend);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* META_BACKEND_PRIVATE_H */
|
#endif /* META_BACKEND_PRIVATE_H */
|
||||||
|
@ -42,14 +42,32 @@ meta_get_backend (void)
|
|||||||
return _backend;
|
return _backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_DEFINE_ABSTRACT_TYPE (MetaBackend, meta_backend, G_TYPE_OBJECT);
|
struct _MetaBackendPrivate
|
||||||
|
{
|
||||||
|
MetaMonitorManager *monitor_manager;
|
||||||
|
};
|
||||||
|
typedef struct _MetaBackendPrivate MetaBackendPrivate;
|
||||||
|
|
||||||
|
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaBackend, meta_backend, G_TYPE_OBJECT);
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_backend_constructed (GObject *object)
|
||||||
|
{
|
||||||
|
MetaBackend *backend = META_BACKEND (object);
|
||||||
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||||
|
|
||||||
|
priv->monitor_manager = META_BACKEND_GET_CLASS (backend)->create_monitor_manager (backend);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_backend_finalize (GObject *object)
|
meta_backend_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
MetaBackend *backend = META_BACKEND (object);
|
MetaBackend *backend = META_BACKEND (object);
|
||||||
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
g_clear_object (&priv->monitor_manager);
|
||||||
|
|
||||||
for (i = 0; i <= backend->device_id_max; i++)
|
for (i = 0; i <= backend->device_id_max; i++)
|
||||||
{
|
{
|
||||||
if (backend->device_monitors[i])
|
if (backend->device_monitors[i])
|
||||||
@ -64,6 +82,7 @@ meta_backend_class_init (MetaBackendClass *klass)
|
|||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->constructed = meta_backend_constructed;
|
||||||
object_class->finalize = meta_backend_finalize;
|
object_class->finalize = meta_backend_finalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,6 +124,14 @@ meta_backend_get_idle_monitor (MetaBackend *backend,
|
|||||||
return backend->device_monitors[device_id];
|
return backend->device_monitors[device_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetaMonitorManager *
|
||||||
|
meta_backend_get_monitor_manager (MetaBackend *backend)
|
||||||
|
{
|
||||||
|
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
|
||||||
|
|
||||||
|
return priv->monitor_manager;
|
||||||
|
}
|
||||||
|
|
||||||
static GType
|
static GType
|
||||||
get_backend_type (void)
|
get_backend_type (void)
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
#include <meta/meta-idle-monitor.h>
|
#include <meta/meta-idle-monitor.h>
|
||||||
|
#include "meta-monitor-manager.h"
|
||||||
|
|
||||||
typedef struct _MetaBackend MetaBackend;
|
typedef struct _MetaBackend MetaBackend;
|
||||||
typedef struct _MetaBackendClass MetaBackendClass;
|
typedef struct _MetaBackendClass MetaBackendClass;
|
||||||
@ -38,6 +39,7 @@ MetaBackend * meta_get_backend (void);
|
|||||||
|
|
||||||
MetaIdleMonitor * meta_backend_get_idle_monitor (MetaBackend *backend,
|
MetaIdleMonitor * meta_backend_get_idle_monitor (MetaBackend *backend,
|
||||||
int device_id);
|
int device_id);
|
||||||
|
MetaMonitorManager * meta_backend_get_monitor_manager (MetaBackend *backend);
|
||||||
|
|
||||||
void meta_clutter_init (void);
|
void meta_clutter_init (void);
|
||||||
|
|
||||||
|
@ -36,9 +36,8 @@
|
|||||||
#include "util-private.h"
|
#include "util-private.h"
|
||||||
#include <meta/errors.h>
|
#include <meta/errors.h>
|
||||||
#include "meta-monitor-config.h"
|
#include "meta-monitor-config.h"
|
||||||
#include "backends/native/meta-monitor-manager-kms.h"
|
|
||||||
#include "backends/x11/meta-monitor-manager-xrandr.h"
|
#include "backends/x11/meta-monitor-manager-xrandr.h"
|
||||||
#include "meta-monitor-manager-dummy.h"
|
#include "meta-backend.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
CONFIRM_DISPLAY_CHANGE,
|
CONFIRM_DISPLAY_CHANGE,
|
||||||
@ -168,46 +167,6 @@ make_logical_config (MetaMonitorManager *manager)
|
|||||||
manager->monitor_infos = (void*)g_array_free (monitor_infos, FALSE);
|
manager->monitor_infos = (void*)g_array_free (monitor_infos, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GType
|
|
||||||
get_default_backend (void)
|
|
||||||
{
|
|
||||||
#if defined(CLUTTER_WINDOWING_EGL)
|
|
||||||
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_EGL))
|
|
||||||
return META_TYPE_MONITOR_MANAGER_KMS;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CLUTTER_WINDOWING_X11)
|
|
||||||
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_X11))
|
|
||||||
{
|
|
||||||
/* If we're a Wayland compositor using the X11 backend,
|
|
||||||
* we're a nested configuration, so return the dummy
|
|
||||||
* monitor setup. */
|
|
||||||
if (meta_is_wayland_compositor ())
|
|
||||||
return META_TYPE_MONITOR_MANAGER_DUMMY;
|
|
||||||
else
|
|
||||||
return META_TYPE_MONITOR_MANAGER_XRANDR;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CLUTTER_WINDOWING_WAYLAND)
|
|
||||||
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_WAYLAND))
|
|
||||||
{
|
|
||||||
/* Use the dummy implementation on Wayland for now.
|
|
||||||
* In the future, we should support wl_fullscreen_output
|
|
||||||
* which will have CRTC management in the protocol. */
|
|
||||||
return META_TYPE_MONITOR_MANAGER_DUMMY;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
|
|
||||||
static MetaMonitorManager *
|
|
||||||
meta_monitor_manager_new (void)
|
|
||||||
{
|
|
||||||
return g_object_new (get_default_backend (), NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_monitor_manager_constructed (GObject *object)
|
meta_monitor_manager_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
@ -1167,20 +1126,12 @@ initialize_dbus_interface (MetaMonitorManager *manager)
|
|||||||
g_object_unref);
|
g_object_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
static MetaMonitorManager *global_monitor_manager;
|
|
||||||
|
|
||||||
void
|
|
||||||
meta_monitor_manager_initialize (void)
|
|
||||||
{
|
|
||||||
global_monitor_manager = meta_monitor_manager_new ();
|
|
||||||
}
|
|
||||||
|
|
||||||
MetaMonitorManager *
|
MetaMonitorManager *
|
||||||
meta_monitor_manager_get (void)
|
meta_monitor_manager_get (void)
|
||||||
{
|
{
|
||||||
g_assert (global_monitor_manager != NULL);
|
MetaBackend *backend = meta_get_backend ();
|
||||||
|
|
||||||
return global_monitor_manager;
|
return meta_backend_get_monitor_manager (backend);
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaMonitorInfo *
|
MetaMonitorInfo *
|
||||||
|
@ -292,7 +292,6 @@ struct _MetaMonitorManagerClass
|
|||||||
|
|
||||||
GType meta_monitor_manager_get_type (void);
|
GType meta_monitor_manager_get_type (void);
|
||||||
|
|
||||||
void meta_monitor_manager_initialize (void);
|
|
||||||
MetaMonitorManager *meta_monitor_manager_get (void);
|
MetaMonitorManager *meta_monitor_manager_get (void);
|
||||||
|
|
||||||
void meta_monitor_manager_rebuild_derived (MetaMonitorManager *manager);
|
void meta_monitor_manager_rebuild_derived (MetaMonitorManager *manager);
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "meta-backend-native.h"
|
#include "meta-backend-native.h"
|
||||||
|
|
||||||
#include "meta-idle-monitor-native.h"
|
#include "meta-idle-monitor-native.h"
|
||||||
|
#include "meta-monitor-manager-kms.h"
|
||||||
#include "meta-weston-launch.h"
|
#include "meta-weston-launch.h"
|
||||||
|
|
||||||
struct _MetaBackendNativePrivate
|
struct _MetaBackendNativePrivate
|
||||||
@ -47,12 +48,19 @@ meta_backend_native_create_idle_monitor (MetaBackend *backend,
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static MetaMonitorManager *
|
||||||
|
meta_backend_native_create_monitor_manager (MetaBackend *backend)
|
||||||
|
{
|
||||||
|
return g_object_new (META_TYPE_MONITOR_MANAGER_KMS, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_backend_native_class_init (MetaBackendNativeClass *klass)
|
meta_backend_native_class_init (MetaBackendNativeClass *klass)
|
||||||
{
|
{
|
||||||
MetaBackendClass *backend_class = META_BACKEND_CLASS (klass);
|
MetaBackendClass *backend_class = META_BACKEND_CLASS (klass);
|
||||||
|
|
||||||
backend_class->create_idle_monitor = meta_backend_native_create_idle_monitor;
|
backend_class->create_idle_monitor = meta_backend_native_create_idle_monitor;
|
||||||
|
backend_class->create_monitor_manager = meta_backend_native_create_monitor_manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
#include <meta/util.h>
|
#include <meta/util.h>
|
||||||
#include "meta-idle-monitor-xsync.h"
|
#include "meta-idle-monitor-xsync.h"
|
||||||
|
#include "meta-monitor-manager-xrandr.h"
|
||||||
|
#include "backends/meta-monitor-manager-dummy.h"
|
||||||
|
|
||||||
G_DEFINE_TYPE (MetaBackendX11, meta_backend_x11, META_TYPE_BACKEND);
|
G_DEFINE_TYPE (MetaBackendX11, meta_backend_x11, META_TYPE_BACKEND);
|
||||||
|
|
||||||
@ -43,12 +45,25 @@ meta_backend_x11_create_idle_monitor (MetaBackend *backend,
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static MetaMonitorManager *
|
||||||
|
meta_backend_x11_create_monitor_manager (MetaBackend *backend)
|
||||||
|
{
|
||||||
|
/* If we're a Wayland compositor using the X11 backend,
|
||||||
|
* we're a nested configuration, so return the dummy
|
||||||
|
* monitor setup. */
|
||||||
|
if (meta_is_wayland_compositor ())
|
||||||
|
return g_object_new (META_TYPE_MONITOR_MANAGER_DUMMY, NULL);
|
||||||
|
|
||||||
|
return g_object_new (META_TYPE_MONITOR_MANAGER_XRANDR, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_backend_x11_class_init (MetaBackendX11Class *klass)
|
meta_backend_x11_class_init (MetaBackendX11Class *klass)
|
||||||
{
|
{
|
||||||
MetaBackendClass *backend_class = META_BACKEND_CLASS (klass);
|
MetaBackendClass *backend_class = META_BACKEND_CLASS (klass);
|
||||||
|
|
||||||
backend_class->create_idle_monitor = meta_backend_x11_create_idle_monitor;
|
backend_class->create_idle_monitor = meta_backend_x11_create_idle_monitor;
|
||||||
|
backend_class->create_monitor_manager = meta_backend_x11_create_monitor_manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -679,9 +679,6 @@ meta_screen_new (MetaDisplay *display,
|
|||||||
screen->xroot = xroot;
|
screen->xroot = xroot;
|
||||||
screen->rect.x = screen->rect.y = 0;
|
screen->rect.x = screen->rect.y = 0;
|
||||||
|
|
||||||
if (!meta_is_wayland_compositor ())
|
|
||||||
meta_monitor_manager_initialize ();
|
|
||||||
|
|
||||||
manager = meta_monitor_manager_get ();
|
manager = meta_monitor_manager_get ();
|
||||||
g_signal_connect (manager, "monitors-changed",
|
g_signal_connect (manager, "monitors-changed",
|
||||||
G_CALLBACK (on_monitors_changed), screen);
|
G_CALLBACK (on_monitors_changed), screen);
|
||||||
|
@ -630,7 +630,6 @@ meta_wayland_init (void)
|
|||||||
|
|
||||||
meta_clutter_init ();
|
meta_clutter_init ();
|
||||||
|
|
||||||
meta_monitor_manager_initialize ();
|
|
||||||
monitors = meta_monitor_manager_get ();
|
monitors = meta_monitor_manager_get ();
|
||||||
g_signal_connect (monitors, "monitors-changed",
|
g_signal_connect (monitors, "monitors-changed",
|
||||||
G_CALLBACK (on_monitors_changed), compositor);
|
G_CALLBACK (on_monitors_changed), compositor);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user