5 Commits

Author SHA1 Message Date
Lucas Oskorep
d911f434af feat: resize bug fixing 2025-10-16 03:42:58 -04:00
Lucas Oskorep
5aef762e5f feat: resize bug fixing 2025-10-16 02:54:49 -04:00
Lucas Oskorep
c4d4768d29 feat: adding resizing 2025-10-16 00:46:33 -04:00
Lucas Oskorep
fe069b1de0 feat: adding in ability to resize windows in a container 2025-10-16 00:09:15 -04:00
Lucas Oskorep
2446520ced feat: adding in ability to resize windows in a container 2025-10-16 00:09:11 -04:00
10 changed files with 399 additions and 596 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::remove-all-dividers', () => { this.settings.connect('changed::reset-window-sizes', () => {
log(`Keybinding remove-all-dividers changed to: ${this.settings.get_strv('remove-all-dividers')}`); log(`Reset window sizes keybinding changed to: ${this.settings.get_strv('reset-window-sizes')}`);
this.refreshKeybinding('remove-all-dividers'); this.refreshKeybinding('reset-window-sizes');
}); });
this.settings.connect('changed::dropdown-option', () => { this.settings.connect('changed::dropdown-option', () => {
@@ -93,10 +93,9 @@ export default class aerospike extends Extension {
Logger.info('Keybinding 4 was pressed!'); Logger.info('Keybinding 4 was pressed!');
}); });
break; break;
case 'remove-all-dividers': case 'reset-window-sizes':
this.bindKeybinding('remove-all-dividers', () => { this.bindKeybinding('reset-window-sizes', () => {
Logger.info('Remove all dividers keybinding pressed!'); this.windowManager.resetAllWindowSizes();
this.windowManager.removeAllDividersFromActiveContainer();
}); });
break; break;
} }
@@ -126,9 +125,8 @@ export default class aerospike extends Extension {
Logger.info('Keybinding 4 was pressed!'); Logger.info('Keybinding 4 was pressed!');
}); });
this.bindKeybinding('remove-all-dividers', () => { this.bindKeybinding('reset-window-sizes', () => {
Logger.info('Remove all dividers keybinding pressed!'); this.windowManager.resetAllWindowSizes();
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 --nested --wayland env MUTTER_DEBUG_DUMMY_MODE_SPECS=1280x720 dbus-run-session -- gnome-shell --devkit
install-and-run: install run install-and-run: install run

BIN
prettyborders.zip Normal file

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="remove-all-dividers" type="as"> <key name="reset-window-sizes" type="as">
<default><![CDATA[['<Alt>z']]]></default> <default><![CDATA[['<Alt>z']]]></default>
<summary>Remove all dividers from active container</summary> <summary>Reset all window sizes</summary>
<description>Keyboard shortcut for removing all dividers from the container with the active window</description> <description>Remove all custom window sizes and return to equal distribution</description>
</key> </key>
</schema> </schema>

View File

@@ -3,27 +3,26 @@ 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: ContainerItem[]; _tiledItems: (WindowWrapper | WindowContainer)[];
_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>();
} }
@@ -36,7 +35,6 @@ 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: () => {
@@ -51,14 +49,12 @@ 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 (Divider.isDivider(item)) { if (item instanceof WindowContainer) {
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 instanceof WindowWrapper && item.getWindowId() === win_id) { } else if (item.getWindowId() === win_id) {
return item; return item;
} }
} }
@@ -80,7 +76,8 @@ 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);
this._cleanupInvalidDividers(); // Shift custom sizes after removed index
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) {
@@ -91,44 +88,105 @@ export default class WindowContainer {
this.tileWindows() this.tileWindows()
} }
/** _shiftCustomSizesAfterRemoval(removedIndex: number): void {
* Removes invalid dividers from the items list. Logger.log(`=== _shiftCustomSizesAfterRemoval called ===`);
* Invalid dividers are: Logger.log(`Removed index: ${removedIndex}`);
* - Dividers at the start or end of the list (no window on one side) Logger.log(`Total items after removal: ${this._tiledItems.length}`);
* - Consecutive dividers (two dividers in a row) Logger.log(`Custom sizes Map size: ${this._customSizes.size}`);
*/
_cleanupInvalidDividers(): void {
let i = 0;
while (i < this._tiledItems.length) {
const item = this._tiledItems[i];
if (Divider.isDivider(item)) { // Convert Map to readable string
// Check if divider is at start or end let customSizesStr = "{ ";
const isAtStart = i === 0; this._customSizes.forEach((size, index) => {
const isAtEnd = i === this._tiledItems.length - 1; customSizesStr += `${index}: ${size}px, `;
});
customSizesStr += "}";
Logger.log(`Custom sizes before shift: ${customSizesStr}`);
// Check if next item is also a divider // Calculate the removed window's size (could be custom or flexible)
const nextIsDivider = i < this._tiledItems.length - 1 && let removedSize = this._customSizes.get(removedIndex);
Divider.isDivider(this._tiledItems[i + 1]);
if (isAtStart || isAtEnd || nextIsDivider) { if (removedSize === undefined) {
Logger.log(`Removing invalid divider at index ${i}`); // Window didn't have custom size, calculate its flexible size
this._tiledItems.splice(i, 1); // Count items BEFORE removal (add 1 to current length)
continue; // Don't increment i, check the same position again const numItemsBeforeRemoval = this._tiledItems.length + 1;
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);
} }
i++; // Skip the removed index
});
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 (Divider.isDivider(item)) { if (item instanceof WindowContainer) {
// Skip dividers - they don't have signals
return;
} else if (item instanceof WindowContainer) {
item.disconnectSignals() item.disconnectSignals()
} else if (item instanceof WindowWrapper) { } else {
item.disconnectWindowSignals(); item.disconnectWindowSignals();
} }
} }
@@ -140,37 +198,26 @@ export default class WindowContainer {
this._tiledWindowLookup.clear() this._tiledWindowLookup.clear()
} }
tileWindows() { tileWindows(skipRetry: boolean = false) {
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() { _tileItems(skipRetry: boolean = false) {
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) => {
// Apply bounds to non-divider items const rect = bounds[index];
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 if (item instanceof WindowWrapper) { } else {
item.safelyResizeWindow(rect); item.safelyResizeWindow(rect, 2, skipRetry);
} }
boundsIndex++;
}) })
} }
@@ -183,177 +230,100 @@ export default class WindowContainer {
} }
getVerticalBounds(): Rect[] { getVerticalBounds(): Rect[] {
// Filter out dividers to get only windows/containers // Calculate available height after accounting for custom-sized windows
const nonDividerItems = this._tiledItems.filter(item => !Divider.isDivider(item)); let totalCustomHeight = 0;
let numFlexibleItems = 0;
if (nonDividerItems.length === 0) { this._tiledItems.forEach((item, index) => {
return []; if (this._customSizes.has(index)) {
} totalCustomHeight += this._customSizes.get(index)!;
// If no dividers, use equal distribution
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;
});
}
// Calculate bounds based on divider positions
const bounds: Rect[] = [];
let currentY = this._workArea.y;
let itemIndex = 0;
for (let i = 0; i < this._tiledItems.length; i++) {
const item = this._tiledItems[i];
if (Divider.isDivider(item)) {
// Next segment starts at divider position
currentY = this._workArea.y + Math.floor(item.getPosition() * this._workArea.height);
} else { } else {
// Find the end position for this item numFlexibleItems++;
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;
} }
});
// 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;
} }
// Count non-divider items until next divider const remainingHeight = this._workArea.height - totalCustomHeight;
let itemCount = 0; const flexHeight = numFlexibleItems > 0 ? Math.floor(remainingHeight / numFlexibleItems) : 0;
let itemsInSegment: number[] = [];
for (let j = i; j < this._tiledItems.length; j++) { // Build the bounds array
if (Divider.isDivider(this._tiledItems[j])) { let currentY = this._workArea.y;
break; return this._tiledItems.map((item, index) => {
} let height = flexHeight;
itemsInSegment.push(j); if (this._customSizes.has(index)) {
itemCount++; height = this._customSizes.get(index)!;
} }
// Divide space equally among items in this segment const rect = {
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, x: this._workArea.x,
y: itemY, y: currentY,
width: this._workArea.width, width: this._workArea.width,
height: itemHeight height: height
} as Rect); } as Rect;
} currentY += height;
return rect;
// Skip the items we just processed });
i += itemCount - 1;
currentY = endY;
}
}
return bounds;
} }
getHorizontalBounds(): Rect[] { getHorizontalBounds(): Rect[] {
// Filter out dividers to get only windows/containers // Calculate available width after accounting for custom-sized windows
const nonDividerItems = this._tiledItems.filter(item => !Divider.isDivider(item)); let totalCustomWidth = 0;
let numFlexibleItems = 0;
if (nonDividerItems.length === 0) { this._tiledItems.forEach((item, index) => {
return []; if (this._customSizes.has(index)) {
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;
} }
// If no dividers, use equal distribution const remainingWidth = this._workArea.width - totalCustomWidth;
const hasDividers = this._tiledItems.some(item => Divider.isDivider(item)); const flexWidth = numFlexibleItems > 0 ? Math.floor(remainingWidth / numFlexibleItems) : 0;
if (!hasDividers) {
const windowWidth = Math.floor(this._workArea.width / nonDividerItems.length); // Build the bounds array
return nonDividerItems.map((_, index) => { let currentX = this._workArea.x;
const x = this._workArea.x + (index * windowWidth); return this._tiledItems.map((item, index) => {
return { let width = flexWidth;
x: x, if (this._customSizes.has(index)) {
width = this._customSizes.get(index)!;
}
const rect = {
x: currentX,
y: this._workArea.y, y: this._workArea.y,
width: windowWidth, width: width,
height: this._workArea.height height: this._workArea.height
} as Rect; } as Rect;
currentX += width;
return rect;
}); });
} }
// Calculate bounds based on divider positions
const bounds: Rect[] = [];
let currentX = this._workArea.x;
for (let i = 0; i < this._tiledItems.length; i++) {
const item = this._tiledItems[i];
if (Divider.isDivider(item)) {
// Next segment starts at divider position
currentX = this._workArea.x + Math.floor(item.getPosition() * this._workArea.width);
} else {
// 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 (Divider.isDivider(container)) { if (container instanceof WindowContainer) {
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 instanceof WindowWrapper && container.getWindowId() === item.getWindowId()) { } else if (container.getWindowId() === item.getWindowId()) {
return i; return i;
} }
} }
@@ -362,271 +332,152 @@ 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 {
// Find the actual index in _tiledItems (including dividers) let original_index = this.getIndexOfItemNested(item);
const original_actual_index = this._getIndexOfWindow(item.getWindowId());
if (original_actual_index === -1) { if (original_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;
// Find which visual slot (non-divider index) we're moving to this.getBounds().forEach((rect, index) => {
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_visual_index = index; new_index = index;
} }
}) })
if (original_index !== new_index) {
// Get current visual index (counting only non-dividers before this item) this._tiledItems.splice(original_index, 1);
let original_visual_index = 0; this._tiledItems.splice(new_index, 0, item);
for (let i = 0; i < original_actual_index; i++) { this.tileWindows()
if (!Divider.isDivider(this._tiledItems[i])) {
original_visual_index++;
}
} }
if (original_visual_index === new_visual_index) {
return; // No movement needed
} }
Logger.log(`Swapping window from visual index ${original_visual_index} to ${new_visual_index}`); windowManuallyResized(win_id: number): void {
const window = this.getWindow(win_id);
// Find the target window at the new visual index if (!window) {
let target_actual_index = -1; // Check nested containers
let visual_count = 0; for (const item of this._tiledItems) {
for (let i = 0; i < this._tiledItems.length; i++) { if (item instanceof WindowContainer) {
if (!Divider.isDivider(this._tiledItems[i])) { item.windowManuallyResized(win_id);
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;
} }
// Simply swap the two windows in place, leaving dividers where they are // Find the index of the window
const temp = this._tiledItems[original_actual_index]; const index = this._getIndexOfWindow(win_id);
this._tiledItems[original_actual_index] = this._tiledItems[target_actual_index]; if (index === -1) {
this._tiledItems[target_actual_index] = temp; Logger.error("Window not found in container during resize");
this.tileWindows();
}
/**
* Handles window resize operations. Creates or updates dividers based on resize direction.
* @param item - The window being resized
* @param resizeEdge - The edge being resized (N, S, E, W, etc.)
* @param newRect - The new rectangle after resize
*/
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());
return; return;
} }
// Determine if this is a valid resize for this container orientation const rect = window.getRect();
const isHorizontalResize = this._isHorizontalResizeOp(resizeEdge); if (this._orientation === Orientation.HORIZONTAL) {
const isVerticalResize = this._isVerticalResizeOp(resizeEdge); this._customSizes.set(index, rect.width);
Logger.log(`Window at index ${index} manually resized to width: ${rect.width}`);
// Only allow horizontal resizes in horizontal containers } else {
// Only allow vertical resizes in vertical containers this._customSizes.set(index, rect.height);
if (this._orientation === Orientation.HORIZONTAL && !isHorizontalResize) { Logger.log(`Window at index ${index} manually resized to height: ${rect.height}`);
Logger.log("Ignoring vertical resize in horizontal container"); }
return; }
resetAllWindowSizes(): void {
Logger.log("Clearing all custom window sizes in container");
this._customSizes.clear();
// Also clear nested containers
for (const item of this._tiledItems) {
if (item instanceof WindowContainer) {
item.resetAllWindowSizes();
}
}
}
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);
}
} }
if (this._orientation === Orientation.VERTICAL && !isVerticalResize) {
Logger.log("Ignoring horizontal resize in vertical container");
return; return;
} }
// Determine which edge is being resized and find adjacent window // Check if the resize direction matches the container orientation
const isHorizontalResize = resizeOp === Meta.GrabOp.RESIZING_E || resizeOp === Meta.GrabOp.RESIZING_W;
const isVerticalResize = resizeOp === Meta.GrabOp.RESIZING_N || resizeOp === Meta.GrabOp.RESIZING_S;
if ((this._orientation === Orientation.HORIZONTAL && !isHorizontalResize) ||
(this._orientation === Orientation.VERTICAL && !isVerticalResize)) {
// Resize direction doesn't match container orientation, ignore
return;
}
// Find the index of the 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;
let dividerPosition = 0; if (resizeOp === Meta.GrabOp.RESIZING_E || resizeOp === Meta.GrabOp.RESIZING_S) {
// Resizing right/down edge - adjust the next window
if (this._orientation === Orientation.HORIZONTAL) { adjacentIndex = index + 1;
// East/West resize } else if (resizeOp === Meta.GrabOp.RESIZING_W || resizeOp === Meta.GrabOp.RESIZING_N) {
if (this._isEastResizeOp(resizeEdge)) { // Resizing left/up edge - adjust the previous window
// Resizing east edge - divider goes after this window adjacentIndex = index - 1;
adjacentIndex = itemIndex + 1;
// Calculate divider position as ratio of container width
const rightEdge = newRect.x + newRect.width;
dividerPosition = (rightEdge - this._workArea.x) / this._workArea.width;
} else if (this._isWestResizeOp(resizeEdge)) {
// Resizing west edge - divider goes before this window
adjacentIndex = itemIndex - 1;
dividerPosition = (newRect.x - this._workArea.x) / this._workArea.width;
} }
// Update current window size
this._customSizes.set(index, newSize);
// Adjust adjacent window only if it has a custom size
// When both windows have custom sizes, always apply opposite delta to maintain total width
let oldAdjacentSize: number | undefined = undefined;
if (adjacentIndex >= 0 && adjacentIndex < this._tiledItems.length &&
this._customSizes.has(adjacentIndex)) {
const adjacentItem = this._tiledItems[adjacentIndex];
if (adjacentItem instanceof WindowWrapper) {
oldAdjacentSize = this._customSizes.get(adjacentIndex)!;
const newAdjacentSize = oldAdjacentSize - delta;
// Check if adjacent window allows resize
if (!adjacentItem.getWindow().allows_resize()) {
Logger.log("Adjacent window doesn't allow resize, reverting");
this._customSizes.set(index, oldSize);
} else { } else {
// Vertical orientation - North/South resize // Always apply the opposite delta to the adjacent window
if (this._isSouthResizeOp(resizeEdge)) { // This keeps the total width constant
// Resizing south edge - divider goes after this window this._customSizes.set(adjacentIndex, newAdjacentSize);
adjacentIndex = itemIndex + 1; }
const bottomEdge = newRect.y + newRect.height;
dividerPosition = (bottomEdge - this._workArea.y) / this._workArea.height;
} 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;
} }
} }
// Make sure there's an adjacent item // Call tileWindows during resize to update all window positions
if (adjacentIndex < 0 || adjacentIndex >= this._tiledItems.length) { // Skip retry logic during active resize to avoid jitter
Logger.log("No adjacent window for resize operation"); this.tileWindows(true);
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();
} }

View File

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

View File

@@ -16,7 +16,6 @@ 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,
@@ -54,13 +53,6 @@ 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;
// } // }
@@ -112,6 +104,9 @@ 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);
}),
); );
} }
@@ -130,12 +125,10 @@ export class WindowWrapper {
} }
} }
safelyResizeWindow(rect: Rect, _retry: number = 2): void { safelyResizeWindow(rect: Rect, _retry: number = 2, _skipRetry: boolean = false): void {
// Keep minimal logging // Keep minimal logging
if (this._dragging && !this._resizing) { // Note: we allow resizing even during drag operations to support position updates
// During drag operations (not resize), skip this entirely // The dragging flag only prevents REORDERING, not position/size changes
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();
@@ -150,19 +143,13 @@ 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 ( _retry > 0 && (new_rect.x != rect.x || rect.y != new_rect.y || rect.width < new_rect.width || rect.height < new_rect.height)) { if (!_skipRetry && _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); this.safelyResizeWindow(rect, _retry-1, _skipRetry);
} }
}) })
} }

View File

@@ -24,6 +24,8 @@ export interface IWindowManager {
handleWindowPositionChanged(winWrap: WindowWrapper): void; handleWindowPositionChanged(winWrap: WindowWrapper): void;
handleWindowSizeChanged(winWrap: WindowWrapper): void;
syncActiveWindow(): number | null; syncActiveWindow(): number | null;
} }
@@ -44,8 +46,9 @@ 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;
@@ -200,50 +203,24 @@ 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 winWrap = this._getWrappedWindow(window); const isResizing = this._isResizeOperation(op);
if (this._isResizeOp(op)) { if (isResizing) {
winWrap?.startResizing(); this._resizingWindow = true;
this._resizeOp = op;
// Don't mark as dragging during resize - we need to update positions freely
} else { } else {
winWrap?.startDragging(); this._getWrappedWindow(window)?.startDragging();
} }
this._grabbedWindowMonitor = window.get_monitor(); this._grabbedWindowMonitor = window.get_monitor();
this._grabbedWindowId = window.get_id(); this._grabbedWindowId = window.get_id();
this._grabbedOp = op;
} }
handleGrabOpEnd(display: Meta.Display, window: Meta.Window, op: Meta.GrabOp): void { _isResizeOperation(op: Meta.GrabOp): boolean {
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 ||
@@ -254,6 +231,26 @@ 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()) {
@@ -281,7 +278,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); wrapped = new WindowWrapper(window, this.handleWindowMinimized.bind(this));
wrapped.connectWindowSignals(this); wrapped.connectWindowSignals(this);
} }
let new_mon = this._monitors.get(monitorId); let new_mon = this._monitors.get(monitorId);
@@ -293,17 +290,21 @@ export default class WindowManager implements IWindowManager {
if (this._changingGrabbedMonitor) { if (this._changingGrabbedMonitor) {
return; return;
} }
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;
// Handle resize operations - update dividers in real-time if (isPureNSEWResize) {
if (this._grabbedOp && this._isResizeOp(this._grabbedOp)) { // Skip itemDragged - don't allow swaps during NSEW resize
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; return;
} }
}
if (winWrap.getWindowId() === this._grabbedWindowId) {
const [mouseX, mouseY, _] = global.get_pointer(); const [mouseX, mouseY, _] = global.get_pointer();
let monitorIndex = -1; let monitorIndex = -1;
@@ -328,6 +329,16 @@ 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()
@@ -392,7 +403,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) var wrapper = new WindowWrapper(window, this.handleWindowMinimized.bind(this))
wrapper.connectWindowSignals(this); wrapper.connectWindowSignals(this);
this._addWindowWrapperToMonitor(wrapper); this._addWindowWrapperToMonitor(wrapper);
@@ -464,25 +475,12 @@ export default class WindowManager implements IWindowManager {
return null; return null;
} }
/** public resetAllWindowSizes(): void {
* Removes all dividers from the container with the currently active window Logger.log("Resetting all custom window sizes");
*/ this._monitors.forEach((monitor: Monitor) => {
public removeAllDividersFromActiveContainer(): void { monitor.resetAllWindowSizes();
const activeWindow = global.display.focus_window; });
if (!activeWindow) { this._tileMonitors();
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`);
}
} }