Skip to content

Commit

Permalink
Merge pull request #766 from klangman/add-focus-effect-0.9.5
Browse files Browse the repository at this point in the history
[CinnamonBurnMyWindows@klangman] Added new Focus effect by Justin Garza
  • Loading branch information
claudiux authored Oct 30, 2024
2 parents 6b88066 + c43f2ee commit c4d51f1
Show file tree
Hide file tree
Showing 14 changed files with 468 additions and 48 deletions.
4 changes: 4 additions & 0 deletions CinnamonBurnMyWindows@klangman/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.9.5

* Added a new "Focus" effect by Justin Garza

## 0.9.4

* Fixed an issue that could interfere with other Cinnamon effects by returning true from Cinnamon's _shouldAnimate(). Some effects like Restore and Manximize might occur even when they were disabled in the Cinnamon Effects setting application. Also some BurnMyWindows effect could happen on events other than window open/close events (but I didn't ever see this occur myself).
Expand Down
1 change: 1 addition & 0 deletions CinnamonBurnMyWindows@klangman/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The window shadows are not part of the animation and therefore they suddenly app
- Doom
- Energize A
- Energize B
- Focus
- Glide
- Glitch
- Hexagon
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
//////////////////////////////////////////////////////////////////////////////////////////
// ) ( //
// ( /( ( ( ) ( ( ( ( )\ ) ( ( //
// )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( //
// ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ //
// | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) //
// | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< //
// |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ //
// |__/ //
//////////////////////////////////////////////////////////////////////////////////////////

// SPDX-FileCopyrightText: Justin Garza [email protected]
// SPDX-License-Identifier: GPL-3.0-or-later

'use strict';

//import * as utils from '../utils.js';

// We import the ShaderFactory only in the Shell process as it is not required in the
// preferences process. The preferences process does not create any shader instances, it
// only uses the static metadata of the effect.
//const ShaderFactory = await utils.importInShellOnly('./ShaderFactory.js');

//const _ = await utils.importGettext();
const {ShaderFactory} = require('./ShaderFactory.js');

const Gettext = imports.gettext;
const GLib = imports.gi.GLib;
const UUID = "CinnamonBurnMyWindows@klangman";

Gettext.bindtextdomain(UUID, GLib.get_home_dir() + "/.local/share/locale");

function _(text) {
let locText = Gettext.dgettext(UUID, text);
if (locText == text) {
locText = window._(text);
}
return locText;
}

//////////////////////////////////////////////////////////////////////////////////////////
// This effect uses a blur effect to allow the window to focus in and out of view. //
//////////////////////////////////////////////////////////////////////////////////////////

// The effect class 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 Effect = class Effect {
// The constructor creates a ShaderFactory which will be used by extension.js to create
// shader instances for this effect. The shaders will be automagically created using the
// GLSL file in resources/shaders/<nick>.glsl. The callback will be called for each
// newly created shader instance.
constructor() {
this.shaderFactory = new ShaderFactory(Effect.getNick(), (shader) => {
// Store uniform locations of newly created shaders.
shader._uBlurAmount = shader.get_uniform_location('uBlurAmount');
shader._uBlurQuality = shader.get_uniform_location('uBlurQuality');

// Write all uniform values at the start of each animation.
shader.connect('begin-animation', (shader, settings) => {
shader.set_uniform_float(shader._uBlurAmount, 1, [
settings.getValue('focus-blur-amount'),
]);

shader.set_uniform_float(shader._uBlurQuality, 1, [
settings.getValue('focus-blur-quality'),
]);
});
});
}

// ---------------------------------------------------------------------------- metadata

// The effect is available on all GNOME Shell versions supported by this extension.
static getMinShellVersion() {
return [3, 36];
}

// 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. '*-enable-effect'), and its animation time
// (e.g. '*-animation-time'). Also, the shader file and the settings UI files should be
// named likes this.
static getNick() {
return 'focus';
}

// 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 _('Focus');
}

// -------------------------------------------------------------------- API for prefs.js

// This is called by the preferences dialog whenever a new effect profile is loaded. It
// binds all user interface elements to the respective settings keys of the profile.
static bindPreferences(dialog) {
// These connect the settings to the UI elements. Have a look at prefs.js
// on how to bind other types of UI elements.
dialog.bindAdjustment('focus-animation-time');
dialog.bindAdjustment('focus-blur-amount');
dialog.bindAdjustment('focus-blur-quality');
}

// ---------------------------------------------------------------- API for extension.js

// The getActorScale() is called from extension.js to adjust the actor's size during the
// animation. This is useful if the effect requires drawing something beyond the usual
// bounds of the actor. This only works for GNOME 3.38+.
static getActorScale(settings, forOpening, actor) {
return {x: 1.0, y: 1.0};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const Doom = require('./effects/Doom.js');
const EnergizeA = require('./effects/EnergizeA.js');
const EnergizeB = require('./effects/EnergizeB.js');
const Fire = require('./effects/Fire.js');
const Focus = require('./effects/Focus.js');
const Glide = require('./effects/Glide.js');
const Glitch = require('./effects/Glitch.js');
const Hexagon = require('./effects/Hexagon.js');
Expand Down Expand Up @@ -58,6 +59,7 @@ const Effect = {
EnergizeA: 3,
EnergizeB: 4,
Fire: 5,
Focus: 21,
Glide: 6,
Glitch: 7,
Hexagon: 8,
Expand Down Expand Up @@ -108,7 +110,9 @@ class BurnMyWindows {
// This function could be called after the extension is enabled, which could be done
// from GNOME Tweaks, when you log in or when the screen is unlocked.
enable() {
// New effects must be registered here and in prefs.js.
// Effects in this array must be ordered by effect number as defined by the setting-schema.json.
// New effects will be added in alphabetical order in the UI list, but the effect number, and
// therefore the order in this array, might not be alphabetical.
this._ALL_EFFECTS = [
new Apparition.Effect(),
new BrokenGlass.Effect(),
Expand All @@ -131,6 +135,7 @@ class BurnMyWindows {
new TVEffect.Effect(),
new TVGlitch.Effect(),
new Wisps.Effect(),
new Focus.Effect(),
];

// Store a reference to the settings object.
Expand Down Expand Up @@ -275,6 +280,8 @@ class BurnMyWindows {
effectOptions.push(Effect.EnergizeB);
//if (this._settings.getValue("file-random-include" + append))
// effectOptions.push(Effect.Fire);
if (this._settings.getValue("focus-random-include" + append))
effectOptions.push(Effect.Focus);
if (this._settings.getValue("glide-random-include" + append))
effectOptions.push(Effect.Glide);
if (this._settings.getValue("glitch-random-include" + append))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"doom-horizontal-scale", "doom-vertical-scale", "doom-pixel-size", "doom-animation-time",
"energize-a-scale", "energize-a-color", "energize-a-animation-time",
"energize-b-scale", "energize-b-color", "energize-b-animation-time",
"focus-blur-amount", "focus-blur-quality", "focus-animation-time",
"glide-scale", "glide-squish", "glide-tilt", "glide-shift", "glide-animation-time",
"glitch-scale", "glitch-strength", "glitch-speed", "glitch-color", "glitch-animation-time",
"hexagon-scale", "hexagon-line-width", "hexagon-line-color", "hexagon-glow-color", "hexagon-additive-blending", "hexagon-animation-time",
Expand All @@ -58,7 +59,7 @@
"random-section" : {
"type" : "section",
"title" : "Effects included in the randomized sets:",
"keys" : ["random-title", "apparition-random-include", "doom-random-include", "energize-a-random-include", "energize-b-random-include", "glide-random-include", "glitch-random-include", "hexagon-random-include", "incinerate-random-include", "pixelate-random-include", "pixel-wheel-random-include", "pixel-wipe-random-include", "portal-random-include", "tv-effect-random-include", "tv-glitch-random-include", "wisps-random-include"]
"keys" : ["random-title", "apparition-random-include", "doom-random-include", "energize-a-random-include", "energize-b-random-include", "focus-random-include", "glide-random-include", "glitch-random-include", "hexagon-random-include", "incinerate-random-include", "pixelate-random-include", "pixel-wheel-random-include", "pixel-wipe-random-include", "portal-random-include", "tv-effect-random-include", "tv-glitch-random-include", "wisps-random-include"]
}
},

Expand All @@ -72,6 +73,7 @@
"Doom": 2,
"Energize A": 3,
"Energize B": 4,
"Focus": 21,
"Glide": 6,
"Glitch": 7,
"Hexagon": 8,
Expand All @@ -92,6 +94,7 @@
"Doom": 2,
"Energize A": 3,
"Energize B": 4,
"Focus": 21,
"Glide": 6,
"Glitch": 7,
"Hexagon": 8,
Expand Down Expand Up @@ -160,6 +163,14 @@
"open" : "energize-b-random-include-open",
"close" : "energize-b-random-include-close"
},
"focus-random-include": {
"type" : "custom",
"file" : "CustomWidgets.py",
"widget" : "TwoCheckButtonsWidget",
"description" : "Focus",
"open" : "focus-random-include-open",
"close" : "focus-random-include-close"
},
"glide-random-include": {
"type" : "custom",
"file" : "CustomWidgets.py",
Expand Down Expand Up @@ -253,6 +264,7 @@
"doom-random-include-open" : { "type": "generic", "default": true },
"energize-a-random-include-open" : { "type": "generic", "default": true },
"energize-b-random-include-open" : { "type": "generic", "default": true },
"focus-random-include-open" : { "type": "generic", "default": true },
"glide-random-include-open" : { "type": "generic", "default": true },
"glitch-random-include-open" : { "type": "generic", "default": true },
"hexagon-random-include-open" : { "type": "generic", "default": true },
Expand All @@ -269,6 +281,7 @@
"doom-random-include-close" : { "type": "generic", "default": true },
"energize-a-random-include-close" : { "type": "generic", "default": true },
"energize-b-random-include-close" : { "type": "generic", "default": true },
"focus-random-include-close" : { "type": "generic", "default": true },
"glide-random-include-close" : { "type": "generic", "default": true },
"glitch-random-include-close" : { "type": "generic", "default": true },
"hexagon-random-include-close" : { "type": "generic", "default": true },
Expand All @@ -289,6 +302,7 @@
"Doom": 2,
"Energize A": 3,
"Energize B": 4,
"Focus": 21,
"Glide": 6,
"Glitch": 7,
"Hexagon": 8,
Expand All @@ -312,6 +326,7 @@
"Doom": 2,
"Energize A": 3,
"Energize B": 4,
"Focus": 21,
"Glide": 6,
"Glitch": 7,
"Hexagon": 8,
Expand All @@ -337,6 +352,7 @@
"Doom": 2,
"Energize A": 3,
"Energize B": 4,
"Focus": 21,
"Glide": 6,
"Glitch": 7,
"Hexagon": 8,
Expand Down Expand Up @@ -498,6 +514,37 @@
"default": 1000
},

"focus-blur-amount": {
"type": "scale",
"description" : "Blur Amount",
"min" : 0,
"max" : 100,
"step" : 1,
"dependency" : "effect-selector=21",
"default": 50
},

"focus-blur-quality": {
"type": "scale",
"description" : "Blur Quality",
"min" : 1,
"max" : 10,
"step" : 1,
"dependency" : "effect-selector=21",
"tooltip": "The Quality of the Blur (Setting this too high may increase GPU load and affect performance)",
"default": 3
},

"focus-animation-time": {
"type": "scale",
"description" : "Effect Duration (milliseconds)",
"min" : 100,
"max" : 5000,
"step" : 10,
"dependency" : "effect-selector=21",
"default": 500
},

"glide-scale": {
"type": "scale",
"description" : "Scale",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"uuid": "CinnamonBurnMyWindows@klangman",
"name": "Burn My Windows",
"version": "0.9.4",
"version": "0.9.5",
"description": "Window open/close effects based on the Burn-My-Windows Gnome extension by Schneegans",
"url": "https://github.com/klangman/CinnamonBurnMyWindows",
"website": "https://github.com/klangman/CinnamonBurnMyWindows",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: CinnamonBurnMyWindows@klangman 0.9.3\n"
"Project-Id-Version: CinnamonBurnMyWindows@klangman 0.9.5\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-"
"extensions/issues\n"
"POT-Creation-Date: 2024-09-17 22:20-0400\n"
"POT-Creation-Date: 2024-10-29 21:27-0400\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
Expand All @@ -17,23 +17,23 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#. 6.2/extension.js:207 6.2/extension.js:436
#. 6.2/extension.js:212 6.2/extension.js:443
msgid "Error"
msgstr ""

#. 6.2/extension.js:207
#. 6.2/extension.js:212
msgid "was NOT enabled"
msgstr ""

#. 6.2/extension.js:208
#. 6.2/extension.js:213
msgid "The existing extension"
msgstr ""

#. 6.2/extension.js:208
#. 6.2/extension.js:213
msgid "conflicts with this extension."
msgstr ""

#. 6.2/extension.js:437
#. 6.2/extension.js:444
msgid ""
"The previously focused window is not backed by an application and therefore "
"application specific effects can not be applied to that window"
Expand Down Expand Up @@ -99,6 +99,14 @@ msgstr ""
msgid "Santa is Coming"
msgstr ""

#. 6.2->settings-schema.json->focus-random-include->description
#. 6.2->settings-schema.json->effect-selector->options
#. 6.2->settings-schema.json->open-window-effect->options
#. 6.2->settings-schema.json->close-window-effect->options
#. 6.2/effects/Focus.js:91
msgid "Focus"
msgstr ""

#. 6.2->settings-schema.json->glide-random-include->description
#. 6.2->settings-schema.json->effect-selector->options
#. 6.2->settings-schema.json->open-window-effect->options
Expand Down Expand Up @@ -325,6 +333,7 @@ msgstr ""
#. 6.2->settings-schema.json->doom-animation-time->description
#. 6.2->settings-schema.json->energize-a-animation-time->description
#. 6.2->settings-schema.json->energize-b-animation-time->description
#. 6.2->settings-schema.json->focus-animation-time->description
#. 6.2->settings-schema.json->glide-animation-time->description
#. 6.2->settings-schema.json->glitch-animation-time->description
#. 6.2->settings-schema.json->hexagon-animation-time->description
Expand Down Expand Up @@ -375,6 +384,20 @@ msgstr ""
msgid "Color"
msgstr ""

#. 6.2->settings-schema.json->focus-blur-amount->description
msgid "Blur Amount"
msgstr ""

#. 6.2->settings-schema.json->focus-blur-quality->description
msgid "Blur Quality"
msgstr ""

#. 6.2->settings-schema.json->focus-blur-quality->tooltip
msgid ""
"The Quality of the Blur (Setting this too high may increase GPU load and "
"affect performance)"
msgstr ""

#. 6.2->settings-schema.json->glide-squish->description
msgid "Squish"
msgstr ""
Expand Down
Loading

0 comments on commit c4d51f1

Please sign in to comment.