mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 21:31:29 +11:00
parent
bf537009d9
commit
95246d81c1
|
@ -1,12 +1,13 @@
|
||||||
use std::mem::transmute;
|
use std::ffi::CStr;
|
||||||
use std::os::raw::c_short;
|
use std::os::raw::c_short;
|
||||||
use std::ptr;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use std::{mem, ptr};
|
||||||
|
|
||||||
|
use x11_dl::xlib::{XIMCallback, XIMPreeditCaretCallbackStruct, XIMPreeditDrawCallbackStruct};
|
||||||
|
|
||||||
|
use crate::platform_impl::platform::x11::ime::{ImeEvent, ImeEventSender};
|
||||||
|
|
||||||
use super::{ffi, util, XConnection, XError};
|
use super::{ffi, util, XConnection, XError};
|
||||||
use crate::platform_impl::platform::x11::ime::{ImeEvent, ImeEventSender};
|
|
||||||
use std::ffi::CStr;
|
|
||||||
use x11_dl::xlib::{XIMCallback, XIMPreeditCaretCallbackStruct, XIMPreeditDrawCallbackStruct};
|
|
||||||
|
|
||||||
/// IME creation error.
|
/// IME creation error.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -163,7 +164,7 @@ struct PreeditCallbacks {
|
||||||
impl PreeditCallbacks {
|
impl PreeditCallbacks {
|
||||||
pub fn new(client_data: ffi::XPointer) -> PreeditCallbacks {
|
pub fn new(client_data: ffi::XPointer) -> PreeditCallbacks {
|
||||||
let start_callback = create_xim_callback(client_data, unsafe {
|
let start_callback = create_xim_callback(client_data, unsafe {
|
||||||
transmute(preedit_start_callback as usize)
|
mem::transmute(preedit_start_callback as usize)
|
||||||
});
|
});
|
||||||
let done_callback = create_xim_callback(client_data, preedit_done_callback);
|
let done_callback = create_xim_callback(client_data, preedit_done_callback);
|
||||||
let caret_callback = create_xim_callback(client_data, preedit_caret_callback);
|
let caret_callback = create_xim_callback(client_data, preedit_caret_callback);
|
||||||
|
|
|
@ -120,7 +120,33 @@ impl Ime {
|
||||||
// Create empty entry in map, so that when IME is rebuilt, this window has a context.
|
// Create empty entry in map, so that when IME is rebuilt, this window has a context.
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let event = if with_preedit {
|
let context = unsafe {
|
||||||
|
ImeContext::new(
|
||||||
|
&self.inner.xconn,
|
||||||
|
self.inner.im,
|
||||||
|
window,
|
||||||
|
None,
|
||||||
|
with_preedit,
|
||||||
|
self.inner.event_sender.clone(),
|
||||||
|
)
|
||||||
|
.or_else(|_| {
|
||||||
|
debug!(
|
||||||
|
"failed to create an IME context {} preedit support",
|
||||||
|
if with_preedit { "with" } else { "without" }
|
||||||
|
);
|
||||||
|
ImeContext::new(
|
||||||
|
&self.inner.xconn,
|
||||||
|
self.inner.im,
|
||||||
|
window,
|
||||||
|
None,
|
||||||
|
!with_preedit,
|
||||||
|
self.inner.event_sender.clone(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}?;
|
||||||
|
|
||||||
|
// Check the state on the context, since it could fail to enable or disable preedit.
|
||||||
|
let event = if context.is_allowed {
|
||||||
ImeEvent::Enabled
|
ImeEvent::Enabled
|
||||||
} else {
|
} else {
|
||||||
// There's no IME without preedit.
|
// There's no IME without preedit.
|
||||||
|
@ -132,16 +158,7 @@ impl Ime {
|
||||||
.send((window, event))
|
.send((window, event))
|
||||||
.expect("Failed to send enabled event");
|
.expect("Failed to send enabled event");
|
||||||
|
|
||||||
Some(unsafe {
|
Some(context)
|
||||||
ImeContext::new(
|
|
||||||
&self.inner.xconn,
|
|
||||||
self.inner.im,
|
|
||||||
window,
|
|
||||||
None,
|
|
||||||
with_preedit,
|
|
||||||
self.inner.event_sender.clone(),
|
|
||||||
)
|
|
||||||
}?)
|
|
||||||
};
|
};
|
||||||
self.inner.contexts.insert(window, context);
|
self.inner.contexts.insert(window, context);
|
||||||
Ok(!self.is_destroyed())
|
Ok(!self.is_destroyed())
|
||||||
|
|
Loading…
Reference in a new issue