diff --git a/CHANGELOG b/CHANGELOG index 859092a..54fb234 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,10 @@ +1.6.2 +- New feature "Show desktop background" and associated blur option +- Improved stability and performance by not attaching listeners to special windows (alerts, notifications, etc) + +1.6.1 +- Fix for KWin crash after waking from sleep + 1.6 - Wayland support for snap groups features and sorting windows by last activation time - New option "Remember window sizes, and restore it on un-snap" for windows snapped with the script diff --git a/contents/config/main.xml b/contents/config/main.xml index 07da137..2c037d1 100644 --- a/contents/config/main.xml +++ b/contents/config/main.xml @@ -85,5 +85,13 @@ 100 + + + false + + + + 18 + diff --git a/contents/ui/code/assist.js b/contents/ui/code/assist.js index fe30e06..e109203 100644 --- a/contents/ui/code/assist.js +++ b/contents/ui/code/assist.js @@ -1,6 +1,7 @@ /// assist function delayedShowAssist(dx, dy, height, width, window){ - clients = Object.values(workspace.clients).filter(c => WindowManager.shouldShowWindow(c)); + const allClients = Object.values(workspace.clients); + clients = allClients.filter(c => WindowManager.shouldShowWindow(c)); if (clients.length == 0) return; cardWidth = currentScreenWidth / 5; @@ -17,6 +18,13 @@ function delayedShowAssist(dx, dy, height, width, window){ if (sortByLastActive) WindowManager.sortClientsByLastActive(); if (descendingOrder) clients = clients.reverse(); + + /// find current desktop background + if (showDesktopBackground) { + const indexOfDesktopWindow = allClients.findIndex((c) => c.desktopWindow && c.screen === workspace.activeScreen); + if (indexOfDesktopWindow < 0) return; + desktopWindowId = allClients[indexOfDesktopWindow].internalId; + } } function showAssist(dx, dy, height, width) { diff --git a/contents/ui/code/windows.js b/contents/ui/code/windows.js index 18b4dae..bbdb67d 100644 --- a/contents/ui/code/windows.js +++ b/contents/ui/code/windows.js @@ -24,6 +24,8 @@ function selectClient(client){ /// listeners function addListenersToClient(client) { + if (!client || client.specialWindow) return; + client.frameGeometryChanged.connect(function() { if (!client.move && !client.resize && activated == false && preventFromShowing == false) { if (delayBeforeShowingAssist == 0) { @@ -80,8 +82,7 @@ function addListenersToClient(client) { } function onWindowResize(window) { - if (!window) return; - if (activated) return; + if (activated || !window || window.deleted || window.specialWindow) return; AssistManager.finishSnap(false); /// make sure we cleared all variables /// don't show assist if window could be fit in the group behind diff --git a/contents/ui/components/DesktopBackground.qml b/contents/ui/components/DesktopBackground.qml new file mode 100644 index 0000000..59c7bb7 --- /dev/null +++ b/contents/ui/components/DesktopBackground.qml @@ -0,0 +1,28 @@ +import QtQuick 2.12 +import QtQuick.Window 2.12 +import QtGraphicalEffects 1.12 +import org.kde.kwin 2.0 as KWinComponents + +Item { + y: - (mainWindow.y - minDy) + x: - (mainWindow.x - minDx) + height: Screen.height + width: currentScreenWidth + visible: showDesktopBackground && mainWindow.activated + + KWinComponents.ThumbnailItem { + wId: desktopWindowId + id: desktopBackground + anchors.fill: parent + } + + /// configurable blur + FastBlur { + id: blurBackground + anchors.fill: parent + source: desktopBackground + radius: desktopBackgroundBlur + cached: false + visible: desktopBackgroundBlur > 0 + } +} diff --git a/contents/ui/config.ui b/contents/ui/config.ui index 85d6110..a962ce5 100644 --- a/contents/ui/config.ui +++ b/contents/ui/config.ui @@ -6,8 +6,8 @@ 0 0 - 868 - 620 + 998 + 715 @@ -298,6 +298,68 @@ + + + + ArrowCursor + + + + + + Show desktop background + + + + + + + + + false + + + 18 + + + 0 + + + 60 + + + px + + + + + + + ArrowCursor + + + + + + Blur radius for desktop background + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + @@ -670,7 +732,7 @@ ArrowCursor - Snap groups + Snap groups (experimental) Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -752,5 +814,22 @@ - + + + kcfg_showDesktopBackground + toggled(bool) + kcfg_desktopBackgroundBlur + setEnabled(bool) + + + 538 + 217 + + + 539 + 245 + + + + diff --git a/contents/ui/main.qml b/contents/ui/main.qml index ea3e497..085ce3e 100644 --- a/contents/ui/main.qml +++ b/contents/ui/main.qml @@ -31,6 +31,7 @@ Window { /// service variables property bool activated: false property var clients: null + property var desktopWindowId: null property var lastActiveClient: null /// last active client to focus if cancelled property int focusedIndex: 0 /// selection by keyboard property bool trackActiveWindows: true @@ -83,6 +84,8 @@ Window { property bool fillOnSnappedMove property int fitWindowInGroupBehind property bool rememberWindowSizes + property bool showDesktopBackground + property int desktopBackgroundBlur Connections { target: workspace @@ -120,6 +123,11 @@ Window { mainWindow.hide(); } + /// Desktop preview on background with blur + Loader { + source: showDesktopBackground && desktopWindowId != null ? 'components/DesktopBackground.qml' : '' + } + /// Main view Rectangle { id: assistBackground @@ -348,6 +356,8 @@ Window { fillOnSnappedClose = KWin.readConfig("fillOnSnappedClose", false); fillOnSnappedMove = KWin.readConfig("fillOnSnappedMove", false); fitWindowInGroupBehind = KWin.readConfig("fitWindowInGroupBehind", false); + showDesktopBackground = KWin.readConfig("showDesktopBackground", false); + desktopBackgroundBlur = KWin.readConfig("desktopBackgroundBlur", 18); trackSnappedWindows = minimizeSnappedTogether || raiseSnappedTogether || fillOnSnappedClose || !showSnappedWindows; trackActiveWindows = sortByLastActive || fitWindowInGroupBehind; diff --git a/metadata.desktop b/metadata.desktop index 734e034..386b013 100644 --- a/metadata.desktop +++ b/metadata.desktop @@ -17,7 +17,7 @@ X-KDE-ConfigModule=kwin/effects/configs/kcm_kwin4_genericscripted X-KDE-PluginInfo-Author=emvaized X-KDE-PluginInfo-Email=maximtsyba@gmail.com X-KDE-PluginInfo-Name=kdesnapassist -X-KDE-PluginInfo-Version=1.6 +X-KDE-PluginInfo-Version=1.6.2 X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-EnabledByDefault=true X-KDE-PluginInfo-Website=https://github.com/emvaized/kde-snap-assist