forge
Explore
Log in

Don't you dare go Hollow

Fullscreen fills the screen with the player, not the app

Browse files at this commit

24cc062fe2f9e3fd2f722ce240bf0c7be5e35089Ahmet Kaan GümüşParent: f30fe44
  • feat
    • fullscreen fills the screen with the player, not the app
Show full message
✨ feat(app): fullscreen fills the screen with the player, not the app

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.rsmodified+10 -0
@@ -30,6 +30,7 @@ pub(crate) use interact::*;
3030 pub(crate) use layout::*;
3131 pub(crate) use library_meta::*;
3232 pub(crate) use menus::*;
33+pub(crate) use render::escape_leaves_player_fullscreen;
3334 pub(crate) use notices::*;
3435 pub(crate) use oracle::*;
3536 pub(crate) use subs::*;
@@ -93,6 +94,14 @@ struct Player {
9394 /// ([`Player::open_preview`] pauses it so the two sounds never overlap):
9495 /// what [`Player::close_preview`] resumes, and only then.
9596 preview_playing: bool,
97+ /// The picture alone, filling the window -- what `Fullscreen` gives every
98+ /// consumer video player, and not what gpui's own `toggle_fullscreen`
99+ /// gives on its own (the OS window, chrome and all). Kept apart from
100+ /// `window.is_fullscreen()` because the two can fall out of step: a
101+ /// compositor keybind changes the window's without this flag hearing
102+ /// about it, so [`Player::act`] reconciles them rather than trusting
103+ /// either alone.
104+ player_fullscreen: bool,
96105 /// Timeline seconds -> frame index, so the clock can be compared to what
97106 /// the decoder hands over.
98107 fps: f64,
@@ -716,6 +725,7 @@ fn main() {
716725 pending_settings: (None, None, None),
717726 preview_session: None,
718727 preview_playing: false,
728+ player_fullscreen: false,
719729 // Full and unmuted, which is what the session it was just
720730 // handed is already set to: nothing to push at startup.
721731 volume: Volume::default(),
crates/app/src/player/actions.rsmodified+14 -4
@@ -98,10 +98,20 @@ impl Player {
9898 // At the window's corner, since a stroke names no place -- and
9999 // [`menu_at`] keeps it on screen from there.
100100 ActionId::Theme => self.open_picker(Pick::Theme, Point::default(), cx),
101- // The platform's own toggle (gpui::Window::toggle_fullscreen); the
102- // window reports its own new state back through `is_fullscreen`,
103- // there is no local bool to keep in step with it.
104- ActionId::Fullscreen => window.toggle_fullscreen(),
101+ // Not the window's own toggle alone -- every consumer video
102+ // player fullscreens the *picture*, chrome and all, not just the
103+ // OS frame around it -- so this flips both: `player_fullscreen`
104+ // is what [`crate::render`] reads to draw the picture only, and
105+ // the platform's own toggle is what actually grows the window to
106+ // the monitor. The two are asked to agree rather than one being
107+ // derived from the other, because a compositor keybind can move
108+ // `window.is_fullscreen()` without this action ever firing.
109+ ActionId::Fullscreen => {
110+ self.player_fullscreen = !self.player_fullscreen;
111+ if window.is_fullscreen() != self.player_fullscreen {
112+ window.toggle_fullscreen();
113+ }
114+ }
105115 // Nothing to cancel while nothing is exporting; the export guard in
106116 // the key handler is what answers this one while there is.
107117 ActionId::CancelExport => {}
crates/app/src/render.rsmodified+144 -91
@@ -3,6 +3,88 @@
33
44 use crate::*;
55
6+/// Whether a stroke leaves player fullscreen. Bare escape does, the same
7+/// stroke every card and menu in this window answers to -- and it is
8+/// answered *first*: the picture-only layout is the chrome itself missing,
9+/// not a card drawn over it, so it goes before a menu close or a preview
10+/// close gets a look at the same key. See the call site in [`Player::render`]
11+/// for the deliberate order this buys with a preview open underneath.
12+pub(crate) fn escape_leaves_player_fullscreen(key: &str, ctrl: bool, player_fullscreen: bool) -> bool {
13+ key == ESCAPE && !ctrl && player_fullscreen
14+}
15+
16+impl Player {
17+ /// The picture region alone: the image, the subtitle cue plate, the
18+ /// preview badge and the three transient bars over its bottom edge.
19+ /// Its own method so player fullscreen ([`Player::act`]) can stand it up
20+ /// as the window's only child without a second copy of what it draws.
21+ fn picture_area(
22+ &mut self,
23+ position: f64,
24+ window: &mut Window,
25+ cx: &mut Context<Self>,
26+ ) -> impl IntoElement {
27+ div()
28+ .flex_1()
29+ .min_h(px(0.))
30+ .overflow_hidden()
31+ // The bed the cue plate is placed against: it hangs off the
32+ // bottom of the picture region, which is the one box that is the
33+ // picture and nothing else.
34+ .relative()
35+ .flex()
36+ .justify_center()
37+ .items_center()
38+ .bg(rgb(BG_CANVAS()))
39+ .children(
40+ self.image
41+ .clone()
42+ .map(|i| {
43+ img(i)
44+ .size_full()
45+ .object_fit(gpui::ObjectFit::Contain)
46+ .into_any_element()
47+ })
48+ // With no file open the letterbox is the whole region,
49+ // and a black rectangle says only that something is
50+ // broken -- so it says what it wants instead. The window
51+ // is already the drop target.
52+ .or_else(|| {
53+ (self.active_session().is_none())
54+ .then(|| empty_hint().into_any_element())
55+ }),
56+ )
57+ // After the picture, so the plate is drawn over it rather than
58+ // under.
59+ .children(self.subtitle_overlay(position, window))
60+ .children(self.preview_badge(cx))
61+ // The three transient lines hang off the bottom of the picture
62+ // rather than taking a row of the column: a notice that arrives
63+ // must not push the transport, the toolbar and the timeline down
64+ // by its own height -- which is a control moving with state, on
65+ // every control below it at once.
66+ .child(
67+ div()
68+ .absolute()
69+ .bottom_0()
70+ .left_0()
71+ .right_0()
72+ .flex()
73+ .flex_col()
74+ .gap(px(2.))
75+ .children(self.import_bar(cx))
76+ .children(self.seek_bar())
77+ .children(self.notice_bar(cx))
78+ // How tall the lot came out, for the cue plate above to
79+ // step over ([`sub_bottom`]) -- the bars are over the
80+ // picture, and a message drawn across the line being
81+ // read loses both of them. Zero with no bar up, since
82+ // this box is then empty.
83+ .child(height_probe(self.notice_h.clone())),
84+ )
85+ }
86+}
87+
688 impl Render for Player {
789 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
890 // A file that has just been opened sits on its first frame with the
@@ -37,6 +119,16 @@ impl Render for Player {
37119 window.set_window_title(&title);
38120 self.titled = title;
39121 }
122+ // A compositor keybind (the window manager's own fullscreen, not
123+ // ours) can drop `window.is_fullscreen()` without ever going through
124+ // [`Player::act`] -- the picture-only layout below must not survive
125+ // that on its own, or the chrome never comes back. Only the *leaving*
126+ // direction is reconciled here: the platform going fullscreen behind
127+ // our back is not this editor asking for the picture-only layout, so
128+ // it is left alone rather than guessed at.
129+ if self.player_fullscreen && !window.is_fullscreen() {
130+ self.player_fullscreen = false;
131+ }
40132 // No shadow flag: the session is the only truth about play state, and
41133 // [`Player::transport`] is the one place it is read.
42134 let state = self.transport();
@@ -477,6 +569,21 @@ impl Render for Player {
477569 // the keys before anything under it does: ↑↓ walk it, enter
478570 // takes the row, and escape falls through to the close below --
479571 // the same three strokes every list in this editor answers.
572+ // The picture-only layout is the outermost thing on screen --
573+ // it is the chrome itself that is missing, not a card drawn
574+ // over it -- so its own escape is answered before any menu or
575+ // preview below gets a look at the stroke. Deliberate order:
576+ // with a preview open *and* the player fullscreen, the first
577+ // Escape only leaves fullscreen (the preview keeps playing,
578+ // now behind the chrome again), and it takes a second Escape
579+ // to stop the preview -- one stroke, one effect, same as
580+ // every other card in this chain.
581+ if escape_leaves_player_fullscreen(key, ctrl, this.player_fullscreen) {
582+ this.player_fullscreen = false;
583+ window.toggle_fullscreen();
584+ cx.notify();
585+ return;
586+ }
480587 if let Some(mut picker) = this.picker {
481588 let rows = this.choices(picker.of);
482589 if !rows.is_empty() && matches!(key, "up" | "down" | "enter") {
@@ -598,107 +705,53 @@ impl Render for Player {
598705 // it. Nothing here moves when the state changes -- the regions are
599706 // fixed and the panels keep their room whether or not anything is
600707 // open in them.
601- .child(self.topbar(window, cx))
602- .child(
603- div()
604- .flex_1()
605- .min_h(px(0.))
606- .flex()
607- .child(self.library(
608- self.split_px(Split::Library, window.viewport_size()),
609- cx,
610- ))
611- // The seams, one per pair of regions: what a hand drags to
612- // give a panel more room and its neighbour less
613- // ([`divider`]).
614- .child(divider(Split::Library, cx))
708+ // Player fullscreen: the picture and nothing else -- what
709+ // `Fullscreen` gives every consumer video player. The four-region
710+ // layout is skipped rather than hidden under it (a hidden library
711+ // and inspector would still lay out and take the split's own
712+ // room), and the picture div itself is untouched either way --
713+ // [`Player::picture_area`] is the same call in both arms.
714+ .when(self.player_fullscreen, |d| {
715+ d.child(self.picture_area(position, window, cx))
716+ })
717+ .when(!self.player_fullscreen, |d| {
718+ d.child(self.topbar(window, cx))
615719 .child(
616720 div()
617721 .flex_1()
618- .min_w(px(0.))
722+ .min_h(px(0.))
619723 .flex()
620- .flex_col()
724+ .child(self.library(
725+ self.split_px(Split::Library, window.viewport_size()),
726+ cx,
727+ ))
728+ // The seams, one per pair of regions: what a hand
729+ // drags to give a panel more room and its
730+ // neighbour less ([`divider`]).
731+ .child(divider(Split::Library, cx))
621732 .child(
622733 div()
623734 .flex_1()
624- .min_h(px(0.))
625- .overflow_hidden()
626- // The bed the cue plate is placed against:
627- // it hangs off the bottom of the picture
628- // region, which is the one box that is the
629- // picture and nothing else.
630- .relative()
735+ .min_w(px(0.))
631736 .flex()
632- .justify_center()
633- .items_center()
634- .bg(rgb(BG_CANVAS()))
635- .children(
636- self.image
637- .clone()
638- .map(|i| {
639- img(i)
640- .size_full()
641- .object_fit(gpui::ObjectFit::Contain)
642- .into_any_element()
643- })
644- // With no file open the letterbox
645- // is the whole region, and a black
646- // rectangle says only that
647- // something is broken -- so it says
648- // what it wants instead. The window
649- // is already the drop target.
650- .or_else(|| {
651- (self.active_session().is_none())
652- .then(|| empty_hint().into_any_element())
653- }),
654- )
655- // After the picture, so the plate is drawn
656- // over it rather than under.
657- .children(self.subtitle_overlay(position, window))
658- .children(self.preview_badge(cx))
659- // The three transient lines hang off the
660- // bottom of the picture rather than taking
661- // a row of the column: a notice that
662- // arrives must not push the transport, the
663- // toolbar and the timeline down by its own
664- // height -- which is a control moving with
665- // state, on every control below it at once.
666- .child(
667- div()
668- .absolute()
669- .bottom_0()
670- .left_0()
671- .right_0()
672- .flex()
673- .flex_col()
674- .gap(px(2.))
675- .children(self.import_bar(cx))
676- .children(self.seek_bar())
677- .children(self.notice_bar(cx))
678- // How tall the lot came out, for the
679- // cue plate above to step over
680- // ([`sub_bottom`]) -- the bars are
681- // over the picture, and a message
682- // drawn across the line being read
683- // loses both of them. Zero with no
684- // bar up, since this box is then
685- // empty.
686- .child(height_probe(self.notice_h.clone())),
687- ),
737+ .flex_col()
738+ .child(self.picture_area(position, window, cx))
739+ .child(self.transport_bar(state, window.viewport_size(), cx)),
688740 )
689- .child(self.transport_bar(state, window.viewport_size(), cx)),
741+ .child(divider(Split::Inspector, cx))
742+ // The settings cards live in here rather than over
743+ // the timeline: adjusting a clip must not hide the
744+ // clip.
745+ .child(self.inspector(window.viewport_size(), cx)),
690746 )
691- .child(divider(Split::Inspector, cx))
692- // The settings cards live in here rather than over the
693- // timeline: adjusting a clip must not hide the clip.
694- .child(self.inspector(window.viewport_size(), cx)),
695- )
696- // Above the toolbar rather than under it: the toolbar is a fixed
697- // strip belonging to the timeline, so the pair moves as one and the
698- // edge the hand is pulling is the edge under the pointer.
699- .child(divider(Split::Timeline, cx))
700- .child(self.toolbar(cx))
701- .child(self.timeline(position, state, window.viewport_size(), cx))
747+ // Above the toolbar rather than under it: the toolbar is
748+ // a fixed strip belonging to the timeline, so the pair
749+ // moves as one and the edge the hand is pulling is the
750+ // edge under the pointer.
751+ .child(divider(Split::Timeline, cx))
752+ .child(self.toolbar(cx))
753+ .child(self.timeline(position, state, window.viewport_size(), cx))
754+ })
702755 // Over the region they were opened on, and under the modal cards:
703756 // they are only ever up while none of those is (`modal`).
704757 .children(self.context_card(window.viewport_size(), cx))
crates/app/src/tests/cards.rsmodified+11 -0
@@ -3,6 +3,17 @@
33
44 use super::*;
55
6+#[test]
7+fn a_bare_escape_leaves_player_fullscreen_before_anything_under_it() {
8+ // Fires while the picture-only layout is up, on the same bare escape
9+ // every menu and preview close on -- and only that key: a chord, or an
10+ // escape while not fullscreen, means nothing to it.
11+ assert!(escape_leaves_player_fullscreen("escape", false, true));
12+ assert!(!escape_leaves_player_fullscreen("escape", false, false));
13+ assert!(!escape_leaves_player_fullscreen("escape", true, true));
14+ assert!(!escape_leaves_player_fullscreen("q", false, true));
15+}
16+
617 #[test]
718 fn only_a_chord_gets_out_of_an_export() {
819 use keymap::ActionId;
crates/app/src/tests/mod.rsmodified+1 -0
@@ -25,6 +25,7 @@ use super::{
2525 bitrate_detail, bitrate_refusal, can_add, cancels_export, clipboard_after_remove, color_snap, commit_mbps,
2626 containers,
2727 enable, envelope, eq_card_w, eq_freq, eq_freq_label, eq_spectrum, eq_x, eq_y,
28+ escape_leaves_player_fullscreen,
2829 estimated_bytes, export_path, export_settings, format_key,
2930 format_line, format_refusal, fps_choices, fps_label, frac_along, frac_down, frame_at,
3031 frame_rate_ladder, histogram,
crates/app/src/ui/toolbar.rsmodified+7 -3
@@ -49,9 +49,13 @@ impl Player {
4949 /// write a file on the right. Export is the one accented button in the
5050 /// window -- the primary action of an editor, where every consumer editor
5151 /// puts it -- and it keeps its rect while it is a Cancel.
52- pub(crate) fn topbar(&self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
52+ pub(crate) fn topbar(&self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
5353 let exporting = self.exporting().is_some();
54- let fullscreen = window.is_fullscreen();
54+ // This button's own row is part of the chrome player fullscreen
55+ // hides, so once it reads true the button is already off screen --
56+ // F11 or Escape is what a person actually leaves by, which is why the
57+ // hint below names both.
58+ let fullscreen = self.player_fullscreen;
5559 div()
5660 .flex_none()
5761 .h(px(TOPBAR_H))
@@ -89,7 +93,7 @@ impl Player {
8993 true => "Exit fullscreen",
9094 false => "Fullscreen",
9195 },
92- "fills the screen with the window, or gives it back",
96+ "fills the screen with the picture; F11 or Escape gives it back",
9397 ActionId::Fullscreen,
9498 cx.listener(|this, _: &ClickEvent, window, cx| {
9599 this.act(ActionId::Fullscreen, window, cx)