2 Commits

Author SHA1 Message Date
Lucas Oskorep
50ceb02124 feat: refactoring 2025-05-04 17:17:33 -04:00
Lucas Oskorep
717c240d70 feat: fixed display signal handling on disable 2025-05-02 01:31:46 -04:00
7 changed files with 170 additions and 311 deletions

View File

@@ -26,6 +26,7 @@ export default class aerospike extends Extension {
disable() { disable() {
this.windowManager.disable() this.windowManager.disable()
this.removeKeybindings()
} }

View File

@@ -33,7 +33,7 @@ run:
install-and-run: install run install-and-run: install run
live-debug: live-debug:
journalctl /usr/bin/gnome-shell -f -o cat journalctl /usr/bin/gnome-shell -f -o cat | tee debug.log
#pack: build #pack: build
# gnome-extensions pack dist \ # gnome-extensions pack dist \

View File

@@ -2,26 +2,37 @@ import {WindowWrapper} from "./window.js";
import {Logger} from "./utils/logger.js"; import {Logger} from "./utils/logger.js";
import Mtk from "@girs/mtk-16"; import Mtk from "@girs/mtk-16";
import Meta from "gi://Meta"; import Meta from "gi://Meta";
import GLib from "gi://GLib";
import queueEvent from "./utils/events.js";
import {Rect} from "./utils/rect.js";
export default class MonitorManager { export default class WindowContainer {
_id: number; _id: number;
_windows: Map<number, WindowWrapper>; _windows: Map<number, WindowWrapper>;
_minimized: Map<number, WindowWrapper>; _minimizedWindows: Map<number, WindowWrapper>;
_workArea: Rect;
constructor(monitorId: number, workspaceArea: Rect) {
constructor(monitorId: number) {
this._windows = new Map<number, WindowWrapper>(); this._windows = new Map<number, WindowWrapper>();
this._minimized = new Map<number, WindowWrapper>(); this._minimizedWindows = new Map<number, WindowWrapper>();
const workspace = global.workspace_manager.get_active_workspace();
this._id = monitorId; this._id = monitorId;
const _workArea = workspace.get_work_area_for_monitor(
this._id
);
} }
addWindow(winWrap: WindowWrapper): void { addWindow(winWrap: WindowWrapper): void {
// Add window to managed windows // Add window to managed windows
this._windows.set(winWrap.getWindowId(), winWrap); this._windows.set(winWrap.getWindowId(), winWrap);
this._tileWindows(); queueEvent({
name: "tiling-windows",
callback: () => {
this._tileWindows();
}
}, 100)
} }
getWindow(win_id: number): WindowWrapper | undefined { getWindow(win_id: number): WindowWrapper | undefined {
@@ -30,21 +41,29 @@ export default class MonitorManager {
removeWindow(win_id: number): void { removeWindow(win_id: number): void {
this._windows.delete(win_id) this._windows.delete(win_id)
// TODO: Should there be re-tiling in this function?
this._tileWindows() this._tileWindows()
} }
minimizeWindow(winWrap: WindowWrapper): void { minimizeWindow(winWrap: WindowWrapper): void {
this._windows.delete(winWrap.getWindowId()) this._windows.delete(winWrap.getWindowId())
this._minimized.set(winWrap.getWindowId(), winWrap) this._minimizedWindows.set(winWrap.getWindowId(), winWrap)
} }
unminimizeWindow(winWrap: WindowWrapper): void { unminimizeWindow(winWrap: WindowWrapper): void {
if (this._minimized.has(winWrap.getWindowId())) { if (this._minimizedWindows.has(winWrap.getWindowId())) {
this._windows.set(winWrap.getWindowId(), winWrap); this._windows.set(winWrap.getWindowId(), winWrap);
this._minimized.delete(winWrap.getWindowId()); this._minimizedWindows.delete(winWrap.getWindowId());
} }
} }
disconnectSignals(): void {
this._windows.forEach((window) => {
window.disconnectWindowSignals();
}
)
}
removeAllWindows(): void { removeAllWindows(): void {
this._windows.clear() this._windows.clear()
} }
@@ -55,28 +74,31 @@ export default class MonitorManager {
const workArea = workspace.get_work_area_for_monitor( const workArea = workspace.get_work_area_for_monitor(
this._id this._id
); );
Logger.log("Workspace", workspace); Logger.log("Workspace", workspace);
Logger.log("WorkArea", workArea); Logger.log("WorkArea", workArea);
// Get all windows for current workspace // Get all windows for current workspace
const windows = Array.from(this._windows.values())
.filter(({_window}) => {
if (_window != null) { let windows = this._getTilableWindows(workspace)
return _window.get_workspace() === workspace;
}
})
.map(x => x);
if (windows.length === 0) { if (windows.length !== 0) {
return; this._tileHorizontally(windows, workArea)
} }
this._tileHorizontally(windows, workArea) return true
} }
_getTilableWindows(workspace: Meta.Workspace): WindowWrapper[] {
_tileHorizontally(windows: (WindowWrapper | null)[], workArea: Mtk.Rectangle) { return Array.from(this._windows.values())
.filter(({_window}) => {
Logger.log("TILING WINDOW:", _window.get_id())
return _window.get_workspace() === workspace;
})
.map(x => x);
}
_tileHorizontally(windows: (WindowWrapper)[], workArea: Mtk.Rectangle) {
const windowWidth = Math.floor(workArea.width / windows.length); const windowWidth = Math.floor(workArea.width / windows.length);
windows.forEach((window, index) => { windows.forEach((window, index) => {
@@ -88,7 +110,7 @@ export default class MonitorManager {
height: workArea.height height: workArea.height
}; };
if (window != null) { if (window != null) {
window.safelyResizeWindow(rect.x, rect.y, rect.width, rect.height); window.safelyResizeWindow(rect);
} }
}); });
} }

20
src/utils/events.ts Normal file
View File

@@ -0,0 +1,20 @@
import GLib from "gi://GLib";
export type QueuedEvent = {
name: string;
callback: () => void;
}
const queuedEvents: QueuedEvent[] = [];
export default function queueEvent(event: QueuedEvent, interval = 200) {
queuedEvents.push(event);
GLib.timeout_add(GLib.PRIORITY_DEFAULT, interval, () => {
const e = queuedEvents.pop()
if (e) {
e.callback();
}
return queuedEvents.length !== 0;
});
}

6
src/utils/rect.ts Normal file
View File

@@ -0,0 +1,6 @@
export type Rect = {
x: number;
y: number;
width: number;
height: number;
}

View File

@@ -1,20 +1,16 @@
import Meta from 'gi://Meta'; import Meta from 'gi://Meta';
import GLib from "gi://GLib";
import Clutter from "gi://Clutter"; import Clutter from "gi://Clutter";
import {IWindowManager} from "./windowManager.js"; import {IWindowManager} from "./windowManager.js";
import {Logger} from "./utils/logger.js"; import {Logger} from "./utils/logger.js";
import {Rect} from "./utils/rect.js";
export type Signal = {
name: string;
id: number;
}
type WindowMinimizedHandler = (window: WindowWrapper) => void; type WindowMinimizedHandler = (window: WindowWrapper) => void;
export class WindowWrapper { export class WindowWrapper {
readonly _window: Meta.Window; readonly _window: Meta.Window;
readonly _windowMinimizedHandler: WindowMinimizedHandler; readonly _windowMinimizedHandler: WindowMinimizedHandler;
readonly _signals: Signal[]; readonly _signals: number[];
constructor(window: Meta.Window, winMinimized: WindowMinimizedHandler) { constructor(window: Meta.Window, winMinimized: WindowMinimizedHandler) {
this._window = window; this._window = window;
@@ -33,199 +29,73 @@ export class WindowWrapper {
connectWindowSignals( connectWindowSignals(
windowManager: IWindowManager, windowManager: IWindowManager,
): void { ): void {
const windowId = this._window.get_id()
const windowId = this._window.get_id();
// Handle window destruction // Handle window destruction
const destroyId = this._window.connect('unmanaging', window => { this._signals.push(
Logger.log("REMOVING WINDOW", windowId); this._window.connect('unmanaging', window => {
windowManager.handleWindowClosed(this) Logger.log("REMOVING WINDOW", windowId);
}); windowManager.handleWindowClosed(this)
this._signals.push({name: 'unmanaging', id: destroyId}); }),
this._window.connect('notify::minimized', () => {
if (this._window.minimized) {
Logger.log(`Window minimized: ${windowId}`);
windowManager.handleWindowMinimized(this);
// Handle focus changes } else if (!this._window.minimized) {
const focusId = this._window.connect('notify::has-focus', () => { Logger.log(`Window unminimized: ${windowId}`);
if (this._window.has_focus()) { windowManager.handleWindowUnminimized(this);
windowManager._activeWindowId = windowId;
}
});
this._signals.push({name: 'notify::has-focus', id: focusId});
// Track window movement using position-changed signal }
let lastPositionChangeTime = 0; }),
let dragInProgress = false; this._window.connect('notify::has-focus', () => {
if (this._window.has_focus()) {
// const positionChangedId = this._window.connect('position-changed', window => { windowManager._activeWindowId = windowId;
// Logger.log("position-changed", window.get_id()); }
// Logger.log(window.get_monitor()) }),
// // const currentTime = Date.now(); this._window.connect('notify::maximized-horizontally', () => {
// // const [x, y, _] = global.get_pointer(); if (this._window.get_maximized()) {
// // Logger.log(`Window maximized: ${windowId}`);
// // // If this is the first move or it's been a while since the last move, consider it the start of a drag } else {
// // if (!dragInProgress) { Logger.log(`Window unmaximized: ${windowId}`);
// // dragInProgress = true; }
// // Logger.log(`Window drag started for window ${windowId}. Mouse position: ${x}, ${y}`); }),
// // } );
// //
// // // Update the time of the last position change
// // lastPositionChangeTime = currentTime;
// //
// // // Set a timeout to detect when dragging stops (when position changes stop coming in)
// // GLib.timeout_add(GLib.PRIORITY_DEFAULT, 300, () => {
// // const timeSinceLastMove = Date.now() - lastPositionChangeTime;
// // // If it's been more than 200ms since the last move and we were dragging, consider the drag ended
// // if (timeSinceLastMove >= 200 && dragInProgress) {
// // dragInProgress = false;
// // const [endX, endY, _] = global.get_pointer();
// // Logger.log(`Window drag ended for window ${windowId}. Mouse position: ${endX}, ${endY}`);
// // }
// // return GLib.SOURCE_REMOVE; // Remove the timeout
// // });
// });
// this._signals.push({name: 'position-changed', id: positionChangedId});
// Handle minimization
const minimizeId = this._window.connect('notify::minimized', () => {
if (this._window.minimized) {
Logger.log(`Window minimized: ${windowId}`);
// Remove window from managed windows temporarily
// windowManager.removeFromTree(this._window);
// If this was the active window, find a new one
// Retile remaining windows
windowManager.handleWindowMinimized(this);
} else if (!this._window.minimized) {
Logger.log(`Window unminimized: ${windowId}`);
// windowManager.addWindow(this._window);
windowManager.handleWindowUnminimized(this);
}
});
this._signals.push({name: 'notify::minimized', id: minimizeId});
// Handle maximization
const maximizeId = this._window.connect('notify::maximized-horizontally', () => {
if (this._window.get_maximized()) {
Logger.log(`Window maximized: ${windowId}`);
} else {
Logger.log(`Window unmaximized: ${windowId}`);
}
});
this._signals.push({name: 'notify::maximized-horizontally', id: maximizeId});
} }
disconnectWindowSignals(): void { disconnectWindowSignals(): void {
// Disconnect signals
if (this._signals) { if (this._signals) {
this._signals.forEach(signal => { this._signals.forEach(signal => {
try { try {
if (this._window != null) { if (this._window != null) {
this._window.disconnect(signal.id); this._window.disconnect(signal);
} }
} catch (e) { } catch (e) {
// Window might already be gone Logger.warn("error disconnecting signal", signal, e);
} }
}); });
} }
} }
resizeWindow(x: number, y: number, width: number, height: number) { // This is meant to be an exact copy of Forge's move function, renamed to maintain your API
// First, ensure window is not maximized or fullscreen safelyResizeWindow(rect: Rect): void {
if (this._window.get_maximized()) { // Keep minimal logging
Logger.log("WINDOW MAXIMIZED") Logger.log("SAFELY RESIZE", rect.x, rect.y, rect.width, rect.height);
this._window.unmaximize(Meta.MaximizeFlags.BOTH);
}
if (this._window.is_fullscreen()) {
Logger.log("WINDOW IS FULLSCREEN")
this._window.unmake_fullscreen();
}
// Logger.log("WINDOW", this._window.get_window_type(), this._window.allows_move());
// Logger.log("MONITOR INFO", getUsableMonitorSpace(this._window));
// Logger.log("NEW_SIZE", x, y, width, height);
// win.move_resize_frame(false, 50, 50, 300, 300);
this._window.move_resize_frame(false, x, y, width, height);
// Logger.log("RESIZED WINDOW", this._window.get_frame_rect().height, this._window.get_frame_rect().width, this._window.get_frame_rect().x, this._window.get_frame_rect().y);
}
safelyResizeWindow(x: number, y: number, width: number, height: number): void {
Logger.log("SAFELY RESIZE", x, y, width, height);
const actor = this._window.get_compositor_private(); const actor = this._window.get_compositor_private();
if (!actor) { if (!actor) {
Logger.log("No actor available, can't resize safely yet"); Logger.log("No actor available, can't resize safely yet");
return; return;
} }
let windowActor = this._window.get_compositor_private() as Clutter.Actor;
if (!windowActor) return;
windowActor.remove_all_transitions();
Logger.info("MOVING")
this._window.move_frame(true, rect.x, rect.y);
Logger.info("RESIZING MOVING")
this._window.move_resize_frame(true, rect.x, rect.y, rect.width, rect.height);
// Set a flag to track if the resize has been done
let resizeDone = false;
// Connect to the first-frame signal
const id = actor.connect('first-frame', () => {
// Disconnect the signal handler
actor.disconnect(id);
if (!resizeDone) {
resizeDone = true;
// Add a small delay
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 50, () => {
try {
this.resizeWindow(x, y, width, height);
} catch (e) {
console.error("Error resizing window:", e);
}
return GLib.SOURCE_REMOVE;
});
}
});
// Fallback timeout in case the first-frame signal doesn't fire
// (for windows that are already mapped)
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 50, () => {
if (!resizeDone) {
resizeDone = true;
try {
this.resizeWindow(x, y, width, height);
} catch (e) {
console.error("Error resizing window (fallback):", e);
}
}
return GLib.SOURCE_REMOVE;
});
} }
// if (!this._window) return;
// this._window.unmaximize(Meta.MaximizeFlags.HORIZONTAL);
// this._window.unmaximize(Meta.MaximizeFlags.VERTICAL);
// this._window.unmaximize(Meta.MaximizeFlags.BOTH);
//
// let windowActor = this._window.get_compositor_private() as Clutter.Actor;
// if (!windowActor) return;
// windowActor.remove_all_transitions();
//
// this._window.move_frame(true, x, y);
// this._window.move_resize_frame(true, x, y, width, height);
} }
function getUsableMonitorSpace(window: Meta.Window) {
// Get the current workspace
const workspace = window.get_workspace();
// Get the monitor index that this window is on
const monitorIndex = window.get_monitor();
// Get the work area
const workArea = workspace.get_work_area_for_monitor(monitorIndex);
return {
x: workArea.x,
y: workArea.y,
width: workArea.width,
height: workArea.height
};
}

View File

@@ -6,7 +6,9 @@ import {WindowWrapper} from './window.js';
import * as Main from "resource:///org/gnome/shell/ui/main.js"; import * as Main from "resource:///org/gnome/shell/ui/main.js";
import Mtk from "@girs/mtk-16"; import Mtk from "@girs/mtk-16";
import {Logger} from "./utils/logger.js"; import {Logger} from "./utils/logger.js";
import MonitorManager from "./monitor.js"; import WindowContainer from "./container.js";
import {MessageTray} from "@girs/gnome-shell/ui/messageTray";
import queueEvent, {QueuedEvent} from "./utils/events.js";
export interface IWindowManager { export interface IWindowManager {
@@ -23,16 +25,17 @@ export interface IWindowManager {
syncActiveWindow(): number | null; syncActiveWindow(): number | null;
} }
const _UNUSED_MONITOR_ID = -1 const _UNUSED_MONITOR_ID = -1
export default class WindowManager implements IWindowManager { export default class WindowManager implements IWindowManager {
_displaySignals: number[]; _displaySignals: number[];
_windowManagerSignals: number[]; _windowManagerSignals: number[];
_workspaceManagerSignals: number[]; _workspaceManagerSignals: number[];
_shieldScreenSignals: number[];
_overviewSignals: number[]; _overviewSignals: number[];
_activeWindowId: number | null; _activeWindowId: number | null;
_grabbedWindowMonitor: number; _grabbedWindowMonitor: number;
_monitors: Map<number, MonitorManager>; _monitors: Map<number, WindowContainer>;
_sessionProxy: Gio.DBusProxy | null; _sessionProxy: Gio.DBusProxy | null;
_lockedSignalId: number | null; _lockedSignalId: number | null;
_isScreenLocked: boolean; _isScreenLocked: boolean;
@@ -42,42 +45,28 @@ export default class WindowManager implements IWindowManager {
this._windowManagerSignals = []; this._windowManagerSignals = [];
this._workspaceManagerSignals = []; this._workspaceManagerSignals = [];
this._overviewSignals = []; this._overviewSignals = [];
this._shieldScreenSignals = [];
this._activeWindowId = null; this._activeWindowId = null;
this._grabbedWindowMonitor = _UNUSED_MONITOR_ID; this._grabbedWindowMonitor = _UNUSED_MONITOR_ID;
this._monitors = new Map<number, MonitorManager>(); this._monitors = new Map<number, WindowContainer>();
this._sessionProxy = null; this._sessionProxy = null;
this._lockedSignalId = null; this._lockedSignalId = null;
this._isScreenLocked = false; this._isScreenLocked = false; // Initialize to unlocked state
} }
public enable(): void { public enable(): void {
Logger.log("Starting Aerospike Window Manager"); Logger.log("Starting Aerospike Window Manager");
this.captureExistingWindows();
// Connect window signals // Connect window signals
this.instantiateDisplaySignals() this.instantiateDisplaySignals();
const mon_count = global.display.get_n_monitors(); const mon_count = global.display.get_n_monitors();
for (let i = 0; i < mon_count; i++) { for (let i = 0; i < mon_count; i++) {
this._monitors.set(i, new MonitorManager(i)); this._monitors.set(i, new WindowContainer(i));
} }
}
public disable(): void { this.captureExistingWindows();
Logger.log("DISABLED AEROSPIKE WINDOW MANAGER!")
// Disconnect the focus signal and remove any existing borders
this.disconnectDisplaySignals();
this.removeAllWindows();
} }
removeAllWindows(): void {
this._monitors.forEach((monitor: MonitorManager) => {
monitor.removeAllWindows();
})
}
instantiateDisplaySignals(): void { instantiateDisplaySignals(): void {
this._displaySignals.push( this._displaySignals.push(
global.display.connect("grab-op-begin", (display, window, op) => { global.display.connect("grab-op-begin", (display, window, op) => {
@@ -95,7 +84,7 @@ export default class WindowManager implements IWindowManager {
global.display.connect("showing-desktop-changed", () => { global.display.connect("showing-desktop-changed", () => {
Logger.log("SHOWING DESKTOP CHANGED"); Logger.log("SHOWING DESKTOP CHANGED");
}), }),
global.display.connect("workareas-changed", () => { global.display.connect("workareas-changed", (display) => {
Logger.log("WORK AREAS CHANGED"); Logger.log("WORK AREAS CHANGED");
}), }),
global.display.connect("in-fullscreen-changed", () => { global.display.connect("in-fullscreen-changed", () => {
@@ -103,20 +92,12 @@ export default class WindowManager implements IWindowManager {
}), }),
) )
this._windowManagerSignals = [ this._windowManagerSignals = [
// global.window_manager.connect("minimize", (_source, window) => {
// Logger.log("MINIMIZING WINDOW")
// }),
// global.window_manager.connect("unminimize", (_source, window) => {
// Logger.log("WINDOW UNMINIMIZED");
// }),
global.window_manager.connect("show-tile-preview", (_, _metaWindow, _rect, _num) => { global.window_manager.connect("show-tile-preview", (_, _metaWindow, _rect, _num) => {
Logger.log("SHOW TITLE PREVIEW!") Logger.log("SHOW TITLE PREVIEW!")
}), }),
]; ];
this._workspaceManagerSignals = [ this._workspaceManagerSignals = [
global.workspace_manager.connect("showing-desktop-changed", () => { global.workspace_manager.connect("showing-desktop-changed", () => {
Logger.log("SHOWING DESKTOP CHANGED AT WORKSPACE LEVEL"); Logger.log("SHOWING DESKTOP CHANGED AT WORKSPACE LEVEL");
@@ -132,21 +113,16 @@ export default class WindowManager implements IWindowManager {
}), }),
]; ];
this._overviewSignals = [ this._overviewSignals = [
Main.overview.connect("hiding", () => { Main.overview.connect("hiding", () => {
// this.fromOverview = true; // this.fromOverview = true;
Logger.log("HIDING OVERVIEW") Logger.log("HIDING OVERVIEW")
const eventObj = { // const eventObj = {
name: "focus-after-overview", // name: "focus-after-overview",
callback: () => { // callback: () => {
// const focusNodeWindow = this.tree.findNode(this.focusMetaWindow); // Logger.log("FOCUSING AFTER OVERVIEW");
// this.updateStackedFocus(focusNodeWindow); // },
// this.updateTabbedFocus(focusNodeWindow); // };
// this.movePointerWith(focusNodeWindow);
Logger.log("FOCUSING AFTER OVERVIEW");
},
};
// this.queueEvent(eventObj); // this.queueEvent(eventObj);
}), }),
Main.overview.connect("showing", () => { Main.overview.connect("showing", () => {
@@ -155,34 +131,50 @@ export default class WindowManager implements IWindowManager {
}), }),
]; ];
// Main.screenShield;
// Handler for lock event }
this._shieldScreenSignals.push(Main.screenShield.connect('lock-screen', () => {
console.log('Session locked at:', new Date().toISOString());
}), Main.screenShield.connect('unlock-screen', () => {
console.log('Session unlocked at:', new Date().toISOString());
})
);
// Handler for unlock event public disable(): void {
Logger.log("DISABLED AEROSPIKE WINDOW MANAGER!")
// Disconnect the focus signal and remove any existing borders
this.disconnectSignals();
this.removeAllWindows();
}
// this._signalsBound = true; removeAllWindows(): void {
this._monitors.forEach((monitor: WindowContainer) => {
monitor.removeAllWindows();
})
}
disconnectSignals(): void {
this.disconnectDisplaySignals();
this.disconnectMonitorSignals();
}
disconnectMonitorSignals(): void {
this._monitors.forEach((monitor: WindowContainer) => {
monitor.disconnectSignals();
})
} }
disconnectDisplaySignals(): void { disconnectDisplaySignals(): void {
this._displaySignals.forEach((signal) => { this._displaySignals.forEach((signal) => {
global.disconnect(signal) global.display.disconnect(signal)
}) })
this._windowManagerSignals.forEach((signal) => { this._windowManagerSignals.forEach((signal) => {
global.disconnect(signal) global.window_manager.disconnect(signal)
}) })
this._workspaceManagerSignals.forEach((signal) => { this._workspaceManagerSignals.forEach((signal) => {
global.disconnect(signal) global.workspace_manager.disconnect(signal)
})
this._overviewSignals.forEach((signal) => {
Main.overview.disconnect(signal)
}) })
} }
handleGrabOpBegin(display: Meta.Display, window: Meta.Window, op: Meta.GrabOp): void { handleGrabOpBegin(display: Meta.Display, window: Meta.Window, op: Meta.GrabOp): void {
Logger.log("Grab Op Start"); Logger.log("Grab Op Start");
Logger.log(display, window, op) Logger.log(display, window, op)
@@ -195,7 +187,6 @@ export default class WindowManager implements IWindowManager {
Logger.log("primary display", display.get_primary_monitor()) Logger.log("primary display", display.get_primary_monitor())
var rect = window.get_frame_rect() var rect = window.get_frame_rect()
Logger.info("Release Location", window.get_monitor(), rect.x, rect.y, rect.width, rect.height) Logger.info("Release Location", window.get_monitor(), rect.x, rect.y, rect.width, rect.height)
this._tileMonitors();
const old_mon_id = this._grabbedWindowMonitor; const old_mon_id = this._grabbedWindowMonitor;
const new_mon_id = window.get_monitor(); const new_mon_id = window.get_monitor();
@@ -215,6 +206,7 @@ export default class WindowManager implements IWindowManager {
} }
new_mon.addWindow(wrapped) new_mon.addWindow(wrapped)
} }
this._tileMonitors();
Logger.info("monitor_start and monitor_end", this._grabbedWindowMonitor, window.get_monitor()); Logger.info("monitor_start and monitor_end", this._grabbedWindowMonitor, window.get_monitor());
} }
@@ -256,10 +248,6 @@ export default class WindowManager implements IWindowManager {
return; return;
} }
Logger.log("WINDOW IS TILABLE"); Logger.log("WINDOW IS TILABLE");
const actor = window.get_compositor_private();
if (!actor) {
return;
}
this.addWindowToMonitor(window); this.addWindowToMonitor(window);
} }
@@ -269,7 +257,7 @@ export default class WindowManager implements IWindowManager {
*/ */
handleWindowClosed(window: WindowWrapper): void { handleWindowClosed(window: WindowWrapper): void {
window.disconnectWindowSignals() // window.disconnectWindowSignals()
const mon_id = window._window.get_monitor(); const mon_id = window._window.get_monitor();
this._monitors.get(mon_id)?.removeWindow(window.getWindowId()); this._monitors.get(mon_id)?.removeWindow(window.getWindowId());
@@ -281,29 +269,22 @@ export default class WindowManager implements IWindowManager {
public addWindowToMonitor(window: Meta.Window) { public addWindowToMonitor(window: Meta.Window) {
Logger.log("ADDING WINDOW TO MONITOR", window, window);
var wrapper = new WindowWrapper(window, this.handleWindowMinimized) var wrapper = new WindowWrapper(window, this.handleWindowMinimized)
wrapper.connectWindowSignals(this) wrapper.connectWindowSignals(this);
// wrapper.connectWindowSignals(this)
this._monitors.get(window.get_monitor())?.addWindow(wrapper) this._monitors.get(window.get_monitor())?.addWindow(wrapper)
} }
// public UnmanageWindow(window: Meta.Window) {
// this._windows.delete(window.get_id());
// this._unmanagedWindows.add(window.get_id())
// }
//
// public ManageWindow(window: Meta.Window) {
// this._windows.set(window.get_id(), {
// window,
// })
// }
_tileMonitors(): void { _tileMonitors(): void {
for (const monitor of this._monitors.values()) { for (const monitor of this._monitors.values()) {
monitor._tileWindows() monitor._tileWindows()
} }
} }
_isWindowTileable(window: Meta.Window) { _isWindowTileable(window: Meta.Window) {
if (!window || !window.get_compositor_private()) { if (!window || !window.get_compositor_private()) {
return false; return false;
} }
@@ -329,47 +310,6 @@ export default class WindowManager implements IWindowManager {
* @returns The window ID of the active window, or null if no window is active * @returns The window ID of the active window, or null if no window is active
*/ */
public syncActiveWindow(): number | null { public syncActiveWindow(): number | null {
// // Get the active workspace
// const workspace = global.workspace_manager.get_active_workspace();
//
// // Check if there is an active window
// const activeWindow = global.display.get_focus_window();
//
// if (!activeWindow) {
// Logger.log("No active window found in GNOME");
// this._activeWindowId = null;
// return null;
// }
//
// // Get the window ID
// const windowId = activeWindow.get_id();
//
// // Check if this window is being managed by our extension
// if (this._windows.has(windowId)) {
// Logger.log(`Setting active window to ${windowId}`);
// this._activeWindowId = windowId;
// return windowId;
// } else {
// Logger.log(`Window ${windowId} is not managed by this extension`);
//
// // Try to find a managed window on the current workspace to make active
// const managedWindows = Array.from(this._windows.entries())
// .filter(([_, wrapper]) =>
// wrapper.window && wrapper.window.get_workspace() === workspace);
//
// if (managedWindows.length > 0) {
// // Take the first managed window on this workspace
// const firstWindowId = managedWindows[0][0];
// Logger.log(`Using managed window ${firstWindowId} as active instead`);
// this._activeWindowId = firstWindowId;
// return firstWindowId;
// }
//
// // No managed windows on this workspace
// Logger.log("No managed windows found on the active workspace");
// this._activeWindowId = null;
// return null;
// }
return null; return null;
} }