🎉 Add some initial kwin files
This commit is contained in:
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
# -------------------------------------------------------------------------------------- #
|
||||
# ) ( #
|
||||
# ( /( ( ( ) ( ( ( ( )\ ) ( ( #
|
||||
# )\()) ))\ )( ( ( )\ ) )\))( )\ ( (()/( ( )\))( ( #
|
||||
# ((_)\ /((_|()\ )\ ) )\ '(()/( ((_)()((_) )\ ) ((_)))\((_)()\ )\ #
|
||||
# | |(_|_))( ((_)_(_/( _((_)) )(_)) _(()((_|_)_(_/( _| |((_)(()((_|(_) #
|
||||
# | '_ \ || | '_| ' \)) | ' \()| || | \ V V / | ' \)) _` / _ \ V V (_-< #
|
||||
# |_.__/\_,_|_| |_||_| |_|_|_| \_, | \_/\_/|_|_||_|\__,_\___/\_/\_//__/ #
|
||||
# |__/ #
|
||||
# Copyright (c) 2021 Simon Schneegans #
|
||||
# Released under the GPLv3 or later. See LICENSE file for details. #
|
||||
# -------------------------------------------------------------------------------------- #
|
||||
|
||||
# Exit the script when one command fails.
|
||||
set -e
|
||||
|
||||
# Go to the script's directory.
|
||||
cd "$( cd "$( dirname "$0" )" && pwd )" || \
|
||||
{ echo "ERROR: Could not find kwin directory."; exit 1; }
|
||||
|
||||
BUILD_DIR="_build"
|
||||
|
||||
mkdir -p "${BUILD_DIR}"
|
||||
|
||||
generate() {
|
||||
cp -r "kwin4_effect_$1" "${BUILD_DIR}"
|
||||
|
||||
mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/shaders"
|
||||
mkdir -p "${BUILD_DIR}/kwin4_effect_$1/contents/code"
|
||||
|
||||
sed -e "s;%NICK%;$1;g" -e "s;%NAME%;$2;g" -e "s;%DESCRIPTION%;$3;g" \
|
||||
metadata.desktop.in > "${BUILD_DIR}/kwin4_effect_$1/metadata.desktop"
|
||||
|
||||
sed -e "s;%NICK%;$1;g" -e "s;%NAME%;$2;g" -e "s;%DESCRIPTION%;$3;g" \
|
||||
main.js.in > "${BUILD_DIR}/kwin4_effect_$1/contents/code/main.js"
|
||||
|
||||
}
|
||||
|
||||
generate "tv" "TV" "Make windows close like turning off a TV"
|
||||
# generate "fire" "Fire" "Make windows burn"
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?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="Color" type="Color">
|
||||
<default>128,128,128</default>
|
||||
</entry>
|
||||
</group>
|
||||
</kcfg>
|
||||
Executable
+80
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TvEffectConfigForm</class>
|
||||
<widget class="QWidget" name="TvEffectConfigForm">
|
||||
<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>
|
||||
Executable
+172
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
SPDX-FileCopyrightText: 2018, 2021, 2022 Vlad Zahorodnii <vlad.zahorodnii@kde.org>, Martin Flöser <mgraesslin@kde.org>, Simon Schneegans
|
||||
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const blacklist = [
|
||||
// The logout screen has to be animated only by the logout effect.
|
||||
"ksmserver ksmserver",
|
||||
"ksmserver-logout-greeter ksmserver-logout-greeter",
|
||||
|
||||
// KDE Plasma splash screen has to be animated only by the login effect.
|
||||
"ksplashqml ksplashqml"
|
||||
];
|
||||
|
||||
class Effect {
|
||||
constructor() {
|
||||
effect.configChanged.connect(this.loadConfig.bind(this));
|
||||
effect.animationEnded.connect(this.cleanupForcedRoles.bind(this));
|
||||
effects.windowAdded.connect(this.slotWindowAdded.bind(this));
|
||||
effects.windowClosed.connect(this.slotWindowClosed.bind(this));
|
||||
effects.windowDataChanged.connect(this.slotWindowDataChanged.bind(this));
|
||||
|
||||
this.shader = effect.addShader(Effect.MapTexture, "%NICK%.frag");
|
||||
|
||||
this.loadConfig();
|
||||
}
|
||||
|
||||
loadConfig() {
|
||||
const defaultDuration = 1000;
|
||||
const duration = effect.readConfig("Duration", defaultDuration) || defaultDuration;
|
||||
this.duration = animationTime(duration);
|
||||
|
||||
effect.setUniform(this.shader, "uEffectColor", effect.readConfig("Color", "white"));
|
||||
}
|
||||
|
||||
static isScaleWindow(window) {
|
||||
// We don't want to animate most of plasmashell's windows, yet, some
|
||||
// of them we want to, for example, Task Manager Settings window.
|
||||
// The problem is that all those window share single window class.
|
||||
// So, the only way to decide whether a window should be animated is
|
||||
// to use a heuristic: if a window has decoration, then it's most
|
||||
// likely a dialog or a settings window so we have to animate it.
|
||||
if (window.windowClass == "plasmashell plasmashell"
|
||||
|| window.windowClass == "plasmashell org.kde.plasmashell") {
|
||||
return window.hasDecoration;
|
||||
}
|
||||
|
||||
if (blacklist.indexOf(window.windowClass) != -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (window.hasDecoration) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Don't animate combobox popups, tooltips, popup menus, etc.
|
||||
if (window.popupWindow) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Dont't animate the outline and the screenlocker as it looks bad.
|
||||
if (window.lockScreen || window.outline) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Override-redirect windows are usually used for user interface
|
||||
// concepts that are not expected to be animated by this effect.
|
||||
if (!window.managed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return window.normalWindow || window.dialog;
|
||||
}
|
||||
|
||||
setupForcedRoles(window) {
|
||||
window.setData(Effect.WindowForceBackgroundContrastRole, true);
|
||||
window.setData(Effect.WindowForceBlurRole, true);
|
||||
}
|
||||
|
||||
cleanupForcedRoles(window) {
|
||||
window.setData(Effect.WindowForceBackgroundContrastRole, null);
|
||||
window.setData(Effect.WindowForceBlurRole, null);
|
||||
}
|
||||
|
||||
slotWindowAdded(window) {
|
||||
if (effects.hasActiveFullScreenEffect) {
|
||||
return;
|
||||
}
|
||||
if (!Effect.isScaleWindow(window)) {
|
||||
return;
|
||||
}
|
||||
if (!window.visible) {
|
||||
return;
|
||||
}
|
||||
if (effect.isGrabbed(window, Effect.WindowAddedGrabRole)) {
|
||||
return;
|
||||
}
|
||||
this.setupForcedRoles(window);
|
||||
window.scaleInAnimation = animate({
|
||||
window: window,
|
||||
curve: QEasingCurve.Linear,
|
||||
duration: this.duration,
|
||||
animations: [
|
||||
{
|
||||
type: Effect.ShaderUniform,
|
||||
shader: this.shader,
|
||||
uniform: "uForOpening",
|
||||
from: 1.0,
|
||||
to: 1.0
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
slotWindowClosed(window) {
|
||||
if (effects.hasActiveFullScreenEffect) {
|
||||
return;
|
||||
}
|
||||
if (!Effect.isScaleWindow(window)) {
|
||||
return;
|
||||
}
|
||||
if (!window.visible || window.skipsCloseAnimation) {
|
||||
return;
|
||||
}
|
||||
if (effect.isGrabbed(window, Effect.WindowClosedGrabRole)) {
|
||||
return;
|
||||
}
|
||||
if (window.scaleInAnimation) {
|
||||
cancel(window.scaleInAnimation);
|
||||
delete window.scaleInAnimation;
|
||||
}
|
||||
this.setupForcedRoles(window);
|
||||
window.scaleOutAnimation = animate({
|
||||
window: window,
|
||||
curve: QEasingCurve.Linear,
|
||||
duration: this.duration,
|
||||
animations: [
|
||||
{
|
||||
type: Effect.ShaderUniform,
|
||||
shader: this.shader,
|
||||
uniform: "uForOpening",
|
||||
from: 0.0,
|
||||
to: 0.0
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
slotWindowDataChanged(window, role) {
|
||||
if (role == Effect.WindowAddedGrabRole) {
|
||||
if (window.scaleInAnimation && effect.isGrabbed(window, role)) {
|
||||
cancel(window.scaleInAnimation);
|
||||
delete window.scaleInAnimation;
|
||||
this.cleanupForcedRoles(window);
|
||||
}
|
||||
} else if (role == Effect.WindowClosedGrabRole) {
|
||||
if (window.scaleOutAnimation && effect.isGrabbed(window, role)) {
|
||||
cancel(window.scaleOutAnimation);
|
||||
delete window.scaleOutAnimation;
|
||||
this.cleanupForcedRoles(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new Effect();
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
[Desktop Entry]
|
||||
Name=%NAME%
|
||||
Icon=preferences-system-windows-effect-%NICK%
|
||||
Comment=%DESCRIPTION%
|
||||
|
||||
Type=Service
|
||||
X-KDE-ServiceTypes=KWin/Effect,KCModule
|
||||
X-KDE-PluginInfo-Author=Vlad Zahorodnii, Martin Flöser, Simon Schneegans
|
||||
X-KDE-PluginInfo-Email=vlad.zahorodnii@kde.org, mgraesslin@kde.org
|
||||
X-KDE-PluginInfo-Name=kwin4_effect_%NICK%
|
||||
X-KDE-PluginInfo-Version=1
|
||||
X-KDE-PluginInfo-Category=Window Open/Close Animation
|
||||
X-KDE-PluginInfo-License=GPLv3
|
||||
X-KDE-PluginInfo-EnabledByDefault=false
|
||||
X-KDE-Ordering=60
|
||||
X-Plasma-API=javascript
|
||||
X-Plasma-MainScript=code/main.js
|
||||
X-KDE-PluginKeyword=kwin4_effect_%NICK%
|
||||
X-KDE-Library=kcm_kwin4_genericscripted
|
||||
X-KWin-Config-TranslationDomain=kwin_effects
|
||||
X-KWin-Exclusive-Category=toplevel-open-close-animation
|
||||
Reference in New Issue
Block a user