From 3593d7cafdb51c5bcf49fe9747d9aaa6ebbbf7a8 Mon Sep 17 00:00:00 2001 From: Lucas Oskorep Date: Wed, 15 Oct 2025 23:53:55 -0400 Subject: [PATCH] feat: remove crap code --- src/wm/container.ts | 25 +++++++++++++++++++++++++ src/wm/monitor.ts | 11 +++++++++++ src/wm/windowManager.ts | 26 +++++++++++++++++++++++--- 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/wm/container.ts b/src/wm/container.ts index 159d477..bde682b 100644 --- a/src/wm/container.ts +++ b/src/wm/container.ts @@ -16,12 +16,14 @@ export default class WindowContainer { _tiledWindowLookup: Map; _orientation: Orientation = Orientation.HORIZONTAL; _workArea: Rect; + _customSizes: Map; // Maps window ID to custom width (horizontal) or height (vertical) constructor(workspaceArea: Rect,) { // this._id = monitorId; this._tiledItems = []; this._tiledWindowLookup = new Map(); this._workArea = workspaceArea; + this._customSizes = new Map(); } @@ -74,6 +76,7 @@ export default class WindowContainer { removeWindow(win_id: number): void { if (this._tiledWindowLookup.has(win_id)) { this._tiledWindowLookup.delete(win_id); + this._customSizes.delete(win_id); const index = this._getIndexOfWindow(win_id) this._tiledItems.splice(index, 1); } else { @@ -201,5 +204,27 @@ export default class WindowContainer { } + windowManuallyResized(win_id: number): void { + const window = this.getWindow(win_id); + if (!window) { + // Check nested containers + for (const item of this._tiledItems) { + if (item instanceof WindowContainer) { + item.windowManuallyResized(win_id); + } + } + return; + } + + const rect = window.getRect(); + if (this._orientation === Orientation.HORIZONTAL) { + this._customSizes.set(win_id, rect.width); + Logger.log(`Window ${win_id} manually resized to width: ${rect.width}`); + } else { + this._customSizes.set(win_id, rect.height); + Logger.log(`Window ${win_id} manually resized to height: ${rect.height}`); + } + } + } \ No newline at end of file diff --git a/src/wm/monitor.ts b/src/wm/monitor.ts index 640f74d..15b711f 100644 --- a/src/wm/monitor.ts +++ b/src/wm/monitor.ts @@ -83,4 +83,15 @@ export default class Monitor { this._workspaces[item.getWorkspace()].itemDragged(item, x, y); } + windowManuallyResized(win_id: number): void { + // Find which workspace contains the window and notify it + for (const container of this._workspaces) { + const win = container.getWindow(win_id); + if (win) { + container.windowManuallyResized(win_id); + return; + } + } + } + } \ No newline at end of file diff --git a/src/wm/windowManager.ts b/src/wm/windowManager.ts index d095593..bec1e79 100644 --- a/src/wm/windowManager.ts +++ b/src/wm/windowManager.ts @@ -199,9 +199,6 @@ export default class WindowManager implements IWindowManager { handleGrabOpBegin(display: Meta.Display, window: Meta.Window, op: Meta.GrabOp): void { - if (op === Meta.GrabOp.MOVING_UNCONSTRAINED){ - - } Logger.log("Grab Op Start", op); Logger.log(display, window, op) Logger.log(window.get_monitor()) @@ -210,9 +207,32 @@ export default class WindowManager implements IWindowManager { this._grabbedWindowId = window.get_id(); } + _isResizeOperation(op: Meta.GrabOp): boolean { + // Check if the operation is any kind of resize + return op === Meta.GrabOp.RESIZING_E || + op === Meta.GrabOp.RESIZING_W || + op === Meta.GrabOp.RESIZING_N || + op === Meta.GrabOp.RESIZING_S || + op === Meta.GrabOp.RESIZING_NE || + op === Meta.GrabOp.RESIZING_NW || + op === Meta.GrabOp.RESIZING_SE || + op === Meta.GrabOp.RESIZING_SW; + } + handleGrabOpEnd(display: Meta.Display, window: Meta.Window, op: Meta.GrabOp): void { Logger.log("Grab Op End ", op); Logger.log("primary display", display.get_primary_monitor()) + + const isResizing = this._isResizeOperation(op); + + if (isResizing) { + // Window was manually resized - capture the new size + const monitor = this._monitors.get(window.get_monitor()); + if (monitor) { + monitor.windowManuallyResized(window.get_id()); + } + } + this._grabbedWindowId = _UNUSED_WINDOW_ID; this._getWrappedWindow(window)?.stopDragging(); this._tileMonitors();