Repository navigation
Conversation
The tray menu was updated by scattered update_menu_state() calls, so the StreamerMsg::Error path (device dropped) and the connect -> WaitingOnStatus path never refreshed it: the menu kept Disconnect enabled and Connect disabled while the main window was already back to Connect. Add a sync_tray() helper that derives the connect/disconnect items and tooltip from connection_state, the same source the main window uses, and call it on every state transition. Default/WaitingOnStatus enable Connect and disable Disconnect; Listening/Connected do the reverse. Refs #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The tray menu is driven by a single
disconnectedboolean passed toupdate_menu_state()from several call sites, so it can drift away from the real connection state:StreamerMsg::Errorresetsconnection_statetoDefaultbut never updates the tray; the menu keepsConnectdisabled andDisconnectenabled while the app is idle.ListeningandConnectedare both encoded asdisconnected = false. While the app is only waiting for a phone, the menu therefore offers Disconnect; clicking it does sendStreamerCommand::Stop, but the label does not describe the state.Changes
ConnectionStateto a menu model:ConnectionStateDefaultWaitingOnStatusListeningConnectedtray-icon(Windows/macOS) andksni(Linux) backends.sync_tray():connect,disconnect,StreamerMsg::Listening,StreamerMsg::Connected, and nowStreamerMsg::Error, which previously left the menu stale.SystemTray::update_menu_state()to takestatus,connect_enabled,stop_enabledandstop_labelinstead ofdisconnected.tray_stop_listeningstring to en / fr / zh-CN.Screenshots (Windows 11, zh-CN)
Default state —
Connectenabled,Disconnectdisabled:Listening —
Connectdisabled, the last item readsStop Listening(停止监听) and is enabled:Connected —
Connectdisabled, the last item readsDisconnect(断开连接) and is enabled:Scope / risk
Listeningthe last item now reads Stop Listening instead of Disconnect, and it still performs the same action (StreamerCommand::Stop).Verification
cargo fmt --all -- --checktray-iconbackend): Default / Listening / Connected match the screenshots above;Stop Listeningreturns the app toDefault.ksnibackend): shares the same state model, not exercised manually in this environment.cargo build/cargo testwere not run locally (protocis not installed on this machine); CI builds Linux / Windows / macOS.