🔧 Gradually fade out windows
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const {Clutter} = imports.gi;
|
||||
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
const Me = imports.misc.extensionUtils.getCurrentExtension();
|
||||
const utils = Me.imports.utils;
|
||||
@@ -30,6 +32,8 @@ class Extension {
|
||||
// from GNOME Tweaks, when you log in or when the screen is unlocked.
|
||||
enable() {
|
||||
|
||||
// imports.ui.windowManager.DESTROY_WINDOW_ANIMATION_TIME = 2000;
|
||||
|
||||
// Store a reference to the settings object.
|
||||
// this._settings = ExtensionUtils.getSettings();
|
||||
|
||||
@@ -38,12 +42,39 @@ class Extension {
|
||||
const transition = actor.get_transition(property);
|
||||
if (transition) {
|
||||
transition.set_to(value);
|
||||
transition.set_progress_mode(Clutter.AnimationMode.EASE_OUT_QUAD);
|
||||
}
|
||||
};
|
||||
|
||||
tweakTransition('opacity', 255);
|
||||
tweakTransition('scale-x', 1);
|
||||
tweakTransition('scale-y', 1);
|
||||
|
||||
const shader = new Clutter.ShaderEffect({
|
||||
shader_type: Clutter.ShaderType.FRAGMENT_SHADER,
|
||||
});
|
||||
|
||||
shader.set_shader_source(`
|
||||
uniform sampler2D texture;
|
||||
uniform float progress;
|
||||
|
||||
const float BLEND_RANGE = 0.1;
|
||||
|
||||
void main(void) {
|
||||
float t = cogl_tex_coord_in[0].t * (1 - BLEND_RANGE);
|
||||
float alpha = 1 - clamp((progress - t) / BLEND_RANGE, 0, 1);
|
||||
|
||||
// This uses premultiplied alpha.
|
||||
cogl_color_out = texture2D(texture, cogl_tex_coord_in[0].st) * alpha;
|
||||
}
|
||||
`);
|
||||
|
||||
actor.add_effect(shader);
|
||||
|
||||
const transition = actor.get_transition('opacity');
|
||||
transition.connect('new-frame', (t) => {
|
||||
shader.set_uniform_value('progress', t.get_progress());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user