xpra icon
Bug tracker and wiki

Opened 3 weeks ago

Last modified 25 hours ago

#1999 new defect

xterm regression: popup window does not get focus

Reported by: Antoine Martin Owned by: J. Max Mena
Priority: critical Milestone: 2.5
Component: core Version: 2.4.x
Keywords: Cc:

Description

Reported on the mailing list here: Xterm menus no mouse tracking.

Only occurs on parts of the popup window that overlap with the xterm window.

Change History (5)

comment:1 Changed 3 weeks ago by Antoine Martin

Easy-ish to bisect:

  • r20795 bad
  • r17000 does not build..
  • r16000 bad
  • r12000 OK - built for expediency with --without-nvenc4 --without-nvenc5 --without-nvenc6 --without-vpx --without-dec_avcodec2 --without-printing --without-html5 (avoids build errors)
  • r13500 OK - build with --without-nvenc7 --without-vpx --without-dec_avcodec2 --without-printing --without-html5 --without-enc_ffmpeg --without-enc_x265 to avoid x265 crashes, etc
  • r14250 bad
  • r13850 bad
  • r13700 bad
  • r13600 OK
  • r13650 OK
  • r13675 OK
  • r13687 OK
  • r13694 bad
  • r13690 bad
  • r13689 OK

The problem comes from r13690, which is a relatively small changeset, but one with big implications.
The commit message links to #770, #1293, #911 and #469!

And indeed, using this env var "fixes" things:

XPRA_REPARENT_ROOT=0 xpra start ...

Let's try to find a workaround that doesn't require reverting this switch.

comment:2 Changed 2 weeks ago by Antoine Martin

Recording the window tree using sleep 5;DISPLAY=:15 xwininfo -root -tree;DISPLAY=:15 xdotool getactivewindow:

  • start-desktop, just an xterm running (and showing the control popup) - works:
    xwininfo: Window id: 0x299 (the root window) (has no name)
    
      Root window id: 0x299 (the root window) (has no name)
      Parent window id: 0x0 (none)
         9 children:
         0xc0004e (has no name): ()  218x428+186+136  +186+136
         0xe00001 "Xpra Audio record": ("Xpra-Audio-record" "Xpra-Audio-record")  10x10+10+10  +10+10
         0xc00022 "antoine@desktop:~/projects/Xpra/trunk/src": ("xterm" "XTerm")  499x316+0+0  +0+0
            1 child:
            0xc0002d (has no name): ()  499x316+0+0  +1+1
               1 child:
               0xc00033 (has no name): ()  14x316+-1+-1  +0+0
         0x40001c "Xpra": ()  10x10+-100+-100  +-100+-100
         0x40001b "Xpra": ()  10x10+-100+-100  +-100+-100
         0x40001a "Xpra": ()  10x10+-100+-100  +-100+-100
         0x400003 "Xpra-ManagerSelection": ()  10x10+-100+-100  +-100+-100
         0x400001 "xpra": ("xpra" "Xpra")  10x10+10+10  +10+10
            1 child:
            0x400002 (has no name): ()  1x1+-1+-1  +9+9
         0x200001 "xpra": ("xpra" "Xpra")  10x10+10+10  +10+10
            1 child:
            0x200002 (has no name): ()  1x1+-1+-1  +9+9
    
    Your windowmanager claims not to support _NET_ACTIVE_WINDOW, so the attempt to query the active window aborted.
    xdo_get_active_window reported an error
    
  • with metacity as window manager added:
    xwininfo: Window id: 0x299 (the root window) (has no name)
    
      Root window id: 0x299 (the root window) (has no name)
      Parent window id: 0x0 (none)
         18 children:
         0xc0004e (has no name): ()  218x428+262+267  +262+267
         0x100019a "metacity": ("metacity" "Metacity")  200x200+0+0  +0+0
            1 child:
            0x100019b (has no name): ()  1x1+-1+-1  +-1+-1
         0x100000e "metacity": ("metacity" "Metacity")  1x1+-200+-200  +-200+-200
            1 child:
            0x100000f (has no name): ()  1x1+-1+-1  +-201+-201
         0x1000021 (has no name): ()  551x405+32+50  +32+50
            1 child:
            0xc00022 "antoine@desktop:~/projects/Xpra/trunk/src": ("xterm" "XTerm")  499x316+26+60  +58+110
               1 child:
               0xc0002d (has no name): ()  499x316+0+0  +58+110
                  1 child:
                  0xc00033 (has no name): ()  14x316+-1+-1  +57+109
         0x1000019 (has no name): ()  1x1+-1+-1  +-1+-1
         0x1000012 (has no name): ()  1x1+-100+-100  +-100+-100
         0x100000c (has no name): ()  1x1+-100+-100  +-100+-100
         0x1000004 (has no name): ()  1x1+-100+-100  +-100+-100
         0x1000003 (has no name): ()  1x1+-100+-100  +-100+-100
         0x1000002 "Metacity": ()  1x1+-100+-100  +-100+-100
         0x1000001 "metacity": ("metacity" "Metacity")  10x10+10+10  +10+10
         0xe00001 "Xpra Audio record": ("Xpra-Audio-record" "Xpra-Audio-record")  10x10+10+10  +10+10
         0x40001c "Xpra": ()  10x10+-100+-100  +-100+-100
         0x40001b "Xpra": ()  10x10+-100+-100  +-100+-100
         0x40001a "Xpra": ()  10x10+-100+-100  +-100+-100
         0x400003 "Xpra-ManagerSelection": ()  10x10+-100+-100  +-100+-100
         0x400001 "xpra": ("xpra" "Xpra")  10x10+10+10  +10+10
            1 child:
            0x400002 (has no name): ()  1x1+-1+-1  +9+9
         0x200001 "xpra": ("xpra" "Xpra")  10x10+10+10  +10+10
            1 child:
            0x200002 (has no name): ()  1x1+-1+-1  +9+9
    
    12582946
    $ python -c 'print(hex(12582946))'
    0xc00022
    
  • with sawfish:
    xwininfo: Window id: 0x299 (the root window) (has no name)
    
      Root window id: 0x299 (the root window) (has no name)
      Parent window id: 0x0 (none)
         11 children:
         0xc0004e (has no name): ()  218x428+272+221  +272+221
         0x1000025 (has no name): ()  507x344+58+73  +58+73
            20 children:
            0x10000a6 (has no name): ()  32x20+470+2  +528+75
            0x10000a3 (has no name): ()  32x20+438+2  +496+75
            0x10000a0 (has no name): ()  32x20+406+2  +464+75
            0x100009d (has no name): ()  4x316+503+24  +561+97
            0x100009a (has no name): ()  4x4+503+340  +561+413
            0x1000097 (has no name): ()  499x4+4+340  +62+413
            0x1000094 (has no name): ()  4x4+0+340  +58+413
            0x1000091 (has no name): ()  4x316+0+24  +58+97
            0x100008e (has no name): ()  32x20+4+2  +62+75
            0x100008b (has no name): ()  32x20+36+2  +94+75
            0x1000088 (has no name): ()  32x20+68+2  +126+75
            0x1000085 (has no name): ()  1x20+502+2  +560+75
            0x1000082 (has no name): ()  4x24+503+0  +561+73
            0x100007f (has no name): ()  4x24+0+0  +58+73
            0x100007c (has no name): ()  499x2+4+22  +62+95
            0x1000079 (has no name): ()  3x20+403+2  +461+75
            0x1000076 (has no name): ()  22x20+100+2  +158+75
            0x1000073 (has no name): ()  292x20+111+2  +169+75
            0x1000070 (has no name): ()  499x2+4+0  +62+73
            0xc00022 "antoine@desktop:~/projects/Xpra/trunk/src": ("xterm" "XTerm")  499x316+4+24  +62+97
               1 child:
               0xc0002d (has no name): ()  499x316+0+0  +62+97
                  1 child:
                  0xc00033 (has no name): ()  14x316+-1+-1  +61+96
         0x1000008 "Sawfish": ()  5x5+-200+-200  +-200+-200
         0x1000001 (has no name): ()  10x10+-10+-10  +-10+-10
         0xe00001 "Xpra Audio record": ("Xpra-Audio-record" "Xpra-Audio-record")  10x10+10+10  +10+10
         0x40001c "Xpra": ()  10x10+-100+-100  +-100+-100
         0x40001b "Xpra": ()  10x10+-100+-100  +-100+-100
         0x40001a "Xpra": ()  10x10+-100+-100  +-100+-100
         0x400003 "Xpra-ManagerSelection": ()  10x10+-100+-100  +-100+-100
         0x400001 "xpra": ("xpra" "Xpra")  10x10+10+10  +10+10
            1 child:
            0x400002 (has no name): ()  1x1+-1+-1  +9+9
         0x200001 "xpra": ("xpra" "Xpra")  10x10+10+10  +10+10
            1 child:
            0x200002 (has no name): ()  1x1+-1+-1  +9+9
    
    12582946
    $ python -c 'print(hex(12582946))'
    0xc00022
    
  • not showing openbox or fluxbox (those window managers create far too many windows - no idea why) - those re-parent to a window with no parent
  • twm:
    xwininfo: Window id: 0x299 (the root window) (has no name)
    
      Root window id: 0x299 (the root window) (has no name)
      Parent window id: 0x0 (none)
         14 children:
         0xc0004e (has no name): ()  218x428+271+189  +271+189
         0x100007c (has no name): ()  101x39+0+0  +0+0
         0x100007a (has no name): ()  5x5+0+0  +0+0
         0x100006b (has no name): ()  499x357+58+73  +58+73
            2 children:
            0xc00022 "antoine@desktop:~/projects/Xpra/trunk/src": ("xterm" "XTerm")  499x316+0+41  +60+116
               1 child:
               0xc0002d (has no name): ()  499x316+0+0  +60+116
                  1 child:
                  0xc00033 (has no name): ()  14x316+-1+-1  +59+115
            0x100006c (has no name): ()  499x39+-2+-2  +58+73
               3 children:
               0x1000073 (has no name): ()  63x35+392+2  +452+77
               0x1000070 (has no name): ()  31x31+463+3  +523+78
               0x100006f (has no name): ()  31x31+3+3  +63+78
         0x1000060 (has no name): ()  150x86+0+0  +0+0
            2 children:
            0x100005e "TWM Icon Manager": ()  150x45+0+41  +2+43
               1 child:
               0x1000074 (has no name): ()  150x45+0+0  +2+43
                  1 child:
                  0x1000075 (has no name): ()  11x11+5+17  +7+60
            0x1000061 (has no name): ()  150x39+-2+-2  +0+0
               3 children:
               0x100006a (has no name): ()  1x35+1280+2  +1282+4
               0x1000065 (has no name): ()  31x31+114+3  +116+5
               0x1000064 (has no name): ()  31x31+3+3  +5+5
         0x1000057 (has no name): ()  122x741+0+0  +0+0
         0x1000056 (has no name): ()  122x741+0+0  +0+0
         0xe00001 "Xpra Audio record": ("Xpra-Audio-record" "Xpra-Audio-record")  10x10+10+10  +10+10
         0x40001c "Xpra": ()  10x10+-100+-100  +-100+-100
         0x40001b "Xpra": ()  10x10+-100+-100  +-100+-100
         0x40001a "Xpra": ()  10x10+-100+-100  +-100+-100
         0x400003 "Xpra-ManagerSelection": ()  10x10+-100+-100  +-100+-100
         0x400001 "xpra": ("xpra" "Xpra")  10x10+10+10  +10+10
            1 child:
            0x400002 (has no name): ()  1x1+-1+-1  +9+9
         0x200001 "xpra": ("xpra" "Xpra")  10x10+10+10  +10+10
            1 child:
            0x200002 (has no name): ()  1x1+-1+-1  +9+9
    
  • xpra without any reparenting in take-window (patched out) - broken:
    xwininfo: Window id: 0x299 (the root window) "Xpra"
    
      Root window id: 0x299 (the root window) "Xpra"
      Parent window id: 0x0 (none)
         13 children:
         0x40002b "Xpra-CorralWindow-0xc00022": ()  499x316+0+71  +0+71
            1 child:
            0xc00022 "antoine@desktop:~/projects/Xpra/trunk/src": ("xterm" "XTerm")  499x316+0+0  +0+71
               1 child:
               0xc0002d (has no name): ()  499x316+0+0  +0+71
                  1 child:
                  0xc00033 (has no name): ()  14x316+-1+-1  +-1+70
         0xc0004e (has no name): ()  218x428+232+210  +232+210
         0xe00001 "Xpra Audio record": ("Xpra-Audio-record" "Xpra-Audio-record")  10x10+10+10  +10+10
         0x400026 (has no name): ()  1x1+-1+-1  +-1+-1
         0x400022 "Xpra-SystemTray": ()  1x1+0+0  +0+0
            1 child:
            0x400023 (has no name): ()  1x1+-1+-1  +-1+-1
         0x400020 "Xpra": ()  10x10+-100+-100  +-100+-100
         0x40001f "Xpra": ()  10x10+-100+-100  +-100+-100
         0x40001e "Xpra": ()  10x10+-100+-100  +-100+-100
         0x40001b "Xpra-WorldWindow": ("xpra" "Xpra")  3840x2160+0+0  +0+0
            1 child:
            0x40001c (has no name): ()  1x1+-1+-1  +-1+-1
         0x40001a "Xpra": ()  1x1+0+0  +0+0
         0x400003 "Xpra-ManagerSelection": ()  10x10+-100+-100  +-100+-100
         0x400001 "xpra": ("xpra" "Xpra")  10x10+10+10  +10+10
            1 child:
            0x400002 (has no name): ()  1x1+-1+-1  +9+9
         0x200001 "xpra": ("xpra" "Xpra")  10x10+10+10  +10+10
            1 child:
            0x200002 (has no name): ()  1x1+-1+-1  +9+9
    
    12582990
    $ python -c 'print(hex(12582990))'
    0xc0004e
    
  • xpra with XPRA_REPARENT_ROOT=1 (broken):
    xwininfo: Window id: 0x299 (the root window) "Xpra"
    
      Root window id: 0x299 (the root window) "Xpra"
      Parent window id: 0x0 (none)
         13 children:
         0x40002b "Xpra-CorralWindow-0xc00022": ()  499x316+0+71  +0+71
            1 child:
            0xc00022 "antoine@desktop:~/projects/Xpra/trunk/src": ("xterm" "XTerm")  499x316+0+0  +0+71
               1 child:
               0xc0002d (has no name): ()  499x316+0+0  +0+71
                  1 child:
                  0xc00033 (has no name): ()  14x316+-1+-1  +-1+70
         0xc0004e (has no name): ()  218x428+214+133  +214+133
         0xe00001 "Xpra Audio record": ("Xpra-Audio-record" "Xpra-Audio-record")  10x10+10+10  +10+10
         0x400026 (has no name): ()  1x1+-1+-1  +-1+-1
         0x400022 "Xpra-SystemTray": ()  1x1+0+0  +0+0
            1 child:
            0x400023 (has no name): ()  1x1+-1+-1  +-1+-1
         0x400020 "Xpra": ()  10x10+-100+-100  +-100+-100
         0x40001f "Xpra": ()  10x10+-100+-100  +-100+-100
         0x40001e "Xpra": ()  10x10+-100+-100  +-100+-100
         0x40001b "Xpra-WorldWindow": ("xpra" "Xpra")  3840x2160+0+0  +0+0
            1 child:
            0x40001c (has no name): ()  1x1+-1+-1  +-1+-1
         0x40001a "Xpra": ()  1x1+0+0  +0+0
         0x400003 "Xpra-ManagerSelection": ()  10x10+-100+-100  +-100+-100
         0x400001 "xpra": ("xpra" "Xpra")  10x10+10+10  +10+10
            1 child:
            0x400002 (has no name): ()  1x1+-1+-1  +9+9
         0x200001 "xpra": ("xpra" "Xpra")  10x10+10+10  +10+10
            1 child:
            0x200002 (has no name): ()  1x1+-1+-1  +9+9
    
    12582990
    $ python -c 'print(hex(12582990))'
    0xc0004e
    
  • xpra with XPRA_REPARENT_ROOT=0 (OK):
    xwininfo: Window id: 0x299 (the root window) "Xpra"
    
      Root window id: 0x299 (the root window) "Xpra"
      Parent window id: 0x0 (none)
         12 children:
         0xc0004e (has no name): ()  218x428+254+227  +254+227
         0x1000001 "Xpra Audio record": ("Xpra-Audio-record" "Xpra-Audio-record")  10x10+10+10  +10+10
         0x400028 (has no name): ()  1x1+-1+-1  +-1+-1
         0x400024 "Xpra-SystemTray": ()  1x1+0+0  +0+0
            1 child:
            0x400025 (has no name): ()  1x1+-1+-1  +-1+-1
         0x400022 "Xpra": ()  10x10+-100+-100  +-100+-100
         0x400021 "Xpra": ()  10x10+-100+-100  +-100+-100
         0x400020 "Xpra": ()  10x10+-100+-100  +-100+-100
         0x40001b "Xpra-WorldWindow": ("xpra" "Xpra")  3840x2160+0+0  +0+0
            2 children:
            0x40001f "Xpra-CorralWindow-0xc00022": ()  499x316+108+173  +108+173
               1 child:
               0xc00022 "antoine@desktop:~/projects/Xpra/trunk/src": ("xterm" "XTerm")  499x316+0+0  +108+173
                  1 child:
                  0xc0002d (has no name): ()  499x316+0+0  +108+173
                     1 child:
                     0xc00033 (has no name): ()  14x316+-1+-1  +107+172
            0x40001c (has no name): ()  1x1+-1+-1  +-1+-1
         0x40001a "Xpra": ()  1x1+0+0  +0+0
         0x400003 "Xpra-ManagerSelection": ()  10x10+-100+-100  +-100+-100
         0x400001 "xpra": ("xpra" "Xpra")  10x10+10+10  +10+10
            1 child:
            0x400002 (has no name): ()  1x1+-1+-1  +9+9
         0x200001 "xpra": ("xpra" "Xpra")  10x10+10+10  +10+10
            1 child:
            0x200002 (has no name): ()  1x1+-1+-1  +9+9
    
    12582990
    $ python -c 'print(hex(12582990))'
    0xc0004e
    

We only reparent the non-OR windows, but it's an OR window that's having this problem!
No amount of trying to force the OR popup window on top of the xterm's main window makes any difference. Yet, it really does look like the motion events are delivered to the main window instead of the popup menu..

comment:3 Changed 2 weeks ago by Antoine Martin

Status: newassigned

Got it, I think.
Pointer events get reported against the parent (non-OR) window, which means that we raise it in _move_pointer.
For some reason, that causes problems when the parent is not root - no idea why that is.
Changing this code is tricky: this could cause all sorts of stacking / focus regressions.
So maybe the easiest short term fix for 2.4 would be to selectively reparent to root (ie: not for Java windows so drag-n-drop will continue to work)

comment:4 Changed 2 weeks ago by Antoine Martin

_move_pointer calls window-model.raise_window which calls raise_ on the corral window.
This pygtk call delegates to gdk_window_raise, the docstring reads: Raises @window to the top of the Z-order (stacking order), so that other windows with the same parent window appear below @window. This is true whether or not the windows are visible.

Deep breath.

Managing stacking is not easy, see Braindump: How to get window stacking right - a great read.

So, simply taking out the calls to raise_window "fixes" the problem, but we can't use this solution: we have no way of knowing what the window stacking is really like on the client side, and the client's window manager is free to re-arrange the window stacking at any point without telling us (we only get notified for big events like iconification, focus lost or gained - but not window stacking changes, especially on other platforms like win32 or macos).
The call to raise_window ensures that the window which is meant to receive the pointer motion event really is the one on top, as there could be multiple overlapping windows at those exact coordinates.

The reason why "reparent to root" makes a difference is to do with how the window stack is searched for siblings during XRaiseWindow. When we don't "reparent to root", the search stops at the world window.

The solution adopted in r20890 is to keep track of the window we last raised and not raise it again. This works with override-redirect windows since the pointer events are still reported against the non-OR window.
This may not work if pagers or the application themselves somehow re-arrange the stacking from underneath us.

r20892 tries to ensure that we do re-raise it again after events that may have pushed the window down the stack: new non-OR windows, focus events, raised_window requests.

Still TODO:

  • backport
  • more testing
  • do we still need XPRA_OSX_FOCUS_WORKAROUND=1 - even with GTK3?
Last edited 2 weeks ago by Antoine Martin (previous) (diff)

comment:5 Changed 25 hours ago by Antoine Martin

Owner: changed from Antoine Martin to J. Max Mena
Status: assignednew

The backport to v2.4 was in r20893 and this was included in version 2.4.1

@maxmylyn: I've never managed to reproduce the macos focus bug reliably, can you reproduce it with / without the workaround?
If not then let's just close this ticket and leave it as-is.

Note: See TracTickets for help on using tickets.