kwin/convergentwindows: Convert to declarative script

This commit is contained in:
Devin Lin 2023-03-25 23:07:18 -07:00
parent 5e22c69d32
commit 28a780a7d3
3 changed files with 48 additions and 36 deletions

View file

@ -1,33 +0,0 @@
// SPDX-FileCopyrightText: 2023 Plata Hill <plata.hill@kdemail.net>
// SPDX-License-Identifier: LGPL-2.1-or-later
function run(client) {
if (client.screen === 0) {
client.setMaximize(true, true);
client.noBorder = true;
} else {
client.noBorder = false;
}
}
workspace.clientAdded.connect((client) => {
if (client.normalWindow) {
client.interactiveMoveResizeFinished.connect((client) => {
run(client);
});
run(client);
}
});
// Windows are moved from the external screen
// to the internal screen if the external screen
// is disconnected.
workspace.screensChanged.connect(() => {
const clients = workspace.clientList();
for (var i = 0; i < clients.length; i++) {
if (clients[i].normalWindow) {
run(clients[i]);
}
}
});

View file

@ -0,0 +1,45 @@
// SPDX-FileCopyrightText: 2023 Plata Hill <plata.hill@kdemail.net>
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: LGPL-2.1-or-later
import QtQuick
import org.kde.kwin
Item {
id: root
function run(client) {
if (client.screen === 0) {
client.setMaximize(true, true);
client.noBorder = true;
} else {
client.noBorder = false;
}
}
Connections {
target: Workspace
function onClientAdded(client) {
if (client.normalWindow) {
client.interactiveMoveResizeFinished.connect((client) => {
root.run(client);
});
root.run(client);
}
}
function onScreensChanged() {
// Windows are moved from the external screen
// to the internal screen if the external screen
// is disconnected.
const clients = Workspace.clientList();
for (var i = 0; i < clients.length; i++) {
if (clients[i].normalWindow) {
root.run(clients[i]);
}
}
}
}
}

View file

@ -60,8 +60,8 @@
"Name[uk]": "Збіжні вікна",
"Name[x-test]": "xxConvergent Windowsxx",
"Version": "1.0",
"Website": "https://invent.kde.org/plata/convergentwindows"
"Website": "https://invent.kde.org/plasma/plasma-mobile"
},
"X-Plasma-API": "javascript",
"X-Plasma-MainScript": "code/main.js"
"X-Plasma-API": "declarativescript",
"X-Plasma-MainScript": "ui/main.qml"
}