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

Added the show system menu method to window #3109

Merged
merged 22 commits into from
Oct 10, 2023
Merged

Added the show system menu method to window #3109

merged 22 commits into from
Oct 10, 2023

Conversation

YouKnow-sys
Copy link
Contributor

@YouKnow-sys YouKnow-sys commented Sep 21, 2023

This PR add support for showing system menu with calling show_system_menu method on Window.
this can be useful when we are drawing our custom titlebar and want to keep the system menu as well.
currently only supported on windows.

related to: #3108

  • Tested on all platforms changed
  • Added an entry to CHANGELOG.md 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
  • Updated feature matrix, if new features were added or implemented

CHANGELOG.md Outdated Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
@notgull
Copy link
Member

notgull commented Sep 22, 2023

This function might be a better fit for menubar.

Co-authored-by: daxpedda <[email protected]>
@YouKnow-sys
Copy link
Contributor Author

YouKnow-sys commented Sep 22, 2023

This function might be a better fit for menubar.

well the name of this crate suggest that its for adding menu bar to programs, how can system menu relate to it?
I mean this mainly will be used alongside things like drag_window and drag_resize_window for window that have custom titlbar and can't access the original system menu...
I also tried to run examples of this project, but compile failed...

@kchibisov
Copy link
Member

This function might be a better fit for menubar.

This has nothing to do with the menubars, this is a system menu on the right click on decorations, which is used to show a compositor menu. Winit already shows such a thing, it just, we don't expose the API winit uses for it, which is required for the
user defined client side decorations.

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.

Given that there was a mention of the mouse or similar happening, I'd say that wayland wants that action to be associated with some input event, like in reaction to mouse click, keyboard button press, touch press, etc.

We should say that the compositor is free to ignore such request though.

src/window.rs Outdated Show resolved Hide resolved
    - now it showcase the `show_system_menu` as well.
    - added "d" hotkey to enable and disable decorations to better showcase the example.
changed `show_system_menu` to `show_window_menu` for being more in line with other platforms.
src/window.rs Outdated Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
src/window.rs Show resolved Hide resolved
@YouKnow-sys
Copy link
Contributor Author

I think now its mostly done?
I update the code based on recent suggestions and also changed the doc as best as I could.

src/window.rs Outdated Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
@daxpedda
Copy link
Member

I think now its mostly done?

Couple of nits on the documentation, otherwise LGTM from me.
I'm not familiar with the Windows backend, so somebody else has to review that.

@YouKnow-sys
Copy link
Contributor Author

Couple of nits on the documentation, otherwise LGTM from me. I'm not familiar with the Windows backend, so somebody else has to review that.

I applied your suggestions, thanks.
sounds good to me.

@daxpedda
Copy link
Member

Could you rebase for CI to run?

@YouKnow-sys
Copy link
Contributor Author

Could you rebase for CI to run?

sure, tests are now running

Copy link
Member

@msiglreith msiglreith left a comment

Choose a reason for hiding this comment

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

Windows implementation lgtm

@daxpedda daxpedda requested a review from kchibisov September 23, 2023 14:07
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.

looks mostly good.

src/window.rs Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@YouKnow-sys
Copy link
Contributor Author

had to add another extra unsafe block inside the handle_showing_window_menu method...
to be honest unsafe_op_in_unsafe_fn doesn't make much sense on functions that are actually unsafe, but here we are.

@kchibisov kchibisov merged commit 1ea41a2 into rust-windowing:master Oct 10, 2023
50 checks passed
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.

5 participants