Subject: bug#74590: 31.0.50 [scratch/igc branch]; key input sometimes skip fcitx input method preedit box

From: Yikai Zhao <[email-masked]>
Date: Wed, 4 Dec 2024 12:55:04 +0800

Here attached the relevant output of "xscope".

t=116.64 is approximately the timestamp of a correct keypress (that
goes to fcitx);
t=116.83 is approximately the timestamp of an incorrect keypress (that
goes to emacs).

I just realized that you mentioned the x11trace tool. I will also try
to reproduce with x11trace later.

---

116.64:                      120 bytes <-- X11 Server 3 (pid 3359 Xorg)
                     ..............EVENT: GenericEvent
                               extension: XInputExtension
                              event type: 0002
                                    data: (27)
116.64: Client 3 -->  140 bytes
     ............REQUEST: ChangeProperty
                    mode: Replace
                  window: WIN 06e000b4
                property: <_NET_WM_USER_TIME>
                    type: <CARDINAL>
                  format: 20
                    data: 4b367e4c
     ............REQUEST: ChangeProperty
                    mode: Append
                  window: WIN 0020015a
                property: <_client10>
                    type: <STRING>
                  format: 08
                    data:
"<^@^J^@`^@{^@^@^@^@^@^B6]\254L~6K\373^A^@^@\265^@\340^F^@^@^@^@\200^F^H^B,^Bb^A^@^@^A^@"
     ............REQUEST: SendEvent
               propagate: False
             destination: WIN 0020015a
              event-mask: 0
                   event:                      ..............EVENT:
ClientMessage
                                  format: 20
                                  window: WIN 0020015a
                                    type: <_XIM_PROTOCOL>
                                    data: 2c 00 00 00 ec 02

116.64:                       32 bytes <-- X11 Server 3 (pid 3359 Xorg)
                     ..............EVENT: PropertyNotify
                                  window: WIN 06e000b4
                                    atom: <_NET_WM_USER_TIME>
                                    time: TIM 4b367e51
                                   state: NewValue
116.70:                      120 bytes <-- X11 Server 3 (pid 3359 Xorg)
                     ..............EVENT: GenericEvent
                               extension: XInputExtension
                              event type: 0003
                                    data: (27)
116.71: Client 3 -->   20 bytes
     ............REQUEST: InternAtom
          only-if-exists: False
                    name: "_client11"
116.71:                       32 bytes <-- X11 Server 3 (pid 3359 Xorg)
                     ..............REPLY: InternAtom
                                    atom: <_client11>
116.71: Client 3 -->  112 bytes
     ............REQUEST: ChangeProperty
                    mode: Append
                  window: WIN 0020015a
                property: <_client11>
                    type: <STRING>
                  format: 08
                    data:
"<^@^J^@`^@{^@^@^@^@^@^C6`\254\221~6K\373^A^@^@\265^@\340^F^@^@^@^@\200^F^H^B,^Bb^A^@^@^A^@"
     ............REQUEST: SendEvent
               propagate: False
             destination: WIN 0020015a
              event-mask: 0
                   event:                      ..............EVENT:
ClientMessage
                                  format: 20
                                  window: WIN 0020015a
                                    type: <_XIM_PROTOCOL>
                                    data: 2c 00 00 00 ed 02

116.71:                       32 bytes <-- X11 Server 3 (pid 3359 Xorg)
                     ..............EVENT: ClientMessage
                                  source: SendEvent
                                  format: 20
                                  window: WIN 06e0001c
                                    type: <_XIM_PROTOCOL>
                                    data: 2c 00 00 00 ed fb
116.71: Client 3 -->   24 bytes
     ............REQUEST: GetProperty
                  delete: True
                  window: WIN 06e0001c
                property: ATM 0000fbed
                    type: AnyPropertyType
             long-offset: 00000000
116.71:                       76 bytes <-- X11 Server 3 (pid 3359 Xorg)
                     ..............REPLY: GetProperty
                                  format: 08
                                    type: <STRING>
                             bytes-after: 00000000
                                   value:
"<^@^J^@`^@{^@^A^@^@^@^C6`\254\221~6K\373^A^@^@\265^@\340^F^@^@^@^@^@^@^@^@,^Bb^A^@^@^@^@"
116.83:                      120 bytes <-- X11 Server 3 (pid 3359 Xorg)
                     ..............EVENT: GenericEvent
                               extension: XInputExtension
                              event type: 0002
                                    data: (27)
116.83: Client 3 -->  164 bytes
     ............REQUEST: ChangeProperty
                    mode: Replace
                  window: WIN 06e000b4
                property: <_NET_WM_USER_TIME>
                    type: <CARDINAL>
                  format: 20
                    data: 4b367f10
     ............REQUEST: SendEvent
               propagate: False
             destination: WIN 0020015a
              event-mask: 0
                   event:                      ..............EVENT:
ClientMessage
                                  format: 08
                                  window: WIN 0020015a
                                    type: <_XIM_PROTOCOL>
                                    data: 3e 00 01 00 60 00

     ............REQUEST: ChangeProperty
                    mode: Append
                  window: WIN 0020015a
                property: <_client12>
                    type: <STRING>
                  format: 08
                    data: "6^@^E^@`^@{^@^L^@^@^@^F^@^H^@^P^@^D^@,^@\256^A"
     ............REQUEST: SendEvent
               propagate: False
             destination: WIN 0020015a
              event-mask: 0
                   event:                      ..............EVENT:
ClientMessage
                                  format: 20
                                  window: WIN 0020015a
                                    type: <_XIM_PROTOCOL>
                                    data: 18 00 00 00 ee 02

116.83:                       32 bytes <-- X11 Server 3 (pid 3359 Xorg)
                     ..............EVENT: PropertyNotify
                                  window: WIN 06e000b4
                                    atom: <_NET_WM_USER_TIME>
                                    time: TIM 4b367f10
                                   state: NewValue
116.83:                       32 bytes <-- X11 Server 3 (pid 3359 Xorg)
                     ..............EVENT: ClientMessage
                                  source: SendEvent
                                  format: 08
                                  window: WIN 06e0001c
                                    type: <_XIM_PROTOCOL>
                                    data: 37 00 01 00 60 00
116.83: Client 3 -->   92 bytes
     ............REQUEST: ChangeProperty
                    mode: Append
                  window: WIN 0020015a
                property: <_client13>
                    type: <STRING>
                  format: 08
                    data: "6^@^E^@`^@{^@^L^@^@^@^F^@^H^@^P^@^D^@,^@\256^A"
     ............REQUEST: SendEvent
               propagate: False
             destination: WIN 0020015a
              event-mask: 0
                   event:                      ..............EVENT:
ClientMessage
                                  format: 20
                                  window: WIN 0020015a
                                    type: <_XIM_PROTOCOL>
                                    data: 18 00 00 00 ef 02

116.83:                       32 bytes <-- X11 Server 3 (pid 3359 Xorg)
                     ..............EVENT: ClientMessage
                                  source: SendEvent
                                  format: 08
                                  window: WIN 06e0001c
                                    type: <_XIM_PROTOCOL>
                                    data: 37 00 01 00 60 00
116.83: Client 3 -->  324 bytes
     ............REQUEST: SetClipRectangles
                ordering: UnSorted
                      gc: GXC 06e006c5
           clip-x-origin: 0
           clip-y-origin: 0
              rectangles: (1)
     ............REQUEST: RenderRequest
           RENDERREQUEST: RenderFillRectangles
                      op: Src
                    dest: PICTURE 06e000fc
                   color: COLOR r:fdfd g:f6f6 b:e3e3 a:ffff
              rectangles: (1)
     ............REQUEST: RenderRequest
           RENDERREQUEST: RenderCompositeGlyphs8
                      op: Over
                  source: PICTURE 06e006cc
                    dest: PICTURE 06e000fc
             mask format: None
                glyphset: GLYPHSET 06e00104
                   x-src: 44
                   y-src: 424
                   items:
                 delta x: 44
                 delta y: 424
     glyph item 8 string: "I"
     ............REQUEST: ChangeGC
                      gc: GXC 06e006c5
              value-mask: clip-mask
              value-list:
                   clip-mask: None
     ............REQUEST: SetClipRectangles
                ordering: UnSorted
                      gc: GXC 06e006c5
           clip-x-origin: 0
           clip-y-origin: 0
              rectangles: (1)
     ............REQUEST: RenderRequest
           RENDERREQUEST: RenderFillRectangles
                      op: Src
                    dest: PICTURE 06e000fc
                   color: COLOR r:fdfd g:f6f6 b:e3e3 a:ffff
              rectangles: (1)
     ............REQUEST: ChangeGC
                      gc: GXC 06e006c5
              value-mask: clip-mask
              value-list:
                   clip-mask: None
     ............REQUEST: SetClipRectangles
                ordering: UnSorted
                      gc: GXC 06e0012f
           clip-x-origin: 0
           clip-y-origin: 0
              rectangles: (1)
     ............REQUEST: RenderRequest
           RENDERREQUEST: RenderFillRectangles
                      op: Src
                    dest: PICTURE 06e000fc
                   color: COLOR r:6565 g:7b7b b:8383 a:ffff
              rectangles: (1)
     ............REQUEST: ChangeGC
                      gc: GXC 06e0012f
              value-mask: clip-mask
              value-list:
                   clip-mask: None
     ............REQUEST: ChangeProperty
                    mode: Append
                  window: WIN 0020015a
                property: <_client14>
                    type: <STRING>
                  format: 08
                    data: "6^@^E^@`^@{^@^L^@^@^@^F^@^H^@^P^@^D^@5^@\256^A"
     ............REQUEST: SendEvent
               propagate: False
             destination: WIN 0020015a
              event-mask: 0
                   event:                      ..............EVENT:
ClientMessage
                                  format: 20
                                  window: WIN 0020015a
                                    type: <_XIM_PROTOCOL>
                                    data: 18 00 00 00 f3 02

116.84:                       32 bytes <-- X11 Server 3 (pid 3359 Xorg)
                     ..............EVENT: ClientMessage
                                  source: SendEvent
                                  format: 08
                                  window: WIN 06e0001c
                                    type: <_XIM_PROTOCOL>
                                    data: 37 00 01 00 60 00
116.84: Client 3 -->   16 bytes
     ............REQUEST: DOUBLE-BUFFER-Request
            minor opcode: 03
                    data: (3)
116.90:                      120 bytes <-- X11 Server 3 (pid 3359 Xorg)
                     ..............EVENT: GenericEvent
                               extension: XInputExtension
                              event type: 0003
                                    data: (27)
116.90: Client 3 -->  112 bytes
     ............REQUEST: ChangeProperty
                    mode: Append
                  window: WIN 0020015a
                property: <_client15>
                    type: <STRING>
                  format: 08
                    data:
"<^@^J^@`^@{^@^@^@^@^@^C^Zw\254Q<del>6K\373^A^@^@\265^@\340^F^@^@^@^@\200^F^H^B,^Bb^A^@^@^A^@"
     ............REQUEST: SendEvent
               propagate: False
             destination: WIN 0020015a
              event-mask: 0
                   event:                      ..............EVENT:
ClientMessage
                                  format: 20
                                  window: WIN 0020015a
                                    type: <_XIM_PROTOCOL>
                                    data: 2c 00 00 00 f5 02

116.90:                       32 bytes <-- X11 Server 3 (pid 3359 Xorg)
                     ..............EVENT: ClientMessage
                                  source: SendEvent
                                  format: 20
                                  window: WIN 06e0001c
                                    type: <_XIM_PROTOCOL>
                                    data: 2c 00 00 00 ee fb
116.90: Client 3 -->   24 bytes
     ............REQUEST: GetProperty
                  delete: True
                  window: WIN 06e0001c
                property: ATM 0000fbee
                    type: AnyPropertyType
             long-offset: 00000000
116.90:                       76 bytes <-- X11 Server 3 (pid 3359 Xorg)
                     ..............REPLY: GetProperty
                                  format: 08
                                    type: <STRING>
                             bytes-after: 00000000
                                   value:
"<^@^J^@`^@{^@^A^@^@^@^C^Zw\254Q<del>6K\373^A^@^@\265^@\340^F^@^@^@^@^@^@^@^@,^Bb^A^@^@^@^@"
116.90: Client 3 -->   44 bytes
     ............REQUEST: SendEvent
               propagate: False
             destination: WIN 0020015a
              event-mask: 0
                   event:                      ..............EVENT:
ClientMessage
                                  format: 08
                                  window: WIN 0020015a
                                    type: <_XIM_PROTOCOL>
                                    data: 3e 00 01 00 60 00

116.93:                      120 bytes <-- X11 Server 3 (pid 3359 Xorg)
                     ..............EVENT: GenericEvent
                               extension: XInputExtension
                              event type: 0002
                                    data: (27)
116.93: Client 3 -->  140 bytes
     ............REQUEST: ChangeProperty
                    mode: Replace
                  window: WIN 06e000b4
                property: <_NET_WM_USER_TIME>
                    type: <CARDINAL>
                  format: 20
                    data: 4b367f73
     ............REQUEST: ChangeProperty
                    mode: Append
                  window: WIN 0020015a
                property: <_client16>
                    type: <STRING>
                  format: 08
                    data:
"<^@^J^@`^@{^@^@^@^@^@^B^^{\254s<del>6K\373^A^@^@\265^@\340^F^@^@^@^@\200^F^H^B,^Bb^A^@^@^A^@"
     ............REQUEST: SendEvent
               propagate: False
             destination: WIN 0020015a
              event-mask: 0
                   event:                      ..............EVENT:
ClientMessage
                                  format: 20
                                  window: WIN 0020015a
                                    type: <_XIM_PROTOCOL>
                                    data: 2c 00 00 00 f6 02

116.93:                       32 bytes <-- X11 Server 3 (pid 3359 Xorg)
                     ..............EVENT: PropertyNotify
                                  window: WIN 06e000b4
                                    atom: <_NET_WM_USER_TIME>
                                    time: TIM 4b367f73
                                   state: NewValue

On Tue, Dec 3, 2024 at 12:26 AM Pip Cet <[email-masked]> wrote:
>
> "Yikai Zhao" <[email-masked]> writes:
>
> > I have reproduced the issue with your patch, here's the relevant log:
>
> Thank you! So it seems we call XFilterEvent correctly but it incorrectly
> indicates that the keypress (event 2) should be handled by Emacs rather
> than the input method. That's rather puzzling, particularly since
> subsequent calls to XFilterEvent return 1, indicating that the key
> release is handled by the input method.
>
> I'm pretty much stumped at this point. It might be a timing difference
> between the MPS and non-MPS builds, but I think it's more likely to be
> a bug in our MPS code.
>
> > Please let me know if there's any other info I can provide.
>
> Well, you already tried setting x-gtk-use-native-input to t :-)
>
> One thing you could try is to run a full x11trace of the Emacs session
> and see whether anything unusual is in there. But that's not guaranteed
> to yield any results.
>
> Pip
>