diff --git a/crates/client/src/gui.rs b/crates/client/src/gui.rs index 0bf1398..abfd101 100644 --- a/crates/client/src/gui.rs +++ b/crates/client/src/gui.rs @@ -1401,6 +1401,7 @@ impl Render for Yumush { self.fullscreen = fullscreen; window.toggle_fullscreen(); } + self.hide_idle_cursor(window, cx); self.schedule_pump(window, cx); let palette = palette(cx); sync_accent(self.themed(cx).accent, cx); diff --git a/crates/client/src/gui/share_view.rs b/crates/client/src/gui/share_view.rs index 6037bec..ae20090 100644 --- a/crates/client/src/gui/share_view.rs +++ b/crates/client/src/gui/share_view.rs @@ -13,8 +13,9 @@ const TOP_QUALITY: Quality = Quality { fps: Fps::F60, }; use gpui_kit::{ - Anchor, AnyElement, AppContext, Context, Div, Entity, InteractiveElement, IntoElement, - MouseButton, ParentElement, StatefulInteractiveElement, Styled, Subscription, Window, + Anchor, AnyElement, App, AppContext, Context, Div, Entity, InteractiveElement, IntoElement, + KeyDownEvent, Keystroke, Modifiers, MouseButton, ParentElement, PlatformInput, + StatefulInteractiveElement, Styled, Subscription, Window, assets::IconName, component::{ Icon, @@ -121,6 +122,7 @@ pub(super) struct Viewer { volume: Entity, restore: f32, active: Instant, + cursor_hidden: bool, stats: bool, _subscriptions: Vec, } @@ -360,6 +362,7 @@ impl Yumush { volume, restore: FULL_VOLUME, active: Instant::now(), + cursor_hidden: false, stats: false, _subscriptions: subscriptions, }); @@ -525,6 +528,29 @@ impl Yumush { Some(self.viewer_pane(viewer, entity, palette)) } + pub(super) fn hide_idle_cursor(&mut self, window: &mut Window, cx: &mut App) { + let Some(viewer) = self.chat.viewer.as_mut().filter(|viewer| { + viewer.fullscreen && !viewer.cursor_hidden && viewer.active.elapsed() >= BAR_TTL + }) else { + return; + }; + viewer.cursor_hidden = true; + window.defer(cx, |window, cx| { + window.dispatch_event( + PlatformInput::KeyDown(KeyDownEvent { + keystroke: Keystroke { + modifiers: Modifiers::default(), + key: "f24".into(), + key_char: Some(String::new()), + }, + is_held: false, + prefer_character_input: false, + }), + cx, + ); + }); + } + pub(super) fn fullscreen_viewer(&self, entity: &Entity, palette: Palette) -> Option
{ let viewer = self .chat @@ -566,6 +592,7 @@ impl Yumush { if let Some(viewer) = yumush.chat.viewer.as_mut() { let hidden = viewer.active.elapsed() >= BAR_TTL; viewer.active = Instant::now(); + viewer.cursor_hidden = false; if hidden { cx.notify(); }