Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wxpython on Wayland is unable to interact with screen coordinates (move a window, GetScreenPosition, etc.)

I found this the hard way. I dove into source code of wx.lib.agw.aui.framemanager and tried to figure out why docking hints don't work properly. I have checked every step until in the very end of calculating a place to draw a hint there was a method ClientToScreen(self,x,y) which should return x,y with an offset of self: wx.Window, but returns x,y with the same offset every time. Then I tried specifying the starting position in the constructor of my main frame, which didn't have any effect on the position of the frame. Then I checked an output from GetScreenPosition while handling EVT_MOVE and it turns out that EVT_MOVE is not even emitted on Wayland, except when you use Move or maximize/minimize the frame (maybe in some other cases, but I have only found mentioned cases).

Inside EVT_MOVE handler GetScreenPosition returns:

  • (0,0) when you maximize the window,
  • the coordinates that you specify in Move when triggered by it (but the Move itself doesn't work)
  • (26, 23) in other cases (including calling it in other places)

Is this a known bug? Maybe I am the only one experiencing it. If not, I will add an issue in wxWidgets/Phoenix.

edit: python 3.6.9, wxPython 4.0.7, Ubuntu 18.04.1, Gnome 3.28.4

like image 211
yar Avatar asked Oct 23 '25 17:10

yar


1 Answers

https://lists.freedesktop.org/archives/wayland-devel/2015-September/024410.html

It is a design decision in Wayland/desktop to not expose absolute window positions to clients at all. This means that you simply cannot know where a top-level window is precisely, you can only know which outputs it overlaps with.

You can set an environment variable GDK_BACKEND=x11 to force Xwayland and the problem is solved. It doesn't seem to be a long term solution, but it works.

like image 192
yar Avatar answered Oct 26 '25 05:10

yar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!