timeLimitsManager: Fix grayscale transition

The code currently gets the `DesaturateEffect.factor` property[0]
backwards: 1.0 means fully desaturated, not full color.

The result is that we are currently "transitioning" from 1.0 to 1.0,
that is the screen is abruptly turned to grayscale with no transition.

[0] https://mutter.gnome.org/clutter/property.DesaturateEffect.factor.html

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8160
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3606>
This commit is contained in:
Florian Müllner
2025-01-21 20:42:11 +01:00
parent 8f53096cfa
commit 8043714478

View File

@ -36,7 +36,7 @@ import * as MessageTray from '../ui/messageTray.js';
export const HISTORY_THRESHOLD_SECONDS = 14 * 7 * 24 * 60 * 60; // maximum time history entries are kept
const LIMIT_UPCOMING_NOTIFICATION_TIME_SECONDS = 10 * 60; // notify the user 10min before their limit is reached
const GRAYSCALE_FADE_TIME_SECONDS = 3;
const GRAYSCALE_SATURATION = 0.0; // saturation ([0.0, 1.0]) when grayscale mode is activated, 1.0 means full color
const GRAYSCALE_SATURATION = 1.0; // saturation ([0.0, 1.0]) when grayscale mode is activated, 1.0 means full desaturation
/** @enum {number} */
export const TimeLimitsState = {
@ -839,9 +839,10 @@ class TimeLimitsDispatcher extends GObject.Object {
this._ensureEnabled();
if (this._manager.grayscaleEnabled) {
this._desaturationEffect.factor = 0.0;
this._desaturationEffect.set_enabled(true);
Main.layoutManager.uiGroup.ease_property(
'@effects.desaturate.factor', 1.0 - GRAYSCALE_SATURATION,
'@effects.desaturate.factor', GRAYSCALE_SATURATION,
{
duration: GRAYSCALE_FADE_TIME_SECONDS * 1000 || 0,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,