From 1e895f9469745db0d8cf146d86111c1974188982 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Nov 15 2022 06:27:52 +0000 Subject: import mutter-40.9-9.el9 --- diff --git a/SOURCES/0001-backends-Move-MetaKeyboardA11yFlags-to-a-public-head.patch b/SOURCES/0001-backends-Move-MetaKeyboardA11yFlags-to-a-public-head.patch new file mode 100644 index 0000000..7af82f1 --- /dev/null +++ b/SOURCES/0001-backends-Move-MetaKeyboardA11yFlags-to-a-public-head.patch @@ -0,0 +1,144 @@ +From 651f5e0c6a33d9ac32c2a16735a026153a2ddf38 Mon Sep 17 00:00:00 2001 +From: Olivier Fourdan +Date: Tue, 14 Jun 2022 16:31:43 +0200 +Subject: [PATCH] backends: Move MetaKeyboardA11yFlags to a public header + +The MetaKeyboardA11yFlags are used by gnome-shell to show a dialog +whenever a keyboard accessibility feature is switched using the +keyboard. + +Unfortunately, commit c3acaeb25 renamed the Clutter flag to Meta and +moved them to a private header. As a result, gnome-shell do not show any +dialog anymore when a keyboard accessibility feature is activated. + +Move the MetaKeyboardA11yFlags definition to a public header so that +gnome-shell can use it. + +Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2306 +Fixes: c3acaeb25 - backends: Move keyboard a11y into backends +Part-of: +--- + src/backends/meta-input-settings-private.h | 19 +------ + src/meta/meson.build | 1 + + src/meta/meta-enums.h | 62 ++++++++++++++++++++++ + 3 files changed, 64 insertions(+), 18 deletions(-) + create mode 100644 src/meta/meta-enums.h + +diff --git a/src/backends/meta-input-settings-private.h b/src/backends/meta-input-settings-private.h +index 42ee0e0e6..5ef54ee84 100644 +--- a/src/backends/meta-input-settings-private.h ++++ b/src/backends/meta-input-settings-private.h +@@ -31,29 +31,12 @@ + #include "backends/meta-backend-types.h" + #include "clutter/clutter.h" + #include "meta/display.h" ++#include "meta/meta-enums.h" + + #define META_TYPE_INPUT_SETTINGS (meta_input_settings_get_type ()) + G_DECLARE_DERIVABLE_TYPE (MetaInputSettings, meta_input_settings, + META, INPUT_SETTINGS, GObject) + +-typedef enum +-{ +- META_A11Y_KEYBOARD_ENABLED = 1 << 0, +- META_A11Y_TIMEOUT_ENABLED = 1 << 1, +- META_A11Y_MOUSE_KEYS_ENABLED = 1 << 2, +- META_A11Y_SLOW_KEYS_ENABLED = 1 << 3, +- META_A11Y_SLOW_KEYS_BEEP_PRESS = 1 << 4, +- META_A11Y_SLOW_KEYS_BEEP_ACCEPT = 1 << 5, +- META_A11Y_SLOW_KEYS_BEEP_REJECT = 1 << 6, +- META_A11Y_BOUNCE_KEYS_ENABLED = 1 << 7, +- META_A11Y_BOUNCE_KEYS_BEEP_REJECT = 1 << 8, +- META_A11Y_TOGGLE_KEYS_ENABLED = 1 << 9, +- META_A11Y_STICKY_KEYS_ENABLED = 1 << 10, +- META_A11Y_STICKY_KEYS_TWO_KEY_OFF = 1 << 11, +- META_A11Y_STICKY_KEYS_BEEP = 1 << 12, +- META_A11Y_FEATURE_STATE_CHANGE_BEEP = 1 << 13, +-} MetaKeyboardA11yFlags; +- + /** + * MetaKbdA11ySettings: + * +diff --git a/src/meta/meson.build b/src/meta/meson.build +index a096ee4dd..4a67abb25 100644 +--- a/src/meta/meson.build ++++ b/src/meta/meson.build +@@ -17,6 +17,7 @@ mutter_public_headers = [ + 'meta-close-dialog.h', + 'meta-cursor-tracker.h', + 'meta-dnd.h', ++ 'meta-enums.h', + 'meta-idle-monitor.h', + 'meta-inhibit-shortcuts-dialog.h', + 'meta-launch-context.h', +diff --git a/src/meta/meta-enums.h b/src/meta/meta-enums.h +new file mode 100644 +index 000000000..e59ebaf72 +--- /dev/null ++++ b/src/meta/meta-enums.h +@@ -0,0 +1,62 @@ ++/* ++ * Copyright (C) 2016-2021 Red Hat Inc. ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License as ++ * published by the Free Software Foundation; either version 2 of the ++ * License, or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, but ++ * WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ++ * 02111-1307, USA. ++ * ++ */ ++ ++#ifndef META_ENUMS_H ++#define META_ENUMS_H ++ ++/** ++ * MetaKeyboardA11yFlags: ++ * @META_A11Y_KEYBOARD_ENABLED: ++ * @META_A11Y_TIMEOUT_ENABLED: ++ * @META_A11Y_MOUSE_KEYS_ENABLED: ++ * @META_A11Y_SLOW_KEYS_ENABLED: ++ * @META_A11Y_SLOW_KEYS_BEEP_PRESS: ++ * @META_A11Y_SLOW_KEYS_BEEP_ACCEPT: ++ * @META_A11Y_SLOW_KEYS_BEEP_REJECT: ++ * @META_A11Y_BOUNCE_KEYS_ENABLED: ++ * @META_A11Y_BOUNCE_KEYS_BEEP_REJECT: ++ * @META_A11Y_TOGGLE_KEYS_ENABLED: ++ * @META_A11Y_STICKY_KEYS_ENABLED: ++ * @META_A11Y_STICKY_KEYS_TWO_KEY_OFF: ++ * @META_A11Y_STICKY_KEYS_BEEP: ++ * @META_A11Y_FEATURE_STATE_CHANGE_BEEP: ++ * ++ * Keyboard accessibility features. ++ * ++ */ ++typedef enum ++{ ++ META_A11Y_KEYBOARD_ENABLED = 1 << 0, ++ META_A11Y_TIMEOUT_ENABLED = 1 << 1, ++ META_A11Y_MOUSE_KEYS_ENABLED = 1 << 2, ++ META_A11Y_SLOW_KEYS_ENABLED = 1 << 3, ++ META_A11Y_SLOW_KEYS_BEEP_PRESS = 1 << 4, ++ META_A11Y_SLOW_KEYS_BEEP_ACCEPT = 1 << 5, ++ META_A11Y_SLOW_KEYS_BEEP_REJECT = 1 << 6, ++ META_A11Y_BOUNCE_KEYS_ENABLED = 1 << 7, ++ META_A11Y_BOUNCE_KEYS_BEEP_REJECT = 1 << 8, ++ META_A11Y_TOGGLE_KEYS_ENABLED = 1 << 9, ++ META_A11Y_STICKY_KEYS_ENABLED = 1 << 10, ++ META_A11Y_STICKY_KEYS_TWO_KEY_OFF = 1 << 11, ++ META_A11Y_STICKY_KEYS_BEEP = 1 << 12, ++ META_A11Y_FEATURE_STATE_CHANGE_BEEP = 1 << 13, ++} MetaKeyboardA11yFlags; ++ ++#endif /* META_ENUMS_H */ +-- +2.36.1 + diff --git a/SOURCES/0001-clutter-Make-ClutterClickAction-independent-of-click.patch b/SOURCES/0001-clutter-Make-ClutterClickAction-independent-of-click.patch new file mode 100644 index 0000000..35af59d --- /dev/null +++ b/SOURCES/0001-clutter-Make-ClutterClickAction-independent-of-click.patch @@ -0,0 +1,38 @@ +From 28030178d7682ce5be03cb7273365ab628065871 Mon Sep 17 00:00:00 2001 +From: Carlos Garnacho +Date: Mon, 27 Sep 2021 20:37:30 +0200 +Subject: [PATCH] clutter: Make ClutterClickAction independent of click count + +This will trigger for every button press/release that is obtained, +regardless of the click count. + +Part-of: +--- + clutter/clutter/clutter-click-action.c | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/clutter/clutter/clutter-click-action.c b/clutter/clutter/clutter-click-action.c +index 45d87e809..266b6da92 100644 +--- a/clutter/clutter/clutter-click-action.c ++++ b/clutter/clutter/clutter-click-action.c +@@ -306,9 +306,6 @@ on_event (ClutterActor *actor, + case CLUTTER_TOUCH_BEGIN: + has_button = FALSE; + case CLUTTER_BUTTON_PRESS: +- if (has_button && clutter_event_get_click_count (event) != 1) +- return CLUTTER_EVENT_PROPAGATE; +- + if (priv->is_held) + return CLUTTER_EVENT_STOP; + +@@ -386,7 +383,6 @@ on_captured_event (ClutterActor *stage, + return CLUTTER_EVENT_STOP; + + if ((has_button && clutter_event_get_button (event) != priv->press_button) || +- (has_button && clutter_event_get_click_count (event) != 1) || + clutter_event_get_device (event) != priv->press_device || + clutter_event_get_event_sequence (event) != priv->press_sequence) + return CLUTTER_EVENT_PROPAGATE; +-- +2.35.1 + diff --git a/SOURCES/0001-events-Pass-CurrentTime-to-XIAllowEvents-when-unfree.patch b/SOURCES/0001-events-Pass-CurrentTime-to-XIAllowEvents-when-unfree.patch new file mode 100644 index 0000000..24a5bcd --- /dev/null +++ b/SOURCES/0001-events-Pass-CurrentTime-to-XIAllowEvents-when-unfree.patch @@ -0,0 +1,26 @@ +From 65ffd7e4df42cd62633f93107644f87208881578 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jonas=20=C3=85dahl?= +Date: Thu, 14 Apr 2022 18:07:41 +0200 +Subject: [PATCH] events: Pass CurrentTime to XIAllowEvents() when unfreezing + pointer + +--- + src/core/events.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/core/events.c b/src/core/events.c +index 0dc3a73222..dd9b4ec981 100644 +--- a/src/core/events.c ++++ b/src/core/events.c +@@ -205,7 +205,7 @@ maybe_unfreeze_pointer_events (MetaBackend *backend, + } + + xdisplay = meta_backend_x11_get_xdisplay (META_BACKEND_X11 (backend)); +- XIAllowEvents (xdisplay, device_id, event_mode, event->button.time); ++ XIAllowEvents (xdisplay, device_id, event_mode, CurrentTime); + } + + static gboolean +-- +2.34.1 + diff --git a/SOURCES/0001-kms-Allow-passing-framebuffer-damage-metadata.patch b/SOURCES/0001-kms-Allow-passing-framebuffer-damage-metadata.patch new file mode 100644 index 0000000..6143687 --- /dev/null +++ b/SOURCES/0001-kms-Allow-passing-framebuffer-damage-metadata.patch @@ -0,0 +1,193 @@ +From af0460d0cedd5a66b2110ab2a99e67c647e7b6fb Mon Sep 17 00:00:00 2001 +From: Piotr Lopatka +Date: Fri, 3 Sep 2021 19:39:12 +0100 +Subject: [PATCH 1/2] kms: Allow passing framebuffer damage metadata + +This commit adds support to atomic KMS backend for optional plane property +prop_fb_damage_clips. Some drivers (e.g. EVDI) take advantage of this +property and process only updated regions of the screen instead of +processing the full frame. This can save system resources. + +Part-of: +--- + .../native/meta-kms-impl-device-atomic.c | 28 +++++++++++++++ + src/backends/native/meta-kms-plane-private.h | 1 + + src/backends/native/meta-kms-plane.c | 5 +++ + src/backends/native/meta-kms-update-private.h | 7 ++++ + src/backends/native/meta-kms-update.c | 35 +++++++++++++++++++ + src/backends/native/meta-kms-update.h | 4 +++ + 6 files changed, 80 insertions(+) + +diff --git a/src/backends/native/meta-kms-impl-device-atomic.c b/src/backends/native/meta-kms-impl-device-atomic.c +index 8e41207ee14..674a24902bd 100644 +--- a/src/backends/native/meta-kms-impl-device-atomic.c ++++ b/src/backends/native/meta-kms-impl-device-atomic.c +@@ -416,6 +416,8 @@ process_plane_assignment (MetaKmsImplDevice *impl_device, + MetaKmsPlaneAssignment *plane_assignment = update_entry; + MetaKmsPlane *plane = plane_assignment->plane; + MetaDrmBuffer *buffer; ++ MetaKmsFbDamage *fb_damage; ++ uint32_t prop_id; + + buffer = plane_assignment->buffer; + +@@ -539,6 +541,32 @@ process_plane_assignment (MetaKmsImplDevice *impl_device, + return FALSE; + } + ++ fb_damage = plane_assignment->fb_damage; ++ if (fb_damage && ++ meta_kms_plane_get_prop_id (plane, ++ META_KMS_PLANE_PROP_FB_DAMAGE_CLIPS_ID)) ++ { ++ meta_topic (META_DEBUG_KMS, ++ "[atomic] Setting %d damage clips on %u", ++ fb_damage->n_rects, ++ meta_kms_plane_get_id (plane)); ++ ++ prop_id = store_new_blob (impl_device, ++ blob_ids, ++ fb_damage->rects, ++ fb_damage->n_rects * ++ sizeof (struct drm_mode_rect), ++ error); ++ if (!prop_id) ++ return FALSE; ++ ++ if (!add_plane_property (impl_device, ++ plane, req, ++ META_KMS_PLANE_PROP_FB_DAMAGE_CLIPS_ID, ++ prop_id, ++ error)) ++ return FALSE; ++ } + return TRUE; + } + +diff --git a/src/backends/native/meta-kms-plane-private.h b/src/backends/native/meta-kms-plane-private.h +index 92f9cfcc9aa..f735c8da8f6 100644 +--- a/src/backends/native/meta-kms-plane-private.h ++++ b/src/backends/native/meta-kms-plane-private.h +@@ -41,6 +41,7 @@ typedef enum _MetaKmsPlaneProp + META_KMS_PLANE_PROP_CRTC_H, + META_KMS_PLANE_PROP_FB_ID, + META_KMS_PLANE_PROP_CRTC_ID, ++ META_KMS_PLANE_PROP_FB_DAMAGE_CLIPS_ID, + META_KMS_PLANE_N_PROPS + } MetaKmsPlaneProp; + +diff --git a/src/backends/native/meta-kms-plane.c b/src/backends/native/meta-kms-plane.c +index 73fab7d8f80..3cb58764ff3 100644 +--- a/src/backends/native/meta-kms-plane.c ++++ b/src/backends/native/meta-kms-plane.c +@@ -446,6 +446,11 @@ init_properties (MetaKmsPlane *plane, + .name = "CRTC_ID", + .type = DRM_MODE_PROP_OBJECT, + }, ++ [META_KMS_PLANE_PROP_FB_DAMAGE_CLIPS_ID] = ++ { ++ .name = "FB_DAMAGE_CLIPS", ++ .type = DRM_MODE_PROP_BLOB, ++ }, + } + }; + +diff --git a/src/backends/native/meta-kms-update-private.h b/src/backends/native/meta-kms-update-private.h +index 22491ece2d5..c89622d09a5 100644 +--- a/src/backends/native/meta-kms-update-private.h ++++ b/src/backends/native/meta-kms-update-private.h +@@ -34,6 +34,12 @@ typedef struct _MetaKmsFeedback + GError *error; + } MetaKmsFeedback; + ++typedef struct _MetaKmsFbDamage ++{ ++ struct drm_mode_rect *rects; ++ int n_rects; ++} MetaKmsFbDamage; ++ + typedef struct _MetaKmsPlaneAssignment + { + MetaKmsUpdate *update; +@@ -43,6 +49,7 @@ typedef struct _MetaKmsPlaneAssignment + MetaFixed16Rectangle src_rect; + MetaRectangle dst_rect; + MetaKmsAssignPlaneFlag flags; ++ MetaKmsFbDamage *fb_damage; + + uint64_t rotation; + +diff --git a/src/backends/native/meta-kms-update.c b/src/backends/native/meta-kms-update.c +index be6eaefcc2c..71e5b423fb7 100644 +--- a/src/backends/native/meta-kms-update.c ++++ b/src/backends/native/meta-kms-update.c +@@ -129,9 +129,17 @@ meta_kms_feedback_get_error (const MetaKmsFeedback *feedback) + return feedback->error; + } + ++static void ++meta_kms_fb_damage_free (MetaKmsFbDamage *fb_damage) ++{ ++ g_free (fb_damage->rects); ++ g_free (fb_damage); ++} ++ + static void + meta_kms_plane_assignment_free (MetaKmsPlaneAssignment *plane_assignment) + { ++ g_clear_pointer (&plane_assignment->fb_damage, meta_kms_fb_damage_free); + g_free (plane_assignment); + } + +@@ -456,6 +464,33 @@ meta_kms_update_set_custom_page_flip (MetaKmsUpdate *update, + update->custom_page_flip = custom_page_flip; + } + ++void ++meta_kms_plane_assignment_set_fb_damage (MetaKmsPlaneAssignment *plane_assignment, ++ const int *rectangles, ++ int n_rectangles) ++{ ++ MetaKmsFbDamage *fb_damage; ++ struct drm_mode_rect *mode_rects; ++ int i; ++ ++ mode_rects = g_new0 (struct drm_mode_rect, n_rectangles); ++ for (i = 0; i < n_rectangles; ++i) ++ { ++ mode_rects[i].x1 = rectangles[i * 4]; ++ mode_rects[i].y1 = rectangles[i * 4 + 1]; ++ mode_rects[i].x2 = mode_rects[i].x1 + rectangles[i * 4 + 2]; ++ mode_rects[i].y2 = mode_rects[i].y1 + rectangles[i * 4 + 3]; ++ } ++ ++ fb_damage = g_new0 (MetaKmsFbDamage, 1); ++ *fb_damage = (MetaKmsFbDamage) { ++ .rects = mode_rects, ++ .n_rects = n_rectangles, ++ }; ++ ++ plane_assignment->fb_damage = fb_damage; ++} ++ + void + meta_kms_plane_assignment_set_rotation (MetaKmsPlaneAssignment *plane_assignment, + uint64_t rotation) +diff --git a/src/backends/native/meta-kms-update.h b/src/backends/native/meta-kms-update.h +index 4a6a8bb4373..e63b6d8711d 100644 +--- a/src/backends/native/meta-kms-update.h ++++ b/src/backends/native/meta-kms-update.h +@@ -115,6 +115,10 @@ void meta_kms_update_set_crtc_gamma (MetaKmsUpdate *update, + const uint16_t *green, + const uint16_t *blue); + ++void meta_kms_plane_assignment_set_fb_damage (MetaKmsPlaneAssignment *plane_assignment, ++ const int *rectangles, ++ int n_rectangles); ++ + MetaKmsPlaneAssignment * meta_kms_update_assign_plane (MetaKmsUpdate *update, + MetaKmsCrtc *crtc, + MetaKmsPlane *plane, +-- +2.36.1 + diff --git a/SOURCES/0001-kms-crtc-Add-function-meta_kms_crtc_has_gamma.patch b/SOURCES/0001-kms-crtc-Add-function-meta_kms_crtc_has_gamma.patch new file mode 100644 index 0000000..5774e45 --- /dev/null +++ b/SOURCES/0001-kms-crtc-Add-function-meta_kms_crtc_has_gamma.patch @@ -0,0 +1,46 @@ +From de3188fcc6863b8a6e3d2443a00cf3b00f6f26ff Mon Sep 17 00:00:00 2001 +From: Daniel van Vugt +Date: Tue, 12 Apr 2022 18:34:58 +0800 +Subject: [PATCH 1/2] kms/crtc: Add function meta_kms_crtc_has_gamma + +Part-of: +--- + src/backends/native/meta-kms-crtc.c | 7 +++++++ + src/backends/native/meta-kms-crtc.h | 3 +++ + 2 files changed, 10 insertions(+) + +diff --git a/src/backends/native/meta-kms-crtc.c b/src/backends/native/meta-kms-crtc.c +index 51d040b44..24f5a2d74 100644 +--- a/src/backends/native/meta-kms-crtc.c ++++ b/src/backends/native/meta-kms-crtc.c +@@ -92,6 +92,13 @@ meta_kms_crtc_is_active (MetaKmsCrtc *crtc) + return crtc->current_state.is_active; + } + ++ ++gboolean ++meta_kms_crtc_has_gamma (MetaKmsCrtc *crtc) ++{ ++ return !!meta_kms_crtc_get_prop_id (crtc, META_KMS_CRTC_PROP_GAMMA_LUT); ++} ++ + static void + read_gamma_state (MetaKmsCrtc *crtc, + MetaKmsImplDevice *impl_device, +diff --git a/src/backends/native/meta-kms-crtc.h b/src/backends/native/meta-kms-crtc.h +index 406ca3ac1..cbaeaa280 100644 +--- a/src/backends/native/meta-kms-crtc.h ++++ b/src/backends/native/meta-kms-crtc.h +@@ -66,6 +66,9 @@ uint32_t meta_kms_crtc_get_id (MetaKmsCrtc *crtc); + + int meta_kms_crtc_get_idx (MetaKmsCrtc *crtc); + ++ ++gboolean meta_kms_crtc_has_gamma (MetaKmsCrtc *crtc); ++ + gboolean meta_kms_crtc_is_active (MetaKmsCrtc *crtc); + + void meta_kms_crtc_gamma_free (MetaKmsCrtcGamma *gamma); +-- +2.35.1 + diff --git a/SOURCES/0001-monitor-manager-Add-NightLightSupported-property-to-.patch b/SOURCES/0001-monitor-manager-Add-NightLightSupported-property-to-.patch new file mode 100644 index 0000000..9c8ec52 --- /dev/null +++ b/SOURCES/0001-monitor-manager-Add-NightLightSupported-property-to-.patch @@ -0,0 +1,218 @@ +From f21c8614daeb70a021c128b97c000a92652cf6f8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jonas=20=C3=85dahl?= +Date: Thu, 24 Feb 2022 12:32:27 +0100 +Subject: [PATCH] monitor-manager: Add NightLightSupported property to + DisplayConfig + +This checks whether it's possible to set a CRTC GAMMA_LUT, which is what +is necessary to implement night light. +--- + src/backends/meta-monitor-manager.c | 76 ++++++++++++++++--- + .../native/meta-monitor-manager-native.c | 25 ++++-- + .../x11/meta-monitor-manager-xrandr.c | 9 ++- + src/org.gnome.Mutter.DisplayConfig.xml | 7 ++ + 4 files changed, 99 insertions(+), 18 deletions(-) + +diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c +index 75146950c3..0f30b3de25 100644 +--- a/src/backends/meta-monitor-manager.c ++++ b/src/backends/meta-monitor-manager.c +@@ -952,6 +952,59 @@ update_panel_orientation_managed (MetaMonitorManager *manager) + handle_orientation_change (orientation_manager, manager); + } + ++static void ++meta_monitor_manager_get_crtc_gamma (MetaMonitorManager *manager, ++ MetaCrtc *crtc, ++ size_t *size, ++ unsigned short **red, ++ unsigned short **green, ++ unsigned short **blue) ++{ ++ MetaMonitorManagerClass *klass = META_MONITOR_MANAGER_GET_CLASS (manager); ++ ++ if (klass->get_crtc_gamma) ++ { ++ klass->get_crtc_gamma (manager, crtc, size, red, green, blue); ++ } ++ else ++ { ++ if (size) ++ *size = 0; ++ if (red) ++ *red = NULL; ++ if (green) ++ *green = NULL; ++ if (blue) ++ *blue = NULL; ++ } ++} ++ ++static gboolean ++is_night_light_supported (MetaMonitorManager *manager) ++{ ++ GList *l; ++ ++ for (l = meta_backend_get_gpus (manager->backend); l; l = l->next) ++ { ++ MetaGpu *gpu = l->data; ++ GList *l_crtc; ++ ++ for (l_crtc = meta_gpu_get_crtcs (gpu); l_crtc; l_crtc = l_crtc->next) ++ { ++ MetaCrtc *crtc = l_crtc->data; ++ size_t gamma_lut_size; ++ ++ meta_monitor_manager_get_crtc_gamma (manager, crtc, ++ &gamma_lut_size, ++ NULL, NULL, NULL); ++ if (gamma_lut_size > 0) ++ return TRUE; ++ } ++ } ++ ++ return FALSE; ++} ++ + void + meta_monitor_manager_setup (MetaMonitorManager *manager) + { +@@ -967,7 +1020,6 @@ meta_monitor_manager_setup (MetaMonitorManager *manager) + meta_dbus_display_config_set_apply_monitors_config_allowed (manager->display_config, + policy->enable_dbus); + +- + meta_monitor_manager_read_current_state (manager); + + meta_monitor_manager_ensure_initial_config (manager); +@@ -2445,7 +2497,6 @@ meta_monitor_manager_handle_get_crtc_gamma (MetaDBusDisplayConfig *skeleton, + guint crtc_id, + MetaMonitorManager *manager) + { +- MetaMonitorManagerClass *klass; + GList *combined_crtcs; + MetaCrtc *crtc; + gsize size; +@@ -2476,14 +2527,8 @@ meta_monitor_manager_handle_get_crtc_gamma (MetaDBusDisplayConfig *skeleton, + crtc = g_list_nth_data (combined_crtcs, crtc_id); + g_list_free (combined_crtcs); + +- klass = META_MONITOR_MANAGER_GET_CLASS (manager); +- if (klass->get_crtc_gamma) +- klass->get_crtc_gamma (manager, crtc, &size, &red, &green, &blue); +- else +- { +- size = 0; +- red = green = blue = NULL; +- } ++ meta_monitor_manager_get_crtc_gamma (manager, crtc, ++ &size, &red, &green, &blue); + + red_bytes = g_bytes_new_take (red, size * sizeof (unsigned short)); + green_bytes = g_bytes_new_take (green, size * sizeof (unsigned short)); +@@ -3078,6 +3123,16 @@ meta_monitor_manager_is_transform_handled (MetaMonitorManager *manager, + return manager_class->is_transform_handled (manager, crtc, transform); + } + ++static void ++update_night_light_supported (MetaMonitorManager *manager) ++{ ++ gboolean night_light_supported; ++ ++ night_light_supported = is_night_light_supported (manager); ++ meta_dbus_display_config_set_night_light_supported (manager->display_config, ++ night_light_supported); ++} ++ + static void + meta_monitor_manager_real_read_current_state (MetaMonitorManager *manager) + { +@@ -3098,6 +3153,7 @@ meta_monitor_manager_real_read_current_state (MetaMonitorManager *manager) + } + + rebuild_monitors (manager); ++ update_night_light_supported (manager); + } + + void +diff --git a/src/backends/native/meta-monitor-manager-native.c b/src/backends/native/meta-monitor-manager-native.c +index fd5e7784ff..37a50f1d6f 100644 +--- a/src/backends/native/meta-monitor-manager-native.c ++++ b/src/backends/native/meta-monitor-manager-native.c +@@ -381,15 +381,30 @@ meta_monitor_manager_native_get_crtc_gamma (MetaMonitorManager *manager, + MetaKmsCrtc *kms_crtc; + const MetaKmsCrtcState *crtc_state; + +- g_return_if_fail (META_IS_CRTC_KMS (crtc)); ++ if (!META_IS_CRTC_KMS (crtc)) ++ { ++ if (size) ++ *size = 0; ++ if (red) ++ *red = NULL; ++ if (green) ++ *green = NULL; ++ if (blue) ++ *blue = NULL; ++ return; ++ } + + kms_crtc = meta_crtc_kms_get_kms_crtc (META_CRTC_KMS (crtc)); + crtc_state = meta_kms_crtc_get_current_state (kms_crtc); + +- *size = crtc_state->gamma.size; +- *red = g_memdup2 (crtc_state->gamma.red, *size * sizeof **red); +- *green = g_memdup2 (crtc_state->gamma.green, *size * sizeof **green); +- *blue = g_memdup2 (crtc_state->gamma.blue, *size * sizeof **blue); ++ if (size) ++ *size = crtc_state->gamma.size; ++ if (red) ++ *red = g_memdup2 (crtc_state->gamma.red, *size * sizeof **red); ++ if (green) ++ *green = g_memdup2 (crtc_state->gamma.green, *size * sizeof **green); ++ if (blue) ++ *blue = g_memdup2 (crtc_state->gamma.blue, *size * sizeof **blue); + } + + static char * +diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c +index 98eb080b6b..865f4e5800 100644 +--- a/src/backends/x11/meta-monitor-manager-xrandr.c ++++ b/src/backends/x11/meta-monitor-manager-xrandr.c +@@ -707,9 +707,12 @@ meta_monitor_manager_xrandr_get_crtc_gamma (MetaMonitorManager *manager, + (XID) meta_crtc_get_id (crtc)); + + *size = gamma->size; +- *red = g_memdup2 (gamma->red, sizeof (unsigned short) * gamma->size); +- *green = g_memdup2 (gamma->green, sizeof (unsigned short) * gamma->size); +- *blue = g_memdup2 (gamma->blue, sizeof (unsigned short) * gamma->size); ++ if (red) ++ *red = g_memdup2 (gamma->red, sizeof (unsigned short) * gamma->size); ++ if (green) ++ *green = g_memdup2 (gamma->green, sizeof (unsigned short) * gamma->size); ++ if (blue) ++ *blue = g_memdup2 (gamma->blue, sizeof (unsigned short) * gamma->size); + + XRRFreeGamma (gamma); + } +diff --git a/src/org.gnome.Mutter.DisplayConfig.xml b/src/org.gnome.Mutter.DisplayConfig.xml +index c6859c2c09..5f85c5e271 100644 +--- a/src/org.gnome.Mutter.DisplayConfig.xml ++++ b/src/org.gnome.Mutter.DisplayConfig.xml +@@ -297,6 +297,13 @@ + --> + + ++ ++ ++ +