From a8fcf42197322d23036e44fdc8be72abaf8b7233 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 2 Apr 2025 12:06:42 +0100 Subject: [PATCH] breakManager: Make brightness setting function clearer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Confusingly, the `brightness` property of `ClutterBrightnessContrastEffect` has type `CoglColor`, but the `set_brightness()` setter takes a single `float`. We previously chose to use the property setter everywhere for consistency (see https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3655#note_2369353), but didn’t realise the types don’t match. GJS optimises `this._brightnessEffect.brightness = foo` into a call to `clutter_brightness_contrast_effect_set_brightness()`, which means the type mismatch between the two results in a warning (see https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8280). So, let’s change from a property setter into an explicit method call to avoid the type ambiguity, at the expense of a bit of clarity from using the same method to set the initial value and each property animation step. Signed-off-by: Philip Withnall Helps: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8280 Part-of: --- js/misc/breakManager.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/js/misc/breakManager.js b/js/misc/breakManager.js index 371201a7a..4374af2d5 100644 --- a/js/misc/breakManager.js +++ b/js/misc/breakManager.js @@ -866,13 +866,6 @@ class BreakDispatcher extends GObject.Object { _brightnessEffectOn() { // the effect value is in the range [0, 255] with 127 as the ‘no change’ mid-point const startVal = 127; - const startColor = new Cogl.Color({ - red: startVal, - green: startVal, - blue: startVal, - alpha: 255, - }); - const finishVal = 127 * BRIGHTNESS_FACTOR; const finishColor = new Cogl.Color({ red: finishVal, @@ -881,7 +874,7 @@ class BreakDispatcher extends GObject.Object { alpha: 255, }); - this._brightnessEffect.brightness = startColor; + this._brightnessEffect.set_brightness(startVal); this._brightnessEffect.set_enabled(true); Main.layoutManager.uiGroup.ease_property(