mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
kwin/convergentwindows: Convert to declarative script
This commit is contained in:
parent
5e22c69d32
commit
28a780a7d3
3 changed files with 48 additions and 36 deletions
|
|
@ -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]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
45
kwin/scripts/convergentwindows/contents/ui/main.qml
Normal file
45
kwin/scripts/convergentwindows/contents/ui/main.qml
Normal 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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -60,8 +60,8 @@
|
||||||
"Name[uk]": "Збіжні вікна",
|
"Name[uk]": "Збіжні вікна",
|
||||||
"Name[x-test]": "xxConvergent Windowsxx",
|
"Name[x-test]": "xxConvergent Windowsxx",
|
||||||
"Version": "1.0",
|
"Version": "1.0",
|
||||||
"Website": "https://invent.kde.org/plata/convergentwindows"
|
"Website": "https://invent.kde.org/plasma/plasma-mobile"
|
||||||
},
|
},
|
||||||
"X-Plasma-API": "javascript",
|
"X-Plasma-API": "declarativescript",
|
||||||
"X-Plasma-MainScript": "code/main.js"
|
"X-Plasma-MainScript": "ui/main.qml"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue