Skip to content

Set MacOS window levels (NSWindow)#3674

Merged
leaanthony merged 4 commits into
wailsapp:v3-alphafrom
OlegGulevskyy:set-window-levels
Aug 20, 2024
Merged

Set MacOS window levels (NSWindow)#3674
leaanthony merged 4 commits into
wailsapp:v3-alphafrom
OlegGulevskyy:set-window-levels

Conversation

@OlegGulevskyy

@OlegGulevskyy OlegGulevskyy commented Aug 9, 2024

Copy link
Copy Markdown
Contributor

Description

Adding ability to set NSWindow level to be able to render the window on different levels. Mainly inspired by a need of rendering a window on top of MacOS menu bar. Well, on top of any window, including menu bar + task pane.
This is an alternative of ElectronJS option here.

Sample usage:

  Mac: application.MacWindow{
    WindowLevel:  application.MacWindowLevelPopUpMenu,
  },

Where MacWindowLevelPopUpMenu allows me to render the window on top of everything else under the sun.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration using wails doctor.

  • Windows
  • macOS
  • Linux

Test Configuration

Please paste the output of wails doctor. If you are unable to run this command, please describe your environment in as much detail as possible.

Checklist:

  • I have updated website/src/pages/changelog.mdx with details of this PR
  • My code follows the general coding style of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • New Features
    • Introduced a -port command-line flag for specifying the application port during development.
    • Added support for the WAILS_VITE_PORT environment variable for enhanced configuration.
    • New window stacking level control for macOS, improving UI management.
  • Bug Fixes
    • Enhanced SetIgnoreMouseEvents functionality now works with already created windows on Windows.
  • Improvements
    • Added multiple functions for granular control over window levels in macOS applications.

@coderabbitai

coderabbitai Bot commented Aug 9, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The recent changes enhance the functionality of the application by introducing a new command-line flag for port customization and environment variable support, improving testing capabilities, and implementing platform-specific features. Notably, macOS gains enhanced window management options, allowing users to define stacking levels for windows, while Windows receives fixes for mouse event handling. These updates collectively improve user experience and application reliability.

Changes

Files Change Summary
v3/pkg/application/webview_window_darwin.go Added multiple functions for managing window levels on macOS, enhancing window control and behavior.
mkdocs-website/docs/en/changelog.md Introduced -port flag and WAILS_VITE_PORT support; improved method tests and platform-specific features for macOS and Windows.

Poem

🐇 In the meadow where windows gleam,
New levels rise, like a dream!
Floating high, or status low,
Each level set, a grand show.
With a hop and a skip, we cheer,
For window magic is finally here! ✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@OlegGulevskyy OlegGulevskyy changed the title set nswindow levels via mac options Set MacOS window levels (NSWindow) Aug 9, 2024

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d405bd4 and 4b7f9b2.

Files selected for processing (2)
  • v3/pkg/application/webview_window_darwin.go (3 hunks)
  • v3/pkg/application/webview_window_options.go (1 hunks)
Additional comments not posted (5)
v3/pkg/application/webview_window_options.go (2)

384-385: Addition of WindowLevel field looks good.

The WindowLevel field enhances the MacWindow struct by allowing the configuration of window levels. Ensure that documentation and usage examples are updated accordingly.


388-399: Definition of MacWindowLevel and constants is well-structured.

The MacWindowLevel type and its associated constants provide a clear and modular way to manage window levels. This approach enhances code readability and maintainability.

v3/pkg/application/webview_window_darwin.go (3)

219-226: Implementation of window level functions is clear and concise.

The functions for setting various window levels are well-implemented, providing modular control over window stacking order. This enhances the maintainability and readability of the code.


1080-1099: Refactor of setWindowLevel method is effective.

The switch statement in setWindowLevel efficiently maps each MacWindowLevel to its corresponding function, improving code clarity and modularity.


1187-1190: Setting a default window level in run method is a good practice.

The logic to assign a default window level if none is specified enhances robustness by preventing potential issues from uninitialized states.

@leaanthony

Copy link
Copy Markdown
Member

Thanks 🙏 Please could you add an entry to the changelog located at mkdocs-website/docs/changelog.md? Thanks!

@OlegGulevskyy

Copy link
Copy Markdown
Contributor Author

Done

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4b7f9b2 and c62d75c.

Files selected for processing (2)
  • mkdocs-website/docs/en/changelog.md (1 hunks)
  • v3/pkg/application/webview_window_darwin.go (3 hunks)
Additional comments not posted (4)
mkdocs-website/docs/en/changelog.md (1)

51-51: Changelog entry added.

The changelog entry for adding the ability to set a window's stacking level on macOS is correctly documented.

v3/pkg/application/webview_window_darwin.go (3)

219-226: Window level functions implemented correctly.

The functions for setting various window levels are correctly implemented using Cocoa's NSWindowLevel constants.


1084-1103: Method setWindowLevel is well-structured and correct.

The setWindowLevel method effectively uses a switch statement to set the appropriate window level based on the MacWindowLevel enum.


1191-1194: Default window level logic is a good addition.

Setting a default window level if none is provided ensures consistent behavior and prevents unexpected issues.

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