mirror of
https://github.com/zoriya/fairy.git
synced 2025-12-06 05:36:09 +00:00
Fix bugged workspaces
This commit is contained in:
@@ -143,11 +143,12 @@ var KeyboardManager = GObject.registerClass(
|
||||
const handle = this._state.monitors[mon].focused;
|
||||
const window = this._state.windows.find((x) => x.handle === handle);
|
||||
if (!window) return;
|
||||
this._focusNext();
|
||||
log("Sending", handle.get_title(), "to tagNbr", tagNbr);
|
||||
this._focusNext(true);
|
||||
window.tags = tag;
|
||||
window.handle.change_workspace_by_index(tagNbr, false);
|
||||
this._renderer.renderAll();
|
||||
this._indicator.update(mon);
|
||||
this._indicator.update();
|
||||
});
|
||||
this._addBinding(`addto-tag-${tagNbr + 1}`, () => {
|
||||
const mon = global.display.get_current_monitor();
|
||||
@@ -157,7 +158,7 @@ var KeyboardManager = GObject.registerClass(
|
||||
if (window.tags & tag) window.tags &= ~tag;
|
||||
else window.tags |= tag;
|
||||
this._renderer.renderAll();
|
||||
this._indicator.update(mon);
|
||||
this._indicator.update();
|
||||
});
|
||||
}
|
||||
this._addBinding("set-tag-all", () => {
|
||||
@@ -216,7 +217,7 @@ var KeyboardManager = GObject.registerClass(
|
||||
this._indicator.update(mon);
|
||||
}
|
||||
|
||||
_focusNext() {
|
||||
_focusNext(skipRender) {
|
||||
const mon = global.display.get_current_monitor();
|
||||
const state = this._state.monitors[mon];
|
||||
const idx = this._state.workIndexByHandle(state.focused);
|
||||
@@ -226,7 +227,8 @@ var KeyboardManager = GObject.registerClass(
|
||||
} else {
|
||||
state.focused = null;
|
||||
}
|
||||
this._renderer.render(mon);
|
||||
if (!skipRender)
|
||||
this._renderer.render(mon);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -156,7 +156,9 @@ var Renderer = GObject.registerClass(
|
||||
),
|
||||
global.display.connect("window-entered-monitor", (_display, _monitor, handle) => {
|
||||
const [oldW, newW] = this._state.updateByHandle(handle);
|
||||
log("Monitor changed for window", oldW.handle.get_title(), oldW.monitor, "to", newW.monitor);
|
||||
// Update by handle return null if the window is not tracked yet (new window).
|
||||
if (!oldW) return;
|
||||
log("Monitor changed for window", newW.handle.get_title(), oldW.monitor, "to", newW.monitor);
|
||||
if (oldW) this.render(oldW.monitor);
|
||||
if (newW) this.render(newW.monitor);
|
||||
this._indicator.update();
|
||||
@@ -259,7 +261,8 @@ var Renderer = GObject.registerClass(
|
||||
}
|
||||
if (!this._isValidWindow(handle)) return;
|
||||
const [oldW, newW] = this._state.updateByHandle(handle);
|
||||
log("Workspace changed for window", oldW.handle.get_title(), oldW.tags, "to", newW.tags);
|
||||
if (!oldW) return;
|
||||
log("Workspace changed for window", newW.handle.get_title(), oldW.tags, "to", newW.tags);
|
||||
if (oldW) this.render(oldW.monitor);
|
||||
if (newW) this.render(newW.monitor);
|
||||
this._indicator.update();
|
||||
@@ -331,10 +334,10 @@ var Renderer = GObject.registerClass(
|
||||
|
||||
if (this._state.singleTagset) {
|
||||
for (let i = 0; i < global.display.get_n_monitors(); i++) {
|
||||
if (this._state.monitors[i] & tags && mon !== i) {
|
||||
if (this._state.monitors[i].tags & tags && mon !== i) {
|
||||
// Remove the selected tag from other monitors.
|
||||
// If the other monitor had only this tag, swap monitor's tags instead.
|
||||
this._state.monitors[i] = this._state.monitors[i] & ~tags || currTags;
|
||||
this._state.monitors[i].tags = this._state.monitors[i].tags & ~tags || currTags;
|
||||
this._setGWorkspaceIfNeeded(i);
|
||||
this.render(i);
|
||||
}
|
||||
|
||||
@@ -36,27 +36,15 @@ var StateManager = GObject.registerClass(
|
||||
this.windows = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Meta.Window} handle
|
||||
* @returns {FairyWindow}
|
||||
*/
|
||||
_windowFromHandle(handle) {
|
||||
const mon = handle.get_monitor();
|
||||
const tags = this.monitors[mon].tags;
|
||||
return {
|
||||
handle,
|
||||
monitor: mon,
|
||||
tags,
|
||||
// Needed for the popByActor that might get called when the actor is already deleted
|
||||
actor: handle.get_compositor_private(),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Meta.Window} handle
|
||||
*/
|
||||
newWindow(handle) {
|
||||
const window = this._windowFromHandle(handle);
|
||||
const window = {
|
||||
handle,
|
||||
monitor: handle.get_monitor(),
|
||||
tags: this.monitors[handle.get_monitor()].tags,
|
||||
};
|
||||
this.monitors[window.monitor].beforeZoom = null;
|
||||
log("New window", window.handle.get_title(), "on tag", window.tags, "monitor", window.monitor);
|
||||
this.windows.unshift(window);
|
||||
@@ -64,12 +52,17 @@ var StateManager = GObject.registerClass(
|
||||
|
||||
/**
|
||||
* @param {Meta.Window} handle
|
||||
* @returns {[FairyWindow, FairyWindow]} [old, new]
|
||||
* @returns {[FairyWindow, FairyWindow] | [null, null]} [old, new]
|
||||
*/
|
||||
updateByHandle(handle) {
|
||||
const i = this.windows.findIndex((x) => x.handle === handle);
|
||||
if (i === -1) return [null, null];
|
||||
const old = { ...this.windows[i] };
|
||||
this.windows[i] = this._windowFromHandle(handle);
|
||||
this.windows[i] = {
|
||||
handle,
|
||||
monitor: handle.get_monitor(),
|
||||
tags: 0b1 << handle.get_workspace().index(),
|
||||
};
|
||||
return [old, this.windows[i]];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user