Winit: Cannot combine x11 window types.

Created on 31 Aug 2019  路  2Comments  路  Source: rust-windowing/winit

In X11, it is possible to have multiple _NET_WM_WINDOW_TYPE properties, so that you can have a combination of window types. winit, however, only allows a single XWindowType.

let window = WindowBuilder::new()
    .with_title("A fantastic window!")
    .with_x11_window_type(XWindowType::Notification)    // this property is overridden
    .with_x11_window_type(XWindowType::Utility)         // by this one
    .build(&event_loop)
    .unwrap();

In Xlib, if you wanted to have a window which had types NOTIFICATION and UTILITY you'd do something like this:

property[2] = XInternAtom(dsp, "_NET_WM_WINDOW_TYPE", false);
property[0] = XInternAtom(dsp, "_NET_WM_WINDOW_TYPE_NOTIFICATION", false);
property[1] = XInternAtom(dsp, "_NET_WM_WINDOW_TYPE_UTILITY", false);
XChangeProperty(dsp, win, property[2], XA_ATOM, 32, PropModeReplace, (unsigned char *) property, 2L);

From a user perspective, I think the most obvious behaviour would be for WindowBuilder.with_x11_window_type() to combine window types rather than replace them, but it seems to just overwrite the property:
https://github.com/rust-windowing/winit/blob/cf0b8babbdb39abc443c94c8a94281201e6e9b0c/src/platform/unix.rs#L367-L370

I would be happy to contribute to fix this issue if a preferred method is described. I locally did a quick and dirty fix by pushing window types to a Vec, which works but allows doubling up on properties. Perhaps a HashSet or bitwise OR would work better.

winit = "0.20.0-alpha2"

good first issue X11 help wanted api

Most helpful comment

Thanks for the issue!

I see no reason not to do this. If you'd like to submit a PR, could you expose this by converting XWindowType to a bitflags type? Also, I'd like to keep with_x11_window_type's current behavior for the sake of consistency with the rest of the API. Moving to a bitflags type would allow us to do that while still making it easy to set multiple window types.

All 2 comments

Thanks for the issue!

I see no reason not to do this. If you'd like to submit a PR, could you expose this by converting XWindowType to a bitflags type? Also, I'd like to keep with_x11_window_type's current behavior for the sake of consistency with the rest of the API. Moving to a bitflags type would allow us to do that while still making it easy to set multiple window types.

Closed by #1147

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tomaka picture tomaka  路  3Comments

rukai picture rukai  路  4Comments

chrisduerr picture chrisduerr  路  3Comments

e00E picture e00E  路  5Comments

hobogenized picture hobogenized  路  3Comments