From 513b77db75dbc243d27d5067fad2ac3dd2fb897c Mon Sep 17 00:00:00 2001 From: Smit Barmase Date: Wed, 13 Aug 2025 04:19:16 +0530 Subject: [PATCH] log --- crates/gpui/src/platform/linux/x11/client.rs | 33 ++++++++++++++++--- .../src/platform/linux/x11/xim_handler.rs | 8 +++++ 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/crates/gpui/src/platform/linux/x11/client.rs b/crates/gpui/src/platform/linux/x11/client.rs index 573e4addf7..a98c8eba82 100644 --- a/crates/gpui/src/platform/linux/x11/client.rs +++ b/crates/gpui/src/platform/linux/x11/client.rs @@ -256,6 +256,7 @@ impl X11ClientStatePtr { } pub fn update_ime_position(&self, bounds: Bounds) { + println!("ime pos"); let Some(client) = self.get_client() else { return; }; @@ -273,6 +274,7 @@ impl X11ClientStatePtr { state.ximc = Some(ximc); return; }; + println!("set ic values"); let ic_attributes = ximc .build_ic_attributes() .push( @@ -642,6 +644,9 @@ impl X11Client { let xim_connected = xim_handler.connected; drop(state); + println!(""); + println!("----start--"); + let xim_filtered = match ximc.filter_event(&event, &mut xim_handler) { Ok(handled) => handled, Err(err) => { @@ -660,12 +665,16 @@ impl X11Client { } if xim_filtered { + println!("filtered skipping"); continue; + } else { + println!("not skipping"); } if xim_connected { self.xim_handle_event(event); } else { + println!("event not connected!"); self.handle_event(event); } } @@ -711,6 +720,7 @@ impl X11Client { }); } } + println!("create ic"); ximc.create_ic(xim_handler.im_id, ic_attributes.build()) .ok(); let mut state = self.0.borrow_mut(); @@ -718,6 +728,7 @@ impl X11Client { } pub fn reset_ime(&self) { + println!("reset called"); let mut state = self.0.borrow_mut(); state.composing = false; if let Some(mut ximc) = state.ximc.take() { @@ -1275,12 +1286,15 @@ impl X11Client { fn handle_xim_callback_event(&self, event: XimCallbackEvent) { match event { XimCallbackEvent::XimXEvent(event) => { + println!("callback from from xim! xevent"); self.handle_event(event); } XimCallbackEvent::XimCommitEvent(window, text) => { + println!("callback from from xim! commit event"); self.xim_handle_commit(window, text); } XimCallbackEvent::XimPreeditEvent(window, text) => { + println!("callback from from xim! preedit event"); self.xim_handle_preedit(window, text); } }; @@ -1288,21 +1302,28 @@ impl X11Client { fn xim_handle_event(&self, event: Event) -> Option<()> { match event { - Event::KeyPress(event) | Event::KeyRelease(event) => { + Event::KeyPress(e) + // | Event::KeyRelease(e) + => { let mut state = self.0.borrow_mut(); state.pre_key_char_down = Some(Keystroke::from_xkb( &state.xkb, state.modifiers, - event.detail.into(), + e.detail.into(), )); let (mut ximc, mut xim_handler) = state.take_xim()?; drop(state); - xim_handler.window = event.event; + xim_handler.window = e.event; + if matches!(event, Event::KeyPress(..)) { + println!("forward key press to xim"); + } else { + println!("forward key release to xim"); + } ximc.forward_event( xim_handler.im_id, xim_handler.ic_id, - xim::ForwardEventFlag::empty(), - &event, + xim::ForwardEventFlag::REQUEST_FILTERING, + &e, ) .context("X11: Failed to forward XIM event") .log_err(); @@ -1311,6 +1332,8 @@ impl X11Client { drop(state); } event => { + println!("other x11 event."); + dbg!(&event); self.handle_event(event); } } diff --git a/crates/gpui/src/platform/linux/x11/xim_handler.rs b/crates/gpui/src/platform/linux/x11/xim_handler.rs index 82b7c96312..ffeabf3219 100644 --- a/crates/gpui/src/platform/linux/x11/xim_handler.rs +++ b/crates/gpui/src/platform/linux/x11/xim_handler.rs @@ -61,6 +61,7 @@ impl> ClientHandler for XimHandler _input_method_id: u16, input_context_id: u16, ) -> Result<(), ClientError> { + println!("create ic"); self.connected = true; self.ic_id = input_context_id; Ok(()) @@ -73,6 +74,8 @@ impl> ClientHandler for XimHandler _input_context_id: u16, text: &str, ) -> Result<(), ClientError> { + println!("commit callback"); + self.last_callback_event = Some(XimCallbackEvent::XimCommitEvent( self.window, String::from(text), @@ -88,6 +91,8 @@ impl> ClientHandler for XimHandler _flag: xim::ForwardEventFlag, xev: C::XEvent, ) -> Result<(), ClientError> { + println!("forward callback"); + match xev.response_type { x11rb::protocol::xproto::KEY_PRESS_EVENT => { self.last_callback_event = Some(XimCallbackEvent::XimXEvent(Event::KeyPress(xev))); @@ -102,6 +107,8 @@ impl> ClientHandler for XimHandler } fn handle_close(&mut self, client: &mut C, _input_method_id: u16) -> Result<(), ClientError> { + println!("disconnect"); + client.disconnect() } @@ -117,6 +124,7 @@ impl> ClientHandler for XimHandler preedit_string: &str, _feedbacks: Vec, ) -> Result<(), ClientError> { + println!("preedit callback"); // XIMReverse: 1, XIMPrimary: 8, XIMTertiary: 32: selected text // XIMUnderline: 2, XIMSecondary: 16: underlined text // XIMHighlight: 4: normal text