From 1ac24b82f1b5ca1229d7b772500d491761fe0d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 19 Aug 2026 20:26:31 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(app):=20the=20player=20goes=20?= =?UTF-8?q?fullscreen=20from=20the=20toolbar=20or=20F11?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gpui Window::toggle_fullscreen wired as ActionId::Fullscreen (View category, always enabled — window-level, touches no edit list). Player::act grows a window parameter to reach the API; topbar gets a state-reflecting Fullscreen / Exit fullscreen button beside Save/Export. --- crates/app/src/keymap.rs | 17 +++++++++++++++-- crates/app/src/oracle.rs | 4 +++- crates/app/src/player/actions.rs | 6 +++++- crates/app/src/render.rs | 6 +++--- crates/app/src/tests/editing.rs | 10 +++++++--- crates/app/src/ui/overlays.rs | 8 ++++---- crates/app/src/ui/toolbar.rs | 21 ++++++++++++++++++++- 7 files changed, 57 insertions(+), 15 deletions(-) diff --git a/crates/app/src/keymap.rs b/crates/app/src/keymap.rs index 9e79c2b..ab82413 100644 --- a/crates/app/src/keymap.rs +++ b/crates/app/src/keymap.rs @@ -134,6 +134,9 @@ actions! { /// toolbar's Theme button. It was a build feature once, which made it a /// choice only whoever compiled the binary could make. Theme, + /// The whole window, borderless over the screen: a player's own control, + /// on the platform's own toggle ([`gpui::Window::toggle_fullscreen`]). + Fullscreen, CancelExport, /// Opens the actions card -- the list every other action is on. A door of /// its own, because a card reachable only by a button in the panel is one a @@ -197,6 +200,7 @@ impl ActionId { ActionId::ToggleProxies => "Proxies on / off for the picture", ActionId::ToggleAutoProxies => "Make proxies on import: on / off", ActionId::Theme => "Theme: the window's colours…", + ActionId::Fullscreen => "Fullscreen on / off", ActionId::CancelExport => "Cancel export", ActionId::ShowActions => "All actions and their keys…", } @@ -255,6 +259,7 @@ impl ActionId { ActionId::ToggleProxies => "toggle-proxies", ActionId::ToggleAutoProxies => "toggle-auto-proxies", ActionId::Theme => "theme", + ActionId::Fullscreen => "fullscreen", ActionId::CancelExport => "cancel-export", ActionId::ShowActions => "show-actions", } @@ -317,7 +322,10 @@ impl ActionId { | ActionId::ToggleAutoProxies // ...and what the whole window is painted in: it edits nothing at // all, it is what one is looking *with*. - | ActionId::Theme => Category::View, + | ActionId::Theme + // ...and whether that window fills the screen: a way of looking, + // same as the zoom and the theme beside it. + | ActionId::Fullscreen => Category::View, ActionId::Cut | ActionId::Regroup | ActionId::Detach @@ -884,6 +892,10 @@ impl Keymap { // it is a preference set once, not a stroke wanted under a hand // that is editing. b(ActionId::Theme, "h", true), + // Every other player's key for it, and free here: nothing in + // this table answers to "f11" (gpui lowercases the keysym + // name it gets from xkb, same as "f1" below). + b(ActionId::Fullscreen, "f11", false), // A chord, and the only escape in this table: bare `esc` is the // stroke a hand throws at anything on screen, and throwing it // at a running export used to delete an hour of encoding. The @@ -1158,7 +1170,8 @@ mod tests { #[test] fn every_default_stroke_reaches_its_action() { let k = Keymap::defaults(); - assert_eq!(k.entries().len(), 53); + assert_eq!(k.entries().len(), 54); + assert_eq!(k.lookup("f11", false), Some(ActionId::Fullscreen)); assert_eq!(k.lookup("p", true), Some(ActionId::ToggleProxies)); assert_eq!(k.lookup("o", true), Some(ActionId::ToggleAutoProxies)); assert_eq!(k.lookup("f1", false), Some(ActionId::ShowActions)); diff --git a/crates/app/src/oracle.rs b/crates/app/src/oracle.rs index 60bcc7d..9f81fe0 100644 --- a/crates/app/src/oracle.rs +++ b/crates/app/src/oracle.rs @@ -98,7 +98,9 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { // The window's own colours: there is always a window, and repainting it // touches no timeline -- so this one is live even while an export is // reading one, which is the only state that dims the list above. - if action == ActionId::Theme { + // ...and whether that window fills the screen: also always there, also + // touching no timeline, live through an export the same way. + if action == ActionId::Theme || action == ActionId::Fullscreen { return Enable::Yes; } if action == ActionId::ShowActions { diff --git a/crates/app/src/player/actions.rs b/crates/app/src/player/actions.rs index f1b34b6..3cdc351 100644 --- a/crates/app/src/player/actions.rs +++ b/crates/app/src/player/actions.rs @@ -7,7 +7,7 @@ impl Player { /// What an action does, wherever it was asked for -- a stroke, or the clip /// menu item that names the same action. One table, so the two can never /// come to mean different things. - pub(crate) fn act(&mut self, action: ActionId, cx: &mut Context) { + pub(crate) fn act(&mut self, action: ActionId, window: &mut Window, cx: &mut Context) { // Two doors, one oracle. This used to be the asymmetry the whole // toolbar was built on: the buttons dimmed themselves off // [`enable`] while the keyboard walked straight past it, so with no @@ -97,6 +97,10 @@ impl Player { // At the window's corner, since a stroke names no place -- and // [`menu_at`] keeps it on screen from there. ActionId::Theme => self.open_picker(Pick::Theme, Point::default(), cx), + // The platform's own toggle (gpui::Window::toggle_fullscreen); the + // window reports its own new state back through `is_fullscreen`, + // there is no local bool to keep in step with it. + ActionId::Fullscreen => window.toggle_fullscreen(), // Nothing to cancel while nothing is exporting; the export guard in // the key handler is what answers this one while there is. ActionId::CancelExport => {} diff --git a/crates/app/src/render.rs b/crates/app/src/render.rs index 1ac0ee0..ed76d46 100644 --- a/crates/app/src/render.rs +++ b/crates/app/src/render.rs @@ -95,7 +95,7 @@ impl Render for Player { div() .track_focus(&self.focus) - .on_key_down(cx.listener(|this, event: &KeyDownEvent, _, cx| { + .on_key_down(cx.listener(|this, event: &KeyDownEvent, window, cx| { let key = event.keystroke.key.as_str(); let ctrl = event.keystroke.modifiers.control; // `is_held` is the auto-repeat, and a value is the one thing @@ -462,7 +462,7 @@ impl Render for Player { } } if let Some(action) = action { - this.act(action, cx); + this.act(action, window, cx); } })) // The whole window is the drop target: gpui turns an external file @@ -548,7 +548,7 @@ impl Render for Player { // it. Nothing here moves when the state changes -- the regions are // fixed and the panels keep their room whether or not anything is // open in them. - .child(self.topbar(cx)) + .child(self.topbar(window, cx)) .child( div() .flex_1() diff --git a/crates/app/src/tests/editing.rs b/crates/app/src/tests/editing.rs index 49974ac..67fcfed 100644 --- a/crates/app/src/tests/editing.rs +++ b/crates/app/src/tests/editing.rs @@ -884,9 +884,13 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() { for action in ActionId::ALL { // Nothing may touch the edit list while an export is reading it -- // and the palette does not: it repaints this window and writes one - // word to the user's own config file, which is why it is the one - // action besides the cancel that stays live here. - let allowed = action == ActionId::CancelExport || action == ActionId::Theme; + // word to the user's own config file, which is why it is one of the + // actions besides the cancel that stay live here. Fullscreen is the + // same kind of thing: the platform's own window toggle, touching no + // edit list either. + let allowed = action == ActionId::CancelExport + || action == ActionId::Theme + || action == ActionId::Fullscreen; assert_eq!( whole(action, busy).yes(), allowed, diff --git a/crates/app/src/ui/overlays.rs b/crates/app/src/ui/overlays.rs index 15def03..9d9b817 100644 --- a/crates/app/src/ui/overlays.rs +++ b/crates/app/src/ui/overlays.rs @@ -304,14 +304,14 @@ impl Player { .when(!refusal.yes(), |d| d.opacity(0.4).cursor_not_allowed()) .when(refusal.yes(), |d| { d.cursor_pointer().hover(|s| s.bg(rgb(BG_HOVER()))).on_click( - cx.listener(move |this, _: &ClickEvent, _, cx| { + cx.listener(move |this, _: &ClickEvent, window, cx| { // The card goes first: several of // these open a card of their own, // and every edit moves the indices // the menus are holding. this.keys_open = false; this.rebinding = None; - this.act(action, cx); + this.act(action, window, cx); cx.notify(); }), ) @@ -578,7 +578,7 @@ impl Player { .when(enabled, |d| { d.cursor_pointer() .hover(|s| s.bg(rgb(BG_HOVER()))) - .on_click(cx.listener(move |this, event: &ClickEvent, _, cx| { + .on_click(cx.listener(move |this, event: &ClickEvent, window, cx| { // Closed first: the action moves the very // indices this menu is holding. this.context_menu = None; @@ -594,7 +594,7 @@ impl Player { cx, ); } else { - this.act(action, cx); + this.act(action, window, cx); } })) }) diff --git a/crates/app/src/ui/toolbar.rs b/crates/app/src/ui/toolbar.rs index 47a7be4..4e0274a 100644 --- a/crates/app/src/ui/toolbar.rs +++ b/crates/app/src/ui/toolbar.rs @@ -49,8 +49,9 @@ impl Player { /// write a file on the right. Export is the one accented button in the /// window -- the primary action of an editor, where every consumer editor /// puts it -- and it keeps its rect while it is a Cancel. - pub(crate) fn topbar(&self, cx: &mut Context) -> impl IntoElement { + pub(crate) fn topbar(&self, window: &mut Window, cx: &mut Context) -> impl IntoElement { let exporting = self.exporting().is_some(); + let fullscreen = window.is_fullscreen(); div() .flex_none() .h(px(TOPBAR_H)) @@ -76,6 +77,24 @@ impl Player { .truncate() .child(self.name.clone()), ) + // The window's own control, in the fixed rect the mute button uses + // for the same reason (toolbar.rs:194-203): fullscreen swaps the + // word and the colour, never the box. + .child(self.action_control( + "fullscreen", + 0., + BG_RAISED(), + None, + match fullscreen { + true => "Exit fullscreen", + false => "Fullscreen", + }, + "fills the screen with the window, or gives it back", + ActionId::Fullscreen, + cx.listener(|this, _: &ClickEvent, window, cx| { + this.act(ActionId::Fullscreen, window, cx) + }), + )) .child(self.action_control( "save", 0.,