🔧 Tweak kwin build process
This commit is contained in:
+30
-8
@@ -41,15 +41,34 @@ generate() {
|
||||
mkdir -p "$BUILD_DIR/$DIR_NAME/contents/config"
|
||||
mkdir -p "$BUILD_DIR/$DIR_NAME/contents/ui"
|
||||
|
||||
# Copy the config and ui files.
|
||||
cp "$DIR_NAME/main.xml" "$BUILD_DIR/$DIR_NAME/contents/config"
|
||||
cp "$DIR_NAME/config.ui" "$BUILD_DIR/$DIR_NAME/contents/ui"
|
||||
# Copy the config file if it exists.
|
||||
if [ -f "$DIR_NAME/main.xml" ]; then
|
||||
cp "$DIR_NAME/main.xml" "$BUILD_DIR/$DIR_NAME/contents/config"
|
||||
fi
|
||||
|
||||
perl -pe "s/%LOAD_CONFIG%/$(tr '/' '\f' < "$DIR_NAME/loadConfig.js")/g;" \
|
||||
main.js.in | tr '\f' '/' > "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
|
||||
# Copy the ui file if it exists.
|
||||
if [ -f "$DIR_NAME/config.ui" ]; then
|
||||
cp "$DIR_NAME/config.ui" "$BUILD_DIR/$DIR_NAME/contents/ui"
|
||||
fi
|
||||
|
||||
perl -pi -e "s/%EFFECT_CLASS%/$EFFECT_CLASS/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
|
||||
perl -pi -e "s/%SHADER_NAME%/$1/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
|
||||
|
||||
ON_SETTINGS_CHANGE=""
|
||||
ON_ANIMATION_BEGIN=""
|
||||
|
||||
if [ -f "$DIR_NAME/onSettingsChanged.js" ]; then
|
||||
ON_SETTINGS_CHANGE=$(tr '/' '\f' < "$DIR_NAME/onSettingsChanged.js")
|
||||
fi
|
||||
|
||||
if [ -f "$DIR_NAME/onAnimationBegin.js" ]; then
|
||||
ON_ANIMATION_BEGIN=$(tr '/' '\f' < "$DIR_NAME/onAnimationBegin.js")
|
||||
fi
|
||||
|
||||
cp main.js.in "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
|
||||
perl -pi -e "s/%ON_SETTINGS_CHANGE%/$ON_SETTINGS_CHANGE/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
|
||||
perl -pi -e "s/%ON_ANIMATION_BEGIN%/$ON_ANIMATION_BEGIN/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
|
||||
perl -pi -e "s/%EFFECT_CLASS%/$EFFECT_CLASS/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
|
||||
perl -pi -e "s/%SHADER_NAME%/$1/g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
|
||||
perl -pi -e "s/\f/\//g;" "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
|
||||
|
||||
cp metadata.desktop.in "$BUILD_DIR/$DIR_NAME/metadata.desktop"
|
||||
perl -pi -e "s/%ICON%/$1/g;" "$BUILD_DIR/$DIR_NAME/metadata.desktop"
|
||||
@@ -75,9 +94,12 @@ generate() {
|
||||
cat "../resources/shaders/common.glsl"
|
||||
cat "../resources/shaders/$1.frag"
|
||||
} > "$BUILD_DIR/$DIR_NAME/contents/shaders/$1.frag"
|
||||
|
||||
# If clang-format is installed, try to beauty the code a bit.
|
||||
}
|
||||
|
||||
generate "tv" "TV Effect" "Make windows close like turning off a TV"
|
||||
generate "energize-a" "Energize A" "Beam your windows away"
|
||||
generate "energize-b" "Energize B" "Using different transporter technology results in an alternative visual effect"
|
||||
generate "hexagon" "Hexagon" "With glowing lines and hexagon-shaped tiles, this effect looks very sci-fi"
|
||||
generate "tv" "TV Effect" "Make windows close like turning off a TV"
|
||||
# generate "fire" "Fire" "Make windows burn"
|
||||
@@ -1,5 +0,0 @@
|
||||
loadConfig() {
|
||||
this.duration = animationTime(effect.readConfig('Duration', 1000));
|
||||
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
|
||||
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// This part is automatically included in the effect's source during the build process.
|
||||
// The code below is called whenever the user changes something in the configuration of
|
||||
// the effect.
|
||||
|
||||
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
|
||||
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
|
||||
@@ -1,5 +0,0 @@
|
||||
loadConfig() {
|
||||
this.duration = animationTime(effect.readConfig('Duration', 1000));
|
||||
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
|
||||
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// This part is automatically included in the effect's source during the build process.
|
||||
// The code below is called whenever the user changes something in the configuration of
|
||||
// the effect.
|
||||
|
||||
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
|
||||
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
|
||||
@@ -1,4 +0,0 @@
|
||||
loadConfig() {
|
||||
this.duration = animationTime(effect.readConfig('Duration', 1000));
|
||||
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// This part is automatically included in the effect's source during the build process.
|
||||
// The code below is called whenever the user changes something in the configuration of
|
||||
// the effect.
|
||||
|
||||
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
|
||||
+20
-19
@@ -30,7 +30,12 @@ class %EFFECT_CLASS% {
|
||||
this.loadConfig();
|
||||
}
|
||||
|
||||
%LOAD_CONFIG%
|
||||
loadConfig() {
|
||||
this.duration = animationTime(effect.readConfig('Duration', 1000));
|
||||
effect.setUniform(this.shader, 'uDuration', this.duration * 0.001);
|
||||
|
||||
%ON_SETTINGS_CHANGE%
|
||||
}
|
||||
|
||||
static isScaleWindow(window) {
|
||||
// We don't want to animate most of plasmashell's windows, yet, some
|
||||
@@ -95,6 +100,11 @@ class %EFFECT_CLASS% {
|
||||
return;
|
||||
}
|
||||
this.setupForcedRoles(window);
|
||||
|
||||
effect.setUniform(this.shader, 'uForOpening', 1.0);
|
||||
|
||||
%ON_ANIMATION_BEGIN%
|
||||
|
||||
window.scaleInAnimation = animate({
|
||||
window: window,
|
||||
curve: QEasingCurve.Linear,
|
||||
@@ -103,16 +113,9 @@ class %EFFECT_CLASS% {
|
||||
{
|
||||
type: Effect.ShaderUniform,
|
||||
fragmentShader: this.shader,
|
||||
uniform: "forOpening",
|
||||
from: 1.0,
|
||||
uniform: "uProgress",
|
||||
from: 0.0,
|
||||
to: 1.0
|
||||
},
|
||||
{
|
||||
type: Effect.ShaderUniform,
|
||||
fragmentShader: this.shader,
|
||||
uniform: "uDuration",
|
||||
from: this.duration * 0.001,
|
||||
to: this.duration * 0.001
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -136,6 +139,11 @@ class %EFFECT_CLASS% {
|
||||
delete window.scaleInAnimation;
|
||||
}
|
||||
this.setupForcedRoles(window);
|
||||
|
||||
effect.setUniform(this.shader, 'uForOpening', 0.0);
|
||||
|
||||
%ON_ANIMATION_BEGIN%
|
||||
|
||||
window.scaleOutAnimation = animate({
|
||||
window: window,
|
||||
curve: QEasingCurve.Linear,
|
||||
@@ -144,16 +152,9 @@ class %EFFECT_CLASS% {
|
||||
{
|
||||
type: Effect.ShaderUniform,
|
||||
fragmentShader: this.shader,
|
||||
uniform: "forOpening",
|
||||
uniform: "uProgress",
|
||||
from: 0.0,
|
||||
to: 0.0
|
||||
},
|
||||
{
|
||||
type: Effect.ShaderUniform,
|
||||
fragmentShader: this.shader,
|
||||
uniform: "uDuration",
|
||||
from: this.duration * 0.001,
|
||||
to: this.duration * 0.001
|
||||
to: 1.0
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -33,23 +33,22 @@
|
||||
// vec4 getInputColor(vec2 coords)
|
||||
// void setOutputColor(vec4 outColor)
|
||||
|
||||
uniform bool uForOpening;
|
||||
uniform float uProgress;
|
||||
uniform float uDuration;
|
||||
|
||||
#if defined(KWIN) // --------------------------------------------------------------------
|
||||
|
||||
uniform float forOpening;
|
||||
uniform sampler2D sampler;
|
||||
uniform float uDuration;
|
||||
uniform int textureWidth;
|
||||
uniform int textureHeight;
|
||||
uniform float animationProgress;
|
||||
|
||||
in vec2 texcoord0;
|
||||
out vec4 fragColor;
|
||||
|
||||
vec2 uSize = vec2(textureWidth, textureHeight);
|
||||
bool uForOpening = forOpening == 1.0;
|
||||
vec2 iTexCoord = vec2(texcoord0.x, 1.0 - texcoord0.y);
|
||||
float uProgress = animationProgress;
|
||||
float uPadding = 0.0;
|
||||
vec2 uSize = vec2(textureWidth, textureHeight);
|
||||
vec2 iTexCoord = vec2(texcoord0.x, 1.0 - texcoord0.y);
|
||||
float uPadding = 0.0;
|
||||
|
||||
vec4 getInputColor(vec2 coords) {
|
||||
vec4 color = texture2D(sampler, vec2(coords.x, 1.0 - coords.y));
|
||||
@@ -67,20 +66,15 @@ void setOutputColor(vec4 outColor) {
|
||||
|
||||
#elif defined(KWIN_LEGACY) // -----------------------------------------------------------
|
||||
|
||||
uniform float forOpening;
|
||||
uniform sampler2D sampler;
|
||||
uniform float uDuration;
|
||||
uniform int textureWidth;
|
||||
uniform int textureHeight;
|
||||
uniform float animationProgress;
|
||||
|
||||
varying vec2 texcoord0;
|
||||
|
||||
vec2 uSize = vec2(textureWidth, textureHeight);
|
||||
bool uForOpening = forOpening == 1.0;
|
||||
vec2 iTexCoord = vec2(texcoord0.x, 1.0 - texcoord0.y);
|
||||
float uProgress = animationProgress;
|
||||
float uPadding = 0.0;
|
||||
vec2 uSize = vec2(textureWidth, textureHeight);
|
||||
vec2 iTexCoord = vec2(texcoord0.x, 1.0 - texcoord0.y);
|
||||
float uPadding = 0.0;
|
||||
|
||||
vec4 getInputColor(vec2 coords) {
|
||||
vec4 color = texture2D(sampler, vec2(coords.x, 1.0 - coords.y));
|
||||
@@ -99,10 +93,7 @@ void setOutputColor(vec4 outColor) {
|
||||
#else // GNOME --------------------------------------------------------------------------
|
||||
|
||||
// On GNOME, the uniforms are just normal uniforms.
|
||||
uniform bool uForOpening;
|
||||
uniform sampler2D uTexture;
|
||||
uniform float uProgress;
|
||||
uniform float uDuration;
|
||||
uniform vec2 uSize;
|
||||
uniform float uPadding;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user