Skip to content

Commit 409555f

Browse files
mmstickLinuxHeki
authored andcommitted
fix(tiling): Window opening on dual monitor
Spotify Flatpak returns `null` for `meta.get_title()`. Use window name instead.
1 parent 7a80d8b commit 409555f

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

src/auto_tiler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,9 +685,9 @@ export class AutoTiler {
685685
return Err('focused window is not attached');
686686
}
687687

688-
return onto.workspace_id() == win.workspace_id()
688+
return onto.meta.get_monitor() == win.meta.get_monitor() && onto.workspace_id() == win.workspace_id()
689689
? Ok(onto)
690-
: Err('window is not on the same workspace');
690+
: Err('window is not on the same monitor or workspace');
691691
}
692692

693693
private toggle_orientation_(ext: Ext, focused: ShellWindow): Result<void, string> {

src/extension.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ export class Ext extends Ecs.System<ExtEvent> {
250250
for (const window of this.tab_list(Meta.TabList.NORMAL, null)) {
251251
wins.push([
252252
window.entity,
253-
window.meta.get_title(),
254-
window.name(this),
253+
window.title(),
254+
window.name(this)
255255
])
256256
}
257257

@@ -501,7 +501,7 @@ export class Ext extends Ecs.System<ExtEvent> {
501501
let wmclass = win.meta.get_wm_class();
502502
if (wmclass) this.conf.add_window_exception(
503503
wmclass,
504-
win.meta.get_title()
504+
win.title()
505505
);
506506
this.exception_dialog()
507507
},
@@ -2057,7 +2057,7 @@ export class Ext extends Ecs.System<ExtEvent> {
20572057
let actor = window.meta.get_compositor_private();
20582058
if (actor) {
20592059
if (!window.meta.minimized) {
2060-
tiler.auto_tile(this, window, true);
2060+
tiler.auto_tile(this, window, false);
20612061
}
20622062
}
20632063
}

src/mod.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ declare namespace Meta {
195195
get_pid(): number;
196196
get_role(): null | string;
197197
get_stable_sequence(): number;
198-
get_title(): string;
198+
get_title(): null | string;
199199
get_transient_for(): Window | null;
200200
get_user_time(): number;
201201
get_wm_class(): string | null;

src/stack.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class Stack {
9292
if (!this.widgets) return;
9393

9494
const entity = window.entity;
95-
const label = window.meta.get_title();
95+
const label = window.title()
9696
const active = Ecs.entity_eq(entity, this.active);
9797

9898
const button: St.Button = new St.Button({
@@ -421,7 +421,7 @@ export class Stack {
421421
}
422422

423423
this.watch_signals(this.active_id, c.button, window);
424-
this.buttons.get(c.button)?.set_label(window.meta.get_title());
424+
this.buttons.get(c.button)?.set_label(window.title());
425425
this.activate(window.entity);
426426
}
427427
}
@@ -576,7 +576,7 @@ export class Stack {
576576
this.tabs[comp].signals = [
577577
window.meta.connect('notify::title', () => {
578578
this.window_exec(comp, entity, (window) => {
579-
this.buttons.get(button)?.set_label(window.meta.get_title())
579+
this.buttons.get(button)?.set_label(window.title())
580580
});
581581
}),
582582

src/window.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ export class ShellWindow {
298298
// If a window lacks a class, it's probably a web browser dialog
299299
&& wm_class !== null
300300
// Blacklist any windows that happen to leak through our filter
301-
&& !ext.conf.window_shall_float(wm_class, this.meta.get_title());
301+
&& !ext.conf.window_shall_float(wm_class, this.title());
302302
};
303303

304304
return !ext.contains_tag(this.entity, Tags.Floating)
@@ -402,6 +402,11 @@ export class ShellWindow {
402402
this.move(ext, br, () => place_pointer_on(this.ext.conf.default_pointer_position, this.meta));
403403
}
404404

405+
title(): string {
406+
const title = this.meta.get_title();
407+
return title ? title : this.name(this.ext)
408+
}
409+
405410

406411
wm_role(): string | null {
407412
return this.extra.wm_role_.get_or_init(() => {

0 commit comments

Comments
 (0)