2 Commits

Author SHA1 Message Date
Lucas Oskorep
dd565da626 feat: add resizing 2025-10-28 12:59:11 -04:00
Lucas Oskorep
88623f32d7 feat: update devkit command 2025-10-16 03:44:33 -04:00
10 changed files with 593 additions and 396 deletions

View File

@@ -53,9 +53,9 @@ export default class aerospike extends Extension {
this.refreshKeybinding('join-with-right'); this.refreshKeybinding('join-with-right');
}); });
this.settings.connect('changed::reset-window-sizes', () => { this.settings.connect('changed::remove-all-dividers', () => {
log(`Reset window sizes keybinding changed to: ${this.settings.get_strv('reset-window-sizes')}`); log(`Keybinding remove-all-dividers changed to: ${this.settings.get_strv('remove-all-dividers')}`);
this.refreshKeybinding('reset-window-sizes'); this.refreshKeybinding('remove-all-dividers');
}); });
this.settings.connect('changed::dropdown-option', () => { this.settings.connect('changed::dropdown-option', () => {
@@ -93,9 +93,10 @@ export default class aerospike extends Extension {
Logger.info('Keybinding 4 was pressed!'); Logger.info('Keybinding 4 was pressed!');
}); });
break; break;
case 'reset-window-sizes': case 'remove-all-dividers':
this.bindKeybinding('reset-window-sizes', () => { this.bindKeybinding('remove-all-dividers', () => {
this.windowManager.resetAllWindowSizes(); Logger.info('Remove all dividers keybinding pressed!');
this.windowManager.removeAllDividersFromActiveContainer();
}); });
break; break;
} }
@@ -125,8 +126,9 @@ export default class aerospike extends Extension {
Logger.info('Keybinding 4 was pressed!'); Logger.info('Keybinding 4 was pressed!');
}); });
this.bindKeybinding('reset-window-sizes', () => { this.bindKeybinding('remove-all-dividers', () => {
this.windowManager.resetAllWindowSizes(); Logger.info('Remove all dividers keybinding pressed!');
this.windowManager.removeAllDividersFromActiveContainer();
}); });
} }

View File

@@ -28,7 +28,7 @@ install: build
cp -r dist/* ~/.local/share/gnome-shell/extensions/{{NAME}}@{{DOMAIN}}/ cp -r dist/* ~/.local/share/gnome-shell/extensions/{{NAME}}@{{DOMAIN}}/
run: run:
env MUTTER_DEBUG_DUMMY_MODE_SPECS=1280x720 dbus-run-session -- gnome-shell --devkit env MUTTER_DEBUG_DUMMY_MODE_SPECS=1280x720 dbus-run-session -- gnome-shell --nested --wayland
install-and-run: install run install-and-run: install run

Binary file not shown.

View File

@@ -37,10 +37,10 @@
<description>Keyboard shortcut for triggering action 4</description> <description>Keyboard shortcut for triggering action 4</description>
</key> </key>
<key name="reset-window-sizes" type="as"> <key name="remove-all-dividers" type="as">
<default><![CDATA[['<Alt>z']]]></default> <default><![CDATA[['<Alt>z']]]></default>
<summary>Reset all window sizes</summary> <summary>Remove all dividers from active container</summary>
<description>Remove all custom window sizes and return to equal distribution</description> <description>Keyboard shortcut for removing all dividers from the container with the active window</description>
</key> </key>
</schema> </schema>

View File

@@ -3,26 +3,27 @@ import {Logger} from "../utils/logger.js";
import Meta from "gi://Meta"; import Meta from "gi://Meta";
import queueEvent from "../utils/events.js"; import queueEvent from "../utils/events.js";
import {Rect} from "../utils/rect.js"; import {Rect} from "../utils/rect.js";
import {Divider} from "./divider.js";
enum Orientation { enum Orientation {
HORIZONTAL = 0, HORIZONTAL = 0,
VERTICAL = 1, VERTICAL = 1,
} }
type ContainerItem = WindowWrapper | WindowContainer | Divider;
export default class WindowContainer { export default class WindowContainer {
_tiledItems: (WindowWrapper | WindowContainer)[]; _tiledItems: ContainerItem[];
_tiledWindowLookup: Map<number, WindowWrapper>; _tiledWindowLookup: Map<number, WindowWrapper>;
_orientation: Orientation = Orientation.HORIZONTAL; _orientation: Orientation = Orientation.HORIZONTAL;
_workArea: Rect; _workArea: Rect;
_customSizes: Map<number, number>; // Maps index to custom width (horizontal) or height (vertical)
constructor(workspaceArea: Rect,) { constructor(workspaceArea: Rect,) {
// this._id = monitorId;
this._tiledItems = []; this._tiledItems = [];
this._tiledWindowLookup = new Map<number, WindowWrapper>(); this._tiledWindowLookup = new Map<number, WindowWrapper>();
this._workArea = workspaceArea; this._workArea = workspaceArea;
this._customSizes = new Map<number, number>();
} }
@@ -35,6 +36,7 @@ export default class WindowContainer {
// Add window to managed windows // Add window to managed windows
this._tiledItems.push(winWrap); this._tiledItems.push(winWrap);
this._tiledWindowLookup.set(winWrap.getWindowId(), winWrap); this._tiledWindowLookup.set(winWrap.getWindowId(), winWrap);
// winWrap.setParent(this);
queueEvent({ queueEvent({
name: "tiling-windows", name: "tiling-windows",
callback: () => { callback: () => {
@@ -49,12 +51,14 @@ export default class WindowContainer {
return this._tiledWindowLookup.get(win_id); return this._tiledWindowLookup.get(win_id);
} }
for (const item of this._tiledItems) { for (const item of this._tiledItems) {
if (item instanceof WindowContainer) { if (Divider.isDivider(item)) {
continue; // Skip dividers
} else if (item instanceof WindowContainer) {
const win = item.getWindow(win_id); const win = item.getWindow(win_id);
if (win) { if (win) {
return win; return win;
} }
} else if (item.getWindowId() === win_id) { } else if (item instanceof WindowWrapper && item.getWindowId() === win_id) {
return item; return item;
} }
} }
@@ -76,8 +80,7 @@ export default class WindowContainer {
this._tiledWindowLookup.delete(win_id); this._tiledWindowLookup.delete(win_id);
const index = this._getIndexOfWindow(win_id) const index = this._getIndexOfWindow(win_id)
this._tiledItems.splice(index, 1); this._tiledItems.splice(index, 1);
// Shift custom sizes after removed index this._cleanupInvalidDividers();
this._shiftCustomSizesAfterRemoval(index);
} else { } else {
for (const item of this._tiledItems) { for (const item of this._tiledItems) {
if (item instanceof WindowContainer) { if (item instanceof WindowContainer) {
@@ -88,105 +91,44 @@ export default class WindowContainer {
this.tileWindows() this.tileWindows()
} }
_shiftCustomSizesAfterRemoval(removedIndex: number): void { /**
Logger.log(`=== _shiftCustomSizesAfterRemoval called ===`); * Removes invalid dividers from the items list.
Logger.log(`Removed index: ${removedIndex}`); * Invalid dividers are:
Logger.log(`Total items after removal: ${this._tiledItems.length}`); * - Dividers at the start or end of the list (no window on one side)
Logger.log(`Custom sizes Map size: ${this._customSizes.size}`); * - Consecutive dividers (two dividers in a row)
*/
_cleanupInvalidDividers(): void {
let i = 0;
while (i < this._tiledItems.length) {
const item = this._tiledItems[i];
// Convert Map to readable string if (Divider.isDivider(item)) {
let customSizesStr = "{ "; // Check if divider is at start or end
this._customSizes.forEach((size, index) => { const isAtStart = i === 0;
customSizesStr += `${index}: ${size}px, `; const isAtEnd = i === this._tiledItems.length - 1;
});
customSizesStr += "}";
Logger.log(`Custom sizes before shift: ${customSizesStr}`);
// Calculate the removed window's size (could be custom or flexible) // Check if next item is also a divider
let removedSize = this._customSizes.get(removedIndex); const nextIsDivider = i < this._tiledItems.length - 1 &&
Divider.isDivider(this._tiledItems[i + 1]);
if (removedSize === undefined) { if (isAtStart || isAtEnd || nextIsDivider) {
// Window didn't have custom size, calculate its flexible size Logger.log(`Removing invalid divider at index ${i}`);
// Count items BEFORE removal (add 1 to current length) this._tiledItems.splice(i, 1);
const numItemsBeforeRemoval = this._tiledItems.length + 1; continue; // Don't increment i, check the same position again
let totalCustomSize = 0; }
let numFlexibleItemsBeforeRemoval = 0;
this._customSizes.forEach((size, index) => {
totalCustomSize += size;
// Don't count this in flexible if it's the removed index
});
numFlexibleItemsBeforeRemoval = numItemsBeforeRemoval - this._customSizes.size;
const containerSize = this._orientation === Orientation.HORIZONTAL ? this._workArea.width : this._workArea.height;
const remainingSize = containerSize - totalCustomSize;
removedSize = numFlexibleItemsBeforeRemoval > 0 ? Math.floor(remainingSize / numFlexibleItemsBeforeRemoval) : 0;
Logger.log(`Removed window was flexible, calculated size: ${removedSize}px (${numFlexibleItemsBeforeRemoval} flexible windows before removal)`);
} else {
Logger.log(`Removed window had custom size: ${removedSize}px`);
}
// Rebuild the custom sizes map with shifted indices
const newCustomSizes = new Map<number, number>();
this._customSizes.forEach((size, index) => {
if (index < removedIndex) {
// Keep indices before removal
Logger.log(`Keeping index ${index} with size ${size}`);
newCustomSizes.set(index, size);
} else if (index > removedIndex) {
// Shift down indices after removal
Logger.log(`Shifting index ${index} -> ${index - 1} with size ${size}`);
newCustomSizes.set(index - 1, size);
} }
// Skip the removed index i++;
});
Logger.log(`New custom sizes Map size after shift: ${newCustomSizes.size}`);
let afterShiftStr = "{ ";
newCustomSizes.forEach((size, index) => {
afterShiftStr += `${index}: ${size}px, `;
});
afterShiftStr += "}";
Logger.log(`Custom sizes after index shift: ${afterShiftStr}`);
// Distribute removed window's size among remaining custom-sized windows only
// Flexible windows will naturally absorb their share through the bounds calculation
const remainingWindowCount = this._tiledItems.length;
const numCustomWindows = newCustomSizes.size;
if (removedSize > 0 && remainingWindowCount > 0 && numCustomWindows > 0) {
const sizePerCustomWindow = Math.floor(removedSize / numCustomWindows);
Logger.log(`Distributing ${removedSize}px among ${numCustomWindows} custom-sized windows (${sizePerCustomWindow}px each)`);
Logger.log(`Flexible windows will naturally absorb remaining space`);
// Add proportional size only to windows that already have custom sizes
newCustomSizes.forEach((size, index) => {
const newSize = size + sizePerCustomWindow;
Logger.log(`Index ${index}: ${size}px + ${sizePerCustomWindow}px = ${newSize}px`);
newCustomSizes.set(index, newSize);
});
} else {
Logger.log(`Not distributing space - removedSize: ${removedSize}, remainingWindows: ${remainingWindowCount}, customWindows: ${numCustomWindows}`);
} }
let finalStr = "{ ";
newCustomSizes.forEach((size, index) => {
finalStr += `${index}: ${size}px, `;
});
finalStr += "}";
Logger.log(`Final custom sizes: ${finalStr}`);
this._customSizes = newCustomSizes;
Logger.log(`=== _shiftCustomSizesAfterRemoval complete ===`);
} }
disconnectSignals(): void { disconnectSignals(): void {
this._tiledItems.forEach((item) => { this._tiledItems.forEach((item) => {
if (item instanceof WindowContainer) { if (Divider.isDivider(item)) {
// Skip dividers - they don't have signals
return;
} else if (item instanceof WindowContainer) {
item.disconnectSignals() item.disconnectSignals()
} else { } else if (item instanceof WindowWrapper) {
item.disconnectWindowSignals(); item.disconnectWindowSignals();
} }
} }
@@ -198,26 +140,37 @@ export default class WindowContainer {
this._tiledWindowLookup.clear() this._tiledWindowLookup.clear()
} }
tileWindows(skipRetry: boolean = false) { tileWindows() {
Logger.log("TILING WINDOWS IN CONTAINER") Logger.log("TILING WINDOWS IN CONTAINER")
Logger.log("WorkArea", this._workArea); Logger.log("WorkArea", this._workArea);
this._tileItems(skipRetry)
// Get all windows for current workspaceArea
this._tileItems()
return true return true
} }
_tileItems(skipRetry: boolean = false) { _tileItems() {
if (this._tiledItems.length === 0) { if (this._tiledItems.length === 0) {
return; return;
} }
const bounds = this.getBounds(); const bounds = this.getBounds();
this._tiledItems.forEach((item, index) => {
const rect = bounds[index]; // Apply bounds to non-divider items
let boundsIndex = 0;
this._tiledItems.forEach((item) => {
if (Divider.isDivider(item)) {
return; // Skip dividers
}
const rect = bounds[boundsIndex];
if (item instanceof WindowContainer) { if (item instanceof WindowContainer) {
item.move(rect); item.move(rect);
} else { } else if (item instanceof WindowWrapper) {
item.safelyResizeWindow(rect, 2, skipRetry); item.safelyResizeWindow(rect);
} }
boundsIndex++;
}) })
} }
@@ -230,100 +183,177 @@ export default class WindowContainer {
} }
getVerticalBounds(): Rect[] { getVerticalBounds(): Rect[] {
// Calculate available height after accounting for custom-sized windows // Filter out dividers to get only windows/containers
let totalCustomHeight = 0; const nonDividerItems = this._tiledItems.filter(item => !Divider.isDivider(item));
let numFlexibleItems = 0;
this._tiledItems.forEach((item, index) => { if (nonDividerItems.length === 0) {
if (this._customSizes.has(index)) { return [];
totalCustomHeight += this._customSizes.get(index)!;
} else {
numFlexibleItems++;
}
});
// Ensure custom sizes don't exceed container height
if (totalCustomHeight > this._workArea.height) {
Logger.warn("Custom heights exceed container, resetting all sizes");
this._customSizes.clear();
totalCustomHeight = 0;
numFlexibleItems = this._tiledItems.length;
} }
const remainingHeight = this._workArea.height - totalCustomHeight; // If no dividers, use equal distribution
const flexHeight = numFlexibleItems > 0 ? Math.floor(remainingHeight / numFlexibleItems) : 0; const hasDividers = this._tiledItems.some(item => Divider.isDivider(item));
if (!hasDividers) {
const containerHeight = Math.floor(this._workArea.height / nonDividerItems.length);
return nonDividerItems.map((_, index) => {
const y = this._workArea.y + (index * containerHeight);
return {
x: this._workArea.x,
y: y,
width: this._workArea.width,
height: containerHeight
} as Rect;
});
}
// Build the bounds array // Calculate bounds based on divider positions
const bounds: Rect[] = [];
let currentY = this._workArea.y; let currentY = this._workArea.y;
return this._tiledItems.map((item, index) => { let itemIndex = 0;
let height = flexHeight;
if (this._customSizes.has(index)) {
height = this._customSizes.get(index)!;
}
const rect = { for (let i = 0; i < this._tiledItems.length; i++) {
x: this._workArea.x, const item = this._tiledItems[i];
y: currentY,
width: this._workArea.width, if (Divider.isDivider(item)) {
height: height // Next segment starts at divider position
} as Rect; currentY = this._workArea.y + Math.floor(item.getPosition() * this._workArea.height);
currentY += height; } else {
return rect; // Find the end position for this item
}); let endY: number = this._workArea.y + this._workArea.height;
// Look ahead to find next divider or end of container
for (let j = i + 1; j < this._tiledItems.length; j++) {
if (Divider.isDivider(this._tiledItems[j])) {
const divider = this._tiledItems[j] as Divider;
endY = this._workArea.y + Math.floor(divider.getPosition() * this._workArea.height);
break;
}
}
// Count non-divider items until next divider
let itemCount = 0;
let itemsInSegment: number[] = [];
for (let j = i; j < this._tiledItems.length; j++) {
if (Divider.isDivider(this._tiledItems[j])) {
break;
}
itemsInSegment.push(j);
itemCount++;
}
// Divide space equally among items in this segment
const segmentHeight = endY - currentY;
const itemHeight = Math.floor(segmentHeight / itemCount);
for (let k = 0; k < itemsInSegment.length; k++) {
const itemY = currentY + (k * itemHeight);
bounds.push({
x: this._workArea.x,
y: itemY,
width: this._workArea.width,
height: itemHeight
} as Rect);
}
// Skip the items we just processed
i += itemCount - 1;
currentY = endY;
}
}
return bounds;
} }
getHorizontalBounds(): Rect[] { getHorizontalBounds(): Rect[] {
// Calculate available width after accounting for custom-sized windows // Filter out dividers to get only windows/containers
let totalCustomWidth = 0; const nonDividerItems = this._tiledItems.filter(item => !Divider.isDivider(item));
let numFlexibleItems = 0;
this._tiledItems.forEach((item, index) => { if (nonDividerItems.length === 0) {
if (this._customSizes.has(index)) { return [];
totalCustomWidth += this._customSizes.get(index)!;
} else {
numFlexibleItems++;
}
});
// Ensure custom sizes don't exceed container width
if (totalCustomWidth > this._workArea.width) {
Logger.warn("Custom widths exceed container, resetting all sizes");
this._customSizes.clear();
totalCustomWidth = 0;
numFlexibleItems = this._tiledItems.length;
} }
const remainingWidth = this._workArea.width - totalCustomWidth; // If no dividers, use equal distribution
const flexWidth = numFlexibleItems > 0 ? Math.floor(remainingWidth / numFlexibleItems) : 0; const hasDividers = this._tiledItems.some(item => Divider.isDivider(item));
if (!hasDividers) {
const windowWidth = Math.floor(this._workArea.width / nonDividerItems.length);
return nonDividerItems.map((_, index) => {
const x = this._workArea.x + (index * windowWidth);
return {
x: x,
y: this._workArea.y,
width: windowWidth,
height: this._workArea.height
} as Rect;
});
}
// Build the bounds array // Calculate bounds based on divider positions
const bounds: Rect[] = [];
let currentX = this._workArea.x; let currentX = this._workArea.x;
return this._tiledItems.map((item, index) => {
let width = flexWidth;
if (this._customSizes.has(index)) {
width = this._customSizes.get(index)!;
}
const rect = { for (let i = 0; i < this._tiledItems.length; i++) {
x: currentX, const item = this._tiledItems[i];
y: this._workArea.y,
width: width, if (Divider.isDivider(item)) {
height: this._workArea.height // Next segment starts at divider position
} as Rect; currentX = this._workArea.x + Math.floor(item.getPosition() * this._workArea.width);
currentX += width; } else {
return rect; // Find the end position for this item
}); let endX: number = this._workArea.x + this._workArea.width;
// Look ahead to find next divider or end of container
for (let j = i + 1; j < this._tiledItems.length; j++) {
if (Divider.isDivider(this._tiledItems[j])) {
const divider = this._tiledItems[j] as Divider;
endX = this._workArea.x + Math.floor(divider.getPosition() * this._workArea.width);
break;
}
}
// Count non-divider items until next divider
let itemCount = 0;
let itemsInSegment: number[] = [];
for (let j = i; j < this._tiledItems.length; j++) {
if (Divider.isDivider(this._tiledItems[j])) {
break;
}
itemsInSegment.push(j);
itemCount++;
}
// Divide space equally among items in this segment
const segmentWidth = endX - currentX;
const itemWidth = Math.floor(segmentWidth / itemCount);
for (let k = 0; k < itemsInSegment.length; k++) {
const itemX = currentX + (k * itemWidth);
bounds.push({
x: itemX,
y: this._workArea.y,
width: itemWidth,
height: this._workArea.height
} as Rect);
}
// Skip the items we just processed
i += itemCount - 1;
currentX = endX;
}
}
return bounds;
} }
getIndexOfItemNested(item: WindowWrapper): number { getIndexOfItemNested(item: WindowWrapper): number {
for (let i = 0; i < this._tiledItems.length; i++) { for (let i = 0; i < this._tiledItems.length; i++) {
const container = this._tiledItems[i]; const container = this._tiledItems[i];
if (container instanceof WindowContainer) { if (Divider.isDivider(container)) {
continue; // Skip dividers
} else if (container instanceof WindowContainer) {
const index = container.getIndexOfItemNested(item); const index = container.getIndexOfItemNested(item);
if (index !== -1) { if (index !== -1) {
return i; return i;
} }
} else if (container.getWindowId() === item.getWindowId()) { } else if (container instanceof WindowWrapper && container.getWindowId() === item.getWindowId()) {
return i; return i;
} }
} }
@@ -332,152 +362,271 @@ export default class WindowContainer {
// TODO: update this to work with nested containers - all other logic should already be working // TODO: update this to work with nested containers - all other logic should already be working
itemDragged(item: WindowWrapper, x: number, y: number): void { itemDragged(item: WindowWrapper, x: number, y: number): void {
let original_index = this.getIndexOfItemNested(item); // Find the actual index in _tiledItems (including dividers)
const original_actual_index = this._getIndexOfWindow(item.getWindowId());
if (original_index === -1) { if (original_actual_index === -1) {
Logger.error("Item not found in container during drag op", item.getWindowId()); Logger.error("Item not found in container during drag op", item.getWindowId());
return; return;
} }
let new_index = original_index;
this.getBounds().forEach((rect, index) => { // Find which visual slot (non-divider index) we're moving to
let new_visual_index = this.getIndexOfItemNested(item);
const bounds = this.getBounds();
bounds.forEach((rect, index) => {
if (rect.x < x && rect.x + rect.width > x && rect.y < y && rect.y + rect.height > y) { if (rect.x < x && rect.x + rect.width > x && rect.y < y && rect.y + rect.height > y) {
new_index = index; new_visual_index = index;
} }
}) })
if (original_index !== new_index) {
this._tiledItems.splice(original_index, 1); // Get current visual index (counting only non-dividers before this item)
this._tiledItems.splice(new_index, 0, item); let original_visual_index = 0;
this.tileWindows() for (let i = 0; i < original_actual_index; i++) {
if (!Divider.isDivider(this._tiledItems[i])) {
original_visual_index++;
}
} }
} if (original_visual_index === new_visual_index) {
return; // No movement needed
}
windowManuallyResized(win_id: number): void { Logger.log(`Swapping window from visual index ${original_visual_index} to ${new_visual_index}`);
const window = this.getWindow(win_id);
if (!window) { // Find the target window at the new visual index
// Check nested containers let target_actual_index = -1;
for (const item of this._tiledItems) { let visual_count = 0;
if (item instanceof WindowContainer) { for (let i = 0; i < this._tiledItems.length; i++) {
item.windowManuallyResized(win_id); if (!Divider.isDivider(this._tiledItems[i])) {
if (visual_count === new_visual_index) {
target_actual_index = i;
break;
} }
visual_count++;
} }
}
if (target_actual_index === -1) {
Logger.warn("Could not find target position for drag");
return; return;
} }
// Find the index of the window // Simply swap the two windows in place, leaving dividers where they are
const index = this._getIndexOfWindow(win_id); const temp = this._tiledItems[original_actual_index];
if (index === -1) { this._tiledItems[original_actual_index] = this._tiledItems[target_actual_index];
Logger.error("Window not found in container during resize"); this._tiledItems[target_actual_index] = temp;
return;
}
const rect = window.getRect(); this.tileWindows();
if (this._orientation === Orientation.HORIZONTAL) {
this._customSizes.set(index, rect.width);
Logger.log(`Window at index ${index} manually resized to width: ${rect.width}`);
} else {
this._customSizes.set(index, rect.height);
Logger.log(`Window at index ${index} manually resized to height: ${rect.height}`);
}
} }
resetAllWindowSizes(): void { /**
Logger.log("Clearing all custom window sizes in container"); * Handles window resize operations. Creates or updates dividers based on resize direction.
this._customSizes.clear(); * @param item - The window being resized
// Also clear nested containers * @param resizeEdge - The edge being resized (N, S, E, W, etc.)
for (const item of this._tiledItems) { * @param newRect - The new rectangle after resize
if (item instanceof WindowContainer) { */
item.resetAllWindowSizes(); handleWindowResize(item: WindowWrapper, resizeEdge: Meta.GrabOp, newRect: Rect): void {
} const itemIndex = this._getIndexOfWindow(item.getWindowId());
} if (itemIndex === -1) {
} Logger.warn("Window not found in container during resize", item.getWindowId());
windowResizing(win_id: number, resizeOp: Meta.GrabOp): void {
const window = this.getWindow(win_id);
if (!window) {
// Check nested containers
for (const item of this._tiledItems) {
if (item instanceof WindowContainer) {
item.windowResizing(win_id, resizeOp);
}
}
return; return;
} }
// Check if the resize direction matches the container orientation // Determine if this is a valid resize for this container orientation
const isHorizontalResize = resizeOp === Meta.GrabOp.RESIZING_E || resizeOp === Meta.GrabOp.RESIZING_W; const isHorizontalResize = this._isHorizontalResizeOp(resizeEdge);
const isVerticalResize = resizeOp === Meta.GrabOp.RESIZING_N || resizeOp === Meta.GrabOp.RESIZING_S; const isVerticalResize = this._isVerticalResizeOp(resizeEdge);
if ((this._orientation === Orientation.HORIZONTAL && !isHorizontalResize) || // Only allow horizontal resizes in horizontal containers
(this._orientation === Orientation.VERTICAL && !isVerticalResize)) { // Only allow vertical resizes in vertical containers
// Resize direction doesn't match container orientation, ignore if (this._orientation === Orientation.HORIZONTAL && !isHorizontalResize) {
Logger.log("Ignoring vertical resize in horizontal container");
return;
}
if (this._orientation === Orientation.VERTICAL && !isVerticalResize) {
Logger.log("Ignoring horizontal resize in vertical container");
return; return;
} }
// Find the index of the window // Determine which edge is being resized and find adjacent window
const index = this._getIndexOfWindow(win_id);
if (index === -1) {
return;
}
// Get the new size
const rect = window.getRect();
const newSize = this._orientation === Orientation.HORIZONTAL ? rect.width : rect.height;
const oldSize = this._customSizes.get(index);
if (oldSize === undefined) {
// First time resizing this window, just set the size
this._customSizes.set(index, newSize);
this.tileWindows(true);
return;
}
// Calculate the delta (how much the window changed)
const delta = newSize - oldSize;
// If delta is 0, the window didn't actually resize (hit its minimum)
if (delta === 0) {
return;
}
// Determine which adjacent window to adjust based on resize direction
let adjacentIndex = -1; let adjacentIndex = -1;
if (resizeOp === Meta.GrabOp.RESIZING_E || resizeOp === Meta.GrabOp.RESIZING_S) { let dividerPosition = 0;
// Resizing right/down edge - adjust the next window
adjacentIndex = index + 1;
} else if (resizeOp === Meta.GrabOp.RESIZING_W || resizeOp === Meta.GrabOp.RESIZING_N) {
// Resizing left/up edge - adjust the previous window
adjacentIndex = index - 1;
}
// Update current window size if (this._orientation === Orientation.HORIZONTAL) {
this._customSizes.set(index, newSize); // East/West resize
if (this._isEastResizeOp(resizeEdge)) {
// Adjust adjacent window only if it has a custom size // Resizing east edge - divider goes after this window
// When both windows have custom sizes, always apply opposite delta to maintain total width adjacentIndex = itemIndex + 1;
let oldAdjacentSize: number | undefined = undefined; // Calculate divider position as ratio of container width
if (adjacentIndex >= 0 && adjacentIndex < this._tiledItems.length && const rightEdge = newRect.x + newRect.width;
this._customSizes.has(adjacentIndex)) { dividerPosition = (rightEdge - this._workArea.x) / this._workArea.width;
const adjacentItem = this._tiledItems[adjacentIndex]; } else if (this._isWestResizeOp(resizeEdge)) {
if (adjacentItem instanceof WindowWrapper) { // Resizing west edge - divider goes before this window
oldAdjacentSize = this._customSizes.get(adjacentIndex)!; adjacentIndex = itemIndex - 1;
const newAdjacentSize = oldAdjacentSize - delta; dividerPosition = (newRect.x - this._workArea.x) / this._workArea.width;
}
// Check if adjacent window allows resize } else {
if (!adjacentItem.getWindow().allows_resize()) { // Vertical orientation - North/South resize
Logger.log("Adjacent window doesn't allow resize, reverting"); if (this._isSouthResizeOp(resizeEdge)) {
this._customSizes.set(index, oldSize); // Resizing south edge - divider goes after this window
} else { adjacentIndex = itemIndex + 1;
// Always apply the opposite delta to the adjacent window const bottomEdge = newRect.y + newRect.height;
// This keeps the total width constant dividerPosition = (bottomEdge - this._workArea.y) / this._workArea.height;
this._customSizes.set(adjacentIndex, newAdjacentSize); } else if (this._isNorthResizeOp(resizeEdge)) {
} // Resizing north edge - divider goes before this window
adjacentIndex = itemIndex - 1;
dividerPosition = (newRect.y - this._workArea.y) / this._workArea.height;
} }
} }
// Call tileWindows during resize to update all window positions // Make sure there's an adjacent item
// Skip retry logic during active resize to avoid jitter if (adjacentIndex < 0 || adjacentIndex >= this._tiledItems.length) {
this.tileWindows(true); Logger.log("No adjacent window for resize operation");
return;
}
// Skip if adjacent item is already a divider
if (Divider.isDivider(this._tiledItems[adjacentIndex])) {
// Update existing divider
const divider = this._tiledItems[adjacentIndex] as Divider;
divider.setPosition(dividerPosition);
Logger.log(`Updated divider at index ${adjacentIndex} to position ${dividerPosition}`);
} else {
// Insert new divider between items
const dividerIndex = Math.max(itemIndex, adjacentIndex);
const newDivider = new Divider(dividerPosition, this._orientation);
this._tiledItems.splice(dividerIndex, 0, newDivider);
Logger.log(`Inserted new divider at index ${dividerIndex} with position ${dividerPosition}`);
}
this.tileWindows();
}
private _isHorizontalResizeOp(op: Meta.GrabOp): boolean {
return op === Meta.GrabOp.RESIZING_E ||
op === Meta.GrabOp.RESIZING_W ||
op === Meta.GrabOp.RESIZING_NE ||
op === Meta.GrabOp.RESIZING_NW ||
op === Meta.GrabOp.RESIZING_SE ||
op === Meta.GrabOp.RESIZING_SW;
}
private _isVerticalResizeOp(op: Meta.GrabOp): boolean {
return op === Meta.GrabOp.RESIZING_N ||
op === Meta.GrabOp.RESIZING_S ||
op === Meta.GrabOp.RESIZING_NE ||
op === Meta.GrabOp.RESIZING_NW ||
op === Meta.GrabOp.RESIZING_SE ||
op === Meta.GrabOp.RESIZING_SW;
}
private _isEastResizeOp(op: Meta.GrabOp): boolean {
return op === Meta.GrabOp.RESIZING_E ||
op === Meta.GrabOp.RESIZING_NE ||
op === Meta.GrabOp.RESIZING_SE;
}
private _isWestResizeOp(op: Meta.GrabOp): boolean {
return op === Meta.GrabOp.RESIZING_W ||
op === Meta.GrabOp.RESIZING_NW ||
op === Meta.GrabOp.RESIZING_SW;
}
private _isSouthResizeOp(op: Meta.GrabOp): boolean {
return op === Meta.GrabOp.RESIZING_S ||
op === Meta.GrabOp.RESIZING_SE ||
op === Meta.GrabOp.RESIZING_SW;
}
private _isNorthResizeOp(op: Meta.GrabOp): boolean {
return op === Meta.GrabOp.RESIZING_N ||
op === Meta.GrabOp.RESIZING_NE ||
op === Meta.GrabOp.RESIZING_NW;
}
/**
* Removes all dividers from this container, reverting to equal space distribution
*/
removeAllDividers(): void {
Logger.log("Removing all dividers from container");
this._tiledItems = this._tiledItems.filter(item => !Divider.isDivider(item));
this.tileWindows();
}
/**
* Updates divider position during a live resize operation (or creates if doesn't exist)
* This is called repeatedly during resize for live feedback
*/
updateDividerDuringResize(item: WindowWrapper, resizeEdge: Meta.GrabOp, newRect: Rect): void {
const itemIndex = this._getIndexOfWindow(item.getWindowId());
if (itemIndex === -1) {
return;
}
// Determine if this is a valid resize for this container orientation
const isHorizontalResize = this._isHorizontalResizeOp(resizeEdge);
const isVerticalResize = this._isVerticalResizeOp(resizeEdge);
if (this._orientation === Orientation.HORIZONTAL && !isHorizontalResize) {
return;
}
if (this._orientation === Orientation.VERTICAL && !isVerticalResize) {
return;
}
// Determine which edge is being resized and find adjacent window
let adjacentIndex = -1;
let dividerPosition = 0;
if (this._orientation === Orientation.HORIZONTAL) {
if (this._isEastResizeOp(resizeEdge)) {
adjacentIndex = itemIndex + 1;
const rightEdge = newRect.x + newRect.width;
dividerPosition = (rightEdge - this._workArea.x) / this._workArea.width;
} else if (this._isWestResizeOp(resizeEdge)) {
adjacentIndex = itemIndex - 1;
dividerPosition = (newRect.x - this._workArea.x) / this._workArea.width;
}
} else {
if (this._isSouthResizeOp(resizeEdge)) {
adjacentIndex = itemIndex + 1;
const bottomEdge = newRect.y + newRect.height;
dividerPosition = (bottomEdge - this._workArea.y) / this._workArea.height;
} else if (this._isNorthResizeOp(resizeEdge)) {
adjacentIndex = itemIndex - 1;
dividerPosition = (newRect.y - this._workArea.y) / this._workArea.height;
}
}
// Make sure there's an adjacent item (window or container, not out of bounds)
if (adjacentIndex < 0 || adjacentIndex >= this._tiledItems.length) {
Logger.log(`No adjacent item at index ${adjacentIndex}`);
return;
}
// Determine where divider should be inserted/updated
// For East/South resizes: divider between current (itemIndex) and next (itemIndex+1)
// For West/North resizes: divider between previous (itemIndex-1) and current (itemIndex)
let dividerIndex: number;
if (this._orientation === Orientation.HORIZONTAL) {
dividerIndex = this._isEastResizeOp(resizeEdge) ? itemIndex + 1 : itemIndex;
} else {
dividerIndex = this._isSouthResizeOp(resizeEdge) ? itemIndex + 1 : itemIndex;
}
// Check if there's already a divider at this position
if (dividerIndex < this._tiledItems.length && Divider.isDivider(this._tiledItems[dividerIndex])) {
// Update existing divider
const divider = this._tiledItems[dividerIndex] as Divider;
divider.setPosition(dividerPosition);
} else {
// Insert new divider
const newDivider = new Divider(dividerPosition, this._orientation);
this._tiledItems.splice(dividerIndex, 0, newDivider);
}
// Retile to show live updates
this.tileWindows();
} }

45
src/wm/divider.ts Normal file
View File

@@ -0,0 +1,45 @@
import {Logger} from "../utils/logger.js";
enum Orientation {
HORIZONTAL = 0,
VERTICAL = 1,
}
/**
* Represents a divider between windows in a container.
* Dividers track the split position as a ratio (0-1) of the container's size.
*/
export class Divider {
private _position: number; // Position as ratio 0-1
private _orientation: Orientation;
/**
* Creates a new divider
* @param position - Position as ratio between 0 and 1
* @param orientation - Orientation of the divider (HORIZONTAL or VERTICAL)
*/
constructor(position: number, orientation: Orientation) {
this._position = Math.max(0, Math.min(1, position)); // Clamp between 0 and 1
this._orientation = orientation;
}
getPosition(): number {
return this._position;
}
setPosition(position: number): void {
this._position = Math.max(0, Math.min(1, position)); // Clamp between 0 and 1
Logger.log(`Divider position updated to ${this._position}`);
}
getOrientation(): Orientation {
return this._orientation;
}
/**
* Check if this is a divider instance
*/
static isDivider(item: any): item is Divider {
return item instanceof Divider;
}
}

View File

@@ -68,6 +68,7 @@ export default class Monitor {
this._workArea = global.workspace_manager.get_active_workspace().get_work_area_for_monitor(this._id); this._workArea = global.workspace_manager.get_active_workspace().get_work_area_for_monitor(this._id);
const activeWorkspace = global.workspace_manager.get_active_workspace(); const activeWorkspace = global.workspace_manager.get_active_workspace();
this._workspaces[activeWorkspace.index()].move(this._workArea); this._workspaces[activeWorkspace.index()].move(this._workArea);
this._workspaces[activeWorkspace.index()].tileWindows()
} }
removeWorkspace(workspaceId: number): void { removeWorkspace(workspaceId: number): void {
@@ -82,32 +83,17 @@ export default class Monitor {
this._workspaces[item.getWorkspace()].itemDragged(item, x, y); this._workspaces[item.getWorkspace()].itemDragged(item, x, y);
} }
windowManuallyResized(win_id: number): void { handleWindowResize(item: WindowWrapper, resizeEdge: Meta.GrabOp, newRect: Rect): void {
// Find which workspace contains the window and notify it this._workspaces[item.getWorkspace()].handleWindowResize(item, resizeEdge, newRect);
for (const container of this._workspaces) {
const win = container.getWindow(win_id);
if (win) {
container.windowManuallyResized(win_id);
return;
}
}
} }
resetAllWindowSizes(): void { updateDividerDuringResize(item: WindowWrapper, resizeEdge: Meta.GrabOp, newRect: Rect): void {
for (const container of this._workspaces) { this._workspaces[item.getWorkspace()].updateDividerDuringResize(item, resizeEdge, newRect);
container.resetAllWindowSizes();
}
} }
windowResizing(win_id: number, resizeOp: Meta.GrabOp): void { removeAllDividersFromActiveContainer(): void {
// Find which workspace contains the window and notify it const activeWorkspace = global.workspace_manager.get_active_workspace();
for (const container of this._workspaces) { this._workspaces[activeWorkspace.index()].removeAllDividers();
const win = container.getWindow(win_id);
if (win) {
container.windowResizing(win_id, resizeOp);
return;
}
}
} }
} }

View File

@@ -16,6 +16,7 @@ export class WindowWrapper {
readonly _signals: number[] = []; readonly _signals: number[] = [];
_parent: WindowContainer | null = null; _parent: WindowContainer | null = null;
_dragging: boolean = false; _dragging: boolean = false;
_resizing: boolean = false;
constructor( constructor(
window: Meta.Window, window: Meta.Window,
@@ -53,6 +54,13 @@ export class WindowWrapper {
this._dragging = false; this._dragging = false;
} }
startResizing(): void {
this._resizing = true;
}
stopResizing(): void {
this._resizing = false;
}
// setParent(parent: WindowContainer): void { // setParent(parent: WindowContainer): void {
// this._parent = parent; // this._parent = parent;
// } // }
@@ -104,9 +112,6 @@ export class WindowWrapper {
this._window.connect("position-changed", (_metaWindow) => { this._window.connect("position-changed", (_metaWindow) => {
windowManager.handleWindowPositionChanged(this); windowManager.handleWindowPositionChanged(this);
}), }),
this._window.connect("size-changed", (_metaWindow) => {
windowManager.handleWindowSizeChanged(this);
}),
); );
} }
@@ -125,10 +130,12 @@ export class WindowWrapper {
} }
} }
safelyResizeWindow(rect: Rect, _retry: number = 2, _skipRetry: boolean = false): void { safelyResizeWindow(rect: Rect, _retry: number = 2): void {
// Keep minimal logging // Keep minimal logging
// Note: we allow resizing even during drag operations to support position updates if (this._dragging && !this._resizing) {
// The dragging flag only prevents REORDERING, not position/size changes // During drag operations (not resize), skip this entirely
return;
}
// Logger.log("SAFELY RESIZE", rect.x, rect.y, rect.width, rect.height); // Logger.log("SAFELY RESIZE", rect.x, rect.y, rect.width, rect.height);
const actor = this._window.get_compositor_private(); const actor = this._window.get_compositor_private();
@@ -143,13 +150,19 @@ export class WindowWrapper {
this._window.move_frame(true, rect.x, rect.y); this._window.move_frame(true, rect.x, rect.y);
// Logger.info("RESIZING MOVING") // Logger.info("RESIZING MOVING")
this._window.move_resize_frame(true, rect.x, rect.y, rect.width, rect.height); this._window.move_resize_frame(true, rect.x, rect.y, rect.width, rect.height);
// Don't retry during live resize operations - it causes spam and isn't needed
if (this._resizing) {
return;
}
let new_rect = this._window.get_frame_rect(); let new_rect = this._window.get_frame_rect();
if (!_skipRetry && _retry > 0 && (new_rect.x != rect.x || rect.y != new_rect.y || rect.width < new_rect.width || rect.height < new_rect.height)) { if ( _retry > 0 && (new_rect.x != rect.x || rect.y != new_rect.y || rect.width < new_rect.width || rect.height < new_rect.height)) {
Logger.warn("RESIZING FAILED AS SMALLER", new_rect.x, new_rect.y, new_rect.width, new_rect.height, rect.x, rect.y, rect.width, rect.height); Logger.warn("RESIZING FAILED AS SMALLER", new_rect.x, new_rect.y, new_rect.width, new_rect.height, rect.x, rect.y, rect.width, rect.height);
queueEvent({ queueEvent({
name: "attempting_delayed_resize", name: "attempting_delayed_resize",
callback: () => { callback: () => {
this.safelyResizeWindow(rect, _retry-1, _skipRetry); this.safelyResizeWindow(rect, _retry-1);
} }
}) })
} }

View File

@@ -24,8 +24,6 @@ export interface IWindowManager {
handleWindowPositionChanged(winWrap: WindowWrapper): void; handleWindowPositionChanged(winWrap: WindowWrapper): void;
handleWindowSizeChanged(winWrap: WindowWrapper): void;
syncActiveWindow(): number | null; syncActiveWindow(): number | null;
} }
@@ -46,9 +44,8 @@ export default class WindowManager implements IWindowManager {
_grabbedWindowMonitor: number = _UNUSED_MONITOR_ID; _grabbedWindowMonitor: number = _UNUSED_MONITOR_ID;
_grabbedWindowId: number = _UNUSED_WINDOW_ID; _grabbedWindowId: number = _UNUSED_WINDOW_ID;
_grabbedOp: Meta.GrabOp | null = null;
_changingGrabbedMonitor: boolean = false; _changingGrabbedMonitor: boolean = false;
_resizingWindow: boolean = false;
_resizeOp: Meta.GrabOp | null = null;
_showingOverview: boolean = false; _showingOverview: boolean = false;
@@ -203,24 +200,50 @@ export default class WindowManager implements IWindowManager {
handleGrabOpBegin(display: Meta.Display, window: Meta.Window, op: Meta.GrabOp): void { handleGrabOpBegin(display: Meta.Display, window: Meta.Window, op: Meta.GrabOp): void {
if (op === Meta.GrabOp.MOVING_UNCONSTRAINED){
}
Logger.log("Grab Op Start", op); Logger.log("Grab Op Start", op);
Logger.log(display, window, op) Logger.log(display, window, op)
Logger.log(window.get_monitor()) Logger.log(window.get_monitor())
const isResizing = this._isResizeOperation(op); const winWrap = this._getWrappedWindow(window);
if (isResizing) { if (this._isResizeOp(op)) {
this._resizingWindow = true; winWrap?.startResizing();
this._resizeOp = op;
// Don't mark as dragging during resize - we need to update positions freely
} else { } else {
this._getWrappedWindow(window)?.startDragging(); winWrap?.startDragging();
} }
this._grabbedWindowMonitor = window.get_monitor(); this._grabbedWindowMonitor = window.get_monitor();
this._grabbedWindowId = window.get_id(); this._grabbedWindowId = window.get_id();
this._grabbedOp = op;
} }
_isResizeOperation(op: Meta.GrabOp): boolean { 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())
// Handle resize operations
if (this._isResizeOp(op)) {
const winWrap = this._getWrappedWindow(window);
if (winWrap && this._grabbedOp) {
const newRect = window.get_frame_rect();
const monitorId = window.get_monitor();
Logger.log(`Handling resize operation: ${op}, new rect:`, newRect);
this._monitors.get(monitorId)?.handleWindowResize(winWrap, this._grabbedOp, newRect);
winWrap.stopResizing();
}
} else {
this._getWrappedWindow(window)?.stopDragging();
}
this._grabbedWindowId = _UNUSED_WINDOW_ID;
this._grabbedOp = null;
this._tileMonitors();
Logger.info("monitor_start and monitor_end", this._grabbedWindowMonitor, window.get_monitor());
}
private _isResizeOp(op: Meta.GrabOp): boolean {
return op === Meta.GrabOp.RESIZING_E || return op === Meta.GrabOp.RESIZING_E ||
op === Meta.GrabOp.RESIZING_W || op === Meta.GrabOp.RESIZING_W ||
op === Meta.GrabOp.RESIZING_N || op === Meta.GrabOp.RESIZING_N ||
@@ -231,26 +254,6 @@ export default class WindowManager implements IWindowManager {
op === Meta.GrabOp.RESIZING_SW; op === Meta.GrabOp.RESIZING_SW;
} }
handleGrabOpEnd(display: Meta.Display, window: Meta.Window, op: Meta.GrabOp): void {
Logger.log("Grab Op End ", op);
Logger.log("primary display", display.get_primary_monitor())
// Check if this was a resize operation
if (this._isResizeOperation(op)) {
const monitor = this._monitors.get(window.get_monitor());
if (monitor) {
monitor.windowManuallyResized(window.get_id());
}
}
this._resizingWindow = false;
this._resizeOp = null;
this._grabbedWindowId = _UNUSED_WINDOW_ID;
this._getWrappedWindow(window)?.stopDragging();
this._tileMonitors();
Logger.info("monitor_start and monitor_end", this._grabbedWindowMonitor, window.get_monitor());
}
_getWrappedWindow(window: Meta.Window): WindowWrapper | undefined { _getWrappedWindow(window: Meta.Window): WindowWrapper | undefined {
let wrapped = undefined; let wrapped = undefined;
for (const monitor of this._monitors.values()) { for (const monitor of this._monitors.values()) {
@@ -278,7 +281,7 @@ export default class WindowManager implements IWindowManager {
let wrapped = this._getAndRemoveWrappedWindow(window); let wrapped = this._getAndRemoveWrappedWindow(window);
if (wrapped === undefined) { if (wrapped === undefined) {
Logger.error("WINDOW NOT DEFINED") Logger.error("WINDOW NOT DEFINED")
wrapped = new WindowWrapper(window, this.handleWindowMinimized.bind(this)); wrapped = new WindowWrapper(window, this.handleWindowMinimized);
wrapped.connectWindowSignals(this); wrapped.connectWindowSignals(this);
} }
let new_mon = this._monitors.get(monitorId); let new_mon = this._monitors.get(monitorId);
@@ -290,21 +293,17 @@ export default class WindowManager implements IWindowManager {
if (this._changingGrabbedMonitor) { if (this._changingGrabbedMonitor) {
return; return;
} }
// Handle resize operations - update dividers in real-time
if (this._grabbedOp && this._isResizeOp(this._grabbedOp)) {
const window = winWrap.getWindow();
const newRect = window.get_frame_rect();
const monitorId = window.get_monitor();
this._monitors.get(monitorId)?.updateDividerDuringResize(winWrap, this._grabbedOp, newRect);
return;
}
if (winWrap.getWindowId() === this._grabbedWindowId) { if (winWrap.getWindowId() === this._grabbedWindowId) {
// Check if we're doing a pure NSEW resize - if so, don't allow position-based swapping
if (this._resizingWindow && this._resizeOp) {
const isPureNSEWResize =
this._resizeOp === Meta.GrabOp.RESIZING_E ||
this._resizeOp === Meta.GrabOp.RESIZING_W ||
this._resizeOp === Meta.GrabOp.RESIZING_N ||
this._resizeOp === Meta.GrabOp.RESIZING_S;
if (isPureNSEWResize) {
// Skip itemDragged - don't allow swaps during NSEW resize
return;
}
}
const [mouseX, mouseY, _] = global.get_pointer(); const [mouseX, mouseY, _] = global.get_pointer();
let monitorIndex = -1; let monitorIndex = -1;
@@ -329,16 +328,6 @@ export default class WindowManager implements IWindowManager {
} }
} }
public handleWindowSizeChanged(winWrap: WindowWrapper): void {
if (this._resizingWindow && winWrap.getWindowId() === this._grabbedWindowId) {
// Check if this is a valid resize direction for the container
const monitor = this._monitors.get(winWrap.getWindow().get_monitor());
if (monitor && this._resizeOp) {
monitor.windowResizing(winWrap.getWindowId(), this._resizeOp);
}
}
}
public handleWindowMinimized(winWrap: WindowWrapper): void { public handleWindowMinimized(winWrap: WindowWrapper): void {
const monitor_id = winWrap.getWindow().get_monitor() const monitor_id = winWrap.getWindow().get_monitor()
@@ -403,7 +392,7 @@ export default class WindowManager implements IWindowManager {
public addWindowToMonitor(window: Meta.Window) { public addWindowToMonitor(window: Meta.Window) {
Logger.log("ADDING WINDOW TO MONITOR", window, window); Logger.log("ADDING WINDOW TO MONITOR", window, window);
var wrapper = new WindowWrapper(window, this.handleWindowMinimized.bind(this)) var wrapper = new WindowWrapper(window, this.handleWindowMinimized)
wrapper.connectWindowSignals(this); wrapper.connectWindowSignals(this);
this._addWindowWrapperToMonitor(wrapper); this._addWindowWrapperToMonitor(wrapper);
@@ -475,12 +464,25 @@ export default class WindowManager implements IWindowManager {
return null; return null;
} }
public resetAllWindowSizes(): void { /**
Logger.log("Resetting all custom window sizes"); * Removes all dividers from the container with the currently active window
this._monitors.forEach((monitor: Monitor) => { */
monitor.resetAllWindowSizes(); public removeAllDividersFromActiveContainer(): void {
}); const activeWindow = global.display.focus_window;
this._tileMonitors(); if (!activeWindow) {
Logger.log("No active window, cannot remove dividers");
return;
}
const monitorId = activeWindow.get_monitor();
const monitor = this._monitors.get(monitorId);
if (monitor) {
Logger.log(`Removing all dividers from monitor ${monitorId}`);
monitor.removeAllDividersFromActiveContainer();
} else {
Logger.warn(`Monitor ${monitorId} not found`);
}
} }