Skip to content

[windows] Add support for click-through overlay window#3667

Merged
leaanthony merged 7 commits into
wailsapp:v3-alphafrom
bruxaodev:setIgnoreMouseEvents
Aug 18, 2024
Merged

[windows] Add support for click-through overlay window#3667
leaanthony merged 7 commits into
wailsapp:v3-alphafrom
bruxaodev:setIgnoreMouseEvents

Conversation

@bruxaodev

@bruxaodev bruxaodev commented Aug 6, 2024

Copy link
Copy Markdown
  • IsIgnoreMouseEvents implementation for windows
  • exemple to use isignore := app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{}).IsIgnoreMouseEvents()
  • SetIgnoreMouseEvents implementation for windows
  • -exemple to use app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{}).SetIgnoreMouseEvents(false)
  • With these changes it will be possible to ignore or not mouse events in an already created window

Summary by CodeRabbit

  • New Features

    • Enhanced mouse event handling in the application with new methods to control ignoring mouse events.
    • Users can now dynamically enable or disable mouse event processing for the webview window, improving interaction management.
    • Improved user interface clarity with updated menu item descriptions for creating new Webview windows.
  • Documentation

    • Updated changelog to reflect the new SetIgnoreMouseEvents feature for better user awareness of functionality changes.
    • New README for the ignore-mouse example to guide users on managing mouse events.

@coderabbitai

coderabbitai Bot commented Aug 6, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The recent changes enhance mouse event management across multiple WebviewWindow implementations by introducing methods for querying and setting mouse event states. These improvements offer developers greater control over user interactions, enabling flexible window management tailored to diverse application needs, especially those requiring specific user experiences.

Changes

Files Change Summary
v3/pkg/application/webview_window.go Added IsIgnoreMouseEvents and SetIgnoreMouseEvents methods for managing mouse events in WebviewWindow.
v3/pkg/application/webview_window_windows.go Introduced isIgnoreMouseEvents and setIgnoreMouseEvents methods for mouse event management in Windows.
v3/pkg/application/webview_window_darwin.go Removed windowIgnoreMouseEvents and added isIgnoreMouseEvents and setIgnoreMouseEvents functions for macOS.
v3/pkg/application/webview_window_linux.go Added ignoreMouseEvents field and setIgnoreMouseEvents method to manage mouse event behavior in Linux.
v3/examples/ignore-mouse/main.go New application demonstrates Wails usage, creating a webview window with mouse event handling capabilities.
v3/examples/window/main.go Updated menu item names for clarity regarding mouse event handling.
v3/pkg/application/window.go Expanded Window interface with IsIgnoreMouseEvents and SetIgnoreMouseEvents methods.
mkdocs-website/docs/en/changelog.md Updated changelog to document changes related to mouse events across platforms.
v3/examples/ignore-mouse/README.md New README provides guidance on managing mouse events; includes run commands and platform status.

Poem

In a window aglow,
A rabbit leaps high,
With clicks now refined,
New controls in the sky.
Ignore or engage,
Mouse events take the stage! 🐇✨


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.

@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 1cd8fa7.

Files selected for processing (2)
  • v3/pkg/application/webview_window.go (2 hunks)
  • v3/pkg/application/webview_window_windows.go (1 hunks)
Additional comments not posted (4)
v3/pkg/application/webview_window.go (2)

1238-1243: LGTM! The function is well-implemented.

The IsIgnoreMouseEvents function is correctly checking if the window is ignoring mouse events and ensures thread safety.


1245-1252: LGTM! The function is well-implemented.

The SetIgnoreMouseEvents function correctly sets whether the window should ignore mouse events and ensures thread safety.

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

1765-1768: LGTM! The function is well-implemented.

The isIgnoreMouseEvents function correctly checks if the window is set to ignore mouse events by evaluating the WS_EX_TRANSPARENT flag.


1770-1778: LGTM! The function is well-implemented.

The setIgnoreMouseEvents function correctly sets whether the window should ignore mouse events by modifying the extended window style.

@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 1cd8fa7 and b4aceda.

Files selected for processing (1)
  • mkdocs-website/docs/en/changelog.md (2 hunks)
Additional comments not posted (1)
mkdocs-website/docs/en/changelog.md (1)

47-47: Entry for SetIgnoreMouseEvents looks good.

The addition of the SetIgnoreMouseEvents function is accurately documented and follows the format of the changelog.

@leaanthony

leaanthony commented Aug 10, 2024

Copy link
Copy Markdown
Member

Thanks for this. I'm going to push some fixes for Mac and Linux support.

@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 b4aceda and d271a22.

Files selected for processing (1)
  • mkdocs-website/docs/en/changelog.md (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • mkdocs-website/docs/en/changelog.md

@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

Outside diff range, codebase verification and nitpick comments (1)
v3/examples/ignore-mouse/main.go (1)

3-8: Review imports for relevance.

The imports are minimal and relevant to the functionality demonstrated. The _ "embed" import is unused in the current code.

Consider removing unused imports to keep the code clean.

-	_ "embed"
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d271a22 and 9890d02.

Files selected for processing (2)
  • v3/examples/ignore-mouse/README.md (1 hunks)
  • v3/examples/ignore-mouse/main.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • v3/examples/ignore-mouse/README.md
Additional comments not posted (4)
v3/examples/ignore-mouse/main.go (4)

10-18: Initialize application with appropriate options.

The application is initialized with options, including a Mac-specific option. This is appropriate for cross-platform considerations.


20-26: Create webview window with initial options.

The webview window is created with specified dimensions, title, URL, and mouse event handling option. This demonstrates the intended usage of the new feature.


28-29: Demonstrate setting and checking ignore mouse events.

The code sets the IgnoreMouseEvents to true and logs the state. This effectively demonstrates the new functionality.


31-35: Error handling for application run.

The error handling for app.Run() is appropriate, logging a fatal error if the application fails to start.

@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 9890d02 and 8b43677.

Files selected for processing (1)
  • v3/examples/ignore-mouse/main.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • v3/examples/ignore-mouse/main.go

@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: 1

Outside diff range, codebase verification and nitpick comments (8)
v3/pkg/application/window.go (2)

39-39: Add documentation for IsIgnoreMouseEvents.

Consider adding a comment to document the purpose and usage of the IsIgnoreMouseEvents method for better clarity.

// IsIgnoreMouseEvents checks if mouse events are ignored for the window.

67-67: Add documentation for SetIgnoreMouseEvents.

Consider adding a comment to document the purpose and usage of the SetIgnoreMouseEvents method for better clarity.

// SetIgnoreMouseEvents sets whether the window should ignore mouse events.
v3/pkg/application/webview_window_linux.go (2)

47-47: Consider initializing ignoreMouseEvents explicitly.

While it's initialized to false by default, explicitly setting it can improve code clarity.

ignoreMouseEvents: false,

373-375: Add documentation for isIgnoreMouseEvents.

Consider adding a comment to document the purpose and usage of the isIgnoreMouseEvents method for better clarity.

// isIgnoreMouseEvents returns true if mouse events are ignored.
v3/pkg/application/webview_window_darwin.go (4)

769-772: Add documentation for isIgnoreMouseEvents.

Consider adding a comment to document the purpose and usage of the isIgnoreMouseEvents function for better clarity.

// isIgnoreMouseEvents checks if the NSWindow is set to ignore mouse events.

774-777: Add documentation for setIgnoreMouseEvents.

Consider adding a comment to document the purpose and usage of the setIgnoreMouseEvents function for better clarity.

// setIgnoreMouseEvents sets whether the NSWindow should ignore mouse events.

1309-1311: Add documentation for isIgnoreMouseEvents method.

Consider adding a comment to document the purpose and usage of the isIgnoreMouseEvents method for better clarity.

// isIgnoreMouseEvents returns true if the NSWindow is ignoring mouse events.

1313-1315: Add documentation for setIgnoreMouseEvents method.

Consider adding a comment to document the purpose and usage of the setIgnoreMouseEvents method for better clarity.

// setIgnoreMouseEvents sets whether the NSWindow should ignore mouse events.
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8b43677 and 5e6b6df.

Files selected for processing (6)
  • v3/examples/window/main.go (2 hunks)
  • v3/pkg/application/webview_window.go (2 hunks)
  • v3/pkg/application/webview_window_darwin.go (4 hunks)
  • v3/pkg/application/webview_window_linux.go (3 hunks)
  • v3/pkg/application/webview_window_windows.go (2 hunks)
  • v3/pkg/application/window.go (2 hunks)
Files skipped from review due to trivial changes (1)
  • v3/examples/window/main.go
Files skipped from review as they are similar to previous changes (2)
  • v3/pkg/application/webview_window.go
  • v3/pkg/application/webview_window_windows.go

Comment on lines +377 to +385
func (w *linuxWebviewWindow) setIgnoreMouseEvents(ignore bool) {
w.ignoreMouseEvents = ignore

if ignore {
C.gtk_widget_set_events((*C.GtkWidget)(unsafe.Pointer(w.window)), C.GDK_ENTER_NOTIFY_MASK|C.GDK_LEAVE_NOTIFY_MASK)
} else {
C.gtk_widget_set_events((*C.GtkWidget)(unsafe.Pointer(w.window)), C.GDK_ALL_EVENTS_MASK)
}
}

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.

Ensure proper error handling in setIgnoreMouseEvents.

Consider adding error handling or logging in case setting the GTK widget events fails.

// Example of adding logging
if ignore {
    if err := C.gtk_widget_set_events((*C.GtkWidget)(unsafe.Pointer(w.window)), C.GDK_ENTER_NOTIFY_MASK|C.GDK_LEAVE_NOTIFY_MASK); err != nil {
        log.Error("Failed to set GTK widget events for ignoring mouse events:", err)
    }
} else {
    if err := C.gtk_widget_set_events((*C.GtkWidget)(unsafe.Pointer(w.window)), C.GDK_ALL_EVENTS_MASK); err != nil {
        log.Error("Failed to set GTK widget events for handling all events:", err)
    }
}

@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 5e6b6df and c79461b.

Files selected for processing (1)
  • v3/pkg/application/webview_window.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • v3/pkg/application/webview_window.go

@sonarqubecloud

Copy link
Copy Markdown

@leaanthony leaanthony merged commit fbcce0b into wailsapp:v3-alpha Aug 18, 2024
stendler added a commit to stendler/wails that referenced this pull request Aug 23, 2024
follow-up to wailsapp#3667 but does not behave as expected
github-actions Bot pushed a commit to stendler/wails that referenced this pull request Aug 26, 2024
follow-up to wailsapp#3667 but does not behave as expected
stendler added a commit to stendler/wails that referenced this pull request Aug 28, 2024
follow-up to wailsapp#3667 but does not behave as expected
github-actions Bot pushed a commit to stendler/wails that referenced this pull request Aug 29, 2024
follow-up to wailsapp#3667 but does not behave as expected
github-actions Bot pushed a commit to stendler/wails that referenced this pull request Sep 2, 2024
follow-up to wailsapp#3667 but does not behave as expected
Grantmartin2002 pushed a commit to Grantmartin2002/wails that referenced this pull request Apr 29, 2026
* [windows] Add support for click-through overlay window

* update changelog

* setIgnoreMouseEvents - exemple

* fix - remove unused import

* Add macOS+Linux support. Update example.

* Fix SetIgnoreMouseEvents before window created.

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
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