Skip to content

Commit

Permalink
Merge pull request #160 from ttytm/chore/fmt
Browse files Browse the repository at this point in the history
chore: format
  • Loading branch information
zeroxoneafour authored Jul 9, 2024
2 parents 515f699 + 14b2c7a commit 3a0b5cc
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 30 deletions.
28 changes: 13 additions & 15 deletions src/controller/actions/windowhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,11 @@ export class WindowHooks {
// have to use imrs and tilechanged
// interactive mr handles moving out of tiles, tilechanged handles moving into tiles
tileChanged(tile: Tile) {
if (
this.ctrl.driverManager.buildingLayout ||
tile == null
) {
if (this.ctrl.driverManager.buildingLayout || tile == null) {
return;
}
// client is moved into managed tile from outside
if (
!this.extensions.isTiled &&
this.ctrl.managedTiles.has(tile)
) {
if (!this.extensions.isTiled && this.ctrl.managedTiles.has(tile)) {
this.logger.debug(
"Putting window",
this.window.resourceClass,
Expand All @@ -95,7 +89,11 @@ export class WindowHooks {
}
// client is in a non-managed tile (move it to a managed one)
else if (!this.ctrl.managedTiles.has(tile)) {
this.logger.debug("Window", this.window.resourceClass, "moved into an unmanaged tile");
this.logger.debug(
"Window",
this.window.resourceClass,
"moved into an unmanaged tile",
);
const center = new GRect(tile.absoluteGeometryInScreen).center;
let newTile = this.ctrl.workspace
.tilingForScreen(this.window.output)
Expand All @@ -114,12 +112,14 @@ export class WindowHooks {
this.ctrl.driverManager.putWindowInTile(
this.window,
newTile,
new GRect(newTile.absoluteGeometryInScreen).directionFromPoint(center),
new GRect(newTile.absoluteGeometryInScreen).directionFromPoint(
center,
),
);
this.ctrl.driverManager.rebuildLayout(this.window.output);
}
}

// should be fine if i just leave this here without a timer
interactiveMoveResizeStepped() {
if (
Expand Down Expand Up @@ -158,7 +158,7 @@ export class WindowHooks {
this.ctrl.driverManager.rebuildLayout(this.window.output);
}
}

putWindowInBestTile(): void {
if (this.extensions.lastTiledLocation != null) {
// fancy and illegally long code to place tile in a similar position from when it was untiled
Expand Down Expand Up @@ -252,9 +252,7 @@ export class WindowHooks {
"set to",
maximized,
);
if (
(maximized && this.extensions.isTiled)
) {
if (maximized && this.extensions.isTiled) {
this.ctrl.driverManager.untileWindow(this.window);
this.ctrl.driverManager.rebuildLayout(this.window.output);
this.extensions.wasTiled = true;
Expand Down
21 changes: 10 additions & 11 deletions src/driver/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,17 @@ export class TilingDriver {
this.fixSizing(tile, kwinTile);
}
}

fixSizing(tile: Tile, kwinTile: Kwin.Tile): void {
// only resize if not root tile (obv)
if (tile.parent == null || kwinTile.parent == null) {
return;
}
let index = tile.parent.tiles.indexOf(tile);
let parentIndex = tile.parent.parent != null ? tile.parent.parent.tiles.indexOf(tile.parent) : null;
let parentIndex =
tile.parent.parent != null
? tile.parent.parent.tiles.indexOf(tile.parent)
: null;
const requestedSize = new GSize();
requestedSize.fitSize(tile.requestedSize);
for (const client of tile.clients) {
Expand All @@ -219,12 +222,12 @@ export class TilingDriver {
}
requestedSize.fitSize(window.minSize);
}
const horizontal = kwinTile.parent.layoutDirection == Kwin.LayoutDirection.Horizontal;
const horizontal =
kwinTile.parent.layoutDirection == Kwin.LayoutDirection.Horizontal;
// horiz resize
if (requestedSize.width > kwinTile.absoluteGeometryInScreen.width) {
let diff =
requestedSize.width -
kwinTile.absoluteGeometryInScreen.width;
requestedSize.width - kwinTile.absoluteGeometryInScreen.width;
if (horizontal) {
// if the layout is horizontal already, width resizing should be easy
if (index == 0) {
Expand All @@ -249,18 +252,14 @@ export class TilingDriver {
// vertical resize
if (requestedSize.height > kwinTile.absoluteGeometryInScreen.height) {
let diff =
requestedSize.height -
kwinTile.absoluteGeometryInScreen.height;
requestedSize.height - kwinTile.absoluteGeometryInScreen.height;
if (!horizontal) {
if (index == 0) {
// first tile in sequence, shift border down
kwinTile.resizeByPixels(diff, Kwin.Edge.BottomEdge);
} else {
// shift border up
kwinTile.resizeByPixels(
-diff,
Kwin.Edge.TopEdge,
);
kwinTile.resizeByPixels(-diff, Kwin.Edge.TopEdge);
}
} else if (parentIndex != null) {
if (parentIndex == 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/driver/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ export class DriverManager {

buildingLayout: boolean = false;
resizingLayout: boolean = false;

constructor(c: Controller) {
this.ctrl = c;
this.engineFactory = new TilingEngineFactory(this.ctrl.config);
this.logger = c.logger;
this.config = c.config;
this.config = c.config;
}

init(): void {
Expand Down
14 changes: 12 additions & 2 deletions src/util/geometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class GPoint implements QPoint {
y: r.y + r.height / 2,
});
}

toString(): string {
return "GPoint(" + this.x + ", " + this.y + ")";
}
Expand Down Expand Up @@ -192,7 +192,17 @@ export class GRect implements QRect {
}

toString(): string {
return "GRect(" + this.x + ", " + this.y + + ", " + this.width + ", " + this.height + ")";
return (
"GRect(" +
this.x +
", " +
this.y +
+", " +
this.width +
", " +
this.height +
")"
);
}
}

Expand Down

0 comments on commit 3a0b5cc

Please sign in to comment.