mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-11-04 13:37:43 +03:00
refactor: ♻️ move rect fuctions to Rect class
This commit is contained in:
parent
3241774800
commit
014a777ff5
@ -4,7 +4,6 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
import Config from "../config";
|
import Config from "../config";
|
||||||
import { toRect } from "../util/kwinutil";
|
|
||||||
import Rect from "../util/rect";
|
import Rect from "../util/rect";
|
||||||
|
|
||||||
export interface DriverSurface {
|
export interface DriverSurface {
|
||||||
@ -66,7 +65,7 @@ export class DriverSurfaceImpl implements DriverSurface {
|
|||||||
this.ignore =
|
this.ignore =
|
||||||
this.config.ignoreActivity.indexOf(activityName) >= 0 ||
|
this.config.ignoreActivity.indexOf(activityName) >= 0 ||
|
||||||
this.config.ignoreScreen.indexOf(screen) >= 0;
|
this.config.ignoreScreen.indexOf(screen) >= 0;
|
||||||
this.workingArea = toRect(
|
this.workingArea = Rect.fromQRect(
|
||||||
this.kwinApi.workspace.clientArea(
|
this.kwinApi.workspace.clientArea(
|
||||||
this.kwinApi.KWin.PlacementArea,
|
this.kwinApi.KWin.PlacementArea,
|
||||||
screen,
|
screen,
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
import { DriverSurface, DriverSurfaceImpl } from "./surface";
|
import { DriverSurface, DriverSurfaceImpl } from "./surface";
|
||||||
|
|
||||||
import Rect from "../util/rect";
|
import Rect from "../util/rect";
|
||||||
import { toQRect, toRect } from "../util/kwinutil";
|
|
||||||
import { clip, matchWords } from "../util/func";
|
import { clip, matchWords } from "../util/func";
|
||||||
import Config from "../config";
|
import Config from "../config";
|
||||||
import { Log } from "../util/log";
|
import { Log } from "../util/log";
|
||||||
@ -42,7 +41,7 @@ export class DriverWindowImpl implements DriverWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get geometry(): Rect {
|
public get geometry(): Rect {
|
||||||
return toRect(this.client.geometry);
|
return Rect.fromQRect(this.client.geometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get active(): boolean {
|
public get active(): boolean {
|
||||||
@ -199,7 +198,7 @@ export class DriverWindowImpl implements DriverWindow {
|
|||||||
if (geometry !== undefined) {
|
if (geometry !== undefined) {
|
||||||
geometry = this.adjustGeometry(geometry);
|
geometry = this.adjustGeometry(geometry);
|
||||||
if (this.config.preventProtrusion) {
|
if (this.config.preventProtrusion) {
|
||||||
const area = toRect(
|
const area = Rect.fromQRect(
|
||||||
this.kwinApi.workspace.clientArea(
|
this.kwinApi.workspace.clientArea(
|
||||||
this.kwinApi.KWin.PlacementArea,
|
this.kwinApi.KWin.PlacementArea,
|
||||||
this.client.screen,
|
this.client.screen,
|
||||||
@ -214,7 +213,7 @@ export class DriverWindowImpl implements DriverWindow {
|
|||||||
geometry = this.adjustGeometry(geometry);
|
geometry = this.adjustGeometry(geometry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.client.geometry = toQRect(geometry);
|
this.client.geometry = geometry.toQRect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +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 Rect from "./rect";
|
|
||||||
|
|
||||||
export function toQRect(rect: Rect): QRect {
|
|
||||||
return Qt.rect(rect.x, rect.y, rect.width, rect.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function toRect(qrect: QRect): Rect {
|
|
||||||
return new Rect(qrect.x, qrect.y, qrect.width, qrect.height);
|
|
||||||
}
|
|
@ -11,6 +11,10 @@ export default class Rect {
|
|||||||
public height: number
|
public height: number
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
public static fromQRect(qRect: QRect): Rect {
|
||||||
|
return new Rect(qRect.x, qRect.y, qRect.width, qRect.height);
|
||||||
|
}
|
||||||
|
|
||||||
public get maxX(): number {
|
public get maxX(): number {
|
||||||
return this.x + this.width;
|
return this.x + this.width;
|
||||||
}
|
}
|
||||||
@ -82,6 +86,10 @@ export default class Rect {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public toQRect(): QRect {
|
||||||
|
return Qt.rect(this.x, this.y, this.width, this.height);
|
||||||
|
}
|
||||||
|
|
||||||
public toString(): string {
|
public toString(): string {
|
||||||
return "Rect(" + [this.x, this.y, this.width, this.height].join(", ") + ")";
|
return "Rect(" + [this.x, this.y, this.width, this.height].join(", ") + ")";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user