mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 22:31:30 +11:00
Fix resize event on X11. Without this change, resizing window larger than initial size doesn't work.
This commit is contained in:
parent
0392dc697a
commit
ad54e01a91
|
@ -1337,6 +1337,23 @@ pub struct XButtonEvent {
|
||||||
pub same_screen: Bool,
|
pub same_screen: Bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[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)]
|
#[repr(C)]
|
||||||
pub struct XF86VidModeModeInfo {
|
pub struct XF86VidModeModeInfo {
|
||||||
pub dotclock: libc::c_uint,
|
pub dotclock: libc::c_uint,
|
||||||
|
|
|
@ -33,6 +33,7 @@ pub struct Window {
|
||||||
screen_id: libc::c_int,
|
screen_id: libc::c_int,
|
||||||
is_fullscreen: bool,
|
is_fullscreen: bool,
|
||||||
current_modifiers: Cell<KeyModifiers>,
|
current_modifiers: Cell<KeyModifiers>,
|
||||||
|
current_size: Cell<(libc::c_int, libc::c_int)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
|
@ -134,7 +135,7 @@ impl Window {
|
||||||
let mut set_win_attr = {
|
let mut set_win_attr = {
|
||||||
let mut swa: ffi::XSetWindowAttributes = unsafe { mem::zeroed() };
|
let mut swa: ffi::XSetWindowAttributes = unsafe { mem::zeroed() };
|
||||||
swa.colormap = cmap;
|
swa.colormap = cmap;
|
||||||
swa.event_mask = ffi::ExposureMask | ffi::ResizeRedirectMask |
|
swa.event_mask = ffi::ExposureMask | ffi::StructureNotifyMask |
|
||||||
ffi::VisibilityChangeMask | ffi::KeyPressMask | ffi::PointerMotionMask |
|
ffi::VisibilityChangeMask | ffi::KeyPressMask | ffi::PointerMotionMask |
|
||||||
ffi::KeyReleaseMask | ffi::ButtonPressMask |
|
ffi::KeyReleaseMask | ffi::ButtonPressMask |
|
||||||
ffi::ButtonReleaseMask | ffi::KeymapStateMask;
|
ffi::ButtonReleaseMask | ffi::KeymapStateMask;
|
||||||
|
@ -246,6 +247,9 @@ impl Window {
|
||||||
context
|
context
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Make context current before call to glViewport below.
|
||||||
|
unsafe { ffi::glx::MakeCurrent(display, window, context) };
|
||||||
|
|
||||||
// creating the window object
|
// creating the window object
|
||||||
let window = Window {
|
let window = Window {
|
||||||
display: display,
|
display: display,
|
||||||
|
@ -259,6 +263,7 @@ impl Window {
|
||||||
screen_id: screen_id,
|
screen_id: screen_id,
|
||||||
is_fullscreen: builder.monitor.is_some(),
|
is_fullscreen: builder.monitor.is_some(),
|
||||||
current_modifiers: Cell::new(KeyModifiers::empty()),
|
current_modifiers: Cell::new(KeyModifiers::empty()),
|
||||||
|
current_size: Cell::new((0, 0)),
|
||||||
};
|
};
|
||||||
|
|
||||||
// calling glViewport
|
// calling glViewport
|
||||||
|
@ -367,10 +372,14 @@ impl Window {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
ffi::ResizeRequest => {
|
ffi::ConfigureNotify => {
|
||||||
use Resized;
|
use Resized;
|
||||||
let rs_event: &ffi::XResizeRequestEvent = unsafe { mem::transmute(&xev) };
|
let cfg_event: &ffi::XConfigureEvent = unsafe { mem::transmute(&xev) };
|
||||||
events.push(Resized(rs_event.width as uint, rs_event.height as uint));
|
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 => {
|
ffi::MotionNotify => {
|
||||||
|
|
Loading…
Reference in a new issue