mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 22:31:30 +11:00
Set WM_CLASS and WM_NAME before mapping window
ICCCM 4.1.2.5 (https://tronche.com/gui/x/icccm/sec-4.html#WM_CLASS) states that: > This property must be present when the window leaves the Withdrawn > state and may be changed only while the window is in the Withdrawn > state. Previously, we would first map the window, and then set these properties, causing sadness for window managers (#167, tomaka/glutin#879). This patch changes that by setting the class and name attributes immediately after the window is created, and before it is mapped. Fixes #167.
This commit is contained in:
parent
6c99546035
commit
4087627b12
|
@ -403,6 +403,19 @@ impl Window {
|
|||
win
|
||||
};
|
||||
|
||||
// Set ICCCM WM_CLASS property based on initial window title
|
||||
// Must be done *before* mapping the window by ICCCM 4.1.2.5
|
||||
unsafe {
|
||||
with_c_str(&*window_attrs.title, |c_name| {
|
||||
let hint = (display.xlib.XAllocClassHint)();
|
||||
(*hint).res_name = c_name as *mut libc::c_char;
|
||||
(*hint).res_class = c_name as *mut libc::c_char;
|
||||
(display.xlib.XSetClassHint)(display.display, window, hint);
|
||||
display.check_errors().expect("Failed to call XSetClassHint");
|
||||
(display.xlib.XFree)(hint as *mut _);
|
||||
});
|
||||
}
|
||||
|
||||
// set visibility
|
||||
if window_attrs.visible {
|
||||
unsafe {
|
||||
|
@ -466,18 +479,6 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
// Set ICCCM WM_CLASS property based on initial window title
|
||||
unsafe {
|
||||
with_c_str(&*window_attrs.title, |c_name| {
|
||||
let hint = (display.xlib.XAllocClassHint)();
|
||||
(*hint).res_name = c_name as *mut libc::c_char;
|
||||
(*hint).res_class = c_name as *mut libc::c_char;
|
||||
(display.xlib.XSetClassHint)(display.display, window, hint);
|
||||
display.check_errors().expect("Failed to call XSetClassHint");
|
||||
(display.xlib.XFree)(hint as *mut _);
|
||||
});
|
||||
}
|
||||
|
||||
let is_fullscreen = window_attrs.monitor.is_some();
|
||||
|
||||
if is_fullscreen {
|
||||
|
|
Loading…
Reference in a new issue