aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/x11
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2016-01-18 22:39:08 -0700
committerMichael Howell <michael@notriddle.com>2016-01-19 09:44:33 -0700
commit0a43f8f733412f7ec7542866b8177ea1215345a5 (patch)
treef7f958ce26a9b39ebc88eff1ee768102b375aa4d /src/api/x11
parent1113fa1c138e8aa06213d7e74e9ed4a971bd10b7 (diff)
downloadglutin-0a43f8f733412f7ec7542866b8177ea1215345a5.tar.gz
glutin-0a43f8f733412f7ec7542866b8177ea1215345a5.zip
Allow it to work under Xvfb.
Part of servo/servo#8641
Diffstat (limited to 'src/api/x11')
-rw-r--r--src/api/x11/window.rs57
1 files changed, 27 insertions, 30 deletions
diff --git a/src/api/x11/window.rs b/src/api/x11/window.rs
index de9cfb6..4b78c4a 100644
--- a/src/api/x11/window.rs
+++ b/src/api/x11/window.rs
@@ -57,7 +57,7 @@ pub struct XWindow {
pub context: Context,
is_fullscreen: bool,
screen_id: libc::c_int,
- xf86_desk_mode: ffi::XF86VidModeModeInfo,
+ xf86_desk_mode: Option<ffi::XF86VidModeModeInfo>,
ic: ffi::XIC,
im: ffi::XIM,
colormap: ffi::Colormap,
@@ -90,7 +90,9 @@ impl Drop for XWindow {
let _lock = GLOBAL_XOPENIM_LOCK.lock().unwrap();
if self.is_fullscreen {
- (self.display.xf86vmode.XF86VidModeSwitchToMode)(self.display.display, self.screen_id, &mut self.xf86_desk_mode);
+ if let Some(mut xf86_desk_mode) = self.xf86_desk_mode {
+ (self.display.xf86vmode.XF86VidModeSwitchToMode)(self.display.display, self.screen_id, &mut xf86_desk_mode);
+ }
(self.display.xf86vmode.XF86VidModeSetViewPort)(self.display.display, self.screen_id, 0, 0);
}
@@ -324,36 +326,31 @@ impl Window {
let mut mode_num: libc::c_int = mem::uninitialized();
let mut modes: *mut *mut ffi::XF86VidModeModeInfo = mem::uninitialized();
if (display.xf86vmode.XF86VidModeGetAllModeLines)(display.display, screen_id, &mut mode_num, &mut modes) == 0 {
- return Err(OsError(format!("Could not query the video modes")));
- }
-
- let xf86_desk_mode: ffi::XF86VidModeModeInfo = ptr::read(*modes.offset(0));
-
- let mode_to_switch_to = if window_attrs.monitor.is_some() {
- let matching_mode = (0 .. mode_num).map(|i| {
- let m: ffi::XF86VidModeModeInfo = ptr::read(*modes.offset(i as isize) as *const _); m
- }).find(|m| m.hdisplay == dimensions.0 as u16 && m.vdisplay == dimensions.1 as u16);
-
- if let Some(matching_mode) = matching_mode {
- Some(matching_mode)
-
- } else {
- let m = (0 .. mode_num).map(|i| {
+ (None, None)
+ } else {
+ let xf86_desk_mode: ffi::XF86VidModeModeInfo = ptr::read(*modes.offset(0));
+ let mode_to_switch_to = if window_attrs.monitor.is_some() {
+ let matching_mode = (0 .. mode_num).map(|i| {
let m: ffi::XF86VidModeModeInfo = ptr::read(*modes.offset(i as isize) as *const _); m
- }).find(|m| m.hdisplay >= dimensions.0 as u16 && m.vdisplay >= dimensions.1 as u16);
-
- match m {
- Some(m) => Some(m),
- None => return Err(OsError(format!("Could not find a suitable graphics mode")))
+ }).find(|m| m.hdisplay == dimensions.0 as u16 && m.vdisplay == dimensions.1 as u16);
+ if let Some(matching_mode) = matching_mode {
+ Some(matching_mode)
+ } else {
+ let m = (0 .. mode_num).map(|i| {
+ let m: ffi::XF86VidModeModeInfo = ptr::read(*modes.offset(i as isize) as *const _); m
+ }).find(|m| m.hdisplay >= dimensions.0 as u16 && m.vdisplay >= dimensions.1 as u16);
+
+ match m {
+ Some(m) => Some(m),
+ None => return Err(OsError(format!("Could not find a suitable graphics mode")))
+ }
}
- }
- } else {
- None
- };
-
- (display.xlib.XFree)(modes as *mut _);
-
- (mode_to_switch_to, xf86_desk_mode)
+ } else {
+ None
+ };
+ (display.xlib.XFree)(modes as *mut _);
+ (mode_to_switch_to, Some(xf86_desk_mode))
+ }
};
// start the context building process