mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-12 05:31:31 +11:00
remove the the redundant code, fix a bug
This commit is contained in:
parent
5e5debc48f
commit
aea61a74fb
|
@ -42,6 +42,8 @@ pub trait WindowExt {
|
||||||
fn get_xlib_screen_id(&self) -> Option<*mut libc::c_void>;
|
fn get_xlib_screen_id(&self) -> Option<*mut libc::c_void>;
|
||||||
|
|
||||||
fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>>;
|
fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>>;
|
||||||
|
|
||||||
|
fn send_xim_spot(&self, x: i16, y: i16);
|
||||||
|
|
||||||
/// This function returns the underlying `xcb_connection_t` of an xlib `Display`.
|
/// This function returns the underlying `xcb_connection_t` of an xlib `Display`.
|
||||||
///
|
///
|
||||||
|
@ -121,6 +123,12 @@ impl WindowExt for Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn send_xim_spot(&self, x: i16, y: i16) {
|
||||||
|
if let LinuxWindow::X(ref w) = self.window {
|
||||||
|
w.send_xim_spot(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_wayland_surface(&self) -> Option<*mut libc::c_void> {
|
fn get_wayland_surface(&self) -> Option<*mut libc::c_void> {
|
||||||
use wayland_client::Proxy;
|
use wayland_client::Proxy;
|
||||||
|
|
|
@ -685,6 +685,7 @@ impl Window2 {
|
||||||
x_events_loop.windows.lock().unwrap().insert(win.id(), WindowData {
|
x_events_loop.windows.lock().unwrap().insert(win.id(), WindowData {
|
||||||
im: im,
|
im: im,
|
||||||
ic: ic,
|
ic: ic,
|
||||||
|
spot: ffi::XPoint {x: 0, y: 0},
|
||||||
config: None,
|
config: None,
|
||||||
multitouch: window.multitouch,
|
multitouch: window.multitouch,
|
||||||
cursor_pos: None,
|
cursor_pos: None,
|
||||||
|
@ -701,6 +702,26 @@ impl Window2 {
|
||||||
pub fn id(&self) -> WindowId {
|
pub fn id(&self) -> WindowId {
|
||||||
self.window.id()
|
self.window.id()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn send_xim_spot(&self, x: i16, y: i16) {
|
||||||
|
if let (Some(windows), Some(display)) = (self.windows.upgrade(), self.display.upgrade()) {
|
||||||
|
let nspot = ffi::XPoint{x: x, y: y};
|
||||||
|
let mut windows = windows.lock().unwrap();
|
||||||
|
let mut w = windows.get_mut(&self.window.id()).unwrap();
|
||||||
|
if w.spot.x == x && w.spot.y == y {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.spot = nspot;
|
||||||
|
unsafe {
|
||||||
|
let preedit_attr = (display.xlib.XVaCreateNestedList)
|
||||||
|
(0, b"spotLocation\0", &nspot, ptr::null::<()>());
|
||||||
|
(display.xlib.XSetICValues)(w.ic, b"preeditAttributes\0",
|
||||||
|
preedit_attr, ptr::null::<()>());
|
||||||
|
(display.xlib.XFree)(preedit_attr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Window2 {
|
impl Drop for Window2 {
|
||||||
|
@ -722,6 +743,7 @@ struct WindowData {
|
||||||
config: Option<WindowConfig>,
|
config: Option<WindowConfig>,
|
||||||
im: ffi::XIM,
|
im: ffi::XIM,
|
||||||
ic: ffi::XIC,
|
ic: ffi::XIC,
|
||||||
|
spot: ffi::XPoint,
|
||||||
multitouch: bool,
|
multitouch: bool,
|
||||||
cursor_pos: Option<(f64, f64)>,
|
cursor_pos: Option<(f64, f64)>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue