【问题标题】:How can I make a window override-redirect with glutin?如何使用 glutin 进行窗口覆盖重定向?
【发布时间】:2018-03-10 21:03:19
【问题描述】:

我正在创建一个使用 glutin 的程序,并且我想提供一个命令行标志来使窗口覆盖重定向,以便它可以用作某些不支持桌面的窗口管理器的桌面壁纸窗口类型。

我进行了大量研究,并设法使用提供的 xlib 显示和来自 glutin 的窗口拼凑出我认为可行的代码块。这是我现有的代码:

unsafe {
    use glutin::os::unix::WindowExt;
    let x_connection = std::sync::Arc::<glutin::os::unix::x11::XConnection>::into_raw(display.gl_window().get_xlib_xconnection().unwrap());
    ((*x_connection).xlib.XChangeWindowAttributes)(
        display.gl_window().get_xlib_display().unwrap() as *mut glutin::os::unix::x11::ffi::Display,
        display.gl_window().get_xlib_window().unwrap() as glutin::os::unix::x11::ffi::XID,
        glutin::os::unix::x11::ffi::CWOverrideRedirect,
        &mut glutin::os::unix::x11::ffi::XSetWindowAttributes {
            background_pixmap: 0,
            background_pixel: 0,
            border_pixmap: 0,
            border_pixel: 0,
            bit_gravity: 0,
            win_gravity: 0,
            backing_store: 0,
            backing_planes: 0,
            backing_pixel: 0,
            save_under: 0,
            event_mask: 0,
            do_not_propagate_mask: 0,
            override_redirect: 1,
            colormap: 0,
            cursor: 0,
        }
    );
}

它不会给我任何错误,并且可以与其余代码一起编译和运行,但它不会像我想要的那样使窗口覆盖重定向。

【问题讨论】:

    标签: rust x11


    【解决方案1】:

    我想通了。覆盖重定向仅在映射窗口时发生,因此如果我取消映射并再次映射它,它就会起作用!

    现在是代码:

    unsafe {
        use glutin::os::unix::WindowExt;
        use glutin::os::unix::x11::XConnection;
        use glutin::os::unix::x11::ffi::{Display, XID, CWOverrideRedirect, XSetWindowAttributes};
        let x_connection = std::sync::Arc::<XConnection>::into_raw(display.gl_window().get_xlib_xconnection().unwrap());
        let x_display = display.gl_window().get_xlib_display().unwrap() as *mut Display;
        let x_window = display.gl_window().get_xlib_window().unwrap() as XID;
        ((*x_connection).xlib.XChangeWindowAttributes)(
            x_display,
            x_window,
            CWOverrideRedirect,
            &mut XSetWindowAttributes {
                background_pixmap: 0,
                background_pixel: 0,
                border_pixmap: 0,
                border_pixel: 0,
                bit_gravity: 0,
                win_gravity: 0,
                backing_store: 0,
                backing_planes: 0,
                backing_pixel: 0,
                save_under: 0,
                event_mask: 0,
                do_not_propagate_mask: 0,
                override_redirect: 1,
                colormap: 0,
                cursor: 0,
            }
        );
        ((*x_connection).xlib.XUnmapWindow)(x_display, x_window);
        ((*x_connection).xlib.XMapWindow)(x_display, x_window);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-15
      • 2018-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多