Add Wayland support for Window.GetHandle #2561
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1217
This PR adds support for getting a
wl_surface
from Window.GetHandle when running on GTK+Wayland. This patch was originally more complicated by trying to support all the GTK windowing backends. Now, any GTK backend besides X11 or Wayland will return 0. This is less confusing than trying to figure out and match the return type of C++ GetHandle on Windows/Mac/etc in the unlikely case someone uses the GTK port on those platforms. This maintains backwards compatibility because up to now, GetHandle failed and returned 0 on any non-X11 GTK backend.I tested on Wayland and X11 on current Arch with Python 3.12. Both work (at least, return a nonzero number) as long as you call
frame.Show()
before callingframe.GetHandle()
. Also confirmed ARM Mac without GTK hasn't broken. I was not able to test Windows.Suggestions welcome!