feat: Keep controls and header bar visible when controls are hovered (#344)

Add a `controls_hovered` state tracked via new `ControlsHoverEnter`/
`ControlsHoverExit` messages. Previously the auto-hide timeout could
fire while the cursor was resting over the controls, since only mouse
movement/clicks reset the timer. Now, this is prevented whenever the
controls are hovered, i.e. `controls_hovered` is true.

Implementation comments:
- Controls popup is wrapped in a single `mouse_area` each to avoid
duplicate enter/exit events at internal widget boundaries.
- Double trigger of enter/exit messages in `update()` is guarded
against.

Resolves #304

- [x] I have disclosed use of any AI generated code in my commit
messages.
- If you are using an LLM, and do not fully understand the changes it is
making to the code base, do not create a PR.
- In our experience, AI generated code often results in overly complex
code that lacks enough context for a proper fix or feature inclusion.
This results in considerably longer code reviews. Due to this, AI
authored or partially authored PRs may be closed without comment.
- [x] I understand these changes in full and will be able to respond to
review comments.
- [x] My change is accurately described in the commit message.
- [x] My contribution is tested and working as described.
- [x] I have read the [Developer Certificate of
Origin](https://developercertificate.org/) and certify my contribution
under its conditions.
This commit is contained in:
Jeremy Soller 2026-10-01 07:12:11 -06:00 • committed by GitHub
commit 8923105997
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -344,6 +344,8 @@ pub enum Message {
VideoAreaClick,
PlaybackSpeed(f64),
ShowControls,
ControlsHoverEnter,
ControlsHoverExit,
SystemThemeModeChange(cosmic_theme::ThemeMode),
WindowClose,
}
@ -355,6 +357,7 @@ pub struct App {
album_art_opt: Option<tempfile::NamedTempFile>,
controls: bool,
controls_time: Instant,
controls_hovered: bool,
dropdown_opt: Option<DropdownKind>,
fullscreen: bool,
key_binds: HashMap<KeyBind, Action>,
@ -652,6 +655,7 @@ impl App {
fn update_controls(&mut self, in_use: bool) {
if in_use
|| self.controls_hovered
|| !self
.video_opt
.as_ref()
@ -932,6 +936,7 @@ impl Application for App {
album_art_opt: None,
controls: true,
controls_time: Instant::now(),
controls_hovered: false,
dropdown_opt: None,
fullscreen: false,
key_binds: key_binds(),
@ -1658,6 +1663,18 @@ impl Application for App {
Message::ShowControls => {
self.update_controls(true);
}
Message::ControlsHoverEnter => {
if !self.controls_hovered {
self.controls_hovered = true;
self.update_controls(true);
}
}
Message::ControlsHoverExit => {
if self.controls_hovered {
self.controls_hovered = false;
self.update_controls(false);
}
}
Message::SystemThemeModeChange(_theme_mode) => {
return self.update_config();
}
@ -2111,7 +2128,11 @@ impl Application for App {
}
}
if !popup_items.is_empty() {
popover = popover.popup(widget::column::with_children(popup_items));
popover = popover.popup(
widget::mouse_area(widget::column::with_children(popup_items))
.on_enter(Message::ControlsHoverEnter)
.on_exit(Message::ControlsHoverExit),
);
}
widget::container(popover)