From cb10908fc0b9321addd377f054ff0634dea4e04a Mon Sep 17 00:00:00 2001 From: Reion Wong Date: Tue, 1 Sep 2026 08:14:30 -0400 Subject: [PATCH] refactor(kwin): use Magic Lamp for minimize animation --- CMakeLists.txt | 1 - README.md | 2 +- config/kwinrc | 3 +- scripts/cutefish_squash/contents/code/main.js | 170 ------------------ scripts/cutefish_squash/metadata.json | 22 --- 5 files changed, 2 insertions(+), 196 deletions(-) delete mode 100644 scripts/cutefish_squash/contents/code/main.js delete mode 100644 scripts/cutefish_squash/metadata.json diff --git a/CMakeLists.txt b/CMakeLists.txt index dfbeb78..86e2021 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,6 @@ install(FILES config/kglobalshortcutsrc DESTINATION "${CUTEFISH_KWIN_CONFIG_DIR} install(FILES config/kwinrc DESTINATION "${CUTEFISH_KWIN_CONFIG_DIR}") install(DIRECTORY scripts/cutefishlauncher DESTINATION "${CUTEFISH_KWIN_DATA_DIR}/scripts") -install(DIRECTORY scripts/cutefish_squash DESTINATION "${CUTEFISH_KWIN_DATA_DIR}/effects") install(DIRECTORY scripts/cutefish_scale DESTINATION "${CUTEFISH_KWIN_DATA_DIR}/effects") install(DIRECTORY scripts/cutefish_popups DESTINATION "${CUTEFISH_KWIN_DATA_DIR}/effects") install(DIRECTORY tabbox/cutefish_thumbnail DESTINATION "${CUTEFISH_KWIN_DATA_DIR}/tabbox") diff --git a/README.md b/README.md index aa3660e..2329ba2 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ CutefishOS. The plugins target KWin 6 (Plasma 6 / KDecoration3). | --- | --- | | `plugins/decoration` | KDecoration3 window decoration (installed as `org.cutefish.decoration`) | | `plugins/roundedwindow` | Rounded corners effect (`cutefish_roundedwindow`) | -| `scripts/` | JavaScript effects and scripts (`cutefish_scale`, `cutefish_squash`, `cutefish_popups`, `cutefishlauncher`) | +| `scripts/` | JavaScript effects and scripts (`cutefish_scale`, `cutefish_popups`, `cutefishlauncher`) | | `tabbox/` | `cutefish_thumbnail` window switcher layout | | `config/` | System-wide KWin defaults installed into `/etc/xdg` | diff --git a/config/kwinrc b/config/kwinrc index d291ba2..2a6c203 100644 --- a/config/kwinrc +++ b/config/kwinrc @@ -6,14 +6,13 @@ dialogparentEnabled=true cutefish_popupsEnabled=true cutefish_roundedwindowEnabled=true cutefish_scaleEnabled=true -cutefish_squashEnabled=true fadingpopupsEnabled=false fadeEnabled=false scaleEnabled=false squashEnabled=false glideEnabled=false -magiclampEnabled=false +magiclampEnabled=true translucencyEnabled=false [Effect-Blur] diff --git a/scripts/cutefish_squash/contents/code/main.js b/scripts/cutefish_squash/contents/code/main.js deleted file mode 100644 index 0e4617b..0000000 --- a/scripts/cutefish_squash/contents/code/main.js +++ /dev/null @@ -1,170 +0,0 @@ -/* - This file is part of the KDE project. - - SPDX-FileCopyrightText: 2021 Reven Martin - SPDX-FileCopyrightText: 2018 Vlad Zahorodnii - - SPDX-License-Identifier: GPL-2.0-or-later -*/ - -"use strict"; - -var squashEffect = { - duration: animationTime(300), - loadConfig: function () { - squashEffect.duration = animationTime(300); - }, - slotWindowMinimized: function (window) { - if (effects.hasActiveFullScreenEffect) { - return; - } - - // If the window doesn't have an icon in the task manager, - // don't animate it. - var iconRect = window.iconGeometry; - if (iconRect.width == 0 || iconRect.height == 0) { - return; - } - - if (window.unminimizeAnimation) { - if (redirect(window.unminimizeAnimation, Effect.Backward)) { - return; - } - cancel(window.unminimizeAnimation); - delete window.unminimizeAnimation; - } - - if (window.minimizeAnimation) { - if (redirect(window.minimizeAnimation, Effect.Forward)) { - return; - } - cancel(window.minimizeAnimation); - } - - var windowRect = window.geometry; - - window.minimizeAnimation = animate({ - window: window, - curve: QEasingCurve.OutSine, //OutQuad, InOutQuad - duration: squashEffect.duration, - animations: [ - { - type: Effect.Size, - from: { - value1: windowRect.width, - value2: windowRect.height - }, - to: { - value1: iconRect.width, - value2: iconRect.height - } - }, - { - type: Effect.Translation, - from: { - value1: 0.0, - value2: 0.0 - }, - to: { - value1: iconRect.x - windowRect.x - - (windowRect.width - iconRect.width) / 2, - value2: iconRect.y - windowRect.y - - (windowRect.height - iconRect.height) / 2, - } - }, - { - type: Effect.Opacity, - from: 1.0, - to: 1.0 - } - ] - }); - }, - slotWindowUnminimized: function (window) { - if (effects.hasActiveFullScreenEffect) { - return; - } - - // If the window doesn't have an icon in the task manager, - // don't animate it. - var iconRect = window.iconGeometry; - if (iconRect.width == 0 || iconRect.height == 0) { - return; - } - - if (window.minimizeAnimation) { - if (redirect(window.minimizeAnimation, Effect.Backward)) { - return; - } - cancel(window.minimizeAnimation); - delete window.minimizeAnimation; - } - - if (window.unminimizeAnimation) { - if (redirect(window.unminimizeAnimation, Effect.Forward)) { - return; - } - cancel(window.unminimizeAnimation); - } - - var windowRect = window.geometry; - - window.unminimizeAnimation = animate({ - window: window, - curve: QEasingCurve.OutSine, // QEasingCurve.OutSine, - duration: squashEffect.duration, - animations: [ - { - type: Effect.Size, - from: { - value1: iconRect.width, - value2: iconRect.height - }, - to: { - value1: windowRect.width, - value2: windowRect.height - } - }, - { - type: Effect.Translation, - from: { - value1: iconRect.x - windowRect.x - - (windowRect.width - iconRect.width) / 2, - value2: iconRect.y - windowRect.y - - (windowRect.height - iconRect.height) / 2, - }, - to: { - value1: 0.0, - value2: 0.0 - } - }, - { - type: Effect.Opacity, - from: 1.0, - to: 1.0 - } - ] - }); - }, - slotWindowAdded: function (window) { - // KWin 6 no longer has effects.windowMinimized/windowUnminimized, - // every window reports its own state changes instead. - window.minimizedChanged.connect(() => { - if (window.minimized) { - squashEffect.slotWindowMinimized(window); - } else { - squashEffect.slotWindowUnminimized(window); - } - }); - }, - init: function () { - effect.configChanged.connect(squashEffect.loadConfig); - - effects.windowAdded.connect(squashEffect.slotWindowAdded); - for (const window of effects.stackingOrder) { - squashEffect.slotWindowAdded(window); - } - } -}; - -squashEffect.init(); diff --git a/scripts/cutefish_squash/metadata.json b/scripts/cutefish_squash/metadata.json deleted file mode 100644 index 852a1ae..0000000 --- a/scripts/cutefish_squash/metadata.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "KPackageStructure": "KWin/Effect", - "KPlugin": { - "Authors": [ - { - "Email": "rivolaks@hot.ee, vlad.zahorodnii@kde.org", - "Name": "Rivo Laks, Vlad Zahorodnii" - } - ], - "Category": "Appearance", - "Description": "Squash windows when they are minimized", - "EnabledByDefault": true, - "Icon": "preferences-system-windows-effect-squash", - "Id": "cutefish_squash", - "License": "GPL", - "Name": "CutefishOS Squash", - "Version": "1" - }, - "X-KDE-Ordering": 60, - "X-KWin-Exclusive-Category": "minimize", - "X-Plasma-API": "javascript" -}