aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/x11
diff options
context:
space:
mode:
authorAdam Badawy <adambada@buffalo.edu>2015-10-26 03:40:37 -0400
committerAdam Badawy <adambada@buffalo.edu>2015-10-26 04:06:40 -0400
commit47df0e9eaa7f1231a07f86fc44426936c7a2589a (patch)
tree6f95ee77b622446c272184b0735107228f9849d1 /src/api/x11
parented8dfa9a52e4034c50bf0fd87c89484bffb043f0 (diff)
downloadglutin-47df0e9eaa7f1231a07f86fc44426936c7a2589a.tar.gz
glutin-47df0e9eaa7f1231a07f86fc44426936c7a2589a.zip
Fix misbehaving fullscreen window
Diffstat (limited to 'src/api/x11')
-rw-r--r--src/api/x11/window.rs59
1 files changed, 51 insertions, 8 deletions
diff --git a/src/api/x11/window.rs b/src/api/x11/window.rs
index b6a9621..2a0bade 100644
--- a/src/api/x11/window.rs
+++ b/src/api/x11/window.rs
@@ -436,14 +436,14 @@ impl Window {
}
// switching to fullscreen
- if let Some(mut mode_to_switch_to) = mode_to_switch_to {
- window_attributes |= ffi::CWOverrideRedirect;
- unsafe {
- (display.xf86vmode.XF86VidModeSwitchToMode)(display.display, screen_id, &mut mode_to_switch_to);
- (display.xf86vmode.XF86VidModeSetViewPort)(display.display, screen_id, 0, 0);
- set_win_attr.override_redirect = 1;
- }
- }
+ // if let Some(mut mode_to_switch_to) = mode_to_switch_to {
+ // window_attributes |= ffi::CWOverrideRedirect;
+ // unsafe {
+ // (display.xf86vmode.XF86VidModeSwitchToMode)(display.display, screen_id, &mut mode_to_switch_to);
+ // (display.xf86vmode.XF86VidModeSetViewPort)(display.display, screen_id, 0, 0);
+ // set_win_attr.override_redirect = 1;
+ // }
+ // }
// finally creating the window
let window = unsafe {
@@ -527,6 +527,49 @@ impl Window {
let is_fullscreen = window_attrs.monitor.is_some();
+ if is_fullscreen {
+ let state_atom = unsafe {
+ with_c_str("_NET_WM_STATE", |state|
+ (display.xlib.XInternAtom)(display.display, state, 0)
+ )
+ };
+ let fs_atom = unsafe {
+ with_c_str("_NET_WM_STATE_FULLSCREEN", |state_fullscreen|
+ (display.xlib.XInternAtom)(display.display, state_fullscreen, 0)
+ )
+ };
+
+ let client_message_event = ffi::XClientMessageEvent {
+ type_: ffi::ClientMessage,
+ serial: 0,
+ send_event: 1,
+ display: display.display,
+ window: window,
+ message_type: state_atom,
+ format: 32,
+ data: {
+ let mut data = unsafe {
+ mem::transmute::<[libc::c_long; 5], ffi::ClientMessageData>([0; 5])
+ };
+ data.set_long(0, 1);
+ data.set_long(1, fs_atom as i64);
+ data.set_long(2, 0);
+ data
+ }
+ };
+ let mut x_event = ffi::XEvent::from(client_message_event);
+
+ unsafe {
+ (display.xlib.XSendEvent)(
+ display.display,
+ root,
+ 0,
+ ffi::SubstructureRedirectMask | ffi::SubstructureNotifyMask,
+ &mut x_event as *mut _
+ );
+ }
+ }
+
// finish creating the OpenGL context
let context = match context {
Prototype::Glx(ctxt) => {