mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 05:21:31 +11:00
Work on input support for X11
This commit is contained in:
parent
433c5b956e
commit
c1da2b1273
|
@ -3,7 +3,7 @@
|
|||
extern crate libc;
|
||||
|
||||
pub use events::{Event, Element, PositionChanged, SizeChanged, Closed, CursorPositionChanged, Focused};
|
||||
pub use events::{Iconified, NeedRefresh};
|
||||
pub use events::{Iconified, NeedRefresh, Pressed, Released};
|
||||
pub use hints::{Hints, ClientAPI, Profile};
|
||||
|
||||
#[cfg(windows)]
|
||||
|
|
1002
src/x11/events.rs
Normal file
1002
src/x11/events.rs
Normal file
File diff suppressed because it is too large
Load diff
1037
src/x11/ffi.rs
1037
src/x11/ffi.rs
File diff suppressed because it is too large
Load diff
|
@ -3,6 +3,7 @@ use libc;
|
|||
use std::{mem, ptr};
|
||||
use std::sync::atomics::AtomicBool;
|
||||
|
||||
mod events;
|
||||
mod ffi;
|
||||
|
||||
pub struct Window {
|
||||
|
@ -61,7 +62,9 @@ impl Window {
|
|||
let mut swa: ffi::XSetWindowAttributes = unsafe { mem::zeroed() };
|
||||
swa.colormap = cmap;
|
||||
swa.event_mask = ffi::ExposureMask | ffi::ResizeRedirectMask |
|
||||
ffi::VisibilityChangeMask | ffi::KeyPressMask | ffi::PointerMotionMask;
|
||||
ffi::VisibilityChangeMask | ffi::KeyPressMask | ffi::PointerMotionMask |
|
||||
ffi::KeyPressMask | ffi::KeyReleaseMask | ffi::ButtonPressMask |
|
||||
ffi::ButtonReleaseMask;
|
||||
swa
|
||||
};
|
||||
|
||||
|
@ -174,6 +177,30 @@ impl Window {
|
|||
events.push(CursorPositionChanged(event.x as uint, event.y as uint));
|
||||
},
|
||||
|
||||
ffi::KeyPress | ffi::KeyRelease => {
|
||||
use {Pressed, Released};
|
||||
let event: &ffi::XKeyEvent = unsafe { mem::transmute(&xev) };
|
||||
|
||||
let keysym = unsafe { ffi::XKeycodeToKeysym(self.display, event.keycode as ffi::KeyCode, 0) };
|
||||
|
||||
match events::keycode_to_element(keysym as libc::c_uint) {
|
||||
Some(elem) if xev.type_ == ffi::KeyPress => {
|
||||
events.push(Pressed(elem));
|
||||
},
|
||||
Some(elem) if xev.type_ == ffi::KeyRelease => {
|
||||
events.push(Released(elem));
|
||||
},
|
||||
_ => ()
|
||||
}
|
||||
//
|
||||
},
|
||||
|
||||
ffi::ButtonPress | ffi::ButtonRelease => {
|
||||
use {Pressed, Released};
|
||||
let event: &ffi::XButtonEvent = unsafe { mem::transmute(&xev) };
|
||||
//events.push(CursorPositionChanged(event.x as uint, event.y as uint));
|
||||
},
|
||||
|
||||
_ => ()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue