Compare commits
7 Commits
fe4558d628
...
feat/fix-l
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4543c98de8 | ||
|
|
ed661b3fa6 | ||
|
|
6a19b77742 | ||
|
|
7b0f37f3f9 | ||
|
|
e1e240924a | ||
|
|
185a8e233c | ||
|
|
84777c4db1 |
36
Makefile
36
Makefile
@@ -1,36 +0,0 @@
|
|||||||
NAME=aerospike
|
|
||||||
DOMAIN=lucaso.io
|
|
||||||
|
|
||||||
.PHONY: all pack install clean
|
|
||||||
|
|
||||||
all: dist/extension.js
|
|
||||||
|
|
||||||
node_modules: package.json
|
|
||||||
pnpm install
|
|
||||||
|
|
||||||
dist/extension.js : node_modules
|
|
||||||
tsc
|
|
||||||
|
|
||||||
schemas/gschemas.compiled: schemas/org.gnome.shell.extensions.$(NAME).gschema.xml
|
|
||||||
glib-compile-schemas schemas
|
|
||||||
|
|
||||||
$(NAME).zip: dist/extension.js dist/prefs.js schemas/gschemas.compiled
|
|
||||||
@rm -rf dist/*
|
|
||||||
@cp metadata.json dist/
|
|
||||||
@cp stylesheet.css dist/
|
|
||||||
@mkdir dist/schemas
|
|
||||||
@cp schemas/*.compiled dist/schemas/
|
|
||||||
@(cd dist && zip ../$(NAME).zip -9r .)
|
|
||||||
|
|
||||||
pack: $(NAME).zip
|
|
||||||
|
|
||||||
install: $(NAME).zip
|
|
||||||
|
|
||||||
clean:
|
|
||||||
@rm -rf dist node_modules $(NAME).zip
|
|
||||||
|
|
||||||
test:
|
|
||||||
@dbus-run-session -- gnome-shell --nested --wayland
|
|
||||||
|
|
||||||
.PHONY: install-and-test
|
|
||||||
install-and-test: install test
|
|
||||||
7
ambient.d.ts
vendored
7
ambient.d.ts
vendored
@@ -2,3 +2,10 @@ import "@girs/gjs";
|
|||||||
import "@girs/gjs/dom";
|
import "@girs/gjs/dom";
|
||||||
import "@girs/gnome-shell/ambient";
|
import "@girs/gnome-shell/ambient";
|
||||||
import "@girs/gnome-shell/extensions/global";
|
import "@girs/gnome-shell/extensions/global";
|
||||||
|
|
||||||
|
// Extend Meta.Window with our custom property
|
||||||
|
declare namespace Meta {
|
||||||
|
interface Window {
|
||||||
|
_aerospikeData?: any;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
422
extension.ts
422
extension.ts
@@ -1,319 +1,137 @@
|
|||||||
import GLib from 'gi://GLib';
|
|
||||||
import St from 'gi://St';
|
|
||||||
import Meta from 'gi://Meta';
|
import Meta from 'gi://Meta';
|
||||||
import {Extension, ExtensionMetadata} from 'resource:///org/gnome/shell/extensions/extension.js';
|
import {Extension, ExtensionMetadata} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||||
|
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||||
// import Gio from 'gi://Gio';
|
import Gio from 'gi://Gio';
|
||||||
// import cairo from "cairo";
|
import Shell from 'gi://Shell';
|
||||||
// import Shell from 'gi://Shell';
|
import WindowManager from './src/windowManager.js'
|
||||||
// import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
import {Logger} from "./src/utils/logger.js";
|
||||||
|
|
||||||
type WinWrapper = {
|
|
||||||
window: Meta.Window | null;
|
|
||||||
signals: Signal[] | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
type Signal = {
|
|
||||||
name: string;
|
|
||||||
id: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class aerospike extends Extension {
|
export default class aerospike extends Extension {
|
||||||
|
settings: Gio.Settings;
|
||||||
borderActor: St.Widget | null;
|
keyBindings: Map<string, number>;
|
||||||
focusWindowSignals: any[];
|
windowManager: WindowManager;
|
||||||
lastFocusedWindow: Meta.Window | null;
|
|
||||||
_focusSignal: number | null;
|
|
||||||
_windowCreateId: number | null;
|
|
||||||
_windows: Map<number, WinWrapper>;
|
|
||||||
_activeWindowId: number | null;
|
|
||||||
|
|
||||||
constructor(metadata: ExtensionMetadata) {
|
constructor(metadata: ExtensionMetadata) {
|
||||||
super(metadata);
|
super(metadata);
|
||||||
// Initialize instance variables
|
this.settings = this.getSettings('org.gnome.shell.extensions.aerospike');
|
||||||
this.borderActor = null;
|
this.keyBindings = new Map();
|
||||||
this.focusWindowSignals = [];
|
this.windowManager = new WindowManager();
|
||||||
this.lastFocusedWindow = null;
|
|
||||||
this._focusSignal = null;
|
|
||||||
this._windowCreateId = null;
|
|
||||||
this._windows = new Map<number, WinWrapper>();
|
|
||||||
this._activeWindowId = null;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
console.log("STARTING AEROSPIKE!")
|
Logger.log("STARTING AEROSPIKE!")
|
||||||
|
this.bindSettings();
|
||||||
// this._captureExistingWindows();
|
this.windowManager.enable()
|
||||||
// Connect window signals
|
|
||||||
this._windowCreateId = global.display.connect(
|
|
||||||
'window-created',
|
|
||||||
(display, window) => {
|
|
||||||
this.handleWindowCreated(window);
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleWindowCreated(window: Meta.Window) {
|
|
||||||
console.log("WINDOW CREATED", window);
|
|
||||||
if (!this._isWindowTileable(window)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log("WINDOW IS TILABLE");
|
|
||||||
const actor = window.get_compositor_private();
|
|
||||||
if (!actor) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
this._addWindow(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
// _captureExistingWindows() {
|
|
||||||
// console.log("CAPTURING WINDOWS")
|
|
||||||
// const workspace = global.workspace_manager.get_active_workspace();
|
|
||||||
// const windows = global.display.get_tab_list(Meta.TabList.NORMAL, workspace);
|
|
||||||
// console.log("WINDOWS", windows);
|
|
||||||
// windows.forEach(window => {
|
|
||||||
// if (this._isWindowTileable(window)) {
|
|
||||||
// this._addWindow(window);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// // this._tileWindows();
|
|
||||||
// }
|
|
||||||
|
|
||||||
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
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
resizeWindow(win: Meta.Window, x:number, y:number, width:number, height:number) {
|
|
||||||
// First, ensure window is not maximized or fullscreen
|
|
||||||
// if (win.get_maximized()) {
|
|
||||||
// console.log("WINDOW MAXIMIZED")
|
|
||||||
// win.unmaximize(Meta.MaximizeFlags.BOTH);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (win.is_fullscreen()) {
|
|
||||||
// console.log("WINDOW IS FULLSCREEN")
|
|
||||||
// win.unmake_fullscreen();
|
|
||||||
// }
|
|
||||||
console.log("WINDOW", win.get_window_type(), win.allows_move());
|
|
||||||
console.log("MONITOR INFO", this.getUsableMonitorSpace(win));
|
|
||||||
console.log("NEW_SIZE", x, y, width, height);
|
|
||||||
win.move_resize_frame(false, 50, 50, 300, 300);
|
|
||||||
console.log("RESIZED WINDOW", win.get_frame_rect().height, win.get_frame_rect().width, win.get_frame_rect().x, win.get_frame_rect().y);
|
|
||||||
}
|
|
||||||
|
|
||||||
_addWindow(window: Meta.Window) {
|
|
||||||
const windowId = window.get_id();
|
|
||||||
|
|
||||||
// Connect to window signals
|
|
||||||
const signals: Signal[] = [];
|
|
||||||
console.log("ADDING WINDOW", window);
|
|
||||||
// const act = window.get_compositor_private();
|
|
||||||
// const id = act.connect('first-frame', _ => {
|
|
||||||
// this.resizeWindow(window);
|
|
||||||
// act.disconnect(id);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const destroyId = window.connect('unmanaging', () => {
|
|
||||||
// console.log("REMOVING WINDOW", windowId);
|
|
||||||
// this._handleWindowClosed(windowId);
|
|
||||||
// });
|
|
||||||
// signals.push({name: 'unmanaging', id: destroyId});
|
|
||||||
|
|
||||||
// const focusId = window.connect('notify::has-focus', () => {
|
|
||||||
// if (window.has_focus()) {
|
|
||||||
// this._activeWindowId = windowId;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// signals.push({name: 'notify::has-focus', id: focusId});
|
|
||||||
|
|
||||||
// Add window to managed windows
|
|
||||||
this._windows.set(windowId, {
|
|
||||||
window: window,
|
|
||||||
signals: signals
|
|
||||||
});
|
|
||||||
|
|
||||||
// If this is the first window, make it the active one
|
|
||||||
if (this._windows.size === 1 || window.has_focus()) {
|
|
||||||
this._activeWindowId = windowId;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._tileWindows();
|
|
||||||
}
|
|
||||||
|
|
||||||
_handleWindowClosed(windowId: number) {
|
|
||||||
|
|
||||||
const windowData = this._windows.get(windowId);
|
|
||||||
if (!windowData) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disconnect signals
|
|
||||||
if (windowData.signals) {
|
|
||||||
windowData.signals.forEach(signal => {
|
|
||||||
try {
|
|
||||||
|
|
||||||
if (windowData.window != null) {
|
|
||||||
windowData.window.disconnect(signal.id);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
// Window might already be gone
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove from managed windows
|
|
||||||
this._windows.delete(windowId);
|
|
||||||
|
|
||||||
// If this was the active window, find a new one
|
|
||||||
if (this._activeWindowId === windowId && this._windows.size > 0) {
|
|
||||||
this._activeWindowId = Array.from(this._windows.keys())[0];
|
|
||||||
} else if (this._windows.size === 0) {
|
|
||||||
this._activeWindowId = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retile remaining windows
|
|
||||||
this._tileWindows();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_tileWindows() {
|
|
||||||
console.log("TILING WINDOWS")
|
|
||||||
const workspace = global.workspace_manager.get_active_workspace();
|
|
||||||
const workArea = workspace.get_work_area_for_monitor(
|
|
||||||
global.display.get_primary_monitor()
|
|
||||||
);
|
|
||||||
console.log("Workspace", workspace);
|
|
||||||
console.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;
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
.map(({window}) => window);
|
|
||||||
|
|
||||||
if (windows.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._tileHorizontally(windows, workArea)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
_tileHorizontally(windows: (Meta.Window | null)[], workArea: Mtk.Rectangle) {
|
|
||||||
const windowWidth = Math.floor(workArea.width / windows.length);
|
|
||||||
|
|
||||||
windows.forEach((window, index) => {
|
|
||||||
const x = workArea.x + (index * windowWidth);
|
|
||||||
const rect = {
|
|
||||||
x: x,
|
|
||||||
y: workArea.y,
|
|
||||||
width: windowWidth,
|
|
||||||
height: workArea.height
|
|
||||||
};
|
|
||||||
if (window != null) {
|
|
||||||
this.resizeWindow(window, rect.x, rect.y, rect.width, rect.height);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_isWindowTileable(window: Meta.Window) {
|
|
||||||
if (!window || !window.get_compositor_private()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const windowType = window.get_window_type();
|
|
||||||
console.log("WINDOW TYPE", windowType);
|
|
||||||
// Skip certain types of windows
|
|
||||||
return !window.is_skip_taskbar() &&
|
|
||||||
windowType !== Meta.WindowType.DESKTOP &&
|
|
||||||
windowType !== Meta.WindowType.DOCK &&
|
|
||||||
windowType !== Meta.WindowType.DIALOG &&
|
|
||||||
windowType !== Meta.WindowType.MODAL_DIALOG &&
|
|
||||||
windowType !== Meta.WindowType.UTILITY &&
|
|
||||||
windowType !== Meta.WindowType.MENU;
|
|
||||||
}
|
|
||||||
|
|
||||||
// _updateBorder(window: Meta.Window) {
|
|
||||||
// console.log("UPDATING THE BORDER")
|
|
||||||
// // Clear the previous border
|
|
||||||
// this._clearBorder();
|
|
||||||
// // Set a new border for the currently focused window
|
|
||||||
// if (window) {
|
|
||||||
// this._setBorder(window);
|
|
||||||
// this.lastFocusedWindow = window;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// _setBorder(window: Meta.Window) {
|
|
||||||
// console.log("SETTING THE BORDER")
|
|
||||||
// if (!window) return;
|
|
||||||
//
|
|
||||||
// const rect = window.get_frame_rect();
|
|
||||||
// if (!rect) return;
|
|
||||||
//
|
|
||||||
// // Create a new actor for the border using St.Widget
|
|
||||||
// this.borderActor = new St.Widget({
|
|
||||||
// name: 'active-window-border',
|
|
||||||
// // style_class: 'active-window-border',
|
|
||||||
// reactive: false,
|
|
||||||
// x: rect.x - 1, // Adjust for border width
|
|
||||||
// y: rect.y - 1,
|
|
||||||
// width: rect.width + 2, // Increased to accommodate border
|
|
||||||
// height: rect.height + 2,
|
|
||||||
// // Initial style with default color.ts
|
|
||||||
// // style: `border: 4px solid hsl(${this.hue}, 100%, 50%); border-radius: 5px;`,
|
|
||||||
// // style: `border: 2px solid rgba(0, 0, 0, 0.5); border-radius: 3px;`
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// // Add the border actor to the UI group
|
|
||||||
// global.window_group.add_child(this.borderActor);
|
|
||||||
// // Main.layoutManager.uiGroup.add_child(this.borderActor);
|
|
||||||
//
|
|
||||||
// // Listen to window's changes in position and size
|
|
||||||
// this.focusWindowSignals?.push(window.connect('position-changed', () => this._updateBorderPosition(window)));
|
|
||||||
// this.focusWindowSignals?.push(window.connect('size-changed', () => this._updateBorderPosition(window)));
|
|
||||||
// this.focusWindowSignals?.push(window.connect('unmanaged', () => this._clearBorder()));
|
|
||||||
//
|
|
||||||
// this._updateBorderPosition(window);
|
|
||||||
//
|
|
||||||
// // Start the color.ts cycling
|
|
||||||
// this._startColorCycle();
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
console.log("DISABLED AEROSPIKE!")
|
this.windowManager.disable()
|
||||||
// Disconnect the focus signal and remove any existing borders
|
|
||||||
if (this._focusSignal) {
|
|
||||||
global.display.disconnect(this._focusSignal);
|
|
||||||
this._focusSignal = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear the border on the last focused window if it exists
|
|
||||||
// this._clearBorder();
|
|
||||||
this.lastFocusedWindow = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private bindSettings() {
|
||||||
|
// Monitor settings changes
|
||||||
|
this.settings.connect('changed::keybinding-1', () => {
|
||||||
|
log(`Keybinding 1 changed to: ${this.settings.get_strv('keybinding-1')}`);
|
||||||
|
this.refreshKeybinding('keybinding-1');
|
||||||
|
});
|
||||||
|
|
||||||
|
this.settings.connect('changed::keybinding-2', () => {
|
||||||
|
log(`Keybinding 2 changed to: ${this.settings.get_strv('keybinding-2')}`);
|
||||||
|
this.refreshKeybinding('keybinding-2');
|
||||||
|
});
|
||||||
|
|
||||||
|
this.settings.connect('changed::keybinding-3', () => {
|
||||||
|
log(`Keybinding 3 changed to: ${this.settings.get_strv('keybinding-3')}`);
|
||||||
|
this.refreshKeybinding('keybinding-3');
|
||||||
|
});
|
||||||
|
|
||||||
|
this.settings.connect('changed::keybinding-4', () => {
|
||||||
|
log(`Keybinding 4 changed to: ${this.settings.get_strv('keybinding-4')}`);
|
||||||
|
this.refreshKeybinding('keybinding-4');
|
||||||
|
});
|
||||||
|
|
||||||
|
this.settings.connect('changed::dropdown-option', () => {
|
||||||
|
log(`Dropdown option changed to: ${this.settings.get_string('dropdown-option')}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.settings.connect('changed::color-selection', () => {
|
||||||
|
log(`Color selection changed to: ${this.settings.get_string('color-selection')}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
private refreshKeybinding(settingName: string) {
|
||||||
|
if (this.keyBindings.has(settingName)) {
|
||||||
|
Main.wm.removeKeybinding(settingName);
|
||||||
|
this.keyBindings.delete(settingName);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (settingName) {
|
||||||
|
case 'keybinding-1':
|
||||||
|
this.bindKeybinding('keybinding-1', () => {
|
||||||
|
log('Keybinding 1 was pressed!');
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'keybinding-2':
|
||||||
|
this.bindKeybinding('keybinding-2', () => {
|
||||||
|
log('Keybinding 2 was pressed!');
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'keybinding-3':
|
||||||
|
this.bindKeybinding('keybinding-3', () => {
|
||||||
|
log('Keybinding 3 was pressed!');
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'keybinding-4':
|
||||||
|
this.bindKeybinding('keybinding-4', () => {
|
||||||
|
log('Keybinding 4 was pressed!');
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private removeKeybindings() {
|
||||||
|
this.keyBindings.forEach((_, key) => {
|
||||||
|
Main.wm.removeKeybinding(key);
|
||||||
|
});
|
||||||
|
this.keyBindings.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private setupKeybindings() {
|
||||||
|
this.bindKeybinding('keybinding-1', () => {
|
||||||
|
log('Keybinding 1 was pressed!');
|
||||||
|
});
|
||||||
|
|
||||||
|
this.bindKeybinding('keybinding-2', () => {
|
||||||
|
log('Keybinding 2 was pressed!');
|
||||||
|
});
|
||||||
|
|
||||||
|
this.bindKeybinding('keybinding-3', () => {
|
||||||
|
log('Keybinding 3 was pressed!');
|
||||||
|
});
|
||||||
|
|
||||||
|
this.bindKeybinding('keybinding-4', () => {
|
||||||
|
log('Keybinding 4 was pressed!');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private bindKeybinding(settingName: string, callback: () => void) {
|
||||||
|
const keyBindingSettings = this.settings.get_strv(settingName);
|
||||||
|
|
||||||
|
if (keyBindingSettings.length === 0 || keyBindingSettings[0] === '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const keyBindingAction = Main.wm.addKeybinding(
|
||||||
|
settingName,
|
||||||
|
this.settings,
|
||||||
|
Meta.KeyBindingFlags.IGNORE_AUTOREPEAT,
|
||||||
|
Shell.ActionMode.NORMAL,
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
|
||||||
|
this.keyBindings.set(settingName, keyBindingAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
25
justfile
25
justfile
@@ -1,19 +1,22 @@
|
|||||||
set dotenv-load
|
set dotenv-load
|
||||||
NAME:="aerospike"
|
NAME:="aerospike"
|
||||||
DOMAIN:="lucaso.io"
|
DOMAIN:="lucaso.io"
|
||||||
|
FULL_NAME:=NAME + "@" + DOMAIN
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
pnpm install
|
pnpm install
|
||||||
|
|
||||||
build: packages
|
build: packages && build-schemas
|
||||||
rm -rf dist/*
|
rm -rf dist/*
|
||||||
tsc
|
tsc
|
||||||
glib-compile-schemas schemas
|
|
||||||
cp metadata.json dist/
|
cp metadata.json dist/
|
||||||
cp stylesheet.css dist/
|
cp stylesheet.css dist/
|
||||||
mkdir dist/schemas
|
mkdir -p dist/schemas
|
||||||
cp schemas/*.compiled dist/schemas/
|
|
||||||
|
|
||||||
|
build-schemas:
|
||||||
|
glib-compile-schemas schemas
|
||||||
|
cp schemas/org.gnome.shell.extensions.aerospike.gschema.xml dist/schemas/
|
||||||
|
cp schemas/gschemas.compiled dist/schemas/
|
||||||
|
|
||||||
build-package: build
|
build-package: build
|
||||||
cd dist && zip ../{{NAME}}.zip -9r .
|
cd dist && zip ../{{NAME}}.zip -9r .
|
||||||
@@ -25,6 +28,18 @@ install: build
|
|||||||
cp -r dist/* ~/.local/share/gnome-shell/extensions/{{NAME}}@{{DOMAIN}}/
|
cp -r dist/* ~/.local/share/gnome-shell/extensions/{{NAME}}@{{DOMAIN}}/
|
||||||
|
|
||||||
run:
|
run:
|
||||||
dbus-run-session -- gnome-shell --nested --wayland
|
env MUTTER_DEBUG_DUMMY_MODE_SPECS=1280x720 dbus-run-session -- gnome-shell --nested --wayland
|
||||||
|
|
||||||
install-and-run: install run
|
install-and-run: install run
|
||||||
|
|
||||||
|
live-debug:
|
||||||
|
journalctl /usr/bin/gnome-shell -f -o cat
|
||||||
|
|
||||||
|
#pack: build
|
||||||
|
# gnome-extensions pack dist \
|
||||||
|
# --force \
|
||||||
|
# --out-dir . \
|
||||||
|
# --schema ../schemas/org.gnome.shell.extensions.aerospike.gschema.xml
|
||||||
|
#
|
||||||
|
#install-pack: pack
|
||||||
|
# gnome-extensions install ./{{FULL_NAME}}.shell-extension.zip --force
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "aerospike",
|
"name": "aerospike",
|
||||||
"description": "Adds pretty rainbow or static borders to the active and inactive windows",
|
"description": "I3 Like Tiling Window Manager for Gnome",
|
||||||
"uuid": "aerospike@lucaso.io",
|
"uuid": "aerospike@lucaso.io",
|
||||||
|
"settings-schema": "org.gnome.shell.extensions.aerospike",
|
||||||
"shell-version": [
|
"shell-version": [
|
||||||
"47",
|
|
||||||
"48"
|
"48"
|
||||||
]
|
],
|
||||||
|
"gettext-domain": "aerospike@lucaso.io",
|
||||||
|
"url": "https://gitea.chaosdev.gay/lucasoskorep/aerospike@lucaso.io"
|
||||||
}
|
}
|
||||||
|
|||||||
54
prefs.ts
54
prefs.ts
@@ -1,52 +1,4 @@
|
|||||||
import Gtk from 'gi://Gtk';
|
// This file is just a wrapper around the compiled TypeScript code
|
||||||
import Adw from 'gi://Adw';
|
import MyExtensionPreferences from './src/prefs/prefs.js';
|
||||||
import Gio from 'gi://Gio';
|
|
||||||
import { ExtensionPreferences, gettext as _ } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
|
|
||||||
|
|
||||||
export default class GnomeRectanglePreferences extends ExtensionPreferences {
|
export default MyExtensionPreferences;
|
||||||
_settings?: Gio.Settings
|
|
||||||
|
|
||||||
fillPreferencesWindow(window: Adw.PreferencesWindow): Promise<void> {
|
|
||||||
this._settings = this.getSettings();
|
|
||||||
|
|
||||||
const page = new Adw.PreferencesPage({
|
|
||||||
title: _('General'),
|
|
||||||
iconName: 'dialog-information-symbolic',
|
|
||||||
});
|
|
||||||
|
|
||||||
const animationGroup = new Adw.PreferencesGroup({
|
|
||||||
title: _('Animation'),
|
|
||||||
description: _('Configure move/resize animation'),
|
|
||||||
});
|
|
||||||
page.add(animationGroup);
|
|
||||||
|
|
||||||
const animationEnabled = new Adw.SwitchRow({
|
|
||||||
title: _('Enabled'),
|
|
||||||
subtitle: _('Wether to animate windows'),
|
|
||||||
});
|
|
||||||
animationGroup.add(animationEnabled);
|
|
||||||
|
|
||||||
const paddingGroup = new Adw.PreferencesGroup({
|
|
||||||
title: _('Paddings'),
|
|
||||||
description: _('Configure the padding between windows'),
|
|
||||||
});
|
|
||||||
page.add(paddingGroup);
|
|
||||||
|
|
||||||
const paddingInner = new Adw.SpinRow({
|
|
||||||
title: _('Inner'),
|
|
||||||
subtitle: _('Padding between windows'),
|
|
||||||
adjustment: new Gtk.Adjustment({
|
|
||||||
lower: 0,
|
|
||||||
upper: 1000,
|
|
||||||
stepIncrement: 1
|
|
||||||
})
|
|
||||||
});
|
|
||||||
paddingGroup.add(paddingInner);
|
|
||||||
|
|
||||||
window.add(page)
|
|
||||||
|
|
||||||
this._settings!.bind('animate', animationEnabled, 'active', Gio.SettingsBindFlags.DEFAULT);
|
|
||||||
this._settings!.bind('padding-inner', paddingInner, 'value', Gio.SettingsBindFlags.DEFAULT);
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,40 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<schemalist>
|
<schemalist>
|
||||||
<schema id="org.gnome.shell.extensions.aerospike" path="/org/gnome/shell/extensions/aerospike/">
|
<schema id="org.gnome.shell.extensions.aerospike" path="/org/gnome/shell/extensions/aerospike/">
|
||||||
<key name="tiling-type" type="s">
|
<key name="keybinding-1" type="as">
|
||||||
<default>"Horizontal"</default>
|
<default><![CDATA[['<Super>1']]]></default>
|
||||||
<summary>Type of tiling</summary>
|
<summary>Keybinding for action 1</summary>
|
||||||
<description>The type of tiling provided by aerospace</description>
|
<description>Keyboard shortcut for triggering action 1</description>
|
||||||
|
</key>
|
||||||
|
|
||||||
|
<key name="keybinding-2" type="as">
|
||||||
|
<default><![CDATA[['<Super>2']]]></default>
|
||||||
|
<summary>Keybinding for action 2</summary>
|
||||||
|
<description>Keyboard shortcut for triggering action 2</description>
|
||||||
|
</key>
|
||||||
|
|
||||||
|
<key name="keybinding-3" type="as">
|
||||||
|
<default><![CDATA[['<Super>3']]]></default>
|
||||||
|
<summary>Keybinding for action 3</summary>
|
||||||
|
<description>Keyboard shortcut for triggering action 3</description>
|
||||||
|
</key>
|
||||||
|
|
||||||
|
<key name="keybinding-4" type="as">
|
||||||
|
<default><![CDATA[['<Super>4']]]></default>
|
||||||
|
<summary>Keybinding for action 4</summary>
|
||||||
|
<description>Keyboard shortcut for triggering action 4</description>
|
||||||
|
</key>
|
||||||
|
|
||||||
|
<key name="dropdown-option" type="s">
|
||||||
|
<default>'option1'</default>
|
||||||
|
<summary>Dropdown selection</summary>
|
||||||
|
<description>Option selected from the dropdown menu</description>
|
||||||
|
</key>
|
||||||
|
|
||||||
|
<key name="color-selection" type="s">
|
||||||
|
<default>'rgb(255,0,0)'</default>
|
||||||
|
<summary>Selected color</summary>
|
||||||
|
<description>Color chosen from the color picker</description>
|
||||||
</key>
|
</key>
|
||||||
</schema>
|
</schema>
|
||||||
</schemalist>
|
</schemalist>
|
||||||
96
src/monitor.ts
Normal file
96
src/monitor.ts
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
import {WindowWrapper} from "./window.js";
|
||||||
|
import {Logger} from "./utils/logger.js";
|
||||||
|
import Mtk from "@girs/mtk-16";
|
||||||
|
import Meta from "gi://Meta";
|
||||||
|
|
||||||
|
|
||||||
|
export default class MonitorManager {
|
||||||
|
|
||||||
|
_id: number;
|
||||||
|
_windows: Map<number, WindowWrapper>;
|
||||||
|
_minimized: Map<number, WindowWrapper>;
|
||||||
|
|
||||||
|
|
||||||
|
constructor(monitorId: number) {
|
||||||
|
this._windows = new Map<number, WindowWrapper>();
|
||||||
|
this._minimized = new Map<number, WindowWrapper>();
|
||||||
|
|
||||||
|
this._id = monitorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
addWindow(winWrap: WindowWrapper): void {
|
||||||
|
// Add window to managed windows
|
||||||
|
this._windows.set(winWrap.getWindowId(), winWrap);
|
||||||
|
this._tileWindows();
|
||||||
|
}
|
||||||
|
|
||||||
|
getWindow(win_id: number): WindowWrapper | undefined {
|
||||||
|
return this._windows.get(win_id)
|
||||||
|
}
|
||||||
|
|
||||||
|
removeWindow(win_id: number): void {
|
||||||
|
this._windows.delete(win_id)
|
||||||
|
this._tileWindows()
|
||||||
|
}
|
||||||
|
|
||||||
|
minimizeWindow(winWrap: WindowWrapper): void {
|
||||||
|
this._windows.delete(winWrap.getWindowId())
|
||||||
|
this._minimized.set(winWrap.getWindowId(), winWrap)
|
||||||
|
}
|
||||||
|
|
||||||
|
unminimizeWindow(winWrap: WindowWrapper): void {
|
||||||
|
if (this._minimized.has(winWrap.getWindowId())) {
|
||||||
|
this._windows.set(winWrap.getWindowId(), winWrap);
|
||||||
|
this._minimized.delete(winWrap.getWindowId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
removeAllWindows(): void {
|
||||||
|
this._windows.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
_tileWindows() {
|
||||||
|
Logger.log("TILING WINDOWS ON MONITOR", this._id)
|
||||||
|
const workspace = global.workspace_manager.get_active_workspace();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.map(x => x);
|
||||||
|
|
||||||
|
if (windows.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._tileHorizontally(windows, workArea)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_tileHorizontally(windows: (WindowWrapper | null)[], workArea: Mtk.Rectangle) {
|
||||||
|
const windowWidth = Math.floor(workArea.width / windows.length);
|
||||||
|
|
||||||
|
windows.forEach((window, index) => {
|
||||||
|
const x = workArea.x + (index * windowWidth);
|
||||||
|
const rect = {
|
||||||
|
x: x,
|
||||||
|
y: workArea.y,
|
||||||
|
width: windowWidth,
|
||||||
|
height: workArea.height
|
||||||
|
};
|
||||||
|
if (window != null) {
|
||||||
|
window.safelyResizeWindow(rect.x, rect.y, rect.width, rect.height);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
192
src/prefs/prefs.ts
Normal file
192
src/prefs/prefs.ts
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
import Adw from 'gi://Adw';
|
||||||
|
import Gio from 'gi://Gio';
|
||||||
|
import Gtk from 'gi://Gtk';
|
||||||
|
import Gdk from 'gi://Gdk';
|
||||||
|
import { ExtensionPreferences, gettext as _ } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
|
||||||
|
|
||||||
|
export default class MyExtensionPreferences extends ExtensionPreferences {
|
||||||
|
async fillPreferencesWindow(window: Adw.PreferencesWindow) {
|
||||||
|
// Create settings object
|
||||||
|
const settings = this.getSettings('org.gnome.shell.extensions.aerospike');
|
||||||
|
|
||||||
|
// Create a preferences page
|
||||||
|
const page = new Adw.PreferencesPage({
|
||||||
|
title: _('Settings'),
|
||||||
|
icon_name: 'preferences-system-symbolic',
|
||||||
|
});
|
||||||
|
window.add(page);
|
||||||
|
|
||||||
|
// Create keybindings group
|
||||||
|
const keybindingsGroup = new Adw.PreferencesGroup({
|
||||||
|
title: _('Keyboard Shortcuts'),
|
||||||
|
});
|
||||||
|
page.add(keybindingsGroup);
|
||||||
|
|
||||||
|
// Add keybinding rows
|
||||||
|
this.addKeybindingRow(keybindingsGroup, settings, 'keybinding-1', _('Action 1'));
|
||||||
|
this.addKeybindingRow(keybindingsGroup, settings, 'keybinding-2', _('Action 2'));
|
||||||
|
this.addKeybindingRow(keybindingsGroup, settings, 'keybinding-3', _('Action 3'));
|
||||||
|
this.addKeybindingRow(keybindingsGroup, settings, 'keybinding-4', _('Action 4'));
|
||||||
|
|
||||||
|
// Create options group
|
||||||
|
const optionsGroup = new Adw.PreferencesGroup({
|
||||||
|
title: _('Options'),
|
||||||
|
});
|
||||||
|
page.add(optionsGroup);
|
||||||
|
|
||||||
|
// Add dropdown
|
||||||
|
const dropdownRow = new Adw.ComboRow({
|
||||||
|
title: _('Select an option'),
|
||||||
|
});
|
||||||
|
optionsGroup.add(dropdownRow);
|
||||||
|
|
||||||
|
// Create dropdown model
|
||||||
|
const dropdownModel = new Gtk.StringList();
|
||||||
|
dropdownModel.append(_('Option 1'));
|
||||||
|
dropdownModel.append(_('Option 2'));
|
||||||
|
dropdownModel.append(_('Option 3'));
|
||||||
|
dropdownModel.append(_('Option 4'));
|
||||||
|
|
||||||
|
dropdownRow.set_model(dropdownModel);
|
||||||
|
|
||||||
|
// Set the active option based on settings
|
||||||
|
const currentOption = settings.get_string('dropdown-option');
|
||||||
|
switch (currentOption) {
|
||||||
|
case 'option1':
|
||||||
|
dropdownRow.set_selected(0);
|
||||||
|
break;
|
||||||
|
case 'option2':
|
||||||
|
dropdownRow.set_selected(1);
|
||||||
|
break;
|
||||||
|
case 'option3':
|
||||||
|
dropdownRow.set_selected(2);
|
||||||
|
break;
|
||||||
|
case 'option4':
|
||||||
|
dropdownRow.set_selected(3);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
dropdownRow.set_selected(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Connect dropdown change signal
|
||||||
|
dropdownRow.connect('notify::selected', () => {
|
||||||
|
const selected = dropdownRow.get_selected();
|
||||||
|
let optionValue: string;
|
||||||
|
|
||||||
|
switch (selected) {
|
||||||
|
case 0:
|
||||||
|
optionValue = 'option1';
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
optionValue = 'option2';
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
optionValue = 'option3';
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
optionValue = 'option4';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
optionValue = 'option1';
|
||||||
|
}
|
||||||
|
|
||||||
|
settings.set_string('dropdown-option', optionValue);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add color button
|
||||||
|
const colorRow = new Adw.ActionRow({
|
||||||
|
title: _('Choose a color'),
|
||||||
|
});
|
||||||
|
optionsGroup.add(colorRow);
|
||||||
|
|
||||||
|
const colorButton = new Gtk.ColorButton();
|
||||||
|
colorRow.add_suffix(colorButton);
|
||||||
|
colorRow.set_activatable_widget(colorButton);
|
||||||
|
|
||||||
|
// Set current color from settings
|
||||||
|
const colorStr = settings.get_string('color-selection');
|
||||||
|
const rgba = new Gdk.RGBA();
|
||||||
|
rgba.parse(colorStr);
|
||||||
|
colorButton.set_rgba(rgba);
|
||||||
|
|
||||||
|
// Connect color button signal
|
||||||
|
colorButton.connect('color-set', () => {
|
||||||
|
const color = colorButton.get_rgba().to_string();
|
||||||
|
settings.set_string('color-selection', color);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private addKeybindingRow(
|
||||||
|
group: Adw.PreferencesGroup,
|
||||||
|
settings: Gio.Settings,
|
||||||
|
key: string,
|
||||||
|
title: string
|
||||||
|
) {
|
||||||
|
const shortcutsRow = new Adw.ActionRow({
|
||||||
|
title: title,
|
||||||
|
});
|
||||||
|
|
||||||
|
group.add(shortcutsRow);
|
||||||
|
|
||||||
|
// Create a button for setting shortcuts
|
||||||
|
const shortcutButton = new Gtk.Button({
|
||||||
|
valign: Gtk.Align.CENTER,
|
||||||
|
label: settings.get_strv(key)[0] || _("Disabled")
|
||||||
|
});
|
||||||
|
|
||||||
|
shortcutsRow.add_suffix(shortcutButton);
|
||||||
|
shortcutsRow.set_activatable_widget(shortcutButton);
|
||||||
|
|
||||||
|
// When clicking the button, show a dialog or start listening for keystroke
|
||||||
|
shortcutButton.connect('clicked', () => {
|
||||||
|
// Show a simple popup stating that the shortcut is being recorded
|
||||||
|
const dialog = new Gtk.MessageDialog({
|
||||||
|
modal: true,
|
||||||
|
text: _("Press a key combination to set as shortcut"),
|
||||||
|
secondary_text: _("Press Esc to cancel or Backspace to disable"),
|
||||||
|
buttons: Gtk.ButtonsType.CANCEL,
|
||||||
|
transient_for: group.get_root() as Gtk.Window
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a keypress event controller
|
||||||
|
const controller = new Gtk.EventControllerKey();
|
||||||
|
dialog.add_controller(controller);
|
||||||
|
|
||||||
|
controller.connect('key-pressed', (_controller, keyval, keycode, state) => {
|
||||||
|
// Get the key name
|
||||||
|
let keyName = Gdk.keyval_name(keyval);
|
||||||
|
|
||||||
|
// Handle special cases
|
||||||
|
if (keyName === 'Escape') {
|
||||||
|
dialog.response(Gtk.ResponseType.CANCEL);
|
||||||
|
return Gdk.EVENT_STOP;
|
||||||
|
} else if (keyName === 'BackSpace') {
|
||||||
|
// Clear the shortcut
|
||||||
|
settings.set_strv(key, []);
|
||||||
|
shortcutButton.set_label(_("Disabled"));
|
||||||
|
dialog.response(Gtk.ResponseType.OK);
|
||||||
|
return Gdk.EVENT_STOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert modifier state to keybinding modifiers
|
||||||
|
let modifiers = state & Gtk.accelerator_get_default_mod_mask();
|
||||||
|
|
||||||
|
// Ignore standalone modifier keys
|
||||||
|
if (Gdk.ModifierType.SHIFT_MASK <= keyval && keyval <= Gdk.ModifierType.META_MASK)
|
||||||
|
return Gdk.EVENT_STOP;
|
||||||
|
|
||||||
|
// Create accelerator string
|
||||||
|
let accelerator = Gtk.accelerator_name(keyval, modifiers);
|
||||||
|
if (accelerator) {
|
||||||
|
settings.set_strv(key, [accelerator]);
|
||||||
|
shortcutButton.set_label(accelerator);
|
||||||
|
dialog.response(Gtk.ResponseType.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Gdk.EVENT_STOP;
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.present();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
30
src/utils/logger.ts
Normal file
30
src/utils/logger.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
export class Logger {
|
||||||
|
|
||||||
|
static fatal(...args: any[]) {
|
||||||
|
console.log(`[Aerospike] [FATAL]`, ...args);
|
||||||
|
}
|
||||||
|
|
||||||
|
static error(...args: any[]) {
|
||||||
|
console.log(`[Aerospike] [ERROR]`, ...args);
|
||||||
|
}
|
||||||
|
|
||||||
|
static warn(...args: any[]) {
|
||||||
|
console.log(`[Aerospike] [WARN]`, ...args);
|
||||||
|
}
|
||||||
|
|
||||||
|
static info(...args: any[]) {
|
||||||
|
console.log(`[Aerospike] [INFO]`, ...args);
|
||||||
|
}
|
||||||
|
|
||||||
|
static debug(...args: any[]) {
|
||||||
|
console.log(`[Aerospike] [DEBUG]`, ...args);
|
||||||
|
}
|
||||||
|
|
||||||
|
static trace(...args: any[]) {
|
||||||
|
console.log(`[Aerospike] [TRACE]`, ...args);
|
||||||
|
}
|
||||||
|
|
||||||
|
static log(...args: any[]) {
|
||||||
|
console.log(`[Aerospike] [LOG]`, ...args);
|
||||||
|
}
|
||||||
|
}
|
||||||
231
src/window.ts
Normal file
231
src/window.ts
Normal file
@@ -0,0 +1,231 @@
|
|||||||
|
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";
|
||||||
|
|
||||||
|
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[];
|
||||||
|
|
||||||
|
constructor(window: Meta.Window, winMinimized: WindowMinimizedHandler) {
|
||||||
|
this._window = window;
|
||||||
|
this._signals = [];
|
||||||
|
this._windowMinimizedHandler = winMinimized;
|
||||||
|
}
|
||||||
|
|
||||||
|
getWindow(): Meta.Window {
|
||||||
|
return this._window;
|
||||||
|
}
|
||||||
|
|
||||||
|
getWindowId(): number {
|
||||||
|
return this._window.get_id();
|
||||||
|
}
|
||||||
|
|
||||||
|
connectWindowSignals(
|
||||||
|
windowManager: IWindowManager,
|
||||||
|
): void {
|
||||||
|
|
||||||
|
const windowId = this._window.get_id();
|
||||||
|
|
||||||
|
|
||||||
|
// Handle window destruction
|
||||||
|
const destroyId = 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', () => {
|
||||||
|
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 {
|
||||||
|
|
||||||
|
// Disconnect signals
|
||||||
|
if (this._signals) {
|
||||||
|
this._signals.forEach(signal => {
|
||||||
|
try {
|
||||||
|
if (this._window != null) {
|
||||||
|
this._window.disconnect(signal.id);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Window might already be gone
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
const actor = this._window.get_compositor_private();
|
||||||
|
|
||||||
|
if (!actor) {
|
||||||
|
Logger.log("No actor available, can't resize safely yet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
};
|
||||||
|
}
|
||||||
377
src/windowManager.ts
Normal file
377
src/windowManager.ts
Normal file
@@ -0,0 +1,377 @@
|
|||||||
|
import Meta from "gi://Meta";
|
||||||
|
import Gio from "gi://Gio";
|
||||||
|
import GLib from "gi://GLib";
|
||||||
|
|
||||||
|
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";
|
||||||
|
|
||||||
|
|
||||||
|
export interface IWindowManager {
|
||||||
|
_activeWindowId: number | null;
|
||||||
|
|
||||||
|
// addWindow(window: Meta.Window): void;
|
||||||
|
|
||||||
|
handleWindowClosed(winWrap: WindowWrapper): void;
|
||||||
|
handleWindowMinimized(winWrap: WindowWrapper): void;
|
||||||
|
handleWindowUnminimized(winWrap: WindowWrapper): void;
|
||||||
|
|
||||||
|
|
||||||
|
// removeFromTree(window: Meta.Window): void;
|
||||||
|
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>;
|
||||||
|
_sessionProxy: Gio.DBusProxy | null;
|
||||||
|
_lockedSignalId: number | null;
|
||||||
|
_isScreenLocked: boolean;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this._displaySignals = [];
|
||||||
|
this._windowManagerSignals = [];
|
||||||
|
this._workspaceManagerSignals = [];
|
||||||
|
this._overviewSignals = [];
|
||||||
|
this._shieldScreenSignals = [];
|
||||||
|
this._activeWindowId = null;
|
||||||
|
this._grabbedWindowMonitor = _UNUSED_MONITOR_ID;
|
||||||
|
this._monitors = new Map<number, MonitorManager>();
|
||||||
|
this._sessionProxy = null;
|
||||||
|
this._lockedSignalId = null;
|
||||||
|
this._isScreenLocked = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public enable(): void {
|
||||||
|
Logger.log("Starting Aerospike Window Manager");
|
||||||
|
this.captureExistingWindows();
|
||||||
|
// Connect window signals
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public disable(): void {
|
||||||
|
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 {
|
||||||
|
this._displaySignals.push(
|
||||||
|
global.display.connect("grab-op-begin", (display, window, op) => {
|
||||||
|
this.handleGrabOpBegin(display, window, op)
|
||||||
|
}),
|
||||||
|
global.display.connect("grab-op-end", (display, window, op) => {
|
||||||
|
this.handleGrabOpEnd(display, window, op)
|
||||||
|
}),
|
||||||
|
global.display.connect("window-entered-monitor", (display, monitor, window) => {
|
||||||
|
Logger.log("WINDOW HAS ENTERED NEW MONITOR!")
|
||||||
|
}),
|
||||||
|
global.display.connect('window-created', (display, window) => {
|
||||||
|
this.handleWindowCreated(display, window);
|
||||||
|
}),
|
||||||
|
global.display.connect("showing-desktop-changed", () => {
|
||||||
|
Logger.log("SHOWING DESKTOP CHANGED");
|
||||||
|
}),
|
||||||
|
global.display.connect("workareas-changed", () => {
|
||||||
|
Logger.log("WORK AREAS CHANGED");
|
||||||
|
}),
|
||||||
|
global.display.connect("in-fullscreen-changed", () => {
|
||||||
|
Logger.log("IN FULL SCREEN CHANGED");
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
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");
|
||||||
|
}),
|
||||||
|
global.workspace_manager.connect("workspace-added", (_, wsIndex) => {
|
||||||
|
Logger.log("WORKSPACE ADDED");
|
||||||
|
}),
|
||||||
|
global.workspace_manager.connect("workspace-removed", (_, wsIndex) => {
|
||||||
|
Logger.log("WORKSPACE REMOVED");
|
||||||
|
}),
|
||||||
|
global.workspace_manager.connect("active-workspace-changed", () => {
|
||||||
|
Logger.log("Active workspace-changed");
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
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");
|
||||||
|
},
|
||||||
|
};
|
||||||
|
// this.queueEvent(eventObj);
|
||||||
|
}),
|
||||||
|
Main.overview.connect("showing", () => {
|
||||||
|
// this.toOverview = true;
|
||||||
|
Logger.log("SHOWING OVERVIEW");
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
|
||||||
|
// 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
|
||||||
|
|
||||||
|
// this._signalsBound = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnectDisplaySignals(): void {
|
||||||
|
this._displaySignals.forEach((signal) => {
|
||||||
|
global.disconnect(signal)
|
||||||
|
})
|
||||||
|
this._windowManagerSignals.forEach((signal) => {
|
||||||
|
global.disconnect(signal)
|
||||||
|
})
|
||||||
|
this._workspaceManagerSignals.forEach((signal) => {
|
||||||
|
global.disconnect(signal)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
handleGrabOpBegin(display: Meta.Display, window: Meta.Window, op: Meta.GrabOp): void {
|
||||||
|
Logger.log("Grab Op Start");
|
||||||
|
Logger.log(display, window, op)
|
||||||
|
Logger.log(window.get_monitor())
|
||||||
|
this._grabbedWindowMonitor = window.get_monitor();
|
||||||
|
}
|
||||||
|
|
||||||
|
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())
|
||||||
|
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();
|
||||||
|
|
||||||
|
Logger.info("MONITOR MATCH", old_mon_id !== new_mon_id);
|
||||||
|
if (old_mon_id !== new_mon_id) {
|
||||||
|
Logger.trace("MOVING MONITOR");
|
||||||
|
let old_mon = this._monitors.get(old_mon_id);
|
||||||
|
let new_mon = this._monitors.get(new_mon_id);
|
||||||
|
if (old_mon === undefined || new_mon === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let wrapped = old_mon.getWindow(window.get_id())
|
||||||
|
if (wrapped === undefined) {
|
||||||
|
wrapped = new WindowWrapper(window, this.handleWindowMinimized);
|
||||||
|
} else {
|
||||||
|
old_mon.removeWindow(window.get_id())
|
||||||
|
}
|
||||||
|
new_mon.addWindow(wrapped)
|
||||||
|
}
|
||||||
|
Logger.info("monitor_start and monitor_end", this._grabbedWindowMonitor, window.get_monitor());
|
||||||
|
}
|
||||||
|
|
||||||
|
public handleWindowMinimized(winWrap: WindowWrapper): void {
|
||||||
|
Logger.warn("WARNING MINIMIZING WINDOW");
|
||||||
|
Logger.log("WARNING MINIMIZED", winWrap);
|
||||||
|
const monitor_id = winWrap.getWindow().get_monitor()
|
||||||
|
Logger.log("WARNING MINIMIZED", monitor_id);
|
||||||
|
Logger.warn("WARNING MINIMIZED", this._monitors);
|
||||||
|
this._monitors.get(monitor_id)?.minimizeWindow(winWrap);
|
||||||
|
this._tileMonitors()
|
||||||
|
}
|
||||||
|
|
||||||
|
public handleWindowUnminimized(winWrap: WindowWrapper): void {
|
||||||
|
Logger.log("WINDOW UNMINIMIZED");
|
||||||
|
const monitor_id = winWrap.getWindow().get_monitor()
|
||||||
|
this._monitors.get(monitor_id)?.unminimizeWindow(winWrap);
|
||||||
|
this._tileMonitors()
|
||||||
|
}
|
||||||
|
|
||||||
|
public captureExistingWindows() {
|
||||||
|
Logger.log("CAPTURING WINDOWS")
|
||||||
|
const workspace = global.workspace_manager.get_active_workspace();
|
||||||
|
const windows = global.display.get_tab_list(Meta.TabList.NORMAL, workspace);
|
||||||
|
Logger.log("WINDOWS", windows);
|
||||||
|
windows.forEach(window => {
|
||||||
|
if (this._isWindowTileable(window)) {
|
||||||
|
this.addWindowToMonitor(window);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this._tileMonitors();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
handleWindowCreated(display: Meta.Display, window: Meta.Window) {
|
||||||
|
Logger.log("WINDOW CREATED ON DISPLAY", window, display);
|
||||||
|
if (!this._isWindowTileable(window)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Logger.log("WINDOW IS TILABLE");
|
||||||
|
const actor = window.get_compositor_private();
|
||||||
|
if (!actor) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.addWindowToMonitor(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle window closed event
|
||||||
|
*/
|
||||||
|
handleWindowClosed(window: WindowWrapper): void {
|
||||||
|
|
||||||
|
window.disconnectWindowSignals()
|
||||||
|
const mon_id = window._window.get_monitor();
|
||||||
|
this._monitors.get(mon_id)?.removeWindow(window.getWindowId());
|
||||||
|
|
||||||
|
// Remove from managed windows
|
||||||
|
this.syncActiveWindow();
|
||||||
|
// Retile remaining windows
|
||||||
|
this._tileMonitors();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public addWindowToMonitor(window: Meta.Window) {
|
||||||
|
var wrapper = new WindowWrapper(window, this.handleWindowMinimized)
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
const windowType = window.get_window_type();
|
||||||
|
Logger.log("WINDOW TYPE", windowType);
|
||||||
|
// Skip certain types of windows
|
||||||
|
return !window.is_skip_taskbar() &&
|
||||||
|
windowType !== Meta.WindowType.DESKTOP &&
|
||||||
|
windowType !== Meta.WindowType.DOCK &&
|
||||||
|
windowType !== Meta.WindowType.DIALOG &&
|
||||||
|
windowType !== Meta.WindowType.MODAL_DIALOG &&
|
||||||
|
windowType !== Meta.WindowType.UTILITY &&
|
||||||
|
windowType !== Meta.WindowType.MENU;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Synchronizes the active window with GNOME's currently active window
|
||||||
|
*
|
||||||
|
* This function queries GNOME Shell for the current focused window and
|
||||||
|
* updates the extension's active window tracking to match.
|
||||||
|
*
|
||||||
|
* @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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
0
src/workspace.ts
Normal file
0
src/workspace.ts
Normal file
@@ -12,10 +12,10 @@
|
|||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"ambient.d.ts",
|
"ambient.d.ts",
|
||||||
|
"prefs.ts",
|
||||||
|
"src/**/*"
|
||||||
],
|
],
|
||||||
"files": [
|
"files": [
|
||||||
"extension.ts",
|
"extension.ts"
|
||||||
"winGroup.ts",
|
|
||||||
"prefs.ts"
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user