From 24cc062fe2f9e3fd2f722ce240bf0c7be5e35089 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 23:13:56 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(app):=20fullscreen=20fills=20t?= =?UTF-8?q?he=20screen=20with=20the=20player,=20not=20the=20app?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fullscreen used to hand the OS window to the monitor with all of the chrome still on it -- a bigger editor, not a bigger picture. It now draws the picture region alone, the way every consumer player does, and asks the platform's own toggle to agree with it. Escape leaves it, and is answered before any menu or preview under it gets a look at the stroke: one stroke, one effect, so an escape with a preview open behind fullscreen leaves fullscreen first and stops the preview on the second. F11 toggles it either way. Driven live in the nested-sway harness on a 4K H.264 mp4: the click on Fullscreen left only the letterboxed picture on screen (no topbar, library, inspector or timeline pixels) with sway fullscreen_mode=1; Escape brought the whole layout back at fullscreen_mode=0; F11 in and Escape out repeated it. 174/174 app tests green. --- crates/app/src/main.rs | 10 ++ crates/app/src/player/actions.rs | 18 ++- crates/app/src/render.rs | 235 +++++++++++++++++++------------ crates/app/src/tests/cards.rs | 11 ++ crates/app/src/tests/mod.rs | 1 + crates/app/src/ui/toolbar.rs | 10 +- 6 files changed, 187 insertions(+), 98 deletions(-) diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index 2e1e893..22dd8c3 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -30,6 +30,7 @@ pub(crate) use interact::*; pub(crate) use layout::*; pub(crate) use library_meta::*; pub(crate) use menus::*; +pub(crate) use render::escape_leaves_player_fullscreen; pub(crate) use notices::*; pub(crate) use oracle::*; pub(crate) use subs::*; @@ -93,6 +94,14 @@ struct Player { /// ([`Player::open_preview`] pauses it so the two sounds never overlap): /// what [`Player::close_preview`] resumes, and only then. preview_playing: bool, + /// The picture alone, filling the window -- what `Fullscreen` gives every + /// consumer video player, and not what gpui's own `toggle_fullscreen` + /// gives on its own (the OS window, chrome and all). Kept apart from + /// `window.is_fullscreen()` because the two can fall out of step: a + /// compositor keybind changes the window's without this flag hearing + /// about it, so [`Player::act`] reconciles them rather than trusting + /// either alone. + player_fullscreen: bool, /// Timeline seconds -> frame index, so the clock can be compared to what /// the decoder hands over. fps: f64, @@ -716,6 +725,7 @@ fn main() { pending_settings: (None, None, None), preview_session: None, preview_playing: false, + player_fullscreen: false, // Full and unmuted, which is what the session it was just // handed is already set to: nothing to push at startup. volume: Volume::default(), diff --git a/crates/app/src/player/actions.rs b/crates/app/src/player/actions.rs index 5f8bdc6..2e65e76 100644 --- a/crates/app/src/player/actions.rs +++ b/crates/app/src/player/actions.rs @@ -98,10 +98,20 @@ 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(), + // Not the window's own toggle alone -- every consumer video + // player fullscreens the *picture*, chrome and all, not just the + // OS frame around it -- so this flips both: `player_fullscreen` + // is what [`crate::render`] reads to draw the picture only, and + // the platform's own toggle is what actually grows the window to + // the monitor. The two are asked to agree rather than one being + // derived from the other, because a compositor keybind can move + // `window.is_fullscreen()` without this action ever firing. + ActionId::Fullscreen => { + self.player_fullscreen = !self.player_fullscreen; + if window.is_fullscreen() != self.player_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 c76da72..439f79f 100644 --- a/crates/app/src/render.rs +++ b/crates/app/src/render.rs @@ -3,6 +3,88 @@ use crate::*; +/// Whether a stroke leaves player fullscreen. Bare escape does, the same +/// stroke every card and menu in this window answers to -- and it is +/// answered *first*: the picture-only layout is the chrome itself missing, +/// not a card drawn over it, so it goes before a menu close or a preview +/// close gets a look at the same key. See the call site in [`Player::render`] +/// for the deliberate order this buys with a preview open underneath. +pub(crate) fn escape_leaves_player_fullscreen(key: &str, ctrl: bool, player_fullscreen: bool) -> bool { + key == ESCAPE && !ctrl && player_fullscreen +} + +impl Player { + /// The picture region alone: the image, the subtitle cue plate, the + /// preview badge and the three transient bars over its bottom edge. + /// Its own method so player fullscreen ([`Player::act`]) can stand it up + /// as the window's only child without a second copy of what it draws. + fn picture_area( + &mut self, + position: f64, + window: &mut Window, + cx: &mut Context, + ) -> impl IntoElement { + div() + .flex_1() + .min_h(px(0.)) + .overflow_hidden() + // The bed the cue plate is placed against: it hangs off the + // bottom of the picture region, which is the one box that is the + // picture and nothing else. + .relative() + .flex() + .justify_center() + .items_center() + .bg(rgb(BG_CANVAS())) + .children( + self.image + .clone() + .map(|i| { + img(i) + .size_full() + .object_fit(gpui::ObjectFit::Contain) + .into_any_element() + }) + // With no file open the letterbox is the whole region, + // and a black rectangle says only that something is + // broken -- so it says what it wants instead. The window + // is already the drop target. + .or_else(|| { + (self.active_session().is_none()) + .then(|| empty_hint().into_any_element()) + }), + ) + // After the picture, so the plate is drawn over it rather than + // under. + .children(self.subtitle_overlay(position, window)) + .children(self.preview_badge(cx)) + // The three transient lines hang off the bottom of the picture + // rather than taking a row of the column: a notice that arrives + // must not push the transport, the toolbar and the timeline down + // by its own height -- which is a control moving with state, on + // every control below it at once. + .child( + div() + .absolute() + .bottom_0() + .left_0() + .right_0() + .flex() + .flex_col() + .gap(px(2.)) + .children(self.import_bar(cx)) + .children(self.seek_bar()) + .children(self.notice_bar(cx)) + // How tall the lot came out, for the cue plate above to + // step over ([`sub_bottom`]) -- the bars are over the + // picture, and a message drawn across the line being + // read loses both of them. Zero with no bar up, since + // this box is then empty. + .child(height_probe(self.notice_h.clone())), + ) + } +} + impl Render for Player { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { // A file that has just been opened sits on its first frame with the @@ -37,6 +119,16 @@ impl Render for Player { window.set_window_title(&title); self.titled = title; } + // A compositor keybind (the window manager's own fullscreen, not + // ours) can drop `window.is_fullscreen()` without ever going through + // [`Player::act`] -- the picture-only layout below must not survive + // that on its own, or the chrome never comes back. Only the *leaving* + // direction is reconciled here: the platform going fullscreen behind + // our back is not this editor asking for the picture-only layout, so + // it is left alone rather than guessed at. + if self.player_fullscreen && !window.is_fullscreen() { + self.player_fullscreen = false; + } // No shadow flag: the session is the only truth about play state, and // [`Player::transport`] is the one place it is read. let state = self.transport(); @@ -477,6 +569,21 @@ impl Render for Player { // the keys before anything under it does: ↑↓ walk it, enter // takes the row, and escape falls through to the close below -- // the same three strokes every list in this editor answers. + // The picture-only layout is the outermost thing on screen -- + // it is the chrome itself that is missing, not a card drawn + // over it -- so its own escape is answered before any menu or + // preview below gets a look at the stroke. Deliberate order: + // with a preview open *and* the player fullscreen, the first + // Escape only leaves fullscreen (the preview keeps playing, + // now behind the chrome again), and it takes a second Escape + // to stop the preview -- one stroke, one effect, same as + // every other card in this chain. + if escape_leaves_player_fullscreen(key, ctrl, this.player_fullscreen) { + this.player_fullscreen = false; + window.toggle_fullscreen(); + cx.notify(); + return; + } if let Some(mut picker) = this.picker { let rows = this.choices(picker.of); if !rows.is_empty() && matches!(key, "up" | "down" | "enter") { @@ -598,107 +705,53 @@ 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(window, cx)) - .child( - div() - .flex_1() - .min_h(px(0.)) - .flex() - .child(self.library( - self.split_px(Split::Library, window.viewport_size()), - cx, - )) - // The seams, one per pair of regions: what a hand drags to - // give a panel more room and its neighbour less - // ([`divider`]). - .child(divider(Split::Library, cx)) + // Player fullscreen: the picture and nothing else -- what + // `Fullscreen` gives every consumer video player. The four-region + // layout is skipped rather than hidden under it (a hidden library + // and inspector would still lay out and take the split's own + // room), and the picture div itself is untouched either way -- + // [`Player::picture_area`] is the same call in both arms. + .when(self.player_fullscreen, |d| { + d.child(self.picture_area(position, window, cx)) + }) + .when(!self.player_fullscreen, |d| { + d.child(self.topbar(window, cx)) .child( div() .flex_1() - .min_w(px(0.)) + .min_h(px(0.)) .flex() - .flex_col() + .child(self.library( + self.split_px(Split::Library, window.viewport_size()), + cx, + )) + // The seams, one per pair of regions: what a hand + // drags to give a panel more room and its + // neighbour less ([`divider`]). + .child(divider(Split::Library, cx)) .child( div() .flex_1() - .min_h(px(0.)) - .overflow_hidden() - // The bed the cue plate is placed against: - // it hangs off the bottom of the picture - // region, which is the one box that is the - // picture and nothing else. - .relative() + .min_w(px(0.)) .flex() - .justify_center() - .items_center() - .bg(rgb(BG_CANVAS())) - .children( - self.image - .clone() - .map(|i| { - img(i) - .size_full() - .object_fit(gpui::ObjectFit::Contain) - .into_any_element() - }) - // With no file open the letterbox - // is the whole region, and a black - // rectangle says only that - // something is broken -- so it says - // what it wants instead. The window - // is already the drop target. - .or_else(|| { - (self.active_session().is_none()) - .then(|| empty_hint().into_any_element()) - }), - ) - // After the picture, so the plate is drawn - // over it rather than under. - .children(self.subtitle_overlay(position, window)) - .children(self.preview_badge(cx)) - // The three transient lines hang off the - // bottom of the picture rather than taking - // a row of the column: a notice that - // arrives must not push the transport, the - // toolbar and the timeline down by its own - // height -- which is a control moving with - // state, on every control below it at once. - .child( - div() - .absolute() - .bottom_0() - .left_0() - .right_0() - .flex() - .flex_col() - .gap(px(2.)) - .children(self.import_bar(cx)) - .children(self.seek_bar()) - .children(self.notice_bar(cx)) - // How tall the lot came out, for the - // cue plate above to step over - // ([`sub_bottom`]) -- the bars are - // over the picture, and a message - // drawn across the line being read - // loses both of them. Zero with no - // bar up, since this box is then - // empty. - .child(height_probe(self.notice_h.clone())), - ), + .flex_col() + .child(self.picture_area(position, window, cx)) + .child(self.transport_bar(state, window.viewport_size(), cx)), ) - .child(self.transport_bar(state, window.viewport_size(), cx)), + .child(divider(Split::Inspector, cx)) + // The settings cards live in here rather than over + // the timeline: adjusting a clip must not hide the + // clip. + .child(self.inspector(window.viewport_size(), cx)), ) - .child(divider(Split::Inspector, cx)) - // The settings cards live in here rather than over the - // timeline: adjusting a clip must not hide the clip. - .child(self.inspector(window.viewport_size(), cx)), - ) - // Above the toolbar rather than under it: the toolbar is a fixed - // strip belonging to the timeline, so the pair moves as one and the - // edge the hand is pulling is the edge under the pointer. - .child(divider(Split::Timeline, cx)) - .child(self.toolbar(cx)) - .child(self.timeline(position, state, window.viewport_size(), cx)) + // Above the toolbar rather than under it: the toolbar is + // a fixed strip belonging to the timeline, so the pair + // moves as one and the edge the hand is pulling is the + // edge under the pointer. + .child(divider(Split::Timeline, cx)) + .child(self.toolbar(cx)) + .child(self.timeline(position, state, window.viewport_size(), cx)) + }) // Over the region they were opened on, and under the modal cards: // they are only ever up while none of those is (`modal`). .children(self.context_card(window.viewport_size(), cx)) diff --git a/crates/app/src/tests/cards.rs b/crates/app/src/tests/cards.rs index 43eb649..12ba0df 100644 --- a/crates/app/src/tests/cards.rs +++ b/crates/app/src/tests/cards.rs @@ -3,6 +3,17 @@ use super::*; +#[test] +fn a_bare_escape_leaves_player_fullscreen_before_anything_under_it() { + // Fires while the picture-only layout is up, on the same bare escape + // every menu and preview close on -- and only that key: a chord, or an + // escape while not fullscreen, means nothing to it. + assert!(escape_leaves_player_fullscreen("escape", false, true)); + assert!(!escape_leaves_player_fullscreen("escape", false, false)); + assert!(!escape_leaves_player_fullscreen("escape", true, true)); + assert!(!escape_leaves_player_fullscreen("q", false, true)); +} + #[test] fn only_a_chord_gets_out_of_an_export() { use keymap::ActionId; diff --git a/crates/app/src/tests/mod.rs b/crates/app/src/tests/mod.rs index 73f7363..72eabe4 100644 --- a/crates/app/src/tests/mod.rs +++ b/crates/app/src/tests/mod.rs @@ -25,6 +25,7 @@ use super::{ bitrate_detail, bitrate_refusal, can_add, cancels_export, clipboard_after_remove, color_snap, commit_mbps, containers, enable, envelope, eq_card_w, eq_freq, eq_freq_label, eq_spectrum, eq_x, eq_y, + escape_leaves_player_fullscreen, estimated_bytes, export_path, export_settings, format_key, format_line, format_refusal, fps_choices, fps_label, frac_along, frac_down, frame_at, frame_rate_ladder, histogram, diff --git a/crates/app/src/ui/toolbar.rs b/crates/app/src/ui/toolbar.rs index 9e5ade7..ca45f5e 100644 --- a/crates/app/src/ui/toolbar.rs +++ b/crates/app/src/ui/toolbar.rs @@ -49,9 +49,13 @@ 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, window: &mut Window, 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(); + // This button's own row is part of the chrome player fullscreen + // hides, so once it reads true the button is already off screen -- + // F11 or Escape is what a person actually leaves by, which is why the + // hint below names both. + let fullscreen = self.player_fullscreen; div() .flex_none() .h(px(TOPBAR_H)) @@ -89,7 +93,7 @@ impl Player { true => "Exit fullscreen", false => "Fullscreen", }, - "fills the screen with the window, or gives it back", + "fills the screen with the picture; F11 or Escape gives it back", ActionId::Fullscreen, cx.listener(|this, _: &ClickEvent, window, cx| { this.act(ActionId::Fullscreen, window, cx)