Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions tiling-assistant@leleat-on-github/src/extension/layoutPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,13 @@ export const LayoutPicker = GObject.registerClass({
let paddingBottom = this.get_theme_node().get_padding(St.Side.BOTTOM);

const monitorArea = Main.layoutManager.monitors[monitorIndex];
const activeWs = global.workspace_manager.get_active_workspace();
const workArea = activeWs.get_work_area_for_monitor(monitorIndex);
const area = this._getArea(monitorIndex);

// using monitorArea.y instead of workArea.y as upper bound to compensate with chromes such us the top bar height
// placing cursor above workArea.y causes visibility glitch. workArea.y and monitorArea.y will be same for other monitor anyways.
// Use monitorArea.y as the lower bound instead of area.y so the picker
// also reveals while the cursor is over a chrome such as the top bar.
if (
curY >= monitorArea.y &&
curY <= workArea.y + h - paddingBottom &&
curY <= area.y + h - paddingBottom &&
curX >= mx + paddingLeft &&
curX <= mx + w - paddingRight
)
Expand Down Expand Up @@ -348,24 +347,33 @@ export const LayoutPicker = GObject.registerClass({
this._setLayoutPickerIcon(this.tileType);
}

_getArea(monitorIndex) {
const monitorArea = Main.layoutManager.monitors[monitorIndex];

if (monitorArea.inFullscreen)
return monitorArea;

const activeWs = global.workspace_manager.get_active_workspace();
return activeWs.get_work_area_for_monitor(monitorIndex);
}

_updateAllocation(monitorIndex) {
// The current monitor can already be gone (e.g. when the last monitor
// is removed during shutdown), so make sure it still exists before
// asking Mutter for its work area.
if (!Main.layoutManager.monitors[monitorIndex])
return;

const activeWs = global.workspace_manager.get_active_workspace();
const workArea = activeWs.get_work_area_for_monitor(monitorIndex);
const area = this._getArea(monitorIndex);

if (workArea === null)
if (area === null)
return;

const [, natWidth] = this.get_preferred_width(-1);
const [, natHeight] = this.get_preferred_height(-1);

const targetX = Math.round(workArea.x + (workArea.width - natWidth) / 2);
const targetY = Math.round(workArea.y - natHeight);
const targetX = Math.round(area.x + (area.width - natWidth) / 2);
const targetY = Math.round(area.y - natHeight);

if (targetX === this.x && targetY === this.y)
return;
Expand Down
Loading