color-manager: Add API to get the color device for a monitor

There is a 1-on-1 mapping between these two entities, so add a getter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
This commit is contained in:
Jonas Ådahl 2021-11-29 18:17:26 +01:00
parent b8ddf7ad8b
commit 6403cfe170
3 changed files with 18 additions and 0 deletions

View File

@ -23,6 +23,7 @@
typedef struct _MetaBackend MetaBackend; typedef struct _MetaBackend MetaBackend;
typedef struct _MetaColorDevice MetaColorDevice;
typedef struct _MetaColorManager MetaColorManager; typedef struct _MetaColorManager MetaColorManager;
typedef struct _MetaMonitorManager MetaMonitorManager; typedef struct _MetaMonitorManager MetaMonitorManager;

View File

@ -355,3 +355,15 @@ meta_color_manager_get_cd_client (MetaColorManager *color_manager)
return priv->cd_client; return priv->cd_client;
} }
MetaColorDevice *
meta_color_manager_get_color_device (MetaColorManager *color_manager,
MetaMonitor *monitor)
{
MetaColorManagerPrivate *priv =
meta_color_manager_get_instance_private (color_manager);
g_autofree char *monitor_id = NULL;
monitor_id = generate_monitor_id (monitor);
return g_hash_table_lookup (priv->devices, monitor_id);
}

View File

@ -21,6 +21,7 @@
#include <glib-object.h> #include <glib-object.h>
#include "backends/meta-backend-types.h" #include "backends/meta-backend-types.h"
#include "core/util-private.h"
#define META_TYPE_COLOR_MANAGER (meta_color_manager_get_type ()) #define META_TYPE_COLOR_MANAGER (meta_color_manager_get_type ())
G_DECLARE_DERIVABLE_TYPE (MetaColorManager, meta_color_manager, G_DECLARE_DERIVABLE_TYPE (MetaColorManager, meta_color_manager,
@ -30,4 +31,8 @@ G_DECLARE_DERIVABLE_TYPE (MetaColorManager, meta_color_manager,
MetaBackend * MetaBackend *
meta_color_manager_get_backend (MetaColorManager *color_manager); meta_color_manager_get_backend (MetaColorManager *color_manager);
META_EXPORT_TEST
MetaColorDevice * meta_color_manager_get_color_device (MetaColorManager *color_manager,
MetaMonitor *monitor);
#endif /* META_COLOR_MANAGER_H */ #endif /* META_COLOR_MANAGER_H */