From 458a382f16aa76e4ca4b7f16a8e353cd343a8892 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Mon, 10 Jan 2022 06:02:21 +0100 Subject: [PATCH] :memo: Add even more comments --- src/FireEffect.js | 13 +++++++++---- src/MatrixEffect.js | 13 +++++++++---- src/TRexEffect.js | 13 +++++++++---- src/TVEffect.js | 12 ++++++++---- src/utils.js | 7 +++++++ 5 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/FireEffect.js b/src/FireEffect.js index 01b676c..e0c5458 100644 --- a/src/FireEffect.js +++ b/src/FireEffect.js @@ -57,7 +57,9 @@ var FireEffect = class FireEffect { // -------------------------------------------------------------------- API for prefs.js - // This is called by the preferences dialog. + // 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 initPreferences(dialog) { // Add the settings page to the builder. @@ -95,13 +97,14 @@ var FireEffect = class FireEffect { // ---------------------------------------------------------------- API for extension.js - + // This is called from extension.js whenever a window is closed with this effect. static createShader(settings) { return new FireShader(settings); } - // If there's a transition in progress, we re-target these transitions so that the - // window is neither scaled nor faded. + // This is also called from extension.js. It is used to tweak the ongoing transitions of + // the actor - usually windows are faded to transparency and scaled down slightly by + // GNOME Shell. Here, we modify this behavior as well as the transition duration. static tweakTransitions(actor, settings) { const animationTime = settings.get_int('fire-animation-time'); @@ -113,6 +116,8 @@ var FireEffect = class FireEffect { } }; + // If there's a transition in progress, we re-target these transitions so that the + // window is neither scaled nor faded. tweakTransition('opacity', 255); tweakTransition('scale-x', 1); tweakTransition('scale-y', 1); diff --git a/src/MatrixEffect.js b/src/MatrixEffect.js index 0584fa8..bd23bd2 100644 --- a/src/MatrixEffect.js +++ b/src/MatrixEffect.js @@ -57,7 +57,9 @@ var MatrixEffect = class MatrixEffect { // -------------------------------------------------------------------- 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 initPreferences(dialog) { // Add the settings page to the builder. @@ -79,13 +81,14 @@ var MatrixEffect = class MatrixEffect { // ---------------------------------------------------------------- API for extension.js - + // This is called from extension.js whenever a window is closed with this effect. static createShader(settings) { return new MatrixShader(settings); } - // If there's a transition in progress, we re-target these transitions so that the - // window is neither scaled nor faded. + // This is also called from extension.js. It is used to tweak the ongoing transitions of + // the actor - usually windows are faded to transparency and scaled down slightly by + // GNOME Shell. Here, we modify this behavior as well as the transition duration. static tweakTransitions(actor, settings) { const animationTime = settings.get_int('matrix-animation-time'); @@ -97,6 +100,8 @@ var MatrixEffect = class MatrixEffect { } }; + // If there's a transition in progress, we re-target these transitions so that the + // window is neither scaled nor faded. tweakTransition('opacity', 255); tweakTransition('scale-x', 1); tweakTransition('scale-y', 1); diff --git a/src/TRexEffect.js b/src/TRexEffect.js index 1c62368..9850601 100644 --- a/src/TRexEffect.js +++ b/src/TRexEffect.js @@ -55,6 +55,9 @@ var TRexEffect = class TRexEffect { // -------------------------------------------------------------------- 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 initPreferences(dialog) { // Add the settings page to the builder. @@ -76,13 +79,14 @@ var TRexEffect = class TRexEffect { // ---------------------------------------------------------------- API for extension.js - + // This is called from extension.js whenever a window is closed with this effect. static createShader(settings) { return new TRexShader(settings); } - // If there's a transition in progress, we re-target these transitions so that the - // window is neither scaled nor faded. + // This is also called from extension.js. It is used to tweak the ongoing transitions of + // the actor - usually windows are faded to transparency and scaled down slightly by + // GNOME Shell. Here, we modify this behavior as well as the transition duration. static tweakTransitions(actor, settings) { const animationTime = settings.get_int('trex-animation-time'); @@ -94,8 +98,9 @@ var TRexEffect = class TRexEffect { } }; + // For this effect, we slightly increase the window's scale as part of the warp + // effect. const warp = 0.5 * settings.get_double('claw-scratch-warp'); - tweakTransition('opacity', 255); tweakTransition('scale-x', 1.0 + warp); tweakTransition('scale-y', 1.0 + warp); diff --git a/src/TVEffect.js b/src/TVEffect.js index f44faec..b38f523 100644 --- a/src/TVEffect.js +++ b/src/TVEffect.js @@ -55,7 +55,9 @@ var TVEffect = class TVEffect { // -------------------------------------------------------------------- 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 initPreferences(dialog) { // Add the settings page to the builder. @@ -74,13 +76,14 @@ var TVEffect = class TVEffect { // ---------------------------------------------------------------- API for extension.js - + // This is called from extension.js whenever a window is closed with this effect. static createShader(settings) { return new TVShader(settings); } - // If there's a transition in progress, we re-target these transitions so that the - // window is neither scaled nor faded. + // This is also called from extension.js. It is used to tweak the ongoing transitions of + // the actor - usually windows are faded to transparency and scaled down slightly by + // GNOME Shell. Here, we modify this behavior as well as the transition duration. static tweakTransitions(actor, settings) { const animationTime = settings.get_int('tv-animation-time'); @@ -92,6 +95,7 @@ var TVEffect = class TVEffect { } }; + // For this effect, we scale the window only vertically. tweakTransition('opacity', 255); tweakTransition('scale-x', 1); tweakTransition('scale-y', 0.5); diff --git a/src/utils.js b/src/utils.js index 11ef4f5..e230444 100644 --- a/src/utils.js +++ b/src/utils.js @@ -46,18 +46,25 @@ function isGTK4() { return Gtk.get_major_version() == 4; } +// This method returns 'gtk3' or 'gtk4' depending on the currently used gtk version. function getGTKString() { return isGTK4() ? 'gtk4' : 'gtk3'; } +// This method returns true if called in GNOME Shell's process, false if called in the +// preferences process. function isInShellProcess() { return window.global && global.stage; } +// This method returns true if the current GNOME Shell version matches the given +// arguments. function shellVersionIs(major, minor) { return GS_MAJOR == major && GS_MINOR == minor; } +// This method returns true if the current GNOME Shell version is at least as high as the +// given arguments. function shellVersionIsAtLeast(major, minor) { if (GS_MAJOR > major) { return true;