color-manager: Add ready state

Ready means it has established the connection to colord and can operate.
Will be used by tests to make sure tests don't fail due to race
conditions when connecting to colord.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
This commit is contained in:
Jonas Ådahl 2021-11-30 08:22:33 +01:00
parent 41ebf3b1bf
commit 8826b29329
2 changed files with 16 additions and 0 deletions

View File

@ -29,4 +29,7 @@ struct _MetaColorManagerClass
CdClient * meta_color_manager_get_cd_client (MetaColorManager *color_manager);
META_EXPORT_TEST
gboolean meta_color_manager_is_ready (MetaColorManager *color_manager);
#endif /* META_COLOR_MANAGER_PRIVATE_H */

View File

@ -74,6 +74,8 @@ typedef struct _MetaColorManagerPrivate
GHashTable *devices;
MetaDbusSettingsDaemonColor *gsd_color;
gboolean is_ready;
} MetaColorManagerPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (MetaColorManager, meta_color_manager, G_TYPE_OBJECT)
@ -203,6 +205,8 @@ cd_client_connect_cb (GObject *source_object,
g_signal_connect (monitor_manager, "monitors-changed-internal",
G_CALLBACK (on_monitors_changed),
color_manager);
priv->is_ready = TRUE;
}
static void
@ -367,3 +371,12 @@ meta_color_manager_get_color_device (MetaColorManager *color_manager,
monitor_id = generate_monitor_id (monitor);
return g_hash_table_lookup (priv->devices, monitor_id);
}
gboolean
meta_color_manager_is_ready (MetaColorManager *color_manager)
{
MetaColorManagerPrivate *priv =
meta_color_manager_get_instance_private (color_manager);
return priv->is_ready;
}