🔀 Merge pull request #121 from Schneegans/feature/thanos

This commit is contained in:
Simon Schneegans
2022-03-31 21:39:06 +02:00
committed by GitHub
52 changed files with 456 additions and 9 deletions
BIN
View File
Binary file not shown.
+8
View File
@@ -1,5 +1,13 @@
# Changelog of the Burn-My-Windows Extension
## [Burn My Window 15](https://github.com/schneegans/Burn-My-Windows/releases/tag/v15)
**Release Date:** TBD
#### Bug Fixes
* Disabled the buggy "Shatter from pointer" option of the Broken Glass effect when opening windows (it only makes sense for closing windows).
## [Burn My Window 14](https://github.com/schneegans/Burn-My-Windows/releases/tag/v14)
**Release Date:** 2022-03-29
+2 -1
View File
@@ -33,11 +33,12 @@ const utils = Me.imports.src.utils;
// New effects must be registered here and in prefs.js.
const ALL_EFFECTS = [
Me.imports.src.BrokenGlass.BrokenGlass,
Me.imports.src.EnergizeA.EnergizeA,
Me.imports.src.EnergizeB.EnergizeB,
Me.imports.src.Fire.Fire,
Me.imports.src.Matrix.Matrix,
Me.imports.src.BrokenGlass.BrokenGlass,
Me.imports.src.SnapOfDisintegration.SnapOfDisintegration,
Me.imports.src.TRexAttack.TRexAttack,
Me.imports.src.TVEffect.TVEffect,
Me.imports.src.Wisps.Wisps,
+2 -1
View File
@@ -32,11 +32,12 @@ const utils = Me.imports.src.utils;
// New effects must be registered here and in extension.js.
const ALL_EFFECTS = [
Me.imports.src.BrokenGlass.BrokenGlass,
Me.imports.src.EnergizeA.EnergizeA,
Me.imports.src.EnergizeB.EnergizeB,
Me.imports.src.Fire.Fire,
Me.imports.src.Matrix.Matrix,
Me.imports.src.BrokenGlass.BrokenGlass,
Me.imports.src.SnapOfDisintegration.SnapOfDisintegration,
Me.imports.src.TRexAttack.TRexAttack,
Me.imports.src.TVEffect.TVEffect,
Me.imports.src.Wisps.Wisps,
Binary file not shown.

After

Width:  |  Height:  |  Size: 434 KiB

+2 -2
View File
@@ -2,9 +2,9 @@
<interface domain="burn-my-windows">
<object class="GtkAdjustment" id="tv-animation-time">
<property name="upper">5000</property>
<property name="upper">10000</property>
<property name="lower">100</property>
<property name="step-increment">10</property>
<property name="step-increment">1</property>
<property name="page-increment">100</property>
</object>
+151
View File
@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkBox" id="snap-prefs">
<property name="orientation">vertical</property>
<child>
<object class="GtkFrame">
<child>
<object class="GtkListBox">
<property name="selection-mode">none</property>
<property name="show-separators">1</property>
<style>
<class name="rich-list" />
</style>
<child>
<object class="GtkListBoxRow">
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Animation Time [ms]</property>
<property name="xalign">0</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="hexpand">1</property>
</object>
</child>
<child>
<object class="GtkScale">
<property name="halign">end</property>
<property name="valign">center</property>
<property name="draw-value">1</property>
<property name="digits">0</property>
<property name="value-pos">left</property>
<property name="width-request">300</property>
<property name="adjustment">
<object class="GtkAdjustment" id="snap-animation-time">
<property name="upper">10000</property>
<property name="lower">500</property>
<property name="step-increment">10</property>
<property name="page-increment">100</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-snap-animation-time">
<property name="icon-name">edit-clear-symbolic</property>
<property name="tooltip-text">Reset to Default Value</property>
<style>
<class name="flat" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Scale</property>
<property name="xalign">0</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="hexpand">1</property>
</object>
</child>
<child>
<object class="GtkScale">
<property name="halign">end</property>
<property name="valign">center</property>
<property name="draw-value">1</property>
<property name="digits">2</property>
<property name="value-pos">left</property>
<property name="width-request">300</property>
<property name="adjustment">
<object class="GtkAdjustment" id="snap-scale">
<property name="upper">5</property>
<property name="lower">0.1</property>
<property name="step-increment">0.01</property>
<property name="page-increment">0.1</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-snap-scale">
<property name="icon-name">edit-clear-symbolic</property>
<property name="tooltip-text">Reset to Default Value</property>
<style>
<class name="flat" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow">
<property name="activatable">0</property>
<child>
<object class="GtkBox">
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Color</property>
<property name="xalign">0</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="hexpand">1</property>
</object>
</child>
<child>
<object class="GtkColorButton" id="snap-color">
<property name="use_alpha">0</property>
<property name="show_editor">1</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset-snap-color">
<property name="icon-name">edit-clear-symbolic</property>
<property name="tooltip-text">Reset to Default Value</property>
<style>
<class name="flat" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
+2 -2
View File
@@ -38,9 +38,9 @@
<property name="width-request">300</property>
<property name="adjustment">
<object class="GtkAdjustment" id="tv-animation-time">
<property name="upper">5000</property>
<property name="upper">10000</property>
<property name="lower">100</property>
<property name="step-increment">10</property>
<property name="step-increment">1</property>
<property name="page-increment">100</property>
</object>
</property>
@@ -375,6 +375,40 @@
<description>Use the pointer location for the broken glass effect.</description>
</key>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Snap of Disintegration Effect Options -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<key name="snap-open-effect" type="b">
<default>false</default>
<summary>Snap Open Effect</summary>
<description>Use the snap effect for window openeing.</description>
</key>
<key name="snap-close-effect" type="b">
<default>false</default>
<summary>Snap Close Effect</summary>
<description>Use the snap effect for window closing.</description>
</key>
<key name="snap-animation-time" type="i">
<default>1000</default>
<summary>Snap Animation Time</summary>
<description>The time the snap effect takes.</description>
</key>
<key name="snap-scale" type="d">
<default>1.0</default>
<summary>Snap Scale</summary>
<description>The size of the snap effect.</description>
</key>
<key name="snap-color" type="s">
<default>"rgb(50, 40, 35)"</default>
<summary>Snap Effect Color</summary>
<description>The color of the dust.</description>
</key>
</schema>
</schemalist>
+6 -3
View File
@@ -142,11 +142,14 @@ if (utils.isInShellProcess()) {
let epicenterY = 0.5;
// However, if this option is set, we use the mouse pointer position.
if (settings.get_boolean('broken-glass-use-pointer')) {
if (!forOpening && settings.get_boolean('broken-glass-use-pointer')) {
const [x, y] = global.get_pointer();
const [ok, localX, localY] = actor.transform_stage_point(x, y);
epicenterX = localX / actor.width;
epicenterY = localY / actor.height;
if (ok) {
epicenterX = localX / actor.width;
epicenterY = localY / actor.height;
}
}
// If we are currently performing integration test, the animation uses a fixed seed.
+229
View File
@@ -0,0 +1,229 @@
//////////////////////////////////////////////////////////////////////////////////////////
// ) ( //
// ( /( ( ( ) ( ( ( ( )\ ) ( ( //
// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
// |__/ //
// Copyright (c) 2021 Simon Schneegans //
// Released under the GPLv3 or later. See LICENSE file for details. //
//////////////////////////////////////////////////////////////////////////////////////////
'use strict';
const GObject = imports.gi.GObject;
const _ = imports.gettext.domain('burn-my-windows').gettext;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const utils = Me.imports.src.utils;
//////////////////////////////////////////////////////////////////////////////////////////
// This effects dissolves your windows into a cloud of dust. For this, it uses an //
// approach similar to the Broken Glass effect. A dust texture is used to segment the //
// window texture into a set of layers. Each layer is then moved, sheared and scaled //
// randomly. Just a few layers are sufficient to create the illusion of many individual //
// dust particles. //
// This effect is not available on GNOME 3.3x, due to the limitation described in the //
// documentation of vfunc_paint_target further down in this file. //
//////////////////////////////////////////////////////////////////////////////////////////
// The shader class for this effect is registered further down in this file.
let Shader = null;
// The effect class is completely static. It can be used to get some metadata (like the
// effect's name or supported GNOME Shell versions), to initialize the respective page of
// the settings dialog, as well as to create the actual shader for the effect.
var SnapOfDisintegration = class SnapOfDisintegration {
// ---------------------------------------------------------------------------- metadata
// This effect is only available on GNOME Shell 40+.
static getMinShellVersion() {
return [40, 0];
}
// This will be called in various places where a unique identifier for this effect is
// required. It should match the prefix of the settings keys which store whether the
// effect is enabled currently (e.g. '*-close-effect'), and its animation time
// (e.g. '*-animation-time').
static getNick() {
return 'snap';
}
// This will be shown in the sidebar of the preferences dialog as well as in the
// drop-down menus where the user can choose the effect.
static getLabel() {
return _('Snap of Disintegration');
}
// -------------------------------------------------------------------- API for prefs.js
// This is called by the preferences dialog. It loads the settings page for this effect,
// binds all properties to the settings and appends the page to the main stack of the
// preferences dialog.
static getPreferences(dialog) {
// Add the settings page to the builder.
dialog.getBuilder().add_from_resource('/ui/gtk4/SnapOfDisintegration.ui');
// Bind all properties.
dialog.bindAdjustment('snap-animation-time');
dialog.bindAdjustment('snap-scale');
dialog.bindColorButton('snap-color');
// Finally, return the new settings page.
return dialog.getBuilder().get_object('snap-prefs');
}
// ---------------------------------------------------------------- API for extension.js
// This is called from extension.js whenever a window is closed with this effect.
static createShader(actor, settings, forOpening) {
return new Shader(actor, settings, forOpening);
}
// The tweakTransition() is called from extension.js to tweak a window's open / close
// transitions - usually windows are faded in / out and scaled up / down by GNOME Shell.
// The parameter 'forOpening' is set to true if this is called for a window-open
// transition, for a window-close transition it is set to false. The modes can be set to
// any value from here: https://gjs-docs.gnome.org/clutter8~8_api/clutter.animationmode.
// The only required property is 'opacity', even if it transitions from 1.0 to 1.0. The
// current value of the opacity transition is passed as uProgress to the shader.
// Tweaking the actor's scale during the transition only works properly for GNOME 3.38+.
// For this effect, windows are set to 1.2 times their original size, so that we have
// some space to draw the dust particles. We also set the animation mode to "Linear".
static tweakTransition(actor, settings, forOpening) {
return {
'opacity': {from: 255, to: 255, mode: 1},
'scale-x': {from: 1.2, to: 1.2, mode: 1},
'scale-y': {from: 1.2, to: 1.2, mode: 1}
};
}
}
//////////////////////////////////////////////////////////////////////////////////////////
// The shader class for this effect will only be registered in GNOME Shell's process //
// (not in the preferences process). It's done this way as Clutter may not be installed //
// on the system and therefore the preferences would crash. //
//////////////////////////////////////////////////////////////////////////////////////////
if (utils.isInShellProcess()) {
const {Clutter, GdkPixbuf, Cogl} = imports.gi;
const shaderSnippets = Me.imports.src.shaderSnippets;
Shader = GObject.registerClass({}, class Shader extends Clutter.ShaderEffect {
_init(actor, settings, forOpening) {
super._init({shader_type: Clutter.ShaderType.FRAGMENT_SHADER});
// Load the dust texture. As the shader is re-created for each window animation,
// this texture is also re-created each time. This could be improved in the future!
const dustData = GdkPixbuf.Pixbuf.new_from_resource('/img/dust.png');
this._dustTexture = new Clutter.Image();
this._dustTexture.set_data(dustData.get_pixels(), Cogl.PixelFormat.RGB_888,
dustData.width, dustData.height, dustData.rowstride);
// The dust particles will fade to this color over time.
const color = Clutter.Color.from_string(settings.get_string('snap-color'))[1];
// If we are currently performing integration test, the animation uses a fixed seed.
const testMode = settings.get_boolean('test-mode');
this.set_shader_source(`
// Inject some common shader snippets.
${shaderSnippets.standardUniforms()}
${shaderSnippets.math2D()}
uniform sampler2D uDustTexture;
const vec2 SEED = vec2(${testMode ? 0 : Math.random()},
${testMode ? 0 : Math.random()});
const float DUST_SCALE = ${settings.get_double('snap-scale')};
const float DUST_LAYERS = 5;
const float ACTOR_SCALE = 1.2;
const float PADDING = ACTOR_SCALE / 2.0 - 0.5;
const vec2 EPICENTER = vec2(0.5);
const vec3 DUST_COLOR = vec3(${color.red / 255},
${color.green / 255},
${color.blue / 255});
void main() {
// We simply inverse the progress for opening windows.
float progress = pow(${forOpening ? '1.0-uProgress' : 'uProgress'}, 2.0);
cogl_color_out = vec4(0, 0, 0, 0);
for (float i=0; i<DUST_LAYERS; ++i) {
// Create a random direction.
float factor = DUST_LAYERS == 1 ? 0 : i/(DUST_LAYERS-1);
float angle = 123.123 * (SEED.x + factor);
vec2 direction = vec2(1.0, 0.0);
direction = rotate(direction, angle);
// Flip direction for one side of the window.
vec2 coords = cogl_tex_coord_in[0].st * ACTOR_SCALE - PADDING - EPICENTER;
if (getWinding(direction, coords) > 0) {
direction *= -1;
}
// Flip direction for half the layers.
if (factor > 0.5) {
direction *= -1;
}
// We grow the layer along the random direction, shrink it orthogonally to it
// and scale it up slightly.
float dist = distToLine(vec2(0.0), direction, coords);
vec2 grow = direction * dist * mix(0, 0.1, progress);
vec2 shrink = vec2(direction.y, -direction.x) * dist * mix(0, 0.1, progress);
float scale = mix(1.0, 1.1, factor * progress);
coords = (coords + grow + shrink) / scale;
// Now check wether there is actually something in the current dust layer at
// the coords position.
vec2 dustCoords = (coords + SEED) * vec2(uSizeX, uSizeY) / DUST_SCALE / 100.0;
vec2 dustMap = texture2D(uDustTexture, dustCoords).rg;
float dustGroup = floor(dustMap.g * DUST_LAYERS * 0.999);
if (dustGroup == i) {
// Fade the window color to DUST_COLOR.
vec4 windowColor = texture2D(uTexture, coords + EPICENTER);
windowColor.rgb = mix(windowColor.rgb, DUST_COLOR*windowColor.a, progress);
// Dissolve the dust particles.
float dissolve = (dustMap.x - progress) > 0 ? 1 : 0;
windowColor *= dissolve;
// Blend the layers.
cogl_color_out = mix(cogl_color_out, windowColor, windowColor.a);
}
}
}
`);
};
// This is overridden to bind the dust texture for drawing. Sadly, this seems to be
// impossible under GNOME 3.3x as this.get_pipeline() is not available. It was called
// get_target() back then but this is not wrapped in GJS.
// https://gitlab.gnome.org/GNOME/mutter/-/blob/gnome-3-36/clutter/clutter/clutter-offscreen-effect.c#L598
vfunc_paint_target(node, paint_context) {
const pipeline = this.get_pipeline();
pipeline.set_layer_filters(0, Cogl.PipelineFilter.LINEAR,
Cogl.PipelineFilter.LINEAR);
pipeline.set_layer_texture(1, this._dustTexture.get_texture());
pipeline.set_layer_wrap_mode(1, Cogl.PipelineWrapMode.REPEAT);
this.set_uniform_value('uDustTexture', 1);
super.vfunc_paint_target(node, paint_context);
}
});
}
+18
View File
@@ -33,6 +33,24 @@ function standardUniforms() {
`;
}
function math2D() {
return `
float distToLine(vec2 origin, vec2 direction, vec2 point) {
vec2 perpendicular = vec2(direction.y, -direction.x);
return abs(dot(normalize(perpendicular), origin - point));
}
float getWinding(vec2 a, vec2 b) {
return cross(vec3(a, 0.0), vec3(b, 0.0)).z;
}
vec2 rotate(vec2 a, float angle) {
return vec2(a.x * cos(angle) - a.y * sin(angle),
a.x * sin(angle) + a.y * cos(angle));
}
`;
}
// This method returns a mask which smoothly transitions towards zero when approaching
// the window's borders. There is a variant which takes the transition area width in
// pixels and one which takes this as a percentage.
+1
View File
@@ -178,6 +178,7 @@ if [[ "${FEDORA_VERSION}" -gt 33 ]]; then
capture_effect "trex"
capture_effect "broken-glass"
capture_effect "matrix"
capture_effect "snap"
fi
echo "All reference images generated successfully."
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 721 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

+1
View File
@@ -207,6 +207,7 @@ if [[ "${FEDORA_VERSION}" -gt 33 ]]; then
test_effect "trex"
test_effect "broken-glass"
test_effect "matrix"
test_effect "snap"
fi
echo "All tests executed successfully."