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.