Skip to content

Commit

Permalink
Try to support modifiers in XIM again
Browse files Browse the repository at this point in the history
  • Loading branch information
amosbird committed Aug 2, 2024
1 parent 8530754 commit 8e8cecd
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions source/xcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1375,14 +1375,9 @@ static void main_loop_x11_event_handler_view(xcb_generic_event_t *event) {
xcb_key_press_event_t *xkpe = (xcb_key_press_event_t *)event;
#ifdef XCB_IMDKIT
if (xcb->ic) {
xcb_keysym_t sym = xcb_key_press_lookup_keysym(xcb->syms, xkpe, 0);
if (xcb_is_modifier_key(sym)) {
rofi_key_press_event_handler(xkpe, state);
} else {
g_log("IMDKit", G_LOG_LEVEL_DEBUG, "press key %d to xim", xkpe->detail);
xcb_xim_forward_event(xcb->im, xcb->ic, xkpe);
return;
}
g_log("IMDKit", G_LOG_LEVEL_DEBUG, "press key %d to xim", xkpe->detail);
xcb_xim_forward_event(xcb->im, xcb->ic, xkpe);
return;
} else
#endif
{
Expand All @@ -1394,14 +1389,19 @@ static void main_loop_x11_event_handler_view(xcb_generic_event_t *event) {
xcb_key_release_event_t *xkre = (xcb_key_release_event_t *)event;
#ifdef XCB_IMDKIT
if (xcb->ic) {
g_log("IMDKit", G_LOG_LEVEL_DEBUG, "release key %d to xim", xkre->detail);

// Check if the keysym is a modifier key (e.g., Shift, Ctrl, Alt). If it
// is, sleep for 5 milliseconds as a workaround for XCB XIM limitation.
// This sleep helps to ensure that XCB XIM can properly handle subsequent
// key events that may occur rapidly after a modifier key is pressed.
xcb_keysym_t sym = xcb_key_press_lookup_keysym(xcb->syms, xkre, 0);
if (xcb_is_modifier_key(sym)) {
rofi_key_press_event_handler(xkre, state);
} else {
g_log("IMDKit", G_LOG_LEVEL_DEBUG, "release key %d to xim", xkre->detail);
xcb_xim_forward_event(xcb->im, xcb->ic, xkre);
return;
struct timespec five_millis = {.tv_sec = 0, .tv_nsec = 5000000};
nanosleep(&five_millis, NULL);
}
xcb_xim_forward_event(xcb->im, xcb->ic, xkre);
return;
} else
#endif
{
Expand Down

0 comments on commit 8e8cecd

Please sign in to comment.