Skip to content

Commit dcd80c1

Browse files
committed
Fix X11 support and add floating window hint for tiling WMs
1 parent 856202c commit dcd80c1

4 files changed

Lines changed: 43 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/processing_glfw/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ workspace = true
88

99
[features]
1010
wayland = ["glfw/wayland"]
11-
x11 = []
11+
x11 = ["dep:x11"]
1212
static-link = ["glfw/static-link"]
1313

1414
[dependencies]
15+
x11 = { version = "2", features = ["xlib"], optional = true }
1516
bevy = { workspace = true }
1617
glfw = "0.60.0"
1718
processing_core = { workspace = true }

crates/processing_glfw/src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,35 @@ impl GlfwContext {
7070
.unwrap();
7171

7272
window.set_all_polling(true);
73+
74+
// Set _NET_WM_WINDOW_TYPE_DIALOG so tiling WMs (i3, sway) float the window
75+
#[cfg(all(target_os = "linux", feature = "x11"))]
76+
unsafe {
77+
use std::ffi::CString;
78+
let display = window.glfw.get_x11_display() as *mut x11::xlib::Display;
79+
let xwindow = window.get_x11_window() as x11::xlib::Window;
80+
let net_wm_window_type = x11::xlib::XInternAtom(
81+
display,
82+
CString::new("_NET_WM_WINDOW_TYPE").unwrap().as_ptr(),
83+
0,
84+
);
85+
let net_wm_window_type_dialog = x11::xlib::XInternAtom(
86+
display,
87+
CString::new("_NET_WM_WINDOW_TYPE_DIALOG").unwrap().as_ptr(),
88+
0,
89+
);
90+
x11::xlib::XChangeProperty(
91+
display,
92+
xwindow,
93+
net_wm_window_type,
94+
x11::xlib::XA_ATOM,
95+
32,
96+
x11::xlib::PropModeReplace,
97+
&net_wm_window_type_dialog as *const _ as *const u8,
98+
1,
99+
);
100+
}
101+
73102
window.show();
74103

75104
Ok(Self {

crates/processing_pyo3/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ crate-type = ["cdylib"]
1414
default = ["wayland", "static-link"]
1515
wayland = ["processing/wayland", "processing_glfw/wayland"]
1616
static-link = ["processing_glfw/static-link"]
17-
x11 = ["processing/x11"]
17+
x11 = ["processing/x11", "processing_glfw/x11"]
1818
webcam = ["processing/webcam", "dep:processing_webcam"]
1919
cuda = ["dep:processing_cuda", "processing_cuda/cuda", "processing/cuda"]
2020

0 commit comments

Comments
 (0)