Dual screen position overridden by Linux window manager?

Hi there,
I’m on a minimal build of Ubuntu 18.04 server with Openbox on top of xorg and GTK3, using this version of wxPython:

https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04 wxPython==4.1.1

My app has been generally working great until it became a dual-screen app. It is now split across 2 monitors and needs to be robust to the user connecting & disconnecting the 2nd monitor/projector, whereupon the GUI reorganises itself between single & dual-screen modes.

Both the windows will end up on the second screen, despite reporting via GetPosition() that one of them is on the first!

On a timer I check whether the 2nd output is plugged in with:

        command ="cat /sys/class/drm/card0-HDMI-A-1/status | grep disconnected"

via subprocess.
When that happens I call xrandr to set up the screens:

        if dualScreen is True:
            command = "xrandr --output eDP-1 --mode 1280x800 --output HDMI-1 --auto --right-of eDP-1"
        else:
            command = "xrandr --output eDP-1 --mode 1280x800"

which works fine.

I then wait til wx.Display.GetCount() notices the 2nd screen, then basically:

def MoveToScreen(self, display, obj):
        screen = wx.Display(display)
        pos_w, pos_h, width, height = screen.GetGeometry()  
        obj.SetPosition((int(pos_w), int(pos_h)))
        print(f"MoveToScreen() {display}, {obj.GetTitle()} intended pos: {pos_w}, {pos_h}, {width}, {height}" ) 
        print(f"MoveToScreen() {display}, {obj.GetTitle()} check pos: ", obj.GetPosition() ) 

and my console output ends up like this:

HDMIconnected_new:  1
HDMI state changed
OS dual screen mode
wx.Display.GetCount:  2
WX display count changed
WX dual screen mode
MoveToScreen() 1, PANELTWO intended pos: 1280, 0, 1680, 1050
MoveToScreen() 1, PANELTWO check pos:  (1280, 0)
MoveToScreen() 0, PANELONE intended pos: 0, 0, 1280, 800
MoveToScreen() 0, PANELONE check pos:  (0, 0)

But it’s a horrible lie! both panels are at 1280,0 in reality.

It gets weirder: If the 2nd monitor is less than 1920x1080 it behaves ok. If it’s 1920x1080, it fails as above. (The first monitor is 1280x800.) Maybe that’s a clue or maybe it’s just confusing!

I doubt it’s actually wxPython’s problem, but hopefully someone’s seen it before. I wonder if it’s Openbox’s fault. I tried XFCE instead and it was worse.

I had something similar, though not in python at all - a little app which just does a slideshow, and puts one window on each monitor, as big as can fit, and cycles through the image library every four seconds, alternating between monitors. Worked fine for years. through two installations of W7, three or four of Ubuntu and all the linux mints until 20.2 (under wine). Then it would move the right window to the left monitor.
What I found was that the width of the toolbar (along the left edge of the right monitor) was misreported, so my code would imagine it had more width than it really did have, and thus tried to create position the window overlapping the toolbar by a few pixels.
Since this app is just my pastime, nothing distributable, I fixed it by handcoding the best fitting position, circumventing my own code which previously calculated the position (and was now wrong).
Sounds similar to your case, but then it also may be completely unrelated.

Hmm, that may be a clue, thankyou