adding debug command

This commit is contained in:
Lucas Oskorep
2025-10-17 01:09:13 -04:00
parent e615efceb9
commit c977c61714
4 changed files with 79 additions and 0 deletions

View File

@@ -53,6 +53,11 @@ export default class aerospike extends Extension {
this.refreshKeybinding('join-with-right');
});
this.settings.connect('changed::print-tree', () => {
log(`Print tree keybinding changed to: ${this.settings.get_strv('print-tree')}`);
this.refreshKeybinding('print-tree');
});
this.settings.connect('changed::dropdown-option', () => {
log(`Dropdown option changed to: ${this.settings.get_string('dropdown-option')}`);
});
@@ -88,6 +93,11 @@ export default class aerospike extends Extension {
Logger.info('Keybinding 4 was pressed!');
});
break;
case 'print-tree':
this.bindKeybinding('print-tree', () => {
this.windowManager.printTreeStructure();
});
break;
}
}
@@ -114,6 +124,10 @@ export default class aerospike extends Extension {
this.bindKeybinding('join-with-right', () => {
Logger.info('Keybinding 4 was pressed!');
});
this.bindKeybinding('print-tree', () => {
this.windowManager.printTreeStructure();
});
}
private bindKeybinding(settingName: string, callback: () => void) {

View File

@@ -37,5 +37,11 @@
<description>Keyboard shortcut for triggering action 4</description>
</key>
<key name="print-tree" type="as">
<default><![CDATA[['<Super><Shift>x']]]></default>
<summary>Print window tree structure</summary>
<description>Prints the current tree of containers and windows per monitor to logs</description>
</key>
</schema>
</schemalist>

View File

@@ -155,6 +155,15 @@ export default class AerospikeExtensions extends ExtensionPreferences {
})
);
keybindingsGroup.add(
new EntryRow({
title: _('Print Tree Structure'),
settings: settings,
bind: 'print-tree',
map: keybindingMap
})
);
}

View File

@@ -7,6 +7,7 @@ import * as Main from "resource:///org/gnome/shell/ui/main.js";
// import Mtk from "@girs/mtk-16";
import {Logger} from "../utils/logger.js";
import Monitor from "./monitor.js";
import WindowContainer from "./container.js";
export interface IWindowManager {
@@ -419,5 +420,54 @@ export default class WindowManager implements IWindowManager {
return null;
}
/**
* Prints the tree structure of all monitors, workspaces, containers, and windows to the logs
*/
public printTreeStructure(): void {
Logger.info("=".repeat(80));
Logger.info("WINDOW TREE STRUCTURE");
Logger.info("=".repeat(80));
this._monitors.forEach((monitor: Monitor, monitorId: number) => {
Logger.info(`Monitor ${monitorId}:`);
Logger.info(` Work Area: x=${monitor._workArea.x}, y=${monitor._workArea.y}, w=${monitor._workArea.width}, h=${monitor._workArea.height}`);
monitor._workspaces.forEach((workspace, workspaceIndex) => {
Logger.info(` Workspace ${workspaceIndex}:`);
Logger.info(` Orientation: ${workspace._orientation === 0 ? 'HORIZONTAL' : 'VERTICAL'}`);
Logger.info(` Items: ${workspace._tiledItems.length}`);
this._printContainerTree(workspace, 4);
});
});
Logger.info("=".repeat(80));
}
/**
* Recursively prints the container tree structure
* @param container The container to print
* @param indentLevel The indentation level (number of spaces)
*/
private _printContainerTree(container: any, indentLevel: number): void {
const indent = " ".repeat(indentLevel);
container._tiledItems.forEach((item: any, index: number) => {
if (item instanceof WindowContainer) {
Logger.info(`${indent}[${index}] Container (${item._orientation === 0 ? 'HORIZONTAL' : 'VERTICAL'}):`);
Logger.info(`${indent} Items: ${item._tiledItems.length}`);
Logger.info(`${indent} Work Area: x=${item._workArea.x}, y=${item._workArea.y}, w=${item._workArea.width}, h=${item._workArea.height}`);
this._printContainerTree(item, indentLevel + 4);
} else {
const window = item.getWindow();
Logger.info(`${indent}[${index}] Window ID: ${item.getWindowId()}`);
Logger.info(`${indent} Title: "${window.get_title()}"`);
Logger.info(`${indent} Class: ${window.get_wm_class()}`);
const rect = item.getRect();
Logger.info(`${indent} Rect: x=${rect.x}, y=${rect.y}, w=${rect.width}, h=${rect.height}`);
}
});
}
}