Skip to content

Commit

Permalink
fix: gnome 47 and meta 15 support
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeAndGin authored Oct 9, 2024
1 parent ced5442 commit 3ac7848
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ export class Ext extends Ecs.System<ExtEvent> {
}

for (const window of this.windows.values()) {
if (window.meta.is_client_decorated()) continue;
if (window.is_client_decorated()) continue;

if (show_title) {
window.decoration_show(this);
Expand Down
2 changes: 1 addition & 1 deletion src/mod.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ declare namespace Meta {
appears_focused: Readonly<boolean>;
minimized: Readonly<boolean>;
window_type: Readonly<any>;
decorated: Readonly<boolean>;

activate(time: number): void;
change_workspace_by_index(workspace: number, append: boolean): void;
Expand All @@ -285,7 +286,6 @@ declare namespace Meta {
has_focus(): boolean;
is_above(): boolean;
is_attached_dialog(): boolean;
is_client_decorated(): boolean;
is_fullscreen(): boolean;
is_on_all_workspaces(): boolean;
is_override_redirect(): boolean;
Expand Down
14 changes: 12 additions & 2 deletions src/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class ShellWindow {
ignore_detach: boolean = false;
was_attached_to?: [Entity, boolean | number];
destroying: boolean = false;

// Awaiting reassignment after a display update
reassignment: boolean = false;

Expand Down Expand Up @@ -103,7 +103,7 @@ export class ShellWindow {
}

if (this.may_decorate()) {
if (!window.is_client_decorated()) {
if (!this.is_client_decorated()) {
if (ext.settings.show_title()) {
this.decoration_show(ext);
} else {
Expand Down Expand Up @@ -265,6 +265,16 @@ export class ShellWindow {
return WM_TITLE_BLACKLIST.findIndex((n) => name.startsWith(n)) !== -1;
}

is_client_decorated(): boolean {
// look I guess I'll hack something together in here if at all possible
// Because Meta.Window.is_client_decorated() was removed in Meta 15, using it breaks the extension in gnome 47 or higher
//return this.meta.window_type == Meta.WindowType.META_WINDOW_OVERRIDE_OTHER;
const xid = this.xid()
const extents = xid ? xprop.get_frame_extents(xid) : false;
if (!extents) return false;
return true;
}

is_maximized(): boolean {
return this.meta.get_maximized() !== 0;
}
Expand Down
10 changes: 10 additions & 0 deletions src/xprop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export var MOTIF_HINTS: string = '_MOTIF_WM_HINTS';
export var HIDE_FLAGS: string[] = ['0x2', '0x0', '0x0', '0x0', '0x0'];
export var SHOW_FLAGS: string[] = ['0x2', '0x0', '0x1', '0x0', '0x0'];

//export var FRAME_EXTENTS: string = "_GTK_FRAME_EXTENTS"

export function get_window_role(xid: string): string | null {
let out = xprop_cmd(xid, 'WM_WINDOW_ROLE');

Expand All @@ -15,6 +17,14 @@ export function get_window_role(xid: string): string | null {
return parse_string(out);
}

export function get_frame_extents(xid: string): string | null {
let out = xprop_cmd(xid, "_GTK_FRAME_EXTENTS");

if (!out) return null;

return parse_string(out)
}

export function get_hint(xid: string, hint: string): Array<string> | null {
let out = xprop_cmd(xid, hint);

Expand Down

0 comments on commit 3ac7848

Please sign in to comment.