Compare commits
2 Commits
822a7bd2e4
...
50ceb02124
Author | SHA1 | Date | |
---|---|---|---|
|
50ceb02124 | ||
|
717c240d70 |
@@ -26,6 +26,7 @@ export default class aerospike extends Extension {
|
||||
|
||||
disable() {
|
||||
this.windowManager.disable()
|
||||
this.removeKeybindings()
|
||||
}
|
||||
|
||||
|
||||
|
2
justfile
2
justfile
@@ -33,7 +33,7 @@ run:
|
||||
install-and-run: install run
|
||||
|
||||
live-debug:
|
||||
journalctl /usr/bin/gnome-shell -f -o cat
|
||||
journalctl /usr/bin/gnome-shell -f -o cat | tee debug.log
|
||||
|
||||
#pack: build
|
||||
# gnome-extensions pack dist \
|
||||
|
@@ -2,27 +2,38 @@ import {WindowWrapper} from "./window.js";
|
||||
import {Logger} from "./utils/logger.js";
|
||||
import Mtk from "@girs/mtk-16";
|
||||
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;
|
||||
_windows: Map<number, WindowWrapper>;
|
||||
_minimized: Map<number, WindowWrapper>;
|
||||
_minimizedWindows: Map<number, WindowWrapper>;
|
||||
_workArea: Rect;
|
||||
|
||||
|
||||
constructor(monitorId: number) {
|
||||
constructor(monitorId: number, workspaceArea: Rect) {
|
||||
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;
|
||||
const _workArea = workspace.get_work_area_for_monitor(
|
||||
this._id
|
||||
);
|
||||
}
|
||||
|
||||
addWindow(winWrap: WindowWrapper): void {
|
||||
// Add window to managed windows
|
||||
this._windows.set(winWrap.getWindowId(), winWrap);
|
||||
queueEvent({
|
||||
name: "tiling-windows",
|
||||
callback: () => {
|
||||
this._tileWindows();
|
||||
}
|
||||
}, 100)
|
||||
}
|
||||
|
||||
getWindow(win_id: number): WindowWrapper | undefined {
|
||||
return this._windows.get(win_id)
|
||||
@@ -30,21 +41,29 @@ export default class MonitorManager {
|
||||
|
||||
removeWindow(win_id: number): void {
|
||||
this._windows.delete(win_id)
|
||||
// TODO: Should there be re-tiling in this function?
|
||||
this._tileWindows()
|
||||
}
|
||||
|
||||
minimizeWindow(winWrap: WindowWrapper): void {
|
||||
this._windows.delete(winWrap.getWindowId())
|
||||
this._minimized.set(winWrap.getWindowId(), winWrap)
|
||||
this._minimizedWindows.set(winWrap.getWindowId(), winWrap)
|
||||
}
|
||||
|
||||
unminimizeWindow(winWrap: WindowWrapper): void {
|
||||
if (this._minimized.has(winWrap.getWindowId())) {
|
||||
if (this._minimizedWindows.has(winWrap.getWindowId())) {
|
||||
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 {
|
||||
this._windows.clear()
|
||||
}
|
||||
@@ -55,28 +74,31 @@ export default class MonitorManager {
|
||||
const workArea = workspace.get_work_area_for_monitor(
|
||||
this._id
|
||||
);
|
||||
|
||||
Logger.log("Workspace", workspace);
|
||||
Logger.log("WorkArea", workArea);
|
||||
|
||||
// Get all windows for current workspace
|
||||
const windows = Array.from(this._windows.values())
|
||||
.filter(({_window}) => {
|
||||
|
||||
if (_window != null) {
|
||||
return _window.get_workspace() === workspace;
|
||||
let windows = this._getTilableWindows(workspace)
|
||||
|
||||
if (windows.length !== 0) {
|
||||
this._tileHorizontally(windows, workArea)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
_getTilableWindows(workspace: Meta.Workspace): WindowWrapper[] {
|
||||
|
||||
return Array.from(this._windows.values())
|
||||
.filter(({_window}) => {
|
||||
Logger.log("TILING WINDOW:", _window.get_id())
|
||||
return _window.get_workspace() === workspace;
|
||||
})
|
||||
.map(x => x);
|
||||
|
||||
if (windows.length === 0) {
|
||||
return;
|
||||
}
|
||||
this._tileHorizontally(windows, workArea)
|
||||
|
||||
}
|
||||
|
||||
|
||||
_tileHorizontally(windows: (WindowWrapper | null)[], workArea: Mtk.Rectangle) {
|
||||
_tileHorizontally(windows: (WindowWrapper)[], workArea: Mtk.Rectangle) {
|
||||
const windowWidth = Math.floor(workArea.width / windows.length);
|
||||
|
||||
windows.forEach((window, index) => {
|
||||
@@ -88,7 +110,7 @@ export default class MonitorManager {
|
||||
height: workArea.height
|
||||
};
|
||||
if (window != null) {
|
||||
window.safelyResizeWindow(rect.x, rect.y, rect.width, rect.height);
|
||||
window.safelyResizeWindow(rect);
|
||||
}
|
||||
});
|
||||
}
|
20
src/utils/events.ts
Normal file
20
src/utils/events.ts
Normal 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
6
src/utils/rect.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export type Rect = {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
188
src/window.ts
188
src/window.ts
@@ -1,20 +1,16 @@
|
||||
import Meta from 'gi://Meta';
|
||||
import GLib from "gi://GLib";
|
||||
import Clutter from "gi://Clutter";
|
||||
import {IWindowManager} from "./windowManager.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;
|
||||
|
||||
export class WindowWrapper {
|
||||
readonly _window: Meta.Window;
|
||||
readonly _windowMinimizedHandler: WindowMinimizedHandler;
|
||||
readonly _signals: Signal[];
|
||||
readonly _signals: number[];
|
||||
|
||||
constructor(window: Meta.Window, winMinimized: WindowMinimizedHandler) {
|
||||
this._window = window;
|
||||
@@ -33,199 +29,73 @@ export class WindowWrapper {
|
||||
connectWindowSignals(
|
||||
windowManager: IWindowManager,
|
||||
): void {
|
||||
|
||||
const windowId = this._window.get_id();
|
||||
|
||||
|
||||
const windowId = this._window.get_id()
|
||||
// Handle window destruction
|
||||
const destroyId = this._window.connect('unmanaging', window => {
|
||||
this._signals.push(
|
||||
this._window.connect('unmanaging', window => {
|
||||
Logger.log("REMOVING WINDOW", windowId);
|
||||
windowManager.handleWindowClosed(this)
|
||||
});
|
||||
this._signals.push({name: 'unmanaging', id: destroyId});
|
||||
|
||||
// Handle focus changes
|
||||
const focusId = this._window.connect('notify::has-focus', () => {
|
||||
if (this._window.has_focus()) {
|
||||
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;
|
||||
|
||||
// const positionChangedId = this._window.connect('position-changed', window => {
|
||||
// Logger.log("position-changed", window.get_id());
|
||||
// Logger.log(window.get_monitor())
|
||||
// // const currentTime = Date.now();
|
||||
// // const [x, y, _] = global.get_pointer();
|
||||
// //
|
||||
// // // If this is the first move or it's been a while since the last move, consider it the start of a drag
|
||||
// // if (!dragInProgress) {
|
||||
// // 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', () => {
|
||||
}),
|
||||
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', () => {
|
||||
}),
|
||||
this._window.connect('notify::has-focus', () => {
|
||||
if (this._window.has_focus()) {
|
||||
windowManager._activeWindowId = windowId;
|
||||
}
|
||||
}),
|
||||
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 {
|
||||
|
||||
// Disconnect signals
|
||||
if (this._signals) {
|
||||
this._signals.forEach(signal => {
|
||||
try {
|
||||
if (this._window != null) {
|
||||
this._window.disconnect(signal.id);
|
||||
this._window.disconnect(signal);
|
||||
}
|
||||
} catch (e) {
|
||||
// Window might already be gone
|
||||
Logger.warn("error disconnecting signal", signal, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
resizeWindow(x: number, y: number, width: number, height: number) {
|
||||
// First, ensure window is not maximized or fullscreen
|
||||
if (this._window.get_maximized()) {
|
||||
Logger.log("WINDOW MAXIMIZED")
|
||||
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);
|
||||
// This is meant to be an exact copy of Forge's move function, renamed to maintain your API
|
||||
safelyResizeWindow(rect: Rect): void {
|
||||
// Keep minimal logging
|
||||
Logger.log("SAFELY RESIZE", rect.x, rect.y, rect.width, rect.height);
|
||||
const actor = this._window.get_compositor_private();
|
||||
|
||||
if (!actor) {
|
||||
Logger.log("No actor available, can't resize safely yet");
|
||||
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
|
||||
};
|
||||
}
|
@@ -6,7 +6,9 @@ import {WindowWrapper} from './window.js';
|
||||
import * as Main from "resource:///org/gnome/shell/ui/main.js";
|
||||
import Mtk from "@girs/mtk-16";
|
||||
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 {
|
||||
@@ -23,16 +25,17 @@ export interface IWindowManager {
|
||||
syncActiveWindow(): number | null;
|
||||
}
|
||||
|
||||
|
||||
const _UNUSED_MONITOR_ID = -1
|
||||
export default class WindowManager implements IWindowManager {
|
||||
_displaySignals: number[];
|
||||
_windowManagerSignals: number[];
|
||||
_workspaceManagerSignals: number[];
|
||||
_shieldScreenSignals: number[];
|
||||
_overviewSignals: number[];
|
||||
|
||||
_activeWindowId: number | null;
|
||||
_grabbedWindowMonitor: number;
|
||||
_monitors: Map<number, MonitorManager>;
|
||||
_monitors: Map<number, WindowContainer>;
|
||||
_sessionProxy: Gio.DBusProxy | null;
|
||||
_lockedSignalId: number | null;
|
||||
_isScreenLocked: boolean;
|
||||
@@ -42,42 +45,28 @@ export default class WindowManager implements IWindowManager {
|
||||
this._windowManagerSignals = [];
|
||||
this._workspaceManagerSignals = [];
|
||||
this._overviewSignals = [];
|
||||
this._shieldScreenSignals = [];
|
||||
this._activeWindowId = null;
|
||||
this._grabbedWindowMonitor = _UNUSED_MONITOR_ID;
|
||||
this._monitors = new Map<number, MonitorManager>();
|
||||
this._monitors = new Map<number, WindowContainer>();
|
||||
this._sessionProxy = null;
|
||||
this._lockedSignalId = null;
|
||||
this._isScreenLocked = false;
|
||||
this._isScreenLocked = false; // Initialize to unlocked state
|
||||
|
||||
}
|
||||
|
||||
public enable(): void {
|
||||
Logger.log("Starting Aerospike Window Manager");
|
||||
this.captureExistingWindows();
|
||||
// Connect window signals
|
||||
this.instantiateDisplaySignals()
|
||||
this.instantiateDisplaySignals();
|
||||
|
||||
const mon_count = global.display.get_n_monitors();
|
||||
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 {
|
||||
Logger.log("DISABLED AEROSPIKE WINDOW MANAGER!")
|
||||
// Disconnect the focus signal and remove any existing borders
|
||||
this.disconnectDisplaySignals();
|
||||
this.removeAllWindows();
|
||||
this.captureExistingWindows();
|
||||
}
|
||||
|
||||
removeAllWindows(): void {
|
||||
this._monitors.forEach((monitor: MonitorManager) => {
|
||||
monitor.removeAllWindows();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
instantiateDisplaySignals(): void {
|
||||
this._displaySignals.push(
|
||||
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", () => {
|
||||
Logger.log("SHOWING DESKTOP CHANGED");
|
||||
}),
|
||||
global.display.connect("workareas-changed", () => {
|
||||
global.display.connect("workareas-changed", (display) => {
|
||||
Logger.log("WORK AREAS CHANGED");
|
||||
}),
|
||||
global.display.connect("in-fullscreen-changed", () => {
|
||||
@@ -103,20 +92,12 @@ export default class WindowManager implements IWindowManager {
|
||||
}),
|
||||
)
|
||||
|
||||
|
||||
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) => {
|
||||
Logger.log("SHOW TITLE PREVIEW!")
|
||||
}),
|
||||
];
|
||||
|
||||
|
||||
this._workspaceManagerSignals = [
|
||||
global.workspace_manager.connect("showing-desktop-changed", () => {
|
||||
Logger.log("SHOWING DESKTOP CHANGED AT WORKSPACE LEVEL");
|
||||
@@ -132,21 +113,16 @@ export default class WindowManager implements IWindowManager {
|
||||
}),
|
||||
];
|
||||
|
||||
|
||||
this._overviewSignals = [
|
||||
Main.overview.connect("hiding", () => {
|
||||
// this.fromOverview = true;
|
||||
Logger.log("HIDING OVERVIEW")
|
||||
const eventObj = {
|
||||
name: "focus-after-overview",
|
||||
callback: () => {
|
||||
// const focusNodeWindow = this.tree.findNode(this.focusMetaWindow);
|
||||
// this.updateStackedFocus(focusNodeWindow);
|
||||
// this.updateTabbedFocus(focusNodeWindow);
|
||||
// this.movePointerWith(focusNodeWindow);
|
||||
Logger.log("FOCUSING AFTER OVERVIEW");
|
||||
},
|
||||
};
|
||||
// const eventObj = {
|
||||
// name: "focus-after-overview",
|
||||
// callback: () => {
|
||||
// Logger.log("FOCUSING AFTER OVERVIEW");
|
||||
// },
|
||||
// };
|
||||
// this.queueEvent(eventObj);
|
||||
}),
|
||||
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());
|
||||
}
|
||||
|
||||
public disable(): void {
|
||||
Logger.log("DISABLED AEROSPIKE WINDOW MANAGER!")
|
||||
// Disconnect the focus signal and remove any existing borders
|
||||
this.disconnectSignals();
|
||||
this.removeAllWindows();
|
||||
}
|
||||
|
||||
removeAllWindows(): void {
|
||||
this._monitors.forEach((monitor: WindowContainer) => {
|
||||
monitor.removeAllWindows();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// Handler for unlock event
|
||||
|
||||
// this._signalsBound = true;
|
||||
disconnectSignals(): void {
|
||||
this.disconnectDisplaySignals();
|
||||
this.disconnectMonitorSignals();
|
||||
}
|
||||
|
||||
disconnectMonitorSignals(): void {
|
||||
this._monitors.forEach((monitor: WindowContainer) => {
|
||||
monitor.disconnectSignals();
|
||||
})
|
||||
}
|
||||
|
||||
disconnectDisplaySignals(): void {
|
||||
this._displaySignals.forEach((signal) => {
|
||||
global.disconnect(signal)
|
||||
global.display.disconnect(signal)
|
||||
})
|
||||
this._windowManagerSignals.forEach((signal) => {
|
||||
global.disconnect(signal)
|
||||
global.window_manager.disconnect(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 {
|
||||
Logger.log("Grab Op Start");
|
||||
Logger.log(display, window, op)
|
||||
@@ -195,7 +187,6 @@ export default class WindowManager implements IWindowManager {
|
||||
Logger.log("primary display", display.get_primary_monitor())
|
||||
var rect = window.get_frame_rect()
|
||||
Logger.info("Release Location", window.get_monitor(), rect.x, rect.y, rect.width, rect.height)
|
||||
this._tileMonitors();
|
||||
const old_mon_id = this._grabbedWindowMonitor;
|
||||
const new_mon_id = window.get_monitor();
|
||||
|
||||
@@ -215,6 +206,7 @@ export default class WindowManager implements IWindowManager {
|
||||
}
|
||||
new_mon.addWindow(wrapped)
|
||||
}
|
||||
this._tileMonitors();
|
||||
Logger.info("monitor_start and monitor_end", this._grabbedWindowMonitor, window.get_monitor());
|
||||
}
|
||||
|
||||
@@ -256,10 +248,6 @@ export default class WindowManager implements IWindowManager {
|
||||
return;
|
||||
}
|
||||
Logger.log("WINDOW IS TILABLE");
|
||||
const actor = window.get_compositor_private();
|
||||
if (!actor) {
|
||||
return;
|
||||
}
|
||||
this.addWindowToMonitor(window);
|
||||
}
|
||||
|
||||
@@ -269,7 +257,7 @@ export default class WindowManager implements IWindowManager {
|
||||
*/
|
||||
handleWindowClosed(window: WindowWrapper): void {
|
||||
|
||||
window.disconnectWindowSignals()
|
||||
// window.disconnectWindowSignals()
|
||||
const mon_id = window._window.get_monitor();
|
||||
this._monitors.get(mon_id)?.removeWindow(window.getWindowId());
|
||||
|
||||
@@ -281,29 +269,22 @@ export default class WindowManager implements IWindowManager {
|
||||
|
||||
|
||||
public addWindowToMonitor(window: Meta.Window) {
|
||||
Logger.log("ADDING WINDOW TO MONITOR", window, window);
|
||||
var wrapper = new WindowWrapper(window, this.handleWindowMinimized)
|
||||
wrapper.connectWindowSignals(this)
|
||||
wrapper.connectWindowSignals(this);
|
||||
// wrapper.connectWindowSignals(this)
|
||||
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 {
|
||||
|
||||
for (const monitor of this._monitors.values()) {
|
||||
monitor._tileWindows()
|
||||
}
|
||||
}
|
||||
|
||||
_isWindowTileable(window: Meta.Window) {
|
||||
|
||||
if (!window || !window.get_compositor_private()) {
|
||||
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
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user