Skip to content

Commit

Permalink
1.6.2, merge from dev
Browse files Browse the repository at this point in the history
Merge pull request #37 from emvaized/dev
  • Loading branch information
emvaized authored Sep 25, 2022
2 parents 132e92a + bfa277a commit 321d360
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 8 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 8 additions & 0 deletions contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,13 @@
<label>Delay in ms before assist gets shown</label>
<default>100</default>
</entry>
<entry name="showDesktopBackground" type="bool">
<label>Show desktop background</label>
<default>false</default>
</entry>
<entry name="desktopBackgroundBlur" type="int">
<label>Amount of blur to apply to desktop background</label>
<default>18</default>
</entry>
</group>
</kcfg>
10 changes: 9 additions & 1 deletion contents/ui/code/assist.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions contents/ui/code/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions contents/ui/components/DesktopBackground.qml
Original file line number Diff line number Diff line change
@@ -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
}
}
87 changes: 83 additions & 4 deletions contents/ui/config.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>868</width>
<height>620</height>
<width>998</width>
<height>715</height>
</rect>
</property>
<property name="minimumSize">
Expand Down Expand Up @@ -298,6 +298,68 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="kcfg_showDesktopBackground">
<property name="cursor">
<cursorShape>ArrowCursor</cursorShape>
</property>
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Show desktop background</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="KIntNumInput" name="kcfg_desktopBackgroundBlur">
<property name="enabled">
<bool>false</bool>
</property>
<property name="value">
<number>18</number>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>60</number>
</property>
<property name="suffix">
<string>px</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="cursor">
<cursorShape>ArrowCursor</cursorShape>
</property>
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Blur radius for desktop background</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -670,7 +732,7 @@
<cursorShape>ArrowCursor</cursorShape>
</property>
<property name="title">
<string>Snap groups</string>
<string>Snap groups (experimental)</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
Expand Down Expand Up @@ -752,5 +814,22 @@
</customwidget>
</customwidgets>
<resources/>
<connections/>
<connections>
<connection>
<sender>kcfg_showDesktopBackground</sender>
<signal>toggled(bool)</signal>
<receiver>kcfg_desktopBackgroundBlur</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>538</x>
<y>217</y>
</hint>
<hint type="destinationlabel">
<x>539</x>
<y>245</y>
</hint>
</hints>
</connection>
</connections>
</ui>
10 changes: 10 additions & 0 deletions contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -83,6 +84,8 @@ Window {
property bool fillOnSnappedMove
property int fitWindowInGroupBehind
property bool rememberWindowSizes
property bool showDesktopBackground
property int desktopBackgroundBlur

Connections {
target: workspace
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion metadata.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ X-KDE-ConfigModule=kwin/effects/configs/kcm_kwin4_genericscripted
X-KDE-PluginInfo-Author=emvaized
[email protected]
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

0 comments on commit 321d360

Please sign in to comment.