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 raw-window-handle feature #772

Merged
merged 1 commit into from
Jan 2, 2023
Merged

Add raw-window-handle feature #772

merged 1 commit into from
Jan 2, 2023

Conversation

notgull
Copy link
Collaborator

@notgull notgull commented Dec 23, 2022

This PR adds a raw-window-handle feature that implements raw_window_handle::HasRawDisplayHandle for XCBConnection.

@psychon
Copy link
Owner

psychon commented Dec 27, 2022

@kchibisov Do you have some time to give this a quick look? Does it seem fine? (I am not quite sure when raw-window-handle would be useful for me and I am also not sure what to do with the fields that are not set in this PR (screen and visual_id), so... it would be great if someone else could take a look at this.)

@notgull
Copy link
Collaborator Author

notgull commented Dec 27, 2022

I am not quite sure when raw-window-handle would be useful for me

I ran into this issue while writing rust-windowing/softbuffer#52, while trying to register an XCBConnection into a function that takes an HasRawDisplayHandle type. While it's possible to construct my own raw handles, it's more ergonomic to pass a reference to the source object in.

I am also not sure what to do with the fields that are not set in this PR (screen and visual_id)

The raw-window-handle spec says that it is up to the consumer of the handle to fill these fields in if they need them.

@kchibisov
Copy link

(screen and visual_id)

You may not set them, however you can use default value for screen, I guess?

But the default screen should be coming from the xcb_connect. And visual is an X11 visual the window is using. In general you may omit it, however it would be impossible for client to know whether it'll have alpha mask or not for example. Though, you likely know all of that.

As @notgull said you can safely omit those values if you don't know what to provide.

Copy link
Owner

@psychon psychon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay... thanks kchibisov. I guess this is good to go then. This code neither has access to a screen number (libxcb only returns that from connect() but does not save it anywhere) nor a visual (only sent to the X11 server here, but never saved).

@mergify mergify bot merged commit c8b4c9b into psychon:master Jan 2, 2023
@notgull notgull deleted the raw-window-handle branch January 2, 2023 02:36
@psychon
Copy link
Owner

psychon commented Mar 18, 2023

Reverted in #799 due to an MSRV bump in raw-window-handle 0.5.1. See rust-windowing/raw-window-handle#101. I also added this to the list in #538

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.

3 participants