shift-shell/kwin/scripts/convergentwindows/contents/ui/main.qml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
1.7 KiB
QML
Raw Normal View History

// 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 as KWinComponents
import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings
Item {
id: root
2023-10-28 19:06:59 +00:00
function run(window) {
if (!ShellSettings.Settings.convergenceModeEnabled) {
2023-10-28 19:06:59 +00:00
window.noBorder = true;
window.setMaximize(true, true);
} else {
2023-10-28 19:06:59 +00:00
window.noBorder = false;
}
}
Connections {
target: ShellSettings.Settings
function onConvergenceModeEnabledChanged() {
2023-10-28 19:06:59 +00:00
const windows = KWinComponents.Workspace.windows;
2023-10-28 19:06:59 +00:00
for (let i = 0; i < windows.length; i++) {
if (windows[i].normalWindow) {
root.run(windows[i]);
}
}
}
}
Connections {
target: KWinComponents.Workspace
2023-10-28 19:06:59 +00:00
function onWindowAdded(window) {
if (window.normalWindow) {
window.interactiveMoveResizeFinished.connect((window) => {
root.run(window);
});
2023-10-28 19:06:59 +00:00
root.run(window);
}
}
function onScreensChanged() {
// Windows are moved from the external screen
// to the internal screen if the external screen
// is disconnected.
2023-10-28 19:06:59 +00:00
const windows = KWinComponents.Workspace.windows;
2023-10-28 19:06:59 +00:00
for (var i = 0; i < windows.length; i++) {
if (windows[i].normalWindow) {
root.run(windows[i]);
}
}
}
}
}