diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-10-05 16:39:31 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-10-05 16:39:31 +0800 |
commit | f502391ceb2fc7fd441718d2152ef14e2ec24973 (patch) | |
tree | b25b50c7eaaf3309723858098ea113a959eaa407 /src/platform/gui/xcb/InputMethod.cpp | |
parent | 047e0eba34c669ff71535602c09edec587912059 (diff) | |
download | cru-f502391ceb2fc7fd441718d2152ef14e2ec24973.tar.gz cru-f502391ceb2fc7fd441718d2152ef14e2ec24973.tar.bz2 cru-f502391ceb2fc7fd441718d2152ef14e2ec24973.zip |
Use xkb.
Diffstat (limited to 'src/platform/gui/xcb/InputMethod.cpp')
-rw-r--r-- | src/platform/gui/xcb/InputMethod.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/platform/gui/xcb/InputMethod.cpp b/src/platform/gui/xcb/InputMethod.cpp index 61753bf3..90bc8f66 100644 --- a/src/platform/gui/xcb/InputMethod.cpp +++ b/src/platform/gui/xcb/InputMethod.cpp @@ -28,8 +28,11 @@ XcbXimInputMethodManager::XcbXimInputMethodManager( if ((event->response_type & ~0x80) == XCB_KEY_PRESS) { manager->DispatchCommit( im, ic, - XorgKeysymToUtf8(XorgKeycodeToKeysyms(manager->application_, - event->detail)[0])); + manager->application_->GetXcbKeyboardManager()->KeycodeToUtf8( + event->detail)); + } else { + if (manager->forward_event_callback_) + manager->forward_event_callback_(event); } }, .commit_string = @@ -41,7 +44,8 @@ XcbXimInputMethodManager::XcbXimInputMethodManager( if (flag & XCB_XIM_LOOKUP_KEYSYM) { std::string text; for (int i = 0; i < nKeySym; i++) { - text += XorgKeysymToUtf8(keysym[i]); + text += manager->application_->GetXcbKeyboardManager() + ->KeysymToUtf8(keysym[i]); } manager->DispatchCommit(im, ic, std::move(text)); } @@ -113,11 +117,17 @@ bool XcbXimInputMethodManager::HandleXEvent(xcb_generic_event_t *event) { if (context->ic_ && (((event->response_type & ~0x80) == XCB_KEY_PRESS) || ((event->response_type & ~0x80) == XCB_KEY_RELEASE))) { xcb_xim_forward_event(im_, *context->ic_, (xcb_key_press_event_t *)event); + return true; } } return false; } +void XcbXimInputMethodManager::SetXimServerUnprocessedXEventCallback( + std::function<void(xcb_key_press_event_t *event)> callback) { + forward_event_callback_ = std::move(callback); +} + XcbXimInputMethodContext::XcbXimInputMethodContext( XcbXimInputMethodManager *manager, XcbWindow *window) : manager_(manager), window_(window), enabled_(false) { |