Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Wayland support for Window.GetHandle #2561

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

unawarez
Copy link

@unawarez unawarez commented Jun 13, 2024

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 calling frame.GetHandle(). Also confirmed ARM Mac without GTK hasn't broken. I was not able to test Windows.

Suggestions welcome!

etg/window.py Show resolved Hide resolved
etg/window.py Outdated Show resolved Hide resolved
@unawarez unawarez marked this pull request as draft June 20, 2024 03:25
@unawarez

This comment was marked as outdated.

This adds support for getting a Wayland `wl_surface` from
`Window.GetHandle`. The behavior of the function is now to return either
an X11 window ID or Wayland `wl_surface` if running a GTK build on those
backends, return 0 on any other GTK backend, or else return the C++
`GetHandle` result unmodified. This is the simplest fix for the Wayland
issue without worrying about breaking existing user code, as this
function already failed for any non-X11 GTK build. Returning 0 on
non-X11/Wayland GTK platforms sidesteps the issue of making sure e.g.
GTK Mac GetHandle returns the same type as native Cocoa Mac GetHandle.
@unawarez unawarez changed the title Support non-X11 GTK backends for Window.GetHandle Add Wayland support for Window.GetHandle Jun 20, 2024
@unawarez
Copy link
Author

Radically simplified & should be ready to go.

@unawarez unawarez marked this pull request as ready for review June 20, 2024 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GetHandle() returns 0 on Linux
1 participant