Skip to content

Commit

Permalink
wayland/color-management: Expose the protocol by default
Browse files Browse the repository at this point in the history
  • Loading branch information
swick authored and Marge Bot committed Feb 25, 2025
1 parent 4fe1e41 commit 8fb2a8a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 56 deletions.
1 change: 0 additions & 1 deletion data/dbus-interfaces/org.gnome.Mutter.DebugControl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

<interface name="org.gnome.Mutter.DebugControl">

<property name="ColorManagementProtocol" type="b" access="readwrite" />
<property name="ForceHDR" type="b" access="readwrite" />
<property name="ForceLinearBlending" type="b" access="readwrite" />
<property name="LuminancePercentage" type="u" access="readwrite" />
Expand Down
2 changes: 0 additions & 2 deletions src/core/meta-debug-control-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

#include "meta/meta-debug-control.h"

gboolean meta_debug_control_is_color_management_protocol_enabled (MetaDebugControl *debug_control);

gboolean meta_debug_control_is_linear_blending_forced (MetaDebugControl *debug_control);

gboolean meta_debug_control_is_hdr_forced (MetaDebugControl *debug_control);
Expand Down
17 changes: 1 addition & 16 deletions src/core/meta-debug-control.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,12 @@ meta_debug_control_init (MetaDebugControl *debug_control)
{
MetaDBusDebugControl *dbus_debug_control =
META_DBUS_DEBUG_CONTROL (debug_control);
gboolean force_hdr, force_linear_blending,
color_management_protocol;
gboolean force_hdr, force_linear_blending;
gboolean session_management_protocol;
gboolean cursor_shape_protocol;
gboolean inhibit_hw_cursor;
gboolean a11y_manager_without_access_control;

color_management_protocol =
g_strcmp0 (getenv ("MUTTER_DEBUG_COLOR_MANAGEMENT_PROTOCOL"), "1") == 0;
meta_dbus_debug_control_set_color_management_protocol (dbus_debug_control,
color_management_protocol);

force_hdr = g_strcmp0 (getenv ("MUTTER_DEBUG_FORCE_HDR"), "1") == 0;
meta_dbus_debug_control_set_force_hdr (dbus_debug_control, force_hdr);

Expand Down Expand Up @@ -211,15 +205,6 @@ meta_debug_control_init (MetaDebugControl *debug_control)
a11y_manager_without_access_control);
}

gboolean
meta_debug_control_is_color_management_protocol_enabled (MetaDebugControl *debug_control)
{
MetaDBusDebugControl *dbus_debug_control =
META_DBUS_DEBUG_CONTROL (debug_control);

return meta_dbus_debug_control_get_color_management_protocol (dbus_debug_control);
}

gboolean
meta_debug_control_is_linear_blending_forced (MetaDebugControl *debug_control)
{
Expand Down
43 changes: 6 additions & 37 deletions src/wayland/meta-wayland-color-management.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "backends/meta-color-device.h"
#include "backends/meta-color-manager.h"
#include "compositor/meta-surface-actor-wayland.h"
#include "core/meta-debug-control-private.h"
#include "wayland/meta-wayland-private.h"
#include "wayland/meta-wayland-versions.h"
#include "wayland/meta-wayland-outputs.h"
Expand All @@ -39,7 +38,6 @@ struct _MetaWaylandColorManager
GObject parent;

MetaWaylandCompositor *compositor;
struct wl_global *global;

gulong color_state_changed_handler_id;

Expand Down Expand Up @@ -1593,48 +1591,19 @@ meta_wayland_color_manager_new (MetaWaylandCompositor *compositor)
return color_manager;
}

static void
update_enabled (MetaWaylandColorManager *color_manager)
{
MetaWaylandCompositor *compositor = color_manager->compositor;
MetaDebugControl *debug_control =
meta_context_get_debug_control (compositor->context);
gboolean is_enabled =
meta_debug_control_is_color_management_protocol_enabled (debug_control);

if (is_enabled && color_manager->global == NULL)
{
color_manager->global =
wl_global_create (compositor->wayland_display,
&wp_color_manager_v1_interface,
META_WP_COLOR_MANAGEMENT_VERSION,
color_manager,
color_management_bind);

if (color_manager->global == NULL)
g_error ("Failed to register a global wp_color_management object");
}
else if (!is_enabled)
{
g_clear_pointer (&color_manager->global, wl_global_destroy);
}
}

void
meta_wayland_init_color_management (MetaWaylandCompositor *compositor)
{
MetaDebugControl *debug_control =
meta_context_get_debug_control (compositor->context);
g_autoptr (MetaWaylandColorManager) color_manager = NULL;

color_manager = meta_wayland_color_manager_new (compositor);

g_signal_connect_data (debug_control, "notify::color-management-protocol",
G_CALLBACK (update_enabled),
color_manager, NULL,
G_CONNECT_SWAPPED | G_CONNECT_AFTER);

update_enabled (color_manager);
if (wl_global_create (compositor->wayland_display,
&wp_color_manager_v1_interface,
META_WP_COLOR_MANAGEMENT_VERSION,
color_manager,
color_management_bind) == NULL)
g_error ("Failed to register a global wp_color_management object");

g_object_set_data_full (G_OBJECT (compositor), "-meta-wayland-color-manager",
g_steal_pointer (&color_manager),
Expand Down

0 comments on commit 8fb2a8a

Please sign in to comment.