convert to QML-based extension

This commit is contained in:
Eon S. Jeon 2018-11-09 23:04:29 +09:00
parent 1893b0fbe2
commit be341e1ccb
3 changed files with 53 additions and 10 deletions

View File

@ -4,6 +4,7 @@ PACKAGE_FILE = $(PACKAGE_NAME).kwinscript
FILE_SCRIPT = pkg/contents/code/script.js
FILE_META = pkg/metadata.desktop
FILE_QML = pkg/contents/ui/main.qml
all: $(PACKAGE_FILE)
@ -13,10 +14,14 @@ clean:
$(PACKAGE_FILE): $(FILE_SCRIPT)
$(PACKAGE_FILE): $(FILE_META)
$(PACKAGE_FILE): $(FILE_QML)
@rm -f "$(PACKAGE_FILE)"
@7z a -tzip $(PACKAGE_FILE) ./pkg/*
$(FILE_SCRIPT):
$(FILE_SCRIPT): src/common.ts
$(FILE_SCRIPT): src/driver.ts
$(FILE_SCRIPT): src/engine.ts
$(FILE_SCRIPT): src/kwin.d.ts
@mkdir -vp `dirname $(FILE_SCRIPT)`
tsc --outFile $(FILE_SCRIPT)
@ -24,4 +29,8 @@ $(FILE_META): res/metadata.desktop
@mkdir -vp `dirname $(FILE_META)`
sed "s/0\.0/$(PACKAGE_VER)/" $< > $(FILE_META)
$(FILE_QML): res/main.qml
@mkdir -vp `dirname $(FILE_QML)`
@cp -v $< $@
.PHONY: all clean

32
res/main.qml Normal file
View File

@ -0,0 +1,32 @@
// Copyright (c) 2018 Eon S. Jeon <esjeon@hyunmu.am>
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore;
import org.kde.plasma.components 2.0 as Plasma;
import org.kde.kwin 2.0;
import "../code/script.js" as K
Item {
Component.onCompleted: {
console.log("KROHNKITE: starting the script");
(new K.KWinDriver()).main();
}
}

View File

@ -79,6 +79,9 @@ class KWinDriver
private onClientAdded = (client: KWin.Client) =>
{
if(client.resourceClass == 'plasmashell')
return;
// TODO: check resourceClasses for some windows
this.engine.manageClient(client);
@ -133,12 +136,10 @@ class KWinDriver
public setClientGeometry(client: KWin.Client, geometry: QRect)
{
client.geometry = {
x: geometry.x,
y: geometry.y,
width: geometry.width,
height: geometry.height
};
client.geometry.x = geometry.x;
client.geometry.y = geometry.y;
client.geometry.width = geometry.width;
client.geometry.height = geometry.height;
}
public isClientVisible(client: KWin.Client, screenId: number)
@ -164,8 +165,9 @@ class KWinDriver
this.bindShortcut();
this.onNumberScreensChanged(workspace.numScreens);
workspace.clientList().map(this.onClientAdded);
var i, clients = workspace.clientList();
for(i = 0; i < clients.length; i++)
this.onClientAdded(clients[i]);
}
}
(new KWinDriver()).main();