From cb97128cf0f22568bb38717b30af6c5b1c180556 Mon Sep 17 00:00:00 2001 From: Mikhail Zolotukhin Date: Thu, 21 Oct 2021 01:15:41 +0300 Subject: [PATCH] docs: add JSDoc to the Driver --- src/driver/index.ts | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/src/driver/index.ts b/src/driver/index.ts index 321ef135..c8c73b96 100644 --- a/src/driver/index.ts +++ b/src/driver/index.ts @@ -17,26 +17,49 @@ import { WindowState } from "../engine/window"; import Config from "../config"; import { Log } from "../util/log"; +/** + * Provides convenient interface to KWin functions. + * Hides all the bad and ugly things current KWin has. + */ export interface Driver { + /** + * All the surfaces/screens currently possess by the KWin + */ readonly screens: DriverSurface[]; + /** + * Surface (screen) of the current window + */ currentSurface: DriverSurface; + + /** + * Currently active (i.e. focused) window + */ currentWindow: EngineWindow | null; + /** + * Show notification to the user + * @param text notification text + */ showNotification(text: string): void; + /** + * Bind script to the various KWin events + */ bindEvents(): void; + + /** + * Bind the shortcut for the action + * @param action + */ bindShortcut(action: Action): void; + + /** + * Manage the windows, that were active before script loading + */ manageWindows(): void; } -/** - * Abstracts KDE implementation specific details. - * - * Driver is responsible for initializing the tiling logic, connecting - * signals (Qt/KDE term for binding events), and providing specific utility - * functions. - */ export class DriverImpl implements Driver { public get currentSurface(): DriverSurface { return new DriverSurfaceImpl( @@ -143,9 +166,6 @@ export class DriverImpl implements Driver { this.kwinApi = kwinApi; } - /** - * Bind script to the various KWin events - */ public bindEvents(): void { const onNumberScreensChanged = (count: number): void => { this.controller.onSurfaceUpdate(`screens=${count}`); @@ -268,9 +288,6 @@ export class DriverImpl implements Driver { * https://github.com/KDE/kwin/blob/master/scripts/minimizeall/contents/code/main.js */ } - /** - * Manage the windows - */ public manageWindows(): void { const clients = this.kwinApi.workspace.clientList(); // TODO: provide interface for using the "for of" cycle