Fullscreen viewer hides the cursor with the controls when the mouse idles (gpui's hide-until-mouse-moves, triggered via a synthetic F24 keydown)
Browse files at this commit49cf52ef861e8379a19cb60cb35d3649de3c8c01Parent: aca4259- feat
- fullscreen viewer hides the cursor with the controls when the mouse idles (gpui's hide-until-mouse-moves, triggered via a synthetic F24 keydown)
2 changed files +30 -2
crates/client/src/gui.rsmodified+1 -0
| @@ -1401,6 +1401,7 @@ impl Render for Yumush { | |||
| 1401 | self.fullscreen = fullscreen; | 1401 | self.fullscreen = fullscreen; |
| 1402 | window.toggle_fullscreen(); | 1402 | window.toggle_fullscreen(); |
| 1403 | } | 1403 | } |
| 1404 | + self.hide_idle_cursor(window, cx); | ||
| 1404 | self.schedule_pump(window, cx); | 1405 | self.schedule_pump(window, cx); |
| 1405 | let palette = palette(cx); | 1406 | let palette = palette(cx); |
| 1406 | sync_accent(self.themed(cx).accent, cx); | 1407 | sync_accent(self.themed(cx).accent, cx); |
crates/client/src/gui/share_view.rsmodified+29 -2
| @@ -13,8 +13,9 @@ const TOP_QUALITY: Quality = Quality { | |||
| 13 | fps: Fps::F60, | 13 | fps: Fps::F60, |
| 14 | }; | 14 | }; |
| 15 | use gpui_kit::{ | 15 | use gpui_kit::{ |
| 16 | - Anchor, AnyElement, AppContext, Context, Div, Entity, InteractiveElement, IntoElement, | 16 | + Anchor, AnyElement, App, AppContext, Context, Div, Entity, InteractiveElement, IntoElement, |
| 17 | - MouseButton, ParentElement, StatefulInteractiveElement, Styled, Subscription, Window, | 17 | + KeyDownEvent, Keystroke, Modifiers, MouseButton, ParentElement, PlatformInput, |
| 18 | + StatefulInteractiveElement, Styled, Subscription, Window, | ||
| 18 | assets::IconName, | 19 | assets::IconName, |
| 19 | component::{ | 20 | component::{ |
| 20 | Icon, | 21 | Icon, |
| @@ -121,6 +122,7 @@ pub(super) struct Viewer { | |||
| 121 | volume: Entity<SliderState>, | 122 | volume: Entity<SliderState>, |
| 122 | restore: f32, | 123 | restore: f32, |
| 123 | active: Instant, | 124 | active: Instant, |
| 125 | + cursor_hidden: bool, | ||
| 124 | stats: bool, | 126 | stats: bool, |
| 125 | _subscriptions: Vec<Subscription>, | 127 | _subscriptions: Vec<Subscription>, |
| 126 | } | 128 | } |
| @@ -360,6 +362,7 @@ impl Yumush { | |||
| 360 | volume, | 362 | volume, |
| 361 | restore: FULL_VOLUME, | 363 | restore: FULL_VOLUME, |
| 362 | active: Instant::now(), | 364 | active: Instant::now(), |
| 365 | + cursor_hidden: false, | ||
| 363 | stats: false, | 366 | stats: false, |
| 364 | _subscriptions: subscriptions, | 367 | _subscriptions: subscriptions, |
| 365 | }); | 368 | }); |
| @@ -525,6 +528,29 @@ impl Yumush { | |||
| 525 | Some(self.viewer_pane(viewer, entity, palette)) | 528 | Some(self.viewer_pane(viewer, entity, palette)) |
| 526 | } | 529 | } |
| 527 | 530 | ||
| 531 | + pub(super) fn hide_idle_cursor(&mut self, window: &mut Window, cx: &mut App) { | ||
| 532 | + let Some(viewer) = self.chat.viewer.as_mut().filter(|viewer| { | ||
| 533 | + viewer.fullscreen && !viewer.cursor_hidden && viewer.active.elapsed() >= BAR_TTL | ||
| 534 | + }) else { | ||
| 535 | + return; | ||
| 536 | + }; | ||
| 537 | + viewer.cursor_hidden = true; | ||
| 538 | + window.defer(cx, |window, cx| { | ||
| 539 | + window.dispatch_event( | ||
| 540 | + PlatformInput::KeyDown(KeyDownEvent { | ||
| 541 | + keystroke: Keystroke { | ||
| 542 | + modifiers: Modifiers::default(), | ||
| 543 | + key: "f24".into(), | ||
| 544 | + key_char: Some(String::new()), | ||
| 545 | + }, | ||
| 546 | + is_held: false, | ||
| 547 | + prefer_character_input: false, | ||
| 548 | + }), | ||
| 549 | + cx, | ||
| 550 | + ); | ||
| 551 | + }); | ||
| 552 | + } | ||
| 553 | + | ||
| 528 | pub(super) fn fullscreen_viewer(&self, entity: &Entity<Self>, palette: Palette) -> Option<Div> { | 554 | pub(super) fn fullscreen_viewer(&self, entity: &Entity<Self>, palette: Palette) -> Option<Div> { |
| 529 | let viewer = self | 555 | let viewer = self |
| 530 | .chat | 556 | .chat |
| @@ -566,6 +592,7 @@ impl Yumush { | |||
| 566 | if let Some(viewer) = yumush.chat.viewer.as_mut() { | 592 | if let Some(viewer) = yumush.chat.viewer.as_mut() { |
| 567 | let hidden = viewer.active.elapsed() >= BAR_TTL; | 593 | let hidden = viewer.active.elapsed() >= BAR_TTL; |
| 568 | viewer.active = Instant::now(); | 594 | viewer.active = Instant::now(); |
| 595 | + viewer.cursor_hidden = false; | ||
| 569 | if hidden { | 596 | if hidden { |
| 570 | cx.notify(); | 597 | cx.notify(); |
| 571 | } | 598 | } |