respect window resize increment hints

- calculate window size based on increment hint, if available.
- fixes freezing issues with xterm, lxterm, and similar applications
This commit is contained in:
Eon S. Jeon 2018-12-17 05:19:38 +09:00
parent 5caa4e0633
commit 18cba1c8d3
5 changed files with 44 additions and 0 deletions

View File

@ -86,6 +86,10 @@ class Rect implements IRect {
public toQRect(): QRect {
return Qt.rect(this.x, this.y, this.width, this.height);
}
public toString(): string {
return "Rect(" + [this.x, this.y, this.width, this.height].join(", ") + ")";
}
}
function clip(min: number, value: number, max: number): number {

View File

@ -133,6 +133,7 @@ class TilingEngine {
if (!tile) return;
if (!tile.isTileable) return;
tile.adjustPadding();
tile.commitGeometry();
}

4
src/kwin.d.ts vendored
View File

@ -83,6 +83,9 @@ declare namespace KWin {
readonly utility: boolean;
readonly windowRole: string;
readonly clientPos: QPoint;
readonly clientSize: QSize;
/* signal */
activitiesChanged: QSignal;
geometryChanged: QSignal;
@ -110,6 +113,7 @@ declare namespace KWin {
minimized: boolean;
noBorder: boolean;
onAllDesktops: boolean;
basicUnit: QSize;
/* signals */
desktopChanged: QSignal;

5
src/qt.d.ts vendored
View File

@ -21,6 +21,11 @@
interface QRect extends IRect {
}
interface QPoint {
x: number;
y: number;
}
interface QSize {
width: number;
height: number;

View File

@ -26,6 +26,9 @@ class Tile {
public geometry: Rect;
public isError: boolean;
private padWidth: number;
private padHeight: number;
constructor(client: KWin.Client) {
this.arrangeCount = 0;
this.client = client;
@ -33,6 +36,9 @@ class Tile {
this.floating = false;
this.geometry = Rect.from(client.geometry);
this.isError = false;
this.padWidth = 0;
this.padHeight = 0;
}
/*
@ -74,6 +80,13 @@ class Tile {
* Methods
*/
public adjustPadding() {
const size = this.client.clientSize;
this.padWidth = this.client.geometry.width - size.width;
this.padHeight = this.client.geometry.height - size.height;
debugObj(() => ["adjustPadding", {size, w: this.padWidth, h: this.padHeight}]);
}
public commitGeometry(reset?: boolean) {
if (this.floating) {
this.client.geometry = this.floatGeometry.toQRect();
@ -85,6 +98,22 @@ class Tile {
if (this.arrangeCount > 5) // TODO: define arbitrary constant
return;
/* respect resize increment */
const unit = this.client.basicUnit;
if (reset && !(unit.width === 1 && unit.height === 1)) /* NOT free-size */ {
const geom = this.geometry;
const base = this.client.minSize;
const nw = Math.floor((geom.width - base.width ) / unit.width);
const nh = Math.floor((geom.height - base.height) / unit.height);
this.geometry.width = base.width + unit.width * nw + this.padWidth;
this.geometry.height = base.height + unit.height * nh + this.padHeight;
const pw = this.padWidth;
const ph = this.padHeight;
debugObj(() => ["commitGometry", {geom, base, unit, pw, ph}]);
}
/* do not commit if not changed */
if (this.clientGeometry.x === this.geometry.x)
if (this.clientGeometry.y === this.geometry.y)
@ -104,6 +133,7 @@ class Tile {
this.geometry.width = clip(this.client.minSize.width , this.geometry.width , this.client.maxSize.width );
this.geometry.height = clip(this.client.minSize.height, this.geometry.height, this.client.maxSize.height);
debugObj(() => ["commitGeometry", {client: this.client, from: this.client.geometry, to: this.geometry}]);
this.client.geometry = this.geometry.toQRect();
}