mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 15:40:41 -05:00
monitor-manager: Keep pointer to backend
Instead of accessing the global singleton, keep a pointer to the backend in the MetaMonitorManager struct. https://bugzilla.gnome.org/show_bug.cgi?id=785381
This commit is contained in:
parent
7603bb5fd5
commit
315a6f43d7
@ -148,6 +148,8 @@ struct _MetaMonitorManager
|
||||
{
|
||||
MetaDBusDisplayConfigSkeleton parent_instance;
|
||||
|
||||
MetaBackend *backend;
|
||||
|
||||
/* XXX: this structure is very badly
|
||||
packed, but I like the logical organization
|
||||
of fields */
|
||||
@ -259,6 +261,8 @@ struct _MetaMonitorManagerClass
|
||||
MetaLogicalMonitorLayoutMode (*get_default_layout_mode) (MetaMonitorManager *);
|
||||
};
|
||||
|
||||
MetaBackend * meta_monitor_manager_get_backend (MetaMonitorManager *manager);
|
||||
|
||||
void meta_monitor_manager_setup (MetaMonitorManager *manager);
|
||||
|
||||
void meta_monitor_manager_rebuild (MetaMonitorManager *manager,
|
||||
|
@ -47,6 +47,17 @@
|
||||
|
||||
#define DEFAULT_DISPLAY_CONFIGURATION_TIMEOUT 20
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
||||
PROP_BACKEND,
|
||||
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
static GParamSpec *obj_props[PROP_LAST];
|
||||
|
||||
enum {
|
||||
CONFIRM_DISPLAY_CHANGE,
|
||||
SIGNALS_LAST
|
||||
@ -77,6 +88,12 @@ static gboolean
|
||||
meta_monitor_manager_is_config_complete (MetaMonitorManager *manager,
|
||||
MetaMonitorsConfig *config);
|
||||
|
||||
MetaBackend *
|
||||
meta_monitor_manager_get_backend (MetaMonitorManager *manager)
|
||||
{
|
||||
return manager->backend;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_monitor_manager_init (MetaMonitorManager *manager)
|
||||
{
|
||||
@ -696,7 +713,7 @@ meta_monitor_manager_constructed (GObject *object)
|
||||
MetaMonitorManager *manager = META_MONITOR_MANAGER (object);
|
||||
MetaMonitorManagerClass *manager_class =
|
||||
META_MONITOR_MANAGER_GET_CLASS (manager);
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaBackend *backend = manager->backend;
|
||||
MetaSettings *settings = meta_backend_get_settings (backend);
|
||||
|
||||
manager->experimental_features_changed_handler_id =
|
||||
@ -735,7 +752,7 @@ meta_monitor_manager_finalize (GObject *object)
|
||||
g_list_free_full (manager->crtcs, g_object_unref);
|
||||
g_list_free_full (manager->logical_monitors, g_object_unref);
|
||||
|
||||
g_signal_handler_disconnect (meta_get_backend (),
|
||||
g_signal_handler_disconnect (manager->backend,
|
||||
manager->experimental_features_changed_handler_id);
|
||||
|
||||
G_OBJECT_CLASS (meta_monitor_manager_parent_class)->finalize (object);
|
||||
@ -772,6 +789,42 @@ meta_monitor_manager_real_get_edid_file (MetaMonitorManager *manager,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_monitor_manager_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MetaMonitorManager *manager = META_MONITOR_MANAGER (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_BACKEND:
|
||||
manager->backend = g_value_get_object (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_monitor_manager_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MetaMonitorManager *manager = META_MONITOR_MANAGER (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_BACKEND:
|
||||
g_value_set_object (value, manager->backend);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_monitor_manager_class_init (MetaMonitorManagerClass *klass)
|
||||
{
|
||||
@ -780,6 +833,8 @@ meta_monitor_manager_class_init (MetaMonitorManagerClass *klass)
|
||||
object_class->constructed = meta_monitor_manager_constructed;
|
||||
object_class->dispose = meta_monitor_manager_dispose;
|
||||
object_class->finalize = meta_monitor_manager_finalize;
|
||||
object_class->get_property = meta_monitor_manager_get_property;
|
||||
object_class->set_property = meta_monitor_manager_set_property;
|
||||
|
||||
klass->get_edid_file = meta_monitor_manager_real_get_edid_file;
|
||||
klass->read_edid = meta_monitor_manager_real_read_edid;
|
||||
@ -792,6 +847,16 @@ meta_monitor_manager_class_init (MetaMonitorManagerClass *klass)
|
||||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
obj_props[PROP_BACKEND] =
|
||||
g_param_spec_object ("backend",
|
||||
"backend",
|
||||
"MetaBackend",
|
||||
META_TYPE_BACKEND,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
g_object_class_install_properties (object_class, PROP_LAST, obj_props);
|
||||
}
|
||||
|
||||
static const double known_diagonals[] = {
|
||||
@ -2502,11 +2567,10 @@ meta_monitor_manager_read_current_state (MetaMonitorManager *manager)
|
||||
static void
|
||||
meta_monitor_manager_notify_monitors_changed (MetaMonitorManager *manager)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
|
||||
manager->current_switch_config = META_MONITOR_SWITCH_CONFIG_UNKNOWN;
|
||||
|
||||
meta_backend_monitors_changed (backend);
|
||||
meta_backend_monitors_changed (manager->backend);
|
||||
|
||||
g_signal_emit_by_name (manager, "monitors-changed");
|
||||
}
|
||||
|
||||
|
@ -403,7 +403,9 @@ static MetaMonitorManager *
|
||||
meta_backend_native_create_monitor_manager (MetaBackend *backend,
|
||||
GError **error)
|
||||
{
|
||||
return g_initable_new (META_TYPE_MONITOR_MANAGER_KMS, NULL, error, NULL);
|
||||
return g_initable_new (META_TYPE_MONITOR_MANAGER_KMS, NULL, error,
|
||||
"backend", backend,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static MetaCursorRenderer *
|
||||
|
@ -1034,7 +1034,7 @@ meta_monitor_manager_kms_calculate_supported_scales (MetaMonitorManager
|
||||
static MetaMonitorManagerCapability
|
||||
meta_monitor_manager_kms_get_capabilities (MetaMonitorManager *manager)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
||||
MetaSettings *settings = meta_backend_get_settings (backend);
|
||||
MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
||||
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
|
||||
@ -1079,7 +1079,7 @@ meta_monitor_manager_kms_get_max_screen_size (MetaMonitorManager *manager,
|
||||
static MetaLogicalMonitorLayoutMode
|
||||
meta_monitor_manager_kms_get_default_layout_mode (MetaMonitorManager *manager)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
||||
MetaSettings *settings = meta_backend_get_settings (backend);
|
||||
|
||||
if (!meta_is_stage_views_enabled ())
|
||||
@ -1147,7 +1147,8 @@ count_devices_with_connectors (const char *seat_id,
|
||||
static char *
|
||||
get_primary_gpu_path (MetaMonitorManagerKms *manager_kms)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
|
||||
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
||||
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
|
||||
MetaLauncher *launcher = meta_backend_native_get_launcher (backend_native);
|
||||
g_autoptr (GUdevEnumerator) enumerator = NULL;
|
||||
@ -1260,7 +1261,8 @@ open_primary_gpu (MetaMonitorManagerKms *manager_kms,
|
||||
char **kms_file_path_out,
|
||||
GError **error)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
|
||||
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
||||
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
|
||||
MetaLauncher *launcher = meta_backend_native_get_launcher (backend_native);
|
||||
g_autofree char *path = NULL;
|
||||
@ -1336,7 +1338,8 @@ static void
|
||||
meta_monitor_manager_kms_finalize (GObject *object)
|
||||
{
|
||||
MetaMonitorManagerKms *manager_kms = META_MONITOR_MANAGER_KMS (object);
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
|
||||
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
||||
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
|
||||
MetaLauncher *launcher = meta_backend_native_get_launcher (backend_native);
|
||||
|
||||
|
@ -102,7 +102,9 @@ static MetaMonitorManager *
|
||||
meta_backend_x11_cm_create_monitor_manager (MetaBackend *backend,
|
||||
GError **error)
|
||||
{
|
||||
return g_object_new (META_TYPE_MONITOR_MANAGER_XRANDR, NULL);
|
||||
return g_object_new (META_TYPE_MONITOR_MANAGER_XRANDR,
|
||||
"backend", backend,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static MetaCursorRenderer *
|
||||
|
@ -1051,9 +1051,13 @@ meta_monitor_manager_xrandr_get_default_layout_mode (MetaMonitorManager *manager
|
||||
}
|
||||
|
||||
static void
|
||||
meta_monitor_manager_xrandr_init (MetaMonitorManagerXrandr *manager_xrandr)
|
||||
meta_monitor_manager_xrandr_constructed (GObject *object)
|
||||
{
|
||||
MetaBackendX11 *backend = META_BACKEND_X11 (meta_get_backend ());
|
||||
MetaMonitorManagerXrandr *manager_xrandr =
|
||||
META_MONITOR_MANAGER_XRANDR (object);
|
||||
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_xrandr);
|
||||
MetaBackendX11 *backend =
|
||||
META_BACKEND_X11 (meta_monitor_manager_get_backend (manager));
|
||||
|
||||
manager_xrandr->xdisplay = meta_backend_x11_get_xdisplay (backend);
|
||||
|
||||
@ -1104,6 +1108,11 @@ meta_monitor_manager_xrandr_finalize (GObject *object)
|
||||
G_OBJECT_CLASS (meta_monitor_manager_xrandr_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_monitor_manager_xrandr_init (MetaMonitorManagerXrandr *manager_xrandr)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
meta_monitor_manager_xrandr_class_init (MetaMonitorManagerXrandrClass *klass)
|
||||
{
|
||||
@ -1111,6 +1120,7 @@ meta_monitor_manager_xrandr_class_init (MetaMonitorManagerXrandrClass *klass)
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = meta_monitor_manager_xrandr_finalize;
|
||||
object_class->constructed = meta_monitor_manager_xrandr_constructed;
|
||||
|
||||
manager_class->read_current = meta_monitor_manager_xrandr_read_current;
|
||||
manager_class->read_edid = meta_monitor_manager_xrandr_read_edid;
|
||||
|
@ -42,7 +42,9 @@ static MetaMonitorManager *
|
||||
meta_backend_x11_nested_create_monitor_manager (MetaBackend *backend,
|
||||
GError **error)
|
||||
{
|
||||
return g_object_new (META_TYPE_MONITOR_MANAGER_DUMMY, NULL);
|
||||
return g_object_new (META_TYPE_MONITOR_MANAGER_DUMMY,
|
||||
"backend", backend,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static MetaCursorRenderer *
|
||||
|
@ -44,6 +44,7 @@
|
||||
#define KEY_GRAVE 0x29 /* assume the use of xf86-input-keyboard */
|
||||
#endif
|
||||
|
||||
#include "backends/meta-backend-private.h"
|
||||
#include "backends/meta-monitor-manager-private.h"
|
||||
#include "backends/meta-logical-monitor.h"
|
||||
#include "backends/x11/meta-backend-x11.h"
|
||||
|
@ -39,7 +39,9 @@ static MetaMonitorManager *
|
||||
meta_backend_test_create_monitor_manager (MetaBackend *backend,
|
||||
GError **error)
|
||||
{
|
||||
return g_object_new (META_TYPE_MONITOR_MANAGER_TEST, NULL);
|
||||
return g_object_new (META_TYPE_MONITOR_MANAGER_TEST,
|
||||
"backend", backend,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user