[gnome-shell] windowManager: Inherit WindowDimmer from Clutter.BrightnessContrastEffect
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] windowManager: Inherit WindowDimmer from Clutter.BrightnessContrastEffect
- Date: Wed, 16 Oct 2019 15:32:58 +0000 (UTC)
commit 0b91dee5a9211ee0ca76ce0750c7f2d2ec8e0317
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date: Wed Aug 28 21:56:53 2019 +0200
windowManager: Inherit WindowDimmer from Clutter.BrightnessContrastEffect
As result add the effect to the actor on the caller function.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/559
js/ui/windowManager.js | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index b5ea54a208..7ff30fdfcd 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -40,6 +40,8 @@ const GSD_WACOM_OBJECT_PATH = '/org/gnome/SettingsDaemon/Wacom';
const GsdWacomIface = loadInterfaceXML('org.gnome.SettingsDaemon.Wacom');
const GsdWacomProxy = Gio.DBusProxy.makeProxyWrapper(GsdWacomIface);
+const WINDOW_DIMMER_EFFECT_NAME = "gnome-shell-window-dimmer";
+
var DisplayChangeDialog = GObject.registerClass(
class DisplayChangeDialog extends ModalDialog.ModalDialog {
_init(wm) {
@@ -114,21 +116,20 @@ class DisplayChangeDialog extends ModalDialog.ModalDialog {
}
});
-var WindowDimmer = class {
- constructor(actor) {
- this._brightnessEffect = new Clutter.BrightnessContrastEffect({
- name: 'dim',
+var WindowDimmer = GObject.registerClass(
+class WindowDimmer extends Clutter.BrightnessContrastEffect {
+ _init() {
+ super._init({
+ name: WINDOW_DIMMER_EFFECT_NAME,
enabled: false
});
- actor.add_effect(this._brightnessEffect);
- this.actor = actor;
this._enabled = true;
}
_syncEnabled() {
- let animating = this.actor.get_transition('@effects.dim.brightness') != null;
- let dimmed = this._brightnessEffect.brightness.red != 127;
- this._brightnessEffect.enabled = this._enabled && (animating || dimmed);
+ let animating = this.actor.get_transition(`@effects.${this.name}.brightness`) != null;
+ let dimmed = this.brightness.red != 127;
+ this.enabled = this._enabled && (animating || dimmed);
}
setEnabled(enabled) {
@@ -140,7 +141,7 @@ var WindowDimmer = class {
let val = 127 * (1 + (dimmed ? 1 : 0) * DIM_BRIGHTNESS);
let color = Clutter.Color.new(val, val, val, 255);
- this.actor.ease_property('@effects.dim.brightness', color, {
+ this.actor.ease_property(`@effects.${this.name}.brightness`, color, {
mode: Clutter.AnimationMode.LINEAR,
duration: (dimmed ? DIM_TIME : UNDIM_TIME) * (animate ? 1 : 0),
onComplete: () => this._syncEnabled()
@@ -148,20 +149,19 @@ var WindowDimmer = class {
this._syncEnabled();
}
-};
+});
function getWindowDimmer(actor) {
let enabled = Meta.prefs_get_attach_modal_dialogs();
- if (actor._windowDimmer)
- actor._windowDimmer.setEnabled(enabled);
+ let effect = actor.get_effect(WINDOW_DIMMER_EFFECT_NAME);
- if (enabled) {
- if (!actor._windowDimmer)
- actor._windowDimmer = new WindowDimmer(actor);
- return actor._windowDimmer;
- } else {
- return null;
+ if (effect) {
+ effect.setEnabled(enabled);
+ } else if (enabled) {
+ effect = new WindowDimmer();
+ actor.add_effect(effect);
}
+ return effect;
}
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]