kwin/scripts: Add convergentwindows and switch from kwin maximized mode

This commit is contained in:
Devin Lin 2023-02-11 10:04:11 -08:00
parent e118946397
commit 987b280f12
5 changed files with 69 additions and 0 deletions

View file

@ -92,6 +92,7 @@ add_subdirectory(components)
add_subdirectory(quicksettings)
add_subdirectory(kcms)
add_subdirectory(kded)
add_subdirectory(kwin)
find_program(PlasmaOpenSettings plasma-open-settings)
set_package_properties(PlasmaOpenSettings PROPERTIES

1
kwin/CMakeLists.txt Normal file
View file

@ -0,0 +1 @@
add_subdirectory(scripts)

View file

@ -0,0 +1,10 @@
function(add_kwin_script name)
kpackage_install_package(${name} ${name} scripts kwin)
# Copy the script to the build directory so one can run tests without prior
# make install. FIXME: use add_custom_command.
file(COPY ${name} DESTINATION ${CMAKE_BINARY_DIR}/bin/kwin/scripts/)
endfunction()
add_kwin_script(convergentwindows)

View file

@ -0,0 +1,33 @@
// 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.clientFinishUserMovedResized.connect((client) => {
run(client);
});
run(client);
}
});
// Windows are moved from the external screen
// to the internal screen if the external screen
// is disconnected.
workspace.numberScreensChanged.connect((count) => {
const clients = workspace.clientList();
for (var i = 0; i < clients.length; i++) {
if (clients[i].normalWindow) {
run(clients[i]);
}
}
});

View file

@ -0,0 +1,24 @@
{
"KPlugin": {
"Name": "Convergent Windows",
"Description": "Removes window decorations and maximizes windows on the first screen only.",
"Icon": "preferences-system-windows",
"Authors": [
{
"Email": "plata.hill@kdemail.net",
"Name": "Plata Hill"
}
],
"Id": "convergentwindows",
"ServiceTypes": [
"KWin/Script"
],
"Version": "1.0",
"Licsense": "LGPL-2.1-or-later",
"Website": "https://invent.kde.org/plata/convergentwindows"
},
"X-Plasma-API": "javascript",
"X-Plasma-MainScript": "code/main.js"
}