Add cutefishos scale animation

pull/3/head
cutefishd 4 years ago
parent 06892a8c6d
commit d4f30145ed

@ -17,4 +17,5 @@ install(FILES config/kwinrulesrc DESTINATION /etc/xdg)
install(DIRECTORY scripts/cutefishlauncher DESTINATION /usr/share/kwin/scripts)
install(DIRECTORY scripts/cutefish_squash DESTINATION /usr/share/kwin/effects)
install(DIRECTORY scripts/cutefish_scale DESTINATION /usr/share/kwin/effects)
install(DIRECTORY tabbox/cutefish_thumbnail DESTINATION /usr/share/kwin/tabbox)

@ -4,7 +4,8 @@ slidingpopupsEnabled=true
kwin4_effect_dialogparentEnabled=true
kwin4_effect_fadeEnabled=false
kwin4_effect_scaleEnabled=true
kwin4_effect_scaleEnabled=false
kwin4_effect_grayscaleEnabled = false
kwin4_effect_squashEnabled=false
kwin4_effect_translucencyEnabled=false

@ -85,14 +85,6 @@ void Decoration::paint(QPainter *painter, const QRect &repaintRegion)
if (s->isAlphaChannelSupported() && radiusAvailable()) {
painter->drawRoundedRect(rect(), m_frameRadius, m_frameRadius);
QPen pen;
pen.setWidthF(0.2);
pen.setColor(QColor(255, 255, 255, 255 * 0.8));
painter->setRenderHint(QPainter::Antialiasing);
painter->setPen(pen);
painter->setBrush(Qt::transparent);
painter->drawRoundedRect(QRect(rect().x() + 1, rect().y() + 1, rect().width() - 2, rect().height() - 2), m_frameRadius - 1, m_frameRadius - 1);
} else {
painter->drawRect(rect());
}

@ -0,0 +1,171 @@
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2021 Reven Martin <revenmartin@gmail.com>
SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
"use strict";
var 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",
"cutefish-launcher cutefish-launcher",
"cutefish-statusbar cutefish-statusbar"
];
var scaleEffect = {
loadConfig: function (window) {
var defaultDuration = 200;
var duration = effect.readConfig("Duration", defaultDuration) || defaultDuration;
scaleEffect.duration = animationTime(duration);
scaleEffect.inScale = effect.readConfig("InScale", 0.96);
scaleEffect.inOpacity = effect.readConfig("InOpacity", 0.4);
scaleEffect.outScale = effect.readConfig("OutScale", 0.96);
scaleEffect.outOpacity = effect.readConfig("OutOpacity", 0.0);
},
isScaleWindow: function (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 because it looks very sick.
if (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.x11Client && !window.managed) {
return false;
}
return window.normalWindow || window.dialog;
},
setupForcedRoles: function (window) {
window.setData(Effect.WindowForceBackgroundContrastRole, true);
window.setData(Effect.WindowForceBlurRole, true);
},
cleanupForcedRoles: function (window) {
window.setData(Effect.WindowForceBackgroundContrastRole, null);
window.setData(Effect.WindowForceBlurRole, null);
},
slotWindowAdded: function (window) {
if (effects.hasActiveFullScreenEffect) {
return;
}
if (!scaleEffect.isScaleWindow(window)) {
return;
}
if (!window.visible) {
return;
}
if (!effect.grab(window, Effect.WindowAddedGrabRole)) {
return;
}
scaleEffect.setupForcedRoles(window);
window.scaleInAnimation = animate({
window: window,
curve: QEasingCurve.InOutSine,
duration: scaleEffect.duration,
animations: [
{
type: Effect.Scale,
from: scaleEffect.inScale
},
{
type: Effect.Opacity,
from: scaleEffect.inOpacity
}
]
});
},
slotWindowClosed: function (window) {
if (effects.hasActiveFullScreenEffect) {
return;
}
if (!scaleEffect.isScaleWindow(window)) {
return;
}
if (!window.visible) {
return;
}
if (!effect.grab(window, Effect.WindowClosedGrabRole)) {
return;
}
if (window.scaleInAnimation) {
cancel(window.scaleInAnimation);
delete window.scaleInAnimation;
}
scaleEffect.setupForcedRoles(window);
window.scaleOutAnimation = animate({
window: window,
curve: QEasingCurve.InOutSine,
duration: scaleEffect.duration,
animations: [
{
type: Effect.Scale,
to: scaleEffect.outScale
},
{
type: Effect.Opacity,
to: scaleEffect.outOpacity
}
]
});
},
slotWindowDataChanged: function (window, role) {
if (role == Effect.WindowAddedGrabRole) {
if (window.scaleInAnimation && effect.isGrabbed(window, role)) {
cancel(window.scaleInAnimation);
delete window.scaleInAnimation;
scaleEffect.cleanupForcedRoles(window);
}
} else if (role == Effect.WindowClosedGrabRole) {
if (window.scaleOutAnimation && effect.isGrabbed(window, role)) {
cancel(window.scaleOutAnimation);
delete window.scaleOutAnimation;
scaleEffect.cleanupForcedRoles(window);
}
}
},
init: function () {
scaleEffect.loadConfig();
effect.configChanged.connect(scaleEffect.loadConfig);
effect.animationEnded.connect(scaleEffect.cleanupForcedRoles);
effects.windowAdded.connect(scaleEffect.slotWindowAdded);
effects.windowClosed.connect(scaleEffect.slotWindowClosed);
effects.windowDataChanged.connect(scaleEffect.slotWindowDataChanged);
}
};
scaleEffect.init();

@ -0,0 +1,19 @@
[Desktop Entry]
Name=Scale
Type=Service
X-KDE-ServiceTypes=KWin/Effect,KCModule
X-KDE-PluginInfo-Author=Vlad Zahorodnii
X-KDE-PluginInfo-Email=vlad.zahorodnii@kde.org
X-KDE-PluginInfo-Name=cutefish_scale
X-KDE-PluginInfo-Version=1
X-KDE-PluginInfo-Category=Window Open/Close Animation
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
X-KDE-Ordering=60
X-Plasma-API=javascript
X-Plasma-MainScript=code/main.js
X-KDE-PluginKeyword=cutefish_scale
X-KDE-Library=kcm_kwin4_genericscripted
X-KDE-ParentComponents=cutefish_scale
X-KWin-Config-TranslationDomain=kwin_effects
X-KWin-Exclusive-Category=toplevel-open-close-animation

@ -0,0 +1,33 @@
{
"KPlugin": {
"Authors": [
{
"Email": "vlad.zahorodnii@kde.org",
"Name": "Vlad Zahorodnii"
}
],
"Category": "Window Open/Close Animation",
"Dependencies": [
],
"Description": "Make windows smoothly scale in and out when they are shown or hidden",
"EnabledByDefault": true,
"Icon": "preferences-system-windows-effect-scale",
"Id": "cutefish_scale",
"License": "GPL",
"Name": "Scale",
"ServiceTypes": [
"KWin/Effect",
"KCModule"
],
"Version": "1"
},
"X-KDE-Ordering": "60",
"X-KDE-ParentComponents": [
"cutefish_scale"
],
"X-KDE-PluginKeyword": "cutefish_scale",
"X-KWin-Config-TranslationDomain": "kwin_effects",
"X-KWin-Exclusive-Category": "toplevel-open-close-animation",
"X-Plasma-API": "javascript",
"X-Plasma-MainScript": "code/main.js"
}

@ -1,6 +1,7 @@
/*
This file is part of the KDE project.
SPDX-FileCopyrightText: 2021 Reven Martin <revenmartin@gmail.com>
SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later

Loading…
Cancel
Save