color-device: Create devices without a ready color manager
Every monitor should eventually have a corresponding color device. To make sure this can work, we must handle situations where the color manager didn't connect to colord yet, and thus isn't ready. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3904>
This commit is contained in:
parent
25e5c59202
commit
a50e0a76b6
@ -55,6 +55,7 @@ struct _MetaColorDevice
|
|||||||
GObject parent;
|
GObject parent;
|
||||||
|
|
||||||
MetaColorManager *color_manager;
|
MetaColorManager *color_manager;
|
||||||
|
gulong manager_ready_handler_id;
|
||||||
|
|
||||||
char *cd_device_id;
|
char *cd_device_id;
|
||||||
MetaMonitor *monitor;
|
MetaMonitor *monitor;
|
||||||
@ -273,13 +274,16 @@ meta_color_device_dispose (GObject *object)
|
|||||||
g_clear_object (&color_device->cancellable);
|
g_clear_object (&color_device->cancellable);
|
||||||
g_clear_signal_handler (&color_device->device_profile_ready_handler_id,
|
g_clear_signal_handler (&color_device->device_profile_ready_handler_id,
|
||||||
color_device->device_profile);
|
color_device->device_profile);
|
||||||
|
g_clear_signal_handler (&color_device->manager_ready_handler_id,
|
||||||
|
color_manager);
|
||||||
|
|
||||||
|
|
||||||
g_clear_object (&color_device->assigned_profile);
|
g_clear_object (&color_device->assigned_profile);
|
||||||
g_clear_object (&color_device->device_profile);
|
g_clear_object (&color_device->device_profile);
|
||||||
|
|
||||||
cd_device = color_device->cd_device;
|
cd_device = color_device->cd_device;
|
||||||
cd_device_id = color_device->cd_device_id;
|
cd_device_id = color_device->cd_device_id;
|
||||||
if (!cd_device && cd_device_id)
|
if (!cd_device && cd_device_id && meta_color_manager_is_ready (color_manager))
|
||||||
{
|
{
|
||||||
g_autoptr (GError) error = NULL;
|
g_autoptr (GError) error = NULL;
|
||||||
|
|
||||||
@ -565,19 +569,14 @@ generate_color_device_props (MetaMonitor *monitor)
|
|||||||
return device_props;
|
return device_props;
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaColorDevice *
|
static void
|
||||||
meta_color_device_new (MetaColorManager *color_manager,
|
create_cd_device (MetaColorDevice *color_device)
|
||||||
MetaMonitor *monitor)
|
|
||||||
{
|
{
|
||||||
MetaColorDevice *color_device;
|
MetaColorManager *color_manager = color_device->color_manager;
|
||||||
|
MetaMonitor *monitor = color_device->monitor;
|
||||||
g_autoptr (GHashTable) device_props = NULL;
|
g_autoptr (GHashTable) device_props = NULL;
|
||||||
|
|
||||||
device_props = generate_color_device_props (monitor);
|
device_props = generate_color_device_props (monitor);
|
||||||
color_device = g_object_new (META_TYPE_COLOR_DEVICE, NULL);
|
|
||||||
color_device->cd_device_id = generate_cd_device_id (monitor);
|
|
||||||
color_device->monitor = g_object_ref (monitor);
|
|
||||||
color_device->cancellable = g_cancellable_new ();
|
|
||||||
color_device->color_manager = color_manager;
|
|
||||||
|
|
||||||
cd_client_create_device (meta_color_manager_get_cd_client (color_manager),
|
cd_client_create_device (meta_color_manager_get_cd_client (color_manager),
|
||||||
color_device->cd_device_id,
|
color_device->cd_device_id,
|
||||||
@ -586,6 +585,38 @@ meta_color_device_new (MetaColorManager *color_manager,
|
|||||||
color_device->cancellable,
|
color_device->cancellable,
|
||||||
on_cd_device_created,
|
on_cd_device_created,
|
||||||
color_device);
|
color_device);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_manager_ready (MetaColorManager *color_manager,
|
||||||
|
MetaColorDevice *color_device)
|
||||||
|
{
|
||||||
|
create_cd_device (color_device);
|
||||||
|
}
|
||||||
|
|
||||||
|
MetaColorDevice *
|
||||||
|
meta_color_device_new (MetaColorManager *color_manager,
|
||||||
|
MetaMonitor *monitor)
|
||||||
|
{
|
||||||
|
MetaColorDevice *color_device;
|
||||||
|
|
||||||
|
color_device = g_object_new (META_TYPE_COLOR_DEVICE, NULL);
|
||||||
|
color_device->cd_device_id = generate_cd_device_id (monitor);
|
||||||
|
color_device->monitor = g_object_ref (monitor);
|
||||||
|
color_device->cancellable = g_cancellable_new ();
|
||||||
|
color_device->color_manager = color_manager;
|
||||||
|
|
||||||
|
if (meta_color_manager_is_ready (color_manager))
|
||||||
|
{
|
||||||
|
create_cd_device (color_device);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
color_device->manager_ready_handler_id =
|
||||||
|
g_signal_connect (color_manager, "ready",
|
||||||
|
G_CALLBACK (on_manager_ready),
|
||||||
|
color_device);
|
||||||
|
}
|
||||||
|
|
||||||
return color_device;
|
return color_device;
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,7 @@
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
DEVICE_UPDATED,
|
DEVICE_UPDATED,
|
||||||
|
READY,
|
||||||
|
|
||||||
N_SIGNALS
|
N_SIGNALS
|
||||||
};
|
};
|
||||||
@ -288,6 +289,7 @@ cd_client_connect_cb (GObject *source_object,
|
|||||||
color_manager);
|
color_manager);
|
||||||
|
|
||||||
priv->is_ready = TRUE;
|
priv->is_ready = TRUE;
|
||||||
|
g_signal_emit (color_manager, signals[READY], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -506,6 +508,13 @@ meta_color_manager_class_init (MetaColorManagerClass *klass)
|
|||||||
NULL, NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
G_TYPE_NONE, 1,
|
G_TYPE_NONE, 1,
|
||||||
META_TYPE_COLOR_DEVICE);
|
META_TYPE_COLOR_DEVICE);
|
||||||
|
|
||||||
|
signals[READY] =
|
||||||
|
g_signal_new ("ready",
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_LAST, 0,
|
||||||
|
NULL, NULL, NULL,
|
||||||
|
G_TYPE_NONE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user