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

[V3-Linux] Systray OnClick on initial icon click #3907

Merged
merged 1 commit into from
Nov 23, 2024

Conversation

atterpac
Copy link
Member

@atterpac atterpac commented Nov 23, 2024

Linux systray has some quirks this PR hopes to remedy some of them.

The StatusNotifier Activate signal emits when the systray is clicked for the first time. However this is the first click once the tray has been focused and is active, thus really being a double click for the end user once to focus the tray and another to get the "first" click

However com.canonical emits dbus messages when the systray is clicked initially and we already have that dbus setup to handle menus we just tie it into the systray and now we have systemTray.OnClick() firing from the canonical menu dbus emit and systemTray.OnDoubleClick firing based off of the StatusNotifier "Activate" message. systemTray.OnRightClick() is functioning in my OS as well

Changes:

  • Convert event handling to switch statement for better readability
  • Fix menu event handlers to properly trigger open/close callbacks
  • Update click behavior to use doubleClickHandler for Activate
# System
┌──────────────────────────────────────────────────────────────────────────────────────────┐
| Name         | Ubuntu                                                                    |
| Version      | 24.04                                                                     |
| ID           | ubuntu                                                                    |
| Branding     | 24.04.1 LTS (Noble Numbat)                                                |
| Platform     | linux                                                                     |
| Architecture | amd64                                                                     |
| CPU          | 12th Gen Intel(R) Core(TM) i5-1235U                                       |
| GPU 1        | Alder Lake-UP3 GT2 [Iris Xe Graphics] (Intel Corporation) - Driver: i915  |
| Memory       | 7GB                                                                       |
└──────────────────────────────────────────────────────────────────────────────────────────┘

# Build Environment
┌─────────────────────────────────────────────────────────┐
| Wails CLI    | v3.0.0-alpha.7                           |
| Go Version   | go1.22.4                                 |
| Revision     | 699743dbe2e247a6c7e9bdfd08f3c4f48809e8a8 |
| Modified     | false                                    |
| -buildmode   | exe                                      |
| -compiler    | gc                                       |
| CGO_CFLAGS   |                                          |
| CGO_CPPFLAGS |                                          |
| CGO_CXXFLAGS |                                          |
| CGO_ENABLED  | 1                                        |
| CGO_LDFLAGS  |                                          |
| GOAMD64      | v1                                       |
| GOARCH       | amd64                                    |
| GOOS         | linux                                    |
| vcs          | git                                      |
| vcs.modified | false                                    |
| vcs.revision | 699743dbe2e247a6c7e9bdfd08f3c4f48809e8a8 |
| vcs.time     | 2024-11-21T16:11:02Z                     |
└─────────────────────────────────────────────────────────┘

# Dependencies
┌──────────────────────────────────────┐
| webkit2gtk | 2.46.3-0ubuntu0.24.04.1 |
| gcc        | 12.10ubuntu1            |
| gtk3       | 3.24.41-4ubuntu1.2      |
| npm        | 10.5.1                  |
| pkg-config | 1.8.1-2build1           |
└────── * - Optional Dependency ───────┘

Summary by CodeRabbit

  • New Features

    • Added commands for updating build assets and generating runtime.
    • Introduced support for darwin universal builds and enhanced events documentation.
    • Added file association support and new window positioning options.
    • Enhanced the system tray with click event handlers for improved interactivity.
  • Bug Fixes

    • Resolved issues with the amd64 appimage compile and Linux systray click implementations.
    • Fixed the AlwaysOnTop feature on Mac and service name determination.
  • Improvements

    • Refactored systray click messaging for better user interaction.
    • Updated asset embedding to support frameworks with subfolders.

Copy link
Contributor

coderabbitai bot commented Nov 23, 2024

Walkthrough

The pull request introduces significant updates to the project's changelog, detailing new features such as support for Darwin universal builds, documentation for events, and enhancements to the application package. It also includes a refactor of the systray click messaging and updates to the linuxSystemTray implementation. New event handlers for the system tray are added, enhancing interactivity. Additionally, several bug fixes are documented, addressing issues with the appimage compile and systray functionalities. Overall, the changes aim to improve the project's functionality and stability.

Changes

File Path Change Summary
mkdocs-website/docs/en/changelog.md Updated changelog with new features, enhancements, and bug fixes. Added commands for build assets and runtime generation.
v3/examples/systray/main.go Added event handlers for system tray: OnClick, OnDoubleClick, and OnRightClick.
v3/pkg/application/systemtray_linux.go Refactored Event method using switch statement; updated Activate method; added Scroll method; clarified comments.

Possibly related PRs

Suggested reviewers

  • leaanthony

🐰 In the meadow, changes bloom,
New features sprout, dispelling gloom.
With clicks and taps, the tray now sings,
Enhancements bright, oh what joy it brings!
So hop along, let’s celebrate,
For every fix, we elevate! 🌼


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.

- Convert event handling to switch statement for better readability
- Fix menu event handlers to properly trigger open/close callbacks
- Update click behavior to use doubleClickHandler for Activate

CHANGELOG.md
@atterpac atterpac marked this pull request as ready for review November 23, 2024 19:48
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: 3

🧹 Outside diff range and nitpick comments (6)
v3/examples/systray/main.go (1)

95-105: Enhance example to demonstrate best practices

As this is an example file that developers will reference, it should demonstrate:

  1. Proper platform-specific handling (especially Linux D-Bus integration)
  2. Proper logging practices
  3. Error handling
  4. Documentation of the platform-specific behaviors

This will help developers understand the correct implementation patterns for different platforms.

Consider adding comments explaining the platform-specific behaviors and requirements, particularly for Linux:

  • Initial click handling via com.canonical
  • Double-click handling via StatusNotifier
  • Right-click behavior
v3/pkg/application/systemtray_linux.go (2)

424-424: Implement menu opening using com.canonical D-Bus messages

The FIXME comment suggests using com.canonical for menu opening, which aligns with the PR objectives. Consider implementing this functionality instead of just logging that it's not implemented.

Would you like help implementing the menu opening functionality using com.canonical D-Bus messages?


712-712: Consider implementing context menu functionality

While the explicit return statement improves code clarity, the function could benefit from actual implementation of context menu functionality, especially since the PR mentions that OnRightClick() is functioning correctly.

Consider implementing the context menu functionality to properly handle right-click events, possibly by showing the menu at the provided coordinates (x, y).

mkdocs-website/docs/en/changelog.md (3)

35-35: Enhance the changelog entry to better reflect the technical improvements.

The current entry could be expanded to better capture the technical details and user impact. Consider this revision:

-- Refactored systray click messaging to better align with user interactions by @atterpac in [#3907](https://github.com/wailsapp/wails/pull/3907)
+- [linux] Enhanced systray click handling by leveraging com.canonical D-Bus messages for initial clicks and StatusNotifier's Activate signal for double clicks, providing more intuitive user interaction by @atterpac in [#3907](https://github.com/wailsapp/wails/pull/3907)

This revision:

  • Specifies the platform affected [linux]
  • Details the technical implementation (D-Bus messages, StatusNotifier)
  • Clarifies the user experience improvement

Line range hint 93-94: Remove duplicate entries.

These entries appear twice in the changelog:

- Do not bind internal service methods in [#3720](https://github.com/wailsapp/wails/pull/3720) by [leaanthony](https://github.com/leaanthony)
- [windows] Fixed system tray startup panic in [#3693](https://github.com/wailsapp/wails/issues/3693) by [@DeltaLaboratory](https://github.com/DeltaLaboratory)

Line range hint 1-24: Maintain consistent platform indicator formatting.

The changelog uses both styles for platform indicators:

  • [platform] (e.g., "[linux]")
  • (platform) (e.g., "(Darwin)")

Consider standardizing to the [platform] format throughout the document for better readability.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between abcc37f and 6b5d0f9.

📒 Files selected for processing (3)
  • mkdocs-website/docs/en/changelog.md (1 hunks)
  • v3/examples/systray/main.go (1 hunks)
  • v3/pkg/application/systemtray_linux.go (3 hunks)
🔇 Additional comments (2)
v3/pkg/application/systemtray_linux.go (2)

625-637: LGTM: Clean event handling implementation

The switch statement implementation improves code readability and correctly handles menu events. The changes align well with the PR objectives for refactoring event handling.


703-705: LGTM: Correct implementation of double-click handling

The change to use doubleClickHandler instead of clickHandler in the Activate method correctly implements the behavior described in the PR objectives, addressing the initial click handling issue.

v3/examples/systray/main.go Show resolved Hide resolved
v3/examples/systray/main.go Show resolved Hide resolved
v3/examples/systray/main.go Show resolved Hide resolved
@leaanthony leaanthony merged commit d27e75c into wailsapp:v3-alpha Nov 23, 2024
13 checks passed
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