From e7f30249a18317de3a54dc185e3a547ee4a74022 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Tue, 12 Oct 2021 19:14:54 +0200 Subject: [PATCH] fix(launcher): Empty window list with Spotify Flatpak Spotify Flatpak returns `null` for `meta.get_title()`. Use window name instead. --- src/extension.ts | 6 +++--- src/mod.d.ts | 2 +- src/stack.ts | 6 +++--- src/window.ts | 7 ++++++- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 95b40e74..90038c83 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -250,8 +250,8 @@ export class Ext extends Ecs.System { for (const window of this.tab_list(Meta.TabList.NORMAL, null)) { wins.push([ window.entity, - window.meta.get_title(), - window.name(this), + window.title(), + window.name(this) ]) } @@ -501,7 +501,7 @@ export class Ext extends Ecs.System { let wmclass = win.meta.get_wm_class(); if (wmclass) this.conf.add_window_exception( wmclass, - win.meta.get_title() + win.title() ); this.exception_dialog() }, diff --git a/src/mod.d.ts b/src/mod.d.ts index 4230f580..f0cd0ba9 100644 --- a/src/mod.d.ts +++ b/src/mod.d.ts @@ -195,7 +195,7 @@ declare namespace Meta { get_pid(): number; get_role(): null | string; get_stable_sequence(): number; - get_title(): string; + get_title(): null | string; get_transient_for(): Window | null; get_user_time(): number; get_wm_class(): string | null; diff --git a/src/stack.ts b/src/stack.ts index 8c43cc80..4376a8e3 100644 --- a/src/stack.ts +++ b/src/stack.ts @@ -92,7 +92,7 @@ export class Stack { if (!this.widgets) return; const entity = window.entity; - const label = window.meta.get_title(); + const label = window.title() const active = Ecs.entity_eq(entity, this.active); const button: St.Button = new St.Button({ @@ -421,7 +421,7 @@ export class Stack { } this.watch_signals(this.active_id, c.button, window); - this.buttons.get(c.button)?.set_label(window.meta.get_title()); + this.buttons.get(c.button)?.set_label(window.title()); this.activate(window.entity); } } @@ -576,7 +576,7 @@ export class Stack { this.tabs[comp].signals = [ window.meta.connect('notify::title', () => { this.window_exec(comp, entity, (window) => { - this.buttons.get(button)?.set_label(window.meta.get_title()) + this.buttons.get(button)?.set_label(window.title()) }); }), diff --git a/src/window.ts b/src/window.ts index dc99d840..9da0568d 100644 --- a/src/window.ts +++ b/src/window.ts @@ -298,7 +298,7 @@ export class ShellWindow { // If a window lacks a class, it's probably a web browser dialog && wm_class !== null // Blacklist any windows that happen to leak through our filter - && !ext.conf.window_shall_float(wm_class, this.meta.get_title()); + && !ext.conf.window_shall_float(wm_class, this.title()); }; return !ext.contains_tag(this.entity, Tags.Floating) @@ -402,6 +402,11 @@ export class ShellWindow { this.move(ext, br, () => place_pointer_on(this.ext.conf.default_pointer_position, this.meta)); } + title(): string { + const title = this.meta.get_title(); + return title ? title : this.name(this.ext) + } + wm_role(): string | null { return this.extra.wm_role_.get_or_init(() => {