Merge remote-tracking branch 'upstream/next' into wayland
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
|
||||
#ifdef XCB_IMDKIT
|
||||
#include <xcb-imdkit/encoding.h>
|
||||
#include <xcb/xcb_keysyms.h>
|
||||
#endif
|
||||
#include <cairo-xcb.h>
|
||||
#include <cairo.h>
|
||||
@@ -91,6 +92,7 @@ struct _xcb_stuff xcb_int = {.connection = NULL,
|
||||
.screen = NULL,
|
||||
#ifdef XCB_IMDKIT
|
||||
.im = NULL,
|
||||
.syms = NULL,
|
||||
#endif
|
||||
.screen_nbr = -1,
|
||||
.sndisplay = NULL,
|
||||
@@ -127,13 +129,13 @@ const struct {
|
||||
} cursor_names[] = {
|
||||
{"default", "left_ptr"}, {"pointer", "hand"}, {"text", "xterm"}};
|
||||
|
||||
static xcb_visualtype_t *lookup_visual(xcb_screen_t *s, xcb_visualid_t visual) {
|
||||
static xcb_visualtype_t *lookup_visual(xcb_screen_t *s, xcb_visualid_t vis) {
|
||||
xcb_depth_iterator_t d;
|
||||
d = xcb_screen_allowed_depths_iterator(s);
|
||||
for (; d.rem; xcb_depth_next(&d)) {
|
||||
xcb_visualtype_iterator_t v = xcb_depth_visuals_iterator(d.data);
|
||||
for (; v.rem; xcb_visualtype_next(&v)) {
|
||||
if (v.data->visual_id == visual) {
|
||||
if (v.data->visual_id == vis) {
|
||||
return v.data;
|
||||
}
|
||||
}
|
||||
@@ -1188,7 +1190,7 @@ static gboolean x11_button_to_nk_bindings_scroll(guint32 x11_button,
|
||||
static void rofi_key_press_event_handler(xcb_key_press_event_t *xkpe,
|
||||
RofiViewState *state) {
|
||||
gchar *text;
|
||||
g_log("IMDKit", G_LOG_LEVEL_DEBUG, "press handler");
|
||||
g_log("IMDKit", G_LOG_LEVEL_DEBUG, "press handler %d", xkpe->detail);
|
||||
|
||||
xcb->last_timestamp = xkpe->time;
|
||||
if (config.xserver_i300_workaround) {
|
||||
@@ -1207,6 +1209,7 @@ static void rofi_key_press_event_handler(xcb_key_press_event_t *xkpe,
|
||||
|
||||
static void rofi_key_release_event_handler(xcb_key_release_event_t *xkre,
|
||||
G_GNUC_UNUSED RofiViewState *state) {
|
||||
g_log("IMDKit", G_LOG_LEVEL_DEBUG, "release handler %d", xkre->detail);
|
||||
xcb->last_timestamp = xkre->time;
|
||||
nk_bindings_seat_handle_key(xcb->bindings_seat, NULL, xkre->detail,
|
||||
NK_BINDINGS_KEY_STATE_RELEASE);
|
||||
@@ -1371,8 +1374,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) {
|
||||
g_log("IMDKit", G_LOG_LEVEL_DEBUG, "input xim");
|
||||
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
|
||||
{
|
||||
@@ -1384,7 +1388,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)) {
|
||||
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
|
||||
{
|
||||
@@ -1407,6 +1423,7 @@ void x11_event_handler_fowarding(G_GNUC_UNUSED xcb_xim_t *im,
|
||||
if (state == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t type = event->response_type & ~0x80;
|
||||
if (type == XCB_KEY_PRESS) {
|
||||
rofi_key_press_event_handler(event, state);
|
||||
@@ -1414,6 +1431,7 @@ void x11_event_handler_fowarding(G_GNUC_UNUSED xcb_xim_t *im,
|
||||
xcb_key_release_event_t *xkre = (xcb_key_release_event_t *)event;
|
||||
rofi_key_release_event_handler(xkre, state);
|
||||
}
|
||||
rofi_view_maybe_update(state);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1434,9 +1452,8 @@ static gboolean main_loop_x11_event_handler(xcb_generic_event_t *ev,
|
||||
}
|
||||
|
||||
#ifdef XCB_IMDKIT
|
||||
if (xcb->im && xcb_xim_filter_event(xcb->im, ev)) {
|
||||
if (xcb->im && xcb_xim_filter_event(xcb->im, ev))
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t type = ev->response_type & ~0x80;
|
||||
@@ -1670,6 +1687,7 @@ static gboolean xcb_display_setup(GMainLoop *main_loop, NkBindings *bindings) {
|
||||
xcb->connection = g_water_xcb_source_get_connection(xcb->source);
|
||||
#ifdef XCB_IMDKIT
|
||||
xcb->im = xcb_xim_create(xcb->connection, xcb->screen_nbr, NULL);
|
||||
xcb->syms = xcb_key_symbols_alloc(xcb->connection);
|
||||
#endif
|
||||
|
||||
#ifdef XCB_IMDKIT
|
||||
@@ -1892,7 +1910,7 @@ static gboolean xcb_display_late_setup(void) {
|
||||
// Try to grab the keyboard as early as possible.
|
||||
// We grab this using the rootwindow (as dmenu does it).
|
||||
// this seems to result in the smallest delay for most people.
|
||||
if (find_arg("-normal-window") >= 0) {
|
||||
if (find_arg("-normal-window") >= 0 || find_arg("-transient-window") >= 0) {
|
||||
return TRUE;
|
||||
}
|
||||
if (find_arg("-no-lazy-grab") >= 0) {
|
||||
|
Reference in New Issue
Block a user