window server backend cursor api
This commit is contained in:
parent
72129ba61e
commit
964d6fe748
|
@ -5,6 +5,7 @@ use super::{
|
|||
|
||||
pub trait WindowServerBackend {
|
||||
type Window;
|
||||
//type WindowEvent = super::window_event::WindowEvent<Self::Window>;
|
||||
|
||||
fn build() -> Self;
|
||||
|
||||
|
@ -46,6 +47,10 @@ pub trait WindowServerBackend {
|
|||
fn screen_size(&self) -> Point<i32>;
|
||||
fn get_window_size(&self, window: Self::Window) -> Option<Point<i32>>;
|
||||
|
||||
fn grab_cursor(&self);
|
||||
fn ungrab_cursor(&self);
|
||||
fn move_cursor(&self, window: Option<Self::Window>, position: Point<i32>);
|
||||
|
||||
fn resize_window(&self, window: Self::Window, new_size: Point<i32>) {
|
||||
self.configure_window(window, Some(new_size), None);
|
||||
}
|
||||
|
|
|
@ -491,8 +491,6 @@ impl XLib {
|
|||
|
||||
XKeySym::new(keysym as u32)
|
||||
}
|
||||
|
||||
fn modifier_state_to_modmask(&self) {}
|
||||
}
|
||||
|
||||
trait ModifierStateExt {
|
||||
|
@ -722,6 +720,46 @@ impl WindowServerBackend for XLib {
|
|||
self.get_window_attributes(window)
|
||||
.map(|wa| (wa.width, wa.height).into())
|
||||
}
|
||||
|
||||
fn grab_cursor(&self) {
|
||||
unsafe {
|
||||
xlib::XGrabPointer(
|
||||
self.dpy(),
|
||||
self.root,
|
||||
0,
|
||||
(xlib::ButtonPressMask
|
||||
| xlib::ButtonReleaseMask
|
||||
| xlib::PointerMotionMask) as u32,
|
||||
xlib::GrabModeAsync,
|
||||
xlib::GrabModeAsync,
|
||||
0,
|
||||
0,
|
||||
xlib::CurrentTime,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn ungrab_cursor(&self) {
|
||||
unsafe {
|
||||
xlib::XUngrabPointer(self.dpy(), xlib::CurrentTime);
|
||||
}
|
||||
}
|
||||
|
||||
fn move_cursor(&self, window: Option<Self::Window>, position: Point<i32>) {
|
||||
unsafe {
|
||||
xlib::XWarpPointer(
|
||||
self.dpy(),
|
||||
0,
|
||||
window.unwrap_or(self.root),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
position.x,
|
||||
position.y,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct XLibAtoms {
|
||||
|
|
|
@ -714,9 +714,8 @@ where
|
|||
)
|
||||
};
|
||||
|
||||
// TODO fix backend cursor api
|
||||
//self.xlib.move_cursor(None, corner_pos);
|
||||
//self.xlib.grab_cursor();
|
||||
self.backend.move_cursor(None, corner_pos.into());
|
||||
self.backend.grab_cursor();
|
||||
|
||||
self.move_resize_window =
|
||||
MoveResizeInfo::Resize(ResizeInfoInner {
|
||||
|
@ -736,8 +735,7 @@ where
|
|||
}
|
||||
MouseButton::Right => {
|
||||
self.move_resize_window = MoveResizeInfo::None;
|
||||
// TODO fix backend cursor api
|
||||
//self.xlib.release_cursor();
|
||||
self.backend.ungrab_cursor();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue