Skip to content

Conversation

@catilac
Copy link
Contributor

@catilac catilac commented Nov 24, 2025

Created a patch from [#1337 in Processing4](https://github.com/processing/processing4/pull/

Copy link
Member

@tychedelia tychedelia left a comment

Choose a reason for hiding this comment

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

Looks great! Just minor comment on use of unsafe.

let (raw_window_handle, raw_display_handle) = {
use raw_window_handle::{WaylandDisplayHandle, WaylandWindowHandle};

let window_handle_ptr = unsafe { NonNull::new_unchecked(window_handle as *mut c_void) };
Copy link
Member

Choose a reason for hiding this comment

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

We should only use the unchecked variants in situations where we control the provenance of the pointer, or at the least document the invariant in the safety information for this function. Here, I think we can do the lazy thing that I do above which is NonNull::new(ptr).unwrap()) which guarantees we'll at least panic if the caller passes us a null ptr (we probably should be returning HandleError).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Amazing! Just addressed the feedback. I am returning HandleError now

@catilac catilac requested a review from tychedelia November 25, 2025 01:12
@tychedelia tychedelia merged commit 5906340 into processing:main Nov 25, 2025
@catilac catilac deleted the 1305-wayland branch November 25, 2025 20:16
tychedelia added a commit that referenced this pull request Nov 25, 2025
- Implement Wayland surface creation
- Add checked pointer unwrapping and error handling for null pointers
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.

2 participants