🔧 Add new kwin effect
This commit is contained in:
+29
-18
@@ -22,30 +22,40 @@ cd "$( cd "$( dirname "$0" )" && pwd )" || \
|
|||||||
|
|
||||||
BUILD_DIR="_build"
|
BUILD_DIR="_build"
|
||||||
|
|
||||||
mkdir -p "${BUILD_DIR}"
|
mkdir -p "$BUILD_DIR"
|
||||||
|
|
||||||
# $1: The nick of the effect (e.g. "tv")
|
# $1: The nick of the effect (e.g. "energize-a")
|
||||||
# $2: The name of the effect (e.g. "TV Effect")
|
# $2: The name of the effect (e.g. "Energize A")
|
||||||
# $3: A short description of the effect (e.g. "Make windows close like turning off a TV")
|
# $3: A short description of the effect (e.g. "Beam your windows away")
|
||||||
generate() {
|
generate() {
|
||||||
|
|
||||||
|
# Use the nick for the effect's directory name by replacing dashes by underscoares.
|
||||||
|
DIR_NAME="kwin4_effect_$(echo $1 | tr '-' '_')"
|
||||||
|
|
||||||
|
# Use the name of the effect for the JavaScript class name by removing all spaces.
|
||||||
|
EFFECT_CLASS="BurnMyWindows$(echo $2 | tr -d ' ')"
|
||||||
|
|
||||||
# Create resource directories.
|
# Create resource directories.
|
||||||
mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/shaders"
|
mkdir -p "$BUILD_DIR/$DIR_NAME/contents/shaders"
|
||||||
mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/code"
|
mkdir -p "$BUILD_DIR/$DIR_NAME/contents/code"
|
||||||
mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/config"
|
mkdir -p "$BUILD_DIR/$DIR_NAME/contents/config"
|
||||||
mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/ui"
|
mkdir -p "$BUILD_DIR/$DIR_NAME/contents/ui"
|
||||||
|
|
||||||
cp "kwin4_effect_$1/main.xml" "${BUILD_DIR}/kwin4_effect_$1/contents/config"
|
# Copy the config and ui files.
|
||||||
cp "kwin4_effect_$1/config.ui" "${BUILD_DIR}/kwin4_effect_$1/contents/ui"
|
cp "$DIR_NAME/main.xml" "$BUILD_DIR/$DIR_NAME/contents/config"
|
||||||
|
cp "$DIR_NAME/config.ui" "$BUILD_DIR/$DIR_NAME/contents/ui"
|
||||||
|
|
||||||
perl -pe "s/%LOAD_CONFIG%/$(tr '/' '\f' < "kwin4_effect_$1/loadConfig.js")/g;" \
|
perl -pe "s/%LOAD_CONFIG%/$(tr '/' '\f' < "$DIR_NAME/loadConfig.js")/g;" \
|
||||||
main.js.in | tr '\f' '/' > "${BUILD_DIR}/kwin4_effect_$1/contents/code/main.js"
|
main.js.in | tr '\f' '/' > "$BUILD_DIR/$DIR_NAME/contents/code/main.js"
|
||||||
|
|
||||||
perl -pi -e "s/%NICK%/$1/g;" "${BUILD_DIR}/kwin4_effect_$1/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 -pe "s/%NICK%/$1/g;" metadata.desktop.in > "${BUILD_DIR}/kwin4_effect_$1/metadata.desktop"
|
cp metadata.desktop.in "$BUILD_DIR/$DIR_NAME/metadata.desktop"
|
||||||
perl -pi -e "s/%NAME%/$2/g;" "${BUILD_DIR}/kwin4_effect_$1/metadata.desktop"
|
perl -pi -e "s/%ICON%/$1/g;" "$BUILD_DIR/$DIR_NAME/metadata.desktop"
|
||||||
perl -pi -e "s/%DESCRIPTION%/$3/g;" "${BUILD_DIR}/kwin4_effect_$1/metadata.desktop"
|
perl -pi -e "s/%NAME%/$2/g;" "$BUILD_DIR/$DIR_NAME/metadata.desktop"
|
||||||
|
perl -pi -e "s/%DESCRIPTION%/$3/g;" "$BUILD_DIR/$DIR_NAME/metadata.desktop"
|
||||||
|
perl -pi -e "s/%DIR_NAME%/$DIR_NAME/g;" "$BUILD_DIR/$DIR_NAME/metadata.desktop"
|
||||||
|
|
||||||
{
|
{
|
||||||
echo "#version 140"
|
echo "#version 140"
|
||||||
@@ -55,7 +65,7 @@ generate() {
|
|||||||
echo ""
|
echo ""
|
||||||
cat "../resources/shaders/common.glsl"
|
cat "../resources/shaders/common.glsl"
|
||||||
cat "../resources/shaders/$1.frag"
|
cat "../resources/shaders/$1.frag"
|
||||||
} > "${BUILD_DIR}/kwin4_effect_$1/contents/shaders/$1_core.frag"
|
} > "$BUILD_DIR/$DIR_NAME/contents/shaders/$1_core.frag"
|
||||||
|
|
||||||
{
|
{
|
||||||
echo "#define KWIN_LEGACY"
|
echo "#define KWIN_LEGACY"
|
||||||
@@ -64,8 +74,9 @@ generate() {
|
|||||||
echo ""
|
echo ""
|
||||||
cat "../resources/shaders/common.glsl"
|
cat "../resources/shaders/common.glsl"
|
||||||
cat "../resources/shaders/$1.frag"
|
cat "../resources/shaders/$1.frag"
|
||||||
} > "${BUILD_DIR}/kwin4_effect_$1/contents/shaders/$1.frag"
|
} > "$BUILD_DIR/$DIR_NAME/contents/shaders/$1.frag"
|
||||||
}
|
}
|
||||||
|
|
||||||
generate "tv" "TV Effect" "Make windows close like turning off a TV"
|
generate "tv" "TV Effect" "Make windows close like turning off a TV"
|
||||||
|
generate "energize-a" "Energize A" "Beam your windows away"
|
||||||
# generate "fire" "Fire" "Make windows burn"
|
# generate "fire" "Fire" "Make windows burn"
|
||||||
Executable
+80
@@ -0,0 +1,80 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>BMWtvEffectConfigForm</class>
|
||||||
|
<widget class="QWidget" name="BMWtvEffectConfigForm">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>498</width>
|
||||||
|
<height>451</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Duration:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Color:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>kcfg_Color</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="KColorCombo" name="kcfg_Color">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QSpinBox" name="kcfg_Duration">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="specialValueText">
|
||||||
|
<string>Default</string>
|
||||||
|
</property>
|
||||||
|
<property name="suffix">
|
||||||
|
<string> milliseconds</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>9999</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>KColorCombo</class>
|
||||||
|
<extends>QComboBox</extends>
|
||||||
|
<header>kcolorcombo.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources />
|
||||||
|
<connections />
|
||||||
|
</ui>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
loadConfig() {
|
||||||
|
const defaultDuration = 2000;
|
||||||
|
const duration = effect.readConfig('Duration', defaultDuration) || defaultDuration;
|
||||||
|
this.duration = animationTime(duration);
|
||||||
|
|
||||||
|
effect.setUniform(this.shader, 'uColor', effect.readConfig('Color', 'white'));
|
||||||
|
effect.setUniform(this.shader, 'uScale', effect.readConfig('Scale', 1.0));
|
||||||
|
}
|
||||||
Executable
+16
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
||||||
|
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
|
||||||
|
<kcfgfile name="" />
|
||||||
|
<group name="">
|
||||||
|
<entry name="Duration" type="UInt">
|
||||||
|
<default>0</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="Scale" type="Double">
|
||||||
|
<default>1</default>
|
||||||
|
</entry>
|
||||||
|
<entry name="Color" type="Color">
|
||||||
|
<default>255, 200, 50</default>
|
||||||
|
</entry>
|
||||||
|
</group>
|
||||||
|
</kcfg>
|
||||||
+5
-5
@@ -17,7 +17,7 @@ const blacklist = [
|
|||||||
"ksplashqml ksplashqml"
|
"ksplashqml ksplashqml"
|
||||||
];
|
];
|
||||||
|
|
||||||
class BMW%NICK%Effect {
|
class %EFFECT_CLASS% {
|
||||||
constructor() {
|
constructor() {
|
||||||
effect.configChanged.connect(this.loadConfig.bind(this));
|
effect.configChanged.connect(this.loadConfig.bind(this));
|
||||||
effect.animationEnded.connect(this.cleanupForcedRoles.bind(this));
|
effect.animationEnded.connect(this.cleanupForcedRoles.bind(this));
|
||||||
@@ -25,7 +25,7 @@ class BMW%NICK%Effect {
|
|||||||
effects.windowClosed.connect(this.slotWindowClosed.bind(this));
|
effects.windowClosed.connect(this.slotWindowClosed.bind(this));
|
||||||
effects.windowDataChanged.connect(this.slotWindowDataChanged.bind(this));
|
effects.windowDataChanged.connect(this.slotWindowDataChanged.bind(this));
|
||||||
|
|
||||||
this.shader = effect.addFragmentShader(Effect.MapTexture, "%NICK%.frag");
|
this.shader = effect.addFragmentShader(Effect.MapTexture, "%SHADER_NAME%.frag");
|
||||||
|
|
||||||
this.loadConfig();
|
this.loadConfig();
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ class BMW%NICK%Effect {
|
|||||||
if (effects.hasActiveFullScreenEffect) {
|
if (effects.hasActiveFullScreenEffect) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!BMW%NICK%Effect.isScaleWindow(window)) {
|
if (!%EFFECT_CLASS%.isScaleWindow(window)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!window.visible) {
|
if (!window.visible) {
|
||||||
@@ -122,7 +122,7 @@ class BMW%NICK%Effect {
|
|||||||
if (effects.hasActiveFullScreenEffect) {
|
if (effects.hasActiveFullScreenEffect) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!BMW%NICK%Effect.isScaleWindow(window)) {
|
if (!%EFFECT_CLASS%.isScaleWindow(window)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!window.visible || window.skipsCloseAnimation) {
|
if (!window.visible || window.skipsCloseAnimation) {
|
||||||
@@ -176,4 +176,4 @@ class BMW%NICK%Effect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new BMW%NICK%Effect();
|
new %EFFECT_CLASS%();
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Name=%NAME%
|
Name=%NAME%
|
||||||
Icon=preferences-system-windows-effect-%NICK%
|
Icon=preferences-system-windows-effect-%ICON%
|
||||||
Comment=%DESCRIPTION%
|
Comment=%DESCRIPTION%
|
||||||
|
|
||||||
Type=Service
|
Type=Service
|
||||||
X-KDE-ServiceTypes=KWin/Effect,KCModule
|
X-KDE-ServiceTypes=KWin/Effect,KCModule
|
||||||
X-KDE-PluginInfo-Author=Vlad Zahorodnii, Martin Flöser, Simon Schneegans
|
X-KDE-PluginInfo-Author=Vlad Zahorodnii, Martin Flöser, Simon Schneegans
|
||||||
X-KDE-PluginInfo-Email=vlad.zahorodnii@kde.org, mgraesslin@kde.org, code@simonschneegans.de
|
X-KDE-PluginInfo-Email=vlad.zahorodnii@kde.org, mgraesslin@kde.org, code@simonschneegans.de
|
||||||
X-KDE-PluginInfo-Name=kwin4_effect_%NICK%
|
X-KDE-PluginInfo-Name=%DIR_NAME%
|
||||||
X-KDE-PluginInfo-Version=1
|
X-KDE-PluginInfo-Version=1
|
||||||
X-KDE-PluginInfo-Category=Window Open/Close Animation
|
X-KDE-PluginInfo-Category=Window Open/Close Animation
|
||||||
X-KDE-PluginInfo-License=GPLv3
|
X-KDE-PluginInfo-License=GPLv3
|
||||||
@@ -15,7 +15,7 @@ X-KDE-PluginInfo-EnabledByDefault=false
|
|||||||
X-KDE-Ordering=60
|
X-KDE-Ordering=60
|
||||||
X-Plasma-API=javascript
|
X-Plasma-API=javascript
|
||||||
X-Plasma-MainScript=code/main.js
|
X-Plasma-MainScript=code/main.js
|
||||||
X-KDE-PluginKeyword=kwin4_effect_%NICK%
|
X-KDE-PluginKeyword=%DIR_NAME%
|
||||||
X-KDE-Library=kcm_kwin4_genericscripted
|
X-KDE-Library=kcm_kwin4_genericscripted
|
||||||
X-KWin-Config-TranslationDomain=kwin_effects
|
X-KWin-Config-TranslationDomain=kwin_effects
|
||||||
X-KWin-Exclusive-Category=toplevel-open-close-animation
|
X-KWin-Exclusive-Category=toplevel-open-close-animation
|
||||||
|
|||||||
Reference in New Issue
Block a user