SetMinSize() and SetSizeHints() platform differences with X11 and Wayland

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
hamishmb
Knows some wx things
Knows some wx things
Posts: 29
Joined: Mon Jul 08, 2019 8:48 pm
Location: /usr/lib/python3/

SetMinSize() and SetSizeHints() platform differences with X11 and Wayland

Post by hamishmb »

Platform: Fedora 32 (also seems to affect 30, 31, and 33 beta)
Compiler: Unsure how to determine, but official package from Fedora 32 (Python3 reports compiler as GCC 10.2.1 20200723, so likely the same)
wx version: 3.0.4
wxPython version: 4.0.7

As I first reported here: https://discuss.wxpython.org/t/setminsi ... nces/34914, I have noticed differences in the way SetMinSize() and SetSizeHints() work depending on whether the X11 or Wayland backend is used.

It seems that SetMineSize() and SetSizeHints() are ignoring the window decoration in the minimum size calculation on X11, but taking it into account on Wayland. The same does not seem to be the case for GetClientSize(), so I'm having trouble setting a minimum window size that is consistent across Linux distros that default to X11 (eg Ubuntu) and Wayland (eg Fedora). On Fedora, the windows can be shrunk a bit more, which I think is because:
  • Get/SetClientSize() work the same on both platforms and ignore the window decoration in the size calculation.
  • SetMinSize() and SetSizeHints() are taking the window decoration into account, but only on Wayland (everything is consistent on X11 AFAICT).
I have tried to do my due diligence and find a report here, on wxWidgets Trac, and on the users' mailing list, but have been unsuccessful - I do apologise if this is already reported/fixed in a newer version. Is there anything else I should investigate / any other information I should provide?
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: SetMinSize() and SetSizeHints() platform differences with X11 and Wayland

Post by doublemax »

Please try to reproduce the issue with a C++ version and wx 3.0.4 first, and then try the same with 3.1.4 or the latest version from Github.

Please also mention whether you built wxWidgets with GTK2 or GTK3.
Use the source, Luke!
hamishmb
Knows some wx things
Knows some wx things
Posts: 29
Joined: Mon Jul 08, 2019 8:48 pm
Location: /usr/lib/python3/

Re: SetMinSize() and SetSizeHints() platform differences with X11 and Wayland

Post by hamishmb »

Okay, seems fair. I'm pretty sure it's GTK3 but I shall check and update the first post.

Is there a simple demo program I can compile and use like with the wxPython demo?
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: SetMinSize() and SetSizeHints() platform differences with X11 and Wayland

Post by doublemax »

hamishmb wrote: Mon Oct 05, 2020 3:55 pm Is there a simple demo program I can compile and use like with the wxPython demo?
yes, the "minimal" sample that comes with wxWidgets. You'll just have to add a few lines to demonstrate the bug/problem.
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: SetMinSize() and SetSizeHints() platform differences with X11 and Wayland

Post by ONEEYEMAN »

Hi,
I believe what you are observing is how X11 and Wayland operate.

The best thing is to set the client size of the window.

On X11 the decoration (sizes) are not available until the window is shown, and so setting the min size may not work reliably.

However I'm not sure about that myself (about the last piece).

But definitely try to reproduce it in the (minimal) sample.

Thank you.
hamishmb
Knows some wx things
Knows some wx things
Posts: 29
Joined: Mon Jul 08, 2019 8:48 pm
Location: /usr/lib/python3/

Re: SetMinSize() and SetSizeHints() platform differences with X11 and Wayland

Post by hamishmb »

Okay, I have managed to compile wxwidgets 3.0.4 (GTK3) and confirm that there are platform differences between X11 and Wayland when setting the minimum size and client size both to 640x480 for the minimal sample.

It behaves slightly oddly as with GDK_BACKEND=x11 the height can go below 480px (392 in my case), and I think this is because of window decoration. With GDK_BACKEND-wayland, the actual minimum window size is 588x340. These sizes are reported by GetClientSize(), as seen in the modified /samples/minimal/minimal.cpp I've attached. Of course, those other weirdnesses might be because I've not done much C++ coding and as such I got rather confused relating wxPython code to wxWidgets code.

I'm now going to compile and test on wxWidgets 3.1.4 and see if the behaviour is the same.
Attachments
minimal.cpp
(7.13 KiB) Downloaded 134 times
hamishmb
Knows some wx things
Knows some wx things
Posts: 29
Joined: Mon Jul 08, 2019 8:48 pm
Location: /usr/lib/python3/

Re: SetMinSize() and SetSizeHints() platform differences with X11 and Wayland

Post by hamishmb »

Behaviour is identical on wxWidgets 3.1.4 (GTK3).

NB: ONEEYEMAN: I usually do both SetClientSize and SetMinSize, is that an okay thing to do or is there another way? Just setting the minimum size for me isn't (or at least didn't used to be) very reliable across different platforms, so I think that is why I do both.
Last edited by hamishmb on Tue Oct 06, 2020 8:18 pm, edited 1 time in total.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: SetMinSize() and SetSizeHints() platform differences with X11 and Wayland

Post by ONEEYEMAN »

Hi,
As I said in my previous post on X11 with GTK3 the decorations are not available until the window is fully realized.

So I presume that the best way is to use client size.

And sorry - I'm not familiar with Wayland at all.

You can try to ask on the wx-users ML where you can catch Paul (main GTK core developer).

Thank you.
hamishmb
Knows some wx things
Knows some wx things
Posts: 29
Joined: Mon Jul 08, 2019 8:48 pm
Location: /usr/lib/python3/

Re: SetMinSize() and SetSizeHints() platform differences with X11 and Wayland

Post by hamishmb »

I never got a response. Anything else I can try?

I guess I could make a ticket on Trac?
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: SetMinSize() and SetSizeHints() platform differences with X11 and Wayland

Post by doublemax »

hamishmb wrote: Wed Mar 10, 2021 7:17 pm I guess I could make a ticket on Trac?
Yes, please do.
Use the source, Luke!
hamishmb
Knows some wx things
Knows some wx things
Posts: 29
Joined: Mon Jul 08, 2019 8:48 pm
Location: /usr/lib/python3/

Re: SetMinSize() and SetSizeHints() platform differences with X11 and Wayland

Post by hamishmb »

Post Reply