From: Po Lu Date: Mon, 22 Nov 2021 06:06:18 +0000 (+0800) Subject: Move XI2 event filtering to a more appropriate location X-Git-Tag: emacs-29.0.90~2852^2~116 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8aea4721d9fadfaaabfea7843df71b62e3fb94a7;p=emacs.git Move XI2 event filtering to a more appropriate location * src/xterm.c (handle_one_xevent): Filter all key press events even if no frame is found. --- diff --git a/src/xterm.c b/src/xterm.c index 4e7ecd840ef..197776ce316 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -10312,6 +10312,36 @@ handle_one_xevent (struct x_display_info *dpyinfo, ptrdiff_t i; int nchars, len; +#if defined (USE_X_TOOLKIT) || defined (USE_GTK) + /* Dispatch XI_KeyPress events when in menu. */ + if (popup_activated ()) + goto XI_OTHER; +#endif + +#ifdef HAVE_X_I18N + XKeyPressedEvent xkey; + + memset (&xkey, 0, sizeof xkey); + + xkey.type = KeyPress; + xkey.serial = 0; + xkey.send_event = xev->send_event; + xkey.display = xev->display; + xkey.window = xev->event; + xkey.root = xev->root; + xkey.subwindow = xev->child; + xkey.time = xev->time; + xkey.state = xev->mods.effective; + xkey.keycode = xev->detail; + xkey.same_screen = True; + + if (x_filter_event (dpyinfo, (XEvent *) &xkey)) + { + *finish = X_EVENT_DROP; + goto XI_OTHER; + } +#endif + #ifdef HAVE_XKB if (dpyinfo->xkb_desc) { @@ -10341,12 +10371,6 @@ handle_one_xevent (struct x_display_info *dpyinfo, x_display_set_last_user_time (dpyinfo, xev->time); ignore_next_mouse_click_timeout = 0; -#if defined (USE_X_TOOLKIT) || defined (USE_GTK) - /* Dispatch XI_KeyPress events when in menu. */ - if (popup_activated ()) - goto XI_OTHER; -#endif - f = x_any_window_to_frame (dpyinfo, xev->event); /* If mouse-highlight is an integer, input clears out @@ -10385,25 +10409,6 @@ handle_one_xevent (struct x_display_info *dpyinfo, inev.ie.timestamp = xev->time; #ifdef HAVE_X_I18N - XKeyPressedEvent xkey; - - memset (&xkey, 0, sizeof xkey); - - xkey.type = KeyPress; - xkey.serial = 0; - xkey.send_event = xev->send_event; - xkey.display = xev->display; - xkey.window = xev->event; - xkey.root = xev->root; - xkey.subwindow = xev->child; - xkey.time = xev->time; - xkey.state = state; - xkey.keycode = keycode; - xkey.same_screen = True; - - if (x_filter_event (dpyinfo, (XEvent *) &xkey)) - goto xi_done_keysym; - if (FRAME_XIC (f)) { Status status_return;