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

wayland: Add WindowExtWayland::xdg_toplevel #4076

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ultimaweapon
Copy link

  • Tested on all platforms changed
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality

I did not update changelog yet because I don't know if this change is okay or not.

Resolves #4068.

@kchibisov
Copy link
Member

We can not expose objects from SCTK like that. We can expose a pointer, but that's about it.

@ultimaweapon
Copy link
Author

Thanks for the review. I have changed the method to return *mut c_void so please check.

@kchibisov
Copy link
Member

You should open your changes against master.

@ultimaweapon
Copy link
Author

Ops sorry for triggering additional review requests. I have cherry-pick my commits to master branch and updated it so please check.

pub trait WindowExtWayland {}
pub trait WindowExtWayland {
/// Returns `xdg_toplevel` of the window or null if the window is X11 window.
fn xdg_toplevel(&self) -> *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.

Could you return an Option<NonNull> instead?

Copy link
Author

Choose a reason for hiding this comment

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

Okay. Will do after next week since I don't have access to my computer.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

@kchibisov kchibisov left a comment

Choose a reason for hiding this comment

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

Needs a changelog entry.

Comment on lines 93 to 94
let id = w.xdg_toplevel().id();
let ptr = NonNull::new(id.as_ptr().cast()).expect("xdg_toplevel should not be null");
Copy link
Member

Choose a reason for hiding this comment

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

could you move this logic to wayland/window/mod.rs and return pointer from there instead, so we don't have an export here. We could also not fail when we can not cast.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

We could also not fail when we can not cast.

Sorry I don't understand what you mean. Do you mean we should use NonNull::new_unchecked instead of NonNull::new?

Copy link
Member

Choose a reason for hiding this comment

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

I mean, that you just forward option up and not panic.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Provides a method to get xdg_toplevel on Wayland
2 participants