feat(wayland): 🔥 remove mouse poller

Mouse poller does not work on Wayland anyway. It uses xdottool, which
does not work on Wayland.

This will break the setup of the users, who used the config setting to
use xdotool
This commit is contained in:
Mikhail Zolotukhin 2021-09-23 02:34:02 +03:00
parent 293e580089
commit 8ca1838f68
7 changed files with 8 additions and 134 deletions

View File

@ -604,16 +604,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_pollMouseXdotool">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If enabled, actual mouse position will be used for certain operations. (e.g. swapping tile by dragging)&lt;/p&gt;&lt;p&gt;To use this feature, user &lt;span style=&quot; text-decoration: underline;&quot;&gt;MUST make sure &lt;/span&gt;&lt;span style=&quot; font-weight:600; font-style:italic; text-decoration: underline;&quot;&gt;xdotool &lt;/span&gt;&lt;span style=&quot; text-decoration: underline;&quot;&gt;is installed&lt;/span&gt; on the system.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Get actual mouse position using xdotool while resizing (HACK)</string>
</property>
</widget>
</item>
<item>
<spacer name="debugSpacer">
<property name="orientation">

View File

@ -175,11 +175,6 @@
<default>0</default>
</entry>
<entry name="pollMouseXdotool" type="Bool">
<label>Poll actual mouse position using xdotool (for tile swapping, for example)</label>
<default>false</default>
</entry>
<entry name="limitTileWidth" type="Bool">
<label>Limit the width of tiles</label>
<default>false</default>

View File

@ -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
};

View File

@ -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();

View File

@ -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<KWin.Client, Window>;
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) {

View File

@ -1,88 +0,0 @@
// SPDX-FileCopyrightText: 2018-2019 Eon S. Jeon <esjeon@hyunmu.am>
// SPDX-FileCopyrightText: 2021 Mikhail Zolotukhin <mail@genda.life>
//
// 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];
}
}

View File

@ -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...
//