Skip to content
This repository has been archived by the owner on Jun 4, 2023. It is now read-only.

Commit

Permalink
Merge pull request #18 from zeroxoneafour/typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroxoneafour committed Apr 4, 2023
2 parents f0ca433 + 5c4df39 commit 4dcd93b
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 124 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME = autotile
VERSION = 1.2.0
VERSION = 1.2.1

PKGFILE = $(NAME).kwinscript
PKGDIR = pkg
Expand Down Expand Up @@ -29,7 +29,8 @@ res: $(PKGDIR)
sed -i "s/%VERSION%/$(VERSION)/" $(PKGDIR)/metadata.json

src: $(PKGDIR)
cd src; cat $(shell ls src) > ../$(PKGDIR)/contents/code/main.js
tsc
mv autotile.js pkg/contents/code/main.js

$(PKGDIR):
mkdir -p $(PKGDIR)
Expand Down
Binary file modified autotile.kwinscript
Binary file not shown.
12 changes: 12 additions & 0 deletions src/kwin/global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// print function, afaik takes anything and prints it
declare function print(...values: any[]): void;
declare function readConfig(key: string, defaultValue?: any): any;
declare function registerShortcut(id: string, desc: string, keybind: string, callback: Function): void;

declare const workspace: KWin.WorkspaceWrapper;
declare const options: KWin.Options;

declare interface Signal<T> {
connect(callback: T): void
disconnect(callback: T): void
}
74 changes: 74 additions & 0 deletions src/kwin/kwin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
namespace KWin {
export class AbstractClientAddons {
// custom stuff, not in base kwin scripts
oldTile: KWin.Tile
wasTiled: boolean
oldDesktop: number
constructor(tile: KWin.Tile, desktop: number) {
this.oldTile = tile;
this.wasTiled = true;
this.oldDesktop = desktop;
}
}
}

declare namespace KWin {
class Toplevel {
readonly popupWindow: boolean
readonly frameGeometry: Qt.QRect
readonly desktop: number
frameGeometryChanged: Signal<(client: AbstractClient, oldGeometry: Qt.QRect) => void>
screenChanged: Signal<() => void>
}
class AbstractClient extends Toplevel {
readonly resizeable: boolean
readonly moveable: boolean
readonly transient: boolean
readonly specialWindow: boolean
tile: Tile | null
keepAbove: boolean
keepBelow: boolean
noBorder: boolean
fullScreen: boolean
resourceClass: Qt.QByteArray
screen: number
// custom tiling stuff that isnt in base kwin but we need it
addons: AbstractClientAddons | undefined
//signals
desktopPresenceChanged: Signal<(client: AbstractClient, desktop: number) => void>
}
class Tile {
tiles: Array<Tile>
windows: Array<AbstractClient>
// null for root tile
parent: Tile | null
padding: number
}
class RootTile extends Tile {
parent: null
layoutModified: Signal<() => void>
}
class TileManager {
rootTile: RootTile
bestTileForPosition(x: number, y: number): Tile
}

class WorkspaceWrapper {
activeClient: AbstractClient | null
tilingForScreen(desktop: number): KWin.TileManager
// doesnt actually exist in api, i made it up
lastActiveClient: AbstractClient | null | undefined
// signals
clientAdded: Signal<(client: KWin.AbstractClient) => void>
clientRemoved: Signal<(client: KWin.AbstractClient) => void>
clientActivated: Signal<(client: KWin.AbstractClient) => void>
clientMinimized: Signal<(client: KWin.AbstractClient) => void>
clientUnminimized: Signal<(client: KWin.AbstractClient) => void>
// idk what user does
clientFullScreenSet: Signal<(client: KWin.AbstractClient, fullscreen: boolean, user: any) => void>
}
class Options {
configChanged: Signal<() => void>
}
}

11 changes: 11 additions & 0 deletions src/kwin/qt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// obviously not all of qt, only the stuff I need

declare namespace Qt {
class QRect {
x: number
y: number
width: number
height: number
}
class QByteArray {}
}
Loading

0 comments on commit 4dcd93b

Please sign in to comment.