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

[mac] fix always on top during window creation #3841

Merged
merged 2 commits into from
Oct 20, 2024

Conversation

leaanthony
Copy link
Member

@leaanthony leaanthony commented Oct 20, 2024

Description

This PR fixes an issue with AlwaysOnTop not being applied to the window correctly during creation.

Summary by CodeRabbit

  • New Features

    • Introduced a new menu item: "New WebviewWindow (Always on top)" to create a window that remains on top of others.
    • Enhanced High DPI Monitor Support with a new DIP system.
    • Expanded services to support plugin functionality.
  • Bug Fixes

    • Resolved the AlwaysOnTop issue on Mac.
    • Fixed compile errors on Linux and custom event processing issues.
  • Documentation

    • Updated changelog to reflect recent changes, bug fixes, and enhancements across platforms.

Copy link

cloudflare-workers-and-pages bot commented Oct 20, 2024

Deploying wails with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3eb8862
Status: ✅  Deploy successful!
Preview URL: https://ca2b7798.wails.pages.dev
Branch Preview URL: https://v3-alpha-bugfix-mac-always-o.wails.pages.dev

View logs

@leaanthony leaanthony marked this pull request as ready for review October 20, 2024 02:09
Copy link
Contributor

coderabbitai bot commented Oct 20, 2024

Walkthrough

The pull request introduces several updates to the project, including an expanded changelog that details various changes, fixes, and enhancements. Notable additions include a new menu item for creating a WebviewWindow that remains always on top and enhancements to the macosWebviewWindow struct to support this feature. The changelog also highlights bug fixes and improvements across multiple platforms, particularly for macOS and Linux. Overall, the changes focus on enhancing functionality and user experience.

Changes

File Path Change Summary
mkdocs-website/docs/en/changelog.md Updated changelog to reflect changes, including expanded "Changed" section, new "Fixed" section, and bug fixes.
v3/examples/window/main.go Added new menu item: "New WebviewWindow (Always on top)" with OnClick handler to create a new window.
v3/pkg/application/webview_window_darwin.go Enhanced macosWebviewWindow struct with setAlwaysOnTop method and updated run method for window state.

Poem

🐇 In the meadow, changes bloom,
New windows rise, dispelling gloom.
Always on top, they gleam and shine,
With a menu item, oh so fine!
Bugs are fixed, the code refined,
A happier world for all to find! 🌼


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

Copy link

sonarcloud bot commented Oct 20, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
C Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
mkdocs-website/docs/en/changelog.md (1)

25-25: Remove redundant "Fixed" for better readability.

There's a repetition of the word "Fixed" at the beginning of this line. To improve readability and maintain consistency with the changelog format, we should remove one instance.

Here's the suggested change:

-### Fixed
-- Fixed `AlwaysOnTop` not working on Mac by [leaanthony](https://github.com/leaanthony)
+### Fixed
+- `AlwaysOnTop` not working on Mac by [leaanthony](https://github.com/leaanthony)
🧰 Tools
🪛 LanguageTool

[duplication] ~25-~25: Possible typo: you repeated a word
Context: ...thub.com//pull/3778) ### Fixed - Fixed AlwaysOnTop not working on Mac by [le...

(ENGLISH_WORD_REPEAT_RULE)

v3/examples/window/main.go (1)

157-167: LGTM! Consider a minor improvement for consistency.

The implementation of the "Always on top" window creation looks good and aligns with the PR objectives. It follows the existing pattern for creating new window types.

For consistency with other similar menu items, consider extracting the window creation logic into a separate function. This would make the code more maintainable and easier to read.

Here's a suggested refactoring:

+func createAlwaysOnTopWindow(app *application.App, windowCounter int) {
+    app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
+        AlwaysOnTop: true,
+    }).
+        SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
+        SetRelativePosition(rand.Intn(1000), rand.Intn(800)).
+        SetURL("https://wails.io").
+        Show()
+}

 myMenu.Add("New WebviewWindow (Always on top)").
     OnClick(func(ctx *application.Context) {
-        app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
-            AlwaysOnTop: true,
-        }).
-            SetTitle("WebviewWindow "+strconv.Itoa(windowCounter)).
-            SetRelativePosition(rand.Intn(1000), rand.Intn(800)).
-            SetURL("https://wails.io").
-            Show()
+        createAlwaysOnTopWindow(app, windowCounter)
         windowCounter++
     })

This refactoring would improve code organization and make it easier to maintain in the future.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 94e8f8b and ef94911.

📒 Files selected for processing (3)
  • mkdocs-website/docs/en/changelog.md (1 hunks)
  • v3/examples/window/main.go (1 hunks)
  • v3/pkg/application/webview_window_darwin.go (1 hunks)
🧰 Additional context used
🪛 LanguageTool
mkdocs-website/docs/en/changelog.md

[duplication] ~25-~25: Possible typo: you repeated a word
Context: ...thub.com//pull/3778) ### Fixed - Fixed AlwaysOnTop not working on Mac by [le...

(ENGLISH_WORD_REPEAT_RULE)

🔇 Additional comments (4)
mkdocs-website/docs/en/changelog.md (2)

25-27: LGTM! This change directly addresses the PR objective.

The addition of the "Fixed" section in the Unreleased changes, specifically addressing the AlwaysOnTop functionality on Mac, aligns perfectly with the PR objectives. The entry is well-formatted and provides clear information about the fix, including the contributor and the associated pull request.

🧰 Tools
🪛 LanguageTool

[duplication] ~25-~25: Possible typo: you repeated a word
Context: ...thub.com//pull/3778) ### Fixed - Fixed AlwaysOnTop not working on Mac by [le...

(ENGLISH_WORD_REPEAT_RULE)


Line range hint 1-28: Excellent changelog structure and content.

The changelog is well-structured and follows the Keep a Changelog format consistently. It provides comprehensive information about various types of changes (Added, Changed, Fixed, etc.) across multiple versions and platforms. The inclusion of contributor information and links to pull requests enhances traceability.

The recent addition addressing the AlwaysOnTop functionality on Mac in the Unreleased section demonstrates active maintenance and aligns with the PR objectives.

🧰 Tools
🪛 LanguageTool

[duplication] ~25-~25: Possible typo: you repeated a word
Context: ...thub.com//pull/3778) ### Fixed - Fixed AlwaysOnTop not working on Mac by [le...

(ENGLISH_WORD_REPEAT_RULE)

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

1253-1253: LGTM: Correctly implemented AlwaysOnTop feature

The addition of w.setAlwaysOnTop(options.AlwaysOnTop) after showing the window is correct and consistent with the expected behavior. This ensures that the AlwaysOnTop property is set appropriately when the window becomes visible.


1259-1259: LGTM: Proper handling of AlwaysOnTop for initially hidden windows

The addition of w.setAlwaysOnTop(options.AlwaysOnTop) within the WindowDidBecomeKey event handler is a good approach. This ensures that the AlwaysOnTop property is correctly set even when the window is initially hidden and becomes visible later.

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.

1 participant