diff --git a/res/config.ui b/res/config.ui index 7a09aa9c..e3e84a49 100644 --- a/res/config.ui +++ b/res/config.ui @@ -604,16 +604,6 @@ - - - - <html><head/><body><p>If enabled, actual mouse position will be used for certain operations. (e.g. swapping tile by dragging)</p><p>To use this feature, user <span style=" text-decoration: underline;">MUST make sure </span><span style=" font-weight:600; font-style:italic; text-decoration: underline;">xdotool </span><span style=" text-decoration: underline;">is installed</span> on the system.</p></body></html> - - - Get actual mouse position using xdotool while resizing (HACK) - - - diff --git a/res/config.xml b/res/config.xml index 973a9fc1..7f3812df 100644 --- a/res/config.xml +++ b/res/config.xml @@ -175,11 +175,6 @@ 0 - - - false - - false diff --git a/res/main.qml b/res/main.qml index a4ea3de5..a98b3ad2 100644 --- a/res/main.qml +++ b/res/main.qml @@ -4,7 +4,6 @@ // SPDX-License-Identifier: MIT 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 org.kde.taskmanager 0.1 as TaskManager @@ -17,11 +16,6 @@ Item { id: activityInfo } - PlasmaCore.DataSource { - id: mousePoller - engine: 'executable' - } - Loader { id: popupDialog source: "popup.qml" @@ -38,7 +32,6 @@ Item { const qmlObjects = { scriptRoot: scriptRoot, activityInfo: activityInfo, - mousePoller: mousePoller, popupDialog: popupDialog }; diff --git a/src/controller/index.ts b/src/controller/index.ts index e512dbc2..c34fac99 100644 --- a/src/controller/index.ts +++ b/src/controller/index.ts @@ -29,11 +29,6 @@ export interface Controller { */ readonly screens: DriverSurface[]; - /** - * Current cursor position. - */ - readonly cursorPosition: [number, number] | null; - /** * Current active window. In other words the window, that has focus. */ @@ -196,10 +191,6 @@ export class TilingController implements Controller { this.driver.currentSurface = value; } - public get cursorPosition(): [number, number] | null { - return this.driver.cursorPosition; - } - public showNotification(text: string): void { this.driver.showNotification(text); } @@ -219,6 +210,7 @@ export class TilingController implements Controller { public onWindowAdded(window: Window): void { this.debug.debugObj(() => ["onWindowAdded", { window }]); + console.log(`New window added: ${window}`); this.engine.manage(window); /* move window to next surface if the current surface is "full" */ @@ -241,6 +233,8 @@ export class TilingController implements Controller { public onWindowRemoved(window: Window): void { this.debug.debugObj(() => ["onWindowRemoved", { window }]); + console.log(`Window remove: ${window}`); + this.engine.unmanage(window); this.engine.arrange(); } @@ -259,11 +253,11 @@ export class TilingController implements Controller { /* swap window by dragging */ if (window.state === WindowState.Tiled) { const tiles = this.engine.windows.getVisibleTiles(this.currentSurface); - const cursorPos = this.cursorPosition || window.actualGeometry.center; + const windowCenter = window.actualGeometry.center; const targets = tiles.filter( (tile) => - tile !== window && tile.actualGeometry.includesPoint(cursorPos) + tile !== window && tile.actualGeometry.includesPoint(windowCenter) ); if (targets.length === 1) { @@ -306,6 +300,7 @@ export class TilingController implements Controller { public onWindowResizeOver(window: Window): void { this.debug.debugObj(() => ["onWindowResizeOver", { window }]); + console.log(`Window resize is over: ${window}`); if (this.config.adjustLayout && window.tiled) { this.engine.adjustLayout(window); this.engine.arrange(); diff --git a/src/driver/index.ts b/src/driver/index.ts index bff4f4a4..915f61da 100644 --- a/src/driver/index.ts +++ b/src/driver/index.ts @@ -4,7 +4,6 @@ // SPDX-License-Identifier: MIT import { DriverSurface } from "./surface"; -import KWinMousePoller from "./kwin_mouse_poller"; import { KWinSurface } from "./surface"; import { KWinWindow } from "./window"; @@ -17,11 +16,10 @@ import { WindowState } from "../engine/window"; import Config from "../config"; import Debug from "../util/debug"; -import qmlSetTimeout, { TimersPool } from "../util/timer"; +import { TimersPool } from "../util/timer"; export interface DriverContext { readonly screens: DriverSurface[]; - readonly cursorPosition: [number, number] | null; currentSurface: DriverSurface; currentWindow: Window | null; @@ -97,14 +95,9 @@ export class KWinDriver implements DriverContext { return screensArr; } - public get cursorPosition(): [number, number] | null { - return this.mousePoller.mousePosition; - } - private controller: Controller; private windowMap: WrapperMap; private entered: boolean; - private mousePoller: KWinMousePoller; private qml: Bismuth.Qml.Main; private kwinApi: KWin.Api; @@ -152,7 +145,6 @@ export class KWinDriver implements DriverContext { ) ); this.entered = false; - this.mousePoller = new KWinMousePoller(qmlObjects, this.config, this.debug); this.qml = qmlObjects; this.kwinApi = kwinApi; @@ -389,11 +381,9 @@ export class KWinDriver implements DriverContext { if (moving !== client.move) { moving = client.move; if (moving) { - this.mousePoller.start(); this.controller.onWindowMoveStart(window); } else { this.controller.onWindowMoveOver(window); - this.mousePoller.stop(); } } if (resizing !== client.resize) { diff --git a/src/driver/kwin_mouse_poller.ts b/src/driver/kwin_mouse_poller.ts deleted file mode 100644 index 7755ccea..00000000 --- a/src/driver/kwin_mouse_poller.ts +++ /dev/null @@ -1,88 +0,0 @@ -// SPDX-FileCopyrightText: 2018-2019 Eon S. Jeon -// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin -// -// SPDX-License-Identifier: MIT - -import Config from "../config"; -import Debug from "../util/debug"; -import qmlSetTimeout from "../util/timer"; - -export default class KWinMousePoller { - public static readonly COMMAND = "xdotool getmouselocation"; - public static readonly INTERVAL = 50; /* ms */ - - public get started(): boolean { - return this.startCount > 0; - } - - public get mousePosition(): [number, number] | null { - return this.parseResult(); - } - - /** poller activates only when count > 0 */ - private startCount: number; - private cmdResult: string | null; - private qml: Bismuth.Qml.Main; - private config: Config; - - constructor(qml: Bismuth.Qml.Main, config: Config, _debug: Debug) { - this.startCount = 0; - this.cmdResult = null; - this.qml = qml; - this.config = config; - - /* we will poll manually, because this interval value will be - * aligned to intervalAlignment, which probably is 1000. */ - this.qml.mousePoller.interval = 0; - - this.qml.mousePoller.onNewData.connect((sourceName: string, data: any) => { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access - this.cmdResult = data["exit code"] === 0 ? data["stdout"] : null; - this.qml.mousePoller.disconnectSource(KWinMousePoller.COMMAND); - - qmlSetTimeout(() => { - if (this.started) { - qml.mousePoller.connectSource(KWinMousePoller.COMMAND); - } - }, KWinMousePoller.INTERVAL); - }); - } - - public start(): void { - this.startCount += 1; - if (this.config.pollMouseXdotool) { - this.qml.mousePoller.connectSource(KWinMousePoller.COMMAND); - } - } - - public stop(): void { - this.startCount = Math.max(this.startCount - 1, 0); - } - - private parseResult(): [number, number] | null { - // output example: x:1031 y:515 screen:0 window:90177537 - if (!this.cmdResult) { - return null; - } - - let x: number | null = null; - let y: number | null = null; - this.cmdResult - .split(" ") - .slice(0, 2) - .forEach((part) => { - const [key, value, _] = part.split(":"); - if (key === "x") { - x = parseInt(value, 10); - } - if (key === "y") { - y = parseInt(value, 10); - } - }); - - if (x === null || y === null) { - return null; - } - return [x, y]; - } -} diff --git a/src/extern/global.d.ts b/src/extern/global.d.ts index d390be79..e9c32a8b 100644 --- a/src/extern/global.d.ts +++ b/src/extern/global.d.ts @@ -10,7 +10,6 @@ declare namespace Bismuth { export interface Main { scriptRoot: object; activityInfo: Plasma.TaskManager.ActivityInfo; - mousePoller: Plasma.PlasmaCore.DataSource; popupDialog: PopupDialog; } @@ -22,7 +21,7 @@ declare namespace Bismuth { // NOTICE: We can not declare the globals, since we use // Node.js when building tests. However, the globals we use -// in production come from Qt JavaScript Envirinment and +// in production come from Qt JavaScript Environment and // not from Node.js and therefore they could mismatch. // Let's hope we will not run into one of these situations... //