summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorTakao Fujiwara <tfujiwar@redhat.com>2024-04-26 01:29:26 +0900
committerTakao Fujiwara <tfujiwar@redhat.com>2024-04-26 01:29:26 +0900
commit5a1e62d77b65ba148b1c6d1d22a81dc2b07e7d9e (patch)
tree9ee1d58f7f98549deeb6d669b1efedfd81da095d /modules
parent5a14178c7cc408f425fe298aeade3dee749b1ca1 (diff)
Accept anon windows in XFilterEvent to update XIM state
When input focuses are switched quickly with shortcut keys in a Java window, the focus is sometimes lost and the Window=0 is assigned in XFilterEvent() but the XKeyEvent was forwarded by a XIM serer(IBus) with XIM_FORWARD_EVENT -> XNextEvent() -> XFilterEvent() and the event needs to be forwarded to the XIM XKeyEvent press and release filters to update the XIM state with Window=0 likes _XimPendingFilter() and _XimUnfabricateSerial(). Closes: #205, #206 Fixes: 024d229f ("ximcp: Unmark to fabricate key events with XKeyEvent serial") Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/246>
Diffstat (limited to 'modules')
-rw-r--r--modules/im/ximcp/imDefFlt.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/modules/im/ximcp/imDefFlt.c b/modules/im/ximcp/imDefFlt.c
index ed3505da..f07d4187 100644
--- a/modules/im/ximcp/imDefFlt.c
+++ b/modules/im/ximcp/imDefFlt.c
@@ -138,7 +138,8 @@ _XimPendingFilter(
static Bool
_XimProtoKeypressFilter(
Xic ic,
- XKeyEvent *ev)
+ XKeyEvent *ev,
+ Window w)
{
Xim im = (Xim)ic->core.im;
@@ -147,6 +148,9 @@ _XimProtoKeypressFilter(
_XimUnfabricateSerial(im, ev);
return NOTFILTERD;
}
+ /* w=0 is used for _XimIsFabricatedSerial() only */
+ if (!w)
+ return NOTFILTERD;
if (IS_NEGLECT_EVENT(ic, KeyPressMask))
return FILTERD;
@@ -193,13 +197,14 @@ _XimFilterKeypress(
XEvent *ev,
XPointer client_data)
{
- return _XimProtoKeypressFilter((Xic)client_data, (XKeyEvent *)ev );
+ return _XimProtoKeypressFilter((Xic)client_data, (XKeyEvent *)ev, w);
}
static Bool
_XimProtoKeyreleaseFilter(
Xic ic,
- XKeyEvent *ev)
+ XKeyEvent *ev,
+ Window w)
{
Xim im = (Xim)ic->core.im;
@@ -208,6 +213,9 @@ _XimProtoKeyreleaseFilter(
_XimUnfabricateSerial(im, ev);
return NOTFILTERD;
}
+ /* w=0 is used for _XimIsFabricatedSerial() only */
+ if (!w)
+ return NOTFILTERD;
if (IS_NEGLECT_EVENT(ic, KeyReleaseMask))
return FILTERD;
@@ -254,7 +262,7 @@ _XimFilterKeyrelease(
XEvent *ev,
XPointer client_data)
{
- return _XimProtoKeyreleaseFilter((Xic)client_data, (XKeyEvent *)ev);
+ return _XimProtoKeyreleaseFilter((Xic)client_data, (XKeyEvent *)ev, w);
}
static void
@@ -264,6 +272,11 @@ _XimRegisterKeyPressFilter(
if (ic->core.focus_window) {
if (!(ic->private.proto.registed_filter_event & KEYPRESS_MASK)) {
_XRegisterFilterByType (ic->core.im->core.display,
+ 0,
+ KeyPress, KeyPress,
+ _XimFilterKeypress,
+ (XPointer)ic);
+ _XRegisterFilterByType (ic->core.im->core.display,
ic->core.focus_window,
KeyPress, KeyPress,
_XimFilterKeypress,
@@ -281,6 +294,11 @@ _XimRegisterKeyReleaseFilter(
if (ic->core.focus_window) {
if (!(ic->private.proto.registed_filter_event & KEYRELEASE_MASK)) {
_XRegisterFilterByType (ic->core.im->core.display,
+ 0,
+ KeyRelease, KeyRelease,
+ _XimFilterKeyrelease,
+ (XPointer)ic);
+ _XRegisterFilterByType (ic->core.im->core.display,
ic->core.focus_window,
KeyRelease, KeyRelease,
_XimFilterKeyrelease,
@@ -301,6 +319,10 @@ _XimUnregisterKeyPressFilter(
ic->core.focus_window,
_XimFilterKeypress,
(XPointer)ic);
+ _XUnregisterFilter (ic->core.im->core.display,
+ 0,
+ _XimFilterKeypress,
+ (XPointer)ic);
ic->private.proto.registed_filter_event &= ~KEYPRESS_MASK;
}
}
@@ -317,6 +339,10 @@ _XimUnregisterKeyReleaseFilter(
ic->core.focus_window,
_XimFilterKeyrelease,
(XPointer)ic);
+ _XUnregisterFilter (ic->core.im->core.display,
+ 0,
+ _XimFilterKeyrelease,
+ (XPointer)ic);
ic->private.proto.registed_filter_event &= ~KEYRELEASE_MASK;
}
}