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
This commit is contained in:
parent
3838220961
commit
0b91dee5a9
@ -40,6 +40,8 @@ const GSD_WACOM_OBJECT_PATH = '/org/gnome/SettingsDaemon/Wacom';
|
|||||||
const GsdWacomIface = loadInterfaceXML('org.gnome.SettingsDaemon.Wacom');
|
const GsdWacomIface = loadInterfaceXML('org.gnome.SettingsDaemon.Wacom');
|
||||||
const GsdWacomProxy = Gio.DBusProxy.makeProxyWrapper(GsdWacomIface);
|
const GsdWacomProxy = Gio.DBusProxy.makeProxyWrapper(GsdWacomIface);
|
||||||
|
|
||||||
|
const WINDOW_DIMMER_EFFECT_NAME = "gnome-shell-window-dimmer";
|
||||||
|
|
||||||
var DisplayChangeDialog = GObject.registerClass(
|
var DisplayChangeDialog = GObject.registerClass(
|
||||||
class DisplayChangeDialog extends ModalDialog.ModalDialog {
|
class DisplayChangeDialog extends ModalDialog.ModalDialog {
|
||||||
_init(wm) {
|
_init(wm) {
|
||||||
@ -114,21 +116,20 @@ class DisplayChangeDialog extends ModalDialog.ModalDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var WindowDimmer = class {
|
var WindowDimmer = GObject.registerClass(
|
||||||
constructor(actor) {
|
class WindowDimmer extends Clutter.BrightnessContrastEffect {
|
||||||
this._brightnessEffect = new Clutter.BrightnessContrastEffect({
|
_init() {
|
||||||
name: 'dim',
|
super._init({
|
||||||
|
name: WINDOW_DIMMER_EFFECT_NAME,
|
||||||
enabled: false
|
enabled: false
|
||||||
});
|
});
|
||||||
actor.add_effect(this._brightnessEffect);
|
|
||||||
this.actor = actor;
|
|
||||||
this._enabled = true;
|
this._enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_syncEnabled() {
|
_syncEnabled() {
|
||||||
let animating = this.actor.get_transition('@effects.dim.brightness') != null;
|
let animating = this.actor.get_transition(`@effects.${this.name}.brightness`) != null;
|
||||||
let dimmed = this._brightnessEffect.brightness.red != 127;
|
let dimmed = this.brightness.red != 127;
|
||||||
this._brightnessEffect.enabled = this._enabled && (animating || dimmed);
|
this.enabled = this._enabled && (animating || dimmed);
|
||||||
}
|
}
|
||||||
|
|
||||||
setEnabled(enabled) {
|
setEnabled(enabled) {
|
||||||
@ -140,7 +141,7 @@ var WindowDimmer = class {
|
|||||||
let val = 127 * (1 + (dimmed ? 1 : 0) * DIM_BRIGHTNESS);
|
let val = 127 * (1 + (dimmed ? 1 : 0) * DIM_BRIGHTNESS);
|
||||||
let color = Clutter.Color.new(val, val, val, 255);
|
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,
|
mode: Clutter.AnimationMode.LINEAR,
|
||||||
duration: (dimmed ? DIM_TIME : UNDIM_TIME) * (animate ? 1 : 0),
|
duration: (dimmed ? DIM_TIME : UNDIM_TIME) * (animate ? 1 : 0),
|
||||||
onComplete: () => this._syncEnabled()
|
onComplete: () => this._syncEnabled()
|
||||||
@ -148,20 +149,19 @@ var WindowDimmer = class {
|
|||||||
|
|
||||||
this._syncEnabled();
|
this._syncEnabled();
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
function getWindowDimmer(actor) {
|
function getWindowDimmer(actor) {
|
||||||
let enabled = Meta.prefs_get_attach_modal_dialogs();
|
let enabled = Meta.prefs_get_attach_modal_dialogs();
|
||||||
if (actor._windowDimmer)
|
let effect = actor.get_effect(WINDOW_DIMMER_EFFECT_NAME);
|
||||||
actor._windowDimmer.setEnabled(enabled);
|
|
||||||
|
|
||||||
if (enabled) {
|
if (effect) {
|
||||||
if (!actor._windowDimmer)
|
effect.setEnabled(enabled);
|
||||||
actor._windowDimmer = new WindowDimmer(actor);
|
} else if (enabled) {
|
||||||
return actor._windowDimmer;
|
effect = new WindowDimmer();
|
||||||
} else {
|
actor.add_effect(effect);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return effect;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user