Skip to content

Cannot combine x11 window types. #1140

@Toqozz

Description

@Toqozz

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:

winit/src/platform/unix.rs

Lines 367 to 370 in cf0b8ba

fn with_x11_window_type(mut self, x11_window_type: XWindowType) -> WindowBuilder {
self.platform_specific.x11_window_type = x11_window_type;
self
}

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    DS - x11Affects the X11 backend, or generally free Unix platformsH - good first issueIdeal for new contributorsH - help wantedSomeone please save usS - apiDesign and usability

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions