diff options
author | tomaka <pierre.krieger1708@gmail.com> | 2014-10-28 07:59:04 +0100 |
---|---|---|
committer | tomaka <pierre.krieger1708@gmail.com> | 2014-10-28 07:59:04 +0100 |
commit | a6d52b65179a50f398d37ad72b3aacc8e4ab1e6d (patch) | |
tree | 271637f40610ba889ccad5aac23088052339bd49 /src/x11 | |
parent | e5bde5e3838dd545b7c0407d50f2ed22aed5a9de (diff) | |
parent | ad54e01a91a0ff034e0f8d84822fdd20b0726481 (diff) | |
download | glutin-a6d52b65179a50f398d37ad72b3aacc8e4ab1e6d.tar.gz glutin-a6d52b65179a50f398d37ad72b3aacc8e4ab1e6d.zip |
Merge pull request #86 from glennw/x11-resize
Fix resize event on X11. Without this change, resizing window larger tha...
Diffstat (limited to 'src/x11')
-rw-r--r-- | src/x11/ffi.rs | 17 | ||||
-rw-r--r-- | src/x11/window/mod.rs | 17 |
2 files changed, 30 insertions, 4 deletions
diff --git a/src/x11/ffi.rs b/src/x11/ffi.rs index f9dc3ad..6fbfd81 100644 --- a/src/x11/ffi.rs +++ b/src/x11/ffi.rs @@ -1338,6 +1338,23 @@ pub struct XButtonEvent { } #[repr(C)] +pub struct XConfigureEvent { + pub type_: libc::c_int, + pub serial: libc::c_ulong, + pub send_event: Bool, + pub display: *mut Display, + pub event: Window, + pub window: Window, + pub x: libc::c_int, + pub y: libc::c_int, + pub width: libc::c_int, + pub height: libc::c_int, + pub border_width: libc::c_int, + pub above: Window, + pub override_redirect: Bool, +} + +#[repr(C)] pub struct XF86VidModeModeInfo { pub dotclock: libc::c_uint, pub hdisplay: libc::c_ushort, diff --git a/src/x11/window/mod.rs b/src/x11/window/mod.rs index 4cb405f..2f00438 100644 --- a/src/x11/window/mod.rs +++ b/src/x11/window/mod.rs @@ -33,6 +33,7 @@ pub struct Window { screen_id: libc::c_int, is_fullscreen: bool, current_modifiers: Cell<KeyModifiers>, + current_size: Cell<(libc::c_int, libc::c_int)>, } impl Window { @@ -134,7 +135,7 @@ impl Window { let mut set_win_attr = { let mut swa: ffi::XSetWindowAttributes = unsafe { mem::zeroed() }; swa.colormap = cmap; - swa.event_mask = ffi::ExposureMask | ffi::ResizeRedirectMask | + swa.event_mask = ffi::ExposureMask | ffi::StructureNotifyMask | ffi::VisibilityChangeMask | ffi::KeyPressMask | ffi::PointerMotionMask | ffi::KeyReleaseMask | ffi::ButtonPressMask | ffi::ButtonReleaseMask | ffi::KeymapStateMask; @@ -248,6 +249,9 @@ impl Window { context }; + // Make context current before call to glViewport below. + unsafe { ffi::glx::MakeCurrent(display, window, context) }; + // creating the window object let window = Window { display: display, @@ -261,6 +265,7 @@ impl Window { screen_id: screen_id, is_fullscreen: builder.monitor.is_some(), current_modifiers: Cell::new(KeyModifiers::empty()), + current_size: Cell::new((0, 0)), }; // calling glViewport @@ -369,10 +374,14 @@ impl Window { } }, - ffi::ResizeRequest => { + ffi::ConfigureNotify => { use Resized; - let rs_event: &ffi::XResizeRequestEvent = unsafe { mem::transmute(&xev) }; - events.push(Resized(rs_event.width as uint, rs_event.height as uint)); + let cfg_event: &ffi::XConfigureEvent = unsafe { mem::transmute(&xev) }; + let (current_width, current_height) = self.current_size.get(); + if current_width != cfg_event.width || current_height != cfg_event.height { + self.current_size.set((cfg_event.width, cfg_event.height)); + events.push(Resized(cfg_event.width as uint, cfg_event.height as uint)); + } }, ffi::MotionNotify => { |