Detecting if UTILITY is popup (#323)

Ardour uses UTILITY atom all over the place for toplevel windows:
Plugins, Dialogs etc
However it does not provide any MOTIF_HINTS at all.

WeChat however uses them for popups and also provides MOTIF_HINTS with
flags 0x2 indicating that only decorations are active. MaterialMaker
also follows what WeChat is doing for right click menus.

This fix assigns UTILITY as popup ONLY if MOTIF_HINTS are provided and
functions are not active.

Couple of apps like Godot mark their windows
(_NET_WM_WINDOW_TYPE_UTILITY) with override_redirect which makes them
popup by default. Potentionally is_popup can be overriden in case MOTIF
functions exists with so no_function_motif would be false.

This fix prefers override_redirect in case that scenario comes up.

Closes #294
This commit is contained in:
GoranKovac 2025-12-22 01:30:50 +01:00 committed by GitHub
parent 979eab242e
commit bf738fffbb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 66 additions and 18 deletions

View file

@ -2048,7 +2048,37 @@ fn popup_heuristics() {
connection.atoms.win_type,
&[connection.atoms.win_type_utility],
);
connection.set_property(
wechat_popup,
connection.atoms.motif_wm_hints,
connection.atoms.motif_wm_hints,
&[0x2_u32, 0, 0, 0, 0],
);
f.map_as_popup(&mut connection, wechat_popup);
let godot_popup = connection.new_window(connection.root, 10, 10, 50, 50, true);
connection.set_property(
godot_popup,
x::ATOM_ATOM,
connection.atoms.win_type,
&[connection.atoms.win_type_utility],
);
connection.set_property(
godot_popup,
connection.atoms.motif_wm_hints,
connection.atoms.motif_wm_hints,
&[0x2_u32, 0, 0, 0, 0],
);
f.map_as_popup(&mut connection, godot_popup);
let ardour_toplevel = connection.new_window(connection.root, 10, 10, 50, 50, false);
connection.set_property(
ardour_toplevel,
x::ATOM_ATOM,
connection.atoms.win_type,
&[connection.atoms.win_type_utility],
);
f.map_as_toplevel(&mut connection, ardour_toplevel);
}
#[test]