Skip to content

Feat: allow config for showing the main app on tray icon click#5361

Open
mattdjenkinson wants to merge 1 commit intoDioxusLabs:mainfrom
mattdjenkinson:feat/tray-icon-show-window-config
Open

Feat: allow config for showing the main app on tray icon click#5361
mattdjenkinson wants to merge 1 commit intoDioxusLabs:mainfrom
mattdjenkinson:feat/tray-icon-show-window-config

Conversation

@mattdjenkinson
Copy link

Summary

Add a Config option to control whether the main window is shown and focused when the tray icon is left-clicked. This allows tray/menu bar apps to show only the context menu on click, without activating the main window.

Ref: #5360

Problem

Currently, handle_tray_icon_event in app.rs unconditionally shows and focuses all windows when the tray icon is left-clicked. This is the default behavior many apps want, but tray apps (menu bar / status bar apps) often want to show only the context menu without activating the main window.

Solution

Add tray_icon_show_window_on_click: bool to Config (default true to preserve current behavior). When set to false, the tray icon left-click will not show or focus the window—only the menu will appear (if configured).

Changes

  • config.rs: Added tray_icon_show_window_on_click field (default true) and with_tray_icon_show_window_on_click(bool) setter.
  • app.rs: Added the field to App, passed it from config, and updated handle_tray_icon_event to only show/focus windows when the option is true.

Usage

Config::new()
    .with_close_behaviour(WindowCloseBehaviour::WindowHides)
    .with_tray_icon_show_window_on_click(false)
    .with_window(window_builder)

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