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::*;
30 pub(crate) use layout::*;30 pub(crate) use layout::*;
31 pub(crate) use library_meta::*;31 pub(crate) use library_meta::*;
32 pub(crate) use menus::*;32 pub(crate) use menus::*;
33+pub(crate) use render::escape_leaves_player_fullscreen;
33 pub(crate) use notices::*;34 pub(crate) use notices::*;
34 pub(crate) use oracle::*;35 pub(crate) use oracle::*;
35 pub(crate) use subs::*;36 pub(crate) use subs::*;
@@ -93,6 +94,14 @@ struct Player {
93 /// ([`Player::open_preview`] pauses it so the two sounds never overlap):94 /// ([`Player::open_preview`] pauses it so the two sounds never overlap):
94 /// what [`Player::close_preview`] resumes, and only then.95 /// what [`Player::close_preview`] resumes, and only then.
95 preview_playing: bool,96 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,
96 /// Timeline seconds -> frame index, so the clock can be compared to what105 /// Timeline seconds -> frame index, so the clock can be compared to what
97 /// the decoder hands over.106 /// the decoder hands over.
98 fps: f64,107 fps: f64,
@@ -716,6 +725,7 @@ fn main() {
716 pending_settings: (None, None, None),725 pending_settings: (None, None, None),
717 preview_session: None,726 preview_session: None,
718 preview_playing: false,727 preview_playing: false,
728+ player_fullscreen: false,
719 // Full and unmuted, which is what the session it was just729 // Full and unmuted, which is what the session it was just
720 // handed is already set to: nothing to push at startup.730 // handed is already set to: nothing to push at startup.
721 volume: Volume::default(),731 volume: Volume::default(),
crates/app/src/player/actions.rsmodified+14 -4
@@ -98,10 +98,20 @@ impl Player {
98 // At the window's corner, since a stroke names no place -- and98 // At the window's corner, since a stroke names no place -- and
99 // [`menu_at`] keeps it on screen from there.99 // [`menu_at`] keeps it on screen from there.
100 ActionId::Theme => self.open_picker(Pick::Theme, Point::default(), cx),100 ActionId::Theme => self.open_picker(Pick::Theme, Point::default(), cx),
101- // The platform's own toggle (gpui::Window::toggle_fullscreen); the101+ // Not the window's own toggle alone -- every consumer video
102- // window reports its own new state back through `is_fullscreen`,102+ // player fullscreens the *picture*, chrome and all, not just the
103- // there is no local bool to keep in step with it.103+ // OS frame around it -- so this flips both: `player_fullscreen`
104- ActionId::Fullscreen => window.toggle_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+ }
105 // Nothing to cancel while nothing is exporting; the export guard in115 // Nothing to cancel while nothing is exporting; the export guard in
106 // the key handler is what answers this one while there is.116 // the key handler is what answers this one while there is.
107 ActionId::CancelExport => {}117 ActionId::CancelExport => {}
crates/app/src/render.rsmodified+144 -91
@@ -3,6 +3,88 @@
3 3
4 use crate::*;4 use crate::*;
5 5
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+
6 impl Render for Player {88 impl Render for Player {
7 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {89 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
8 // A file that has just been opened sits on its first frame with the90 // A file that has just been opened sits on its first frame with the
@@ -37,6 +119,16 @@ impl Render for Player {
37 window.set_window_title(&title);119 window.set_window_title(&title);
38 self.titled = title;120 self.titled = title;
39 }121 }
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+ }
40 // No shadow flag: the session is the only truth about play state, and132 // No shadow flag: the session is the only truth about play state, and
41 // [`Player::transport`] is the one place it is read.133 // [`Player::transport`] is the one place it is read.
42 let state = self.transport();134 let state = self.transport();
@@ -477,6 +569,21 @@ impl Render for Player {
477 // the keys before anything under it does: ↑↓ walk it, enter569 // the keys before anything under it does: ↑↓ walk it, enter
478 // takes the row, and escape falls through to the close below --570 // takes the row, and escape falls through to the close below --
479 // the same three strokes every list in this editor answers.571 // 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+ }
480 if let Some(mut picker) = this.picker {587 if let Some(mut picker) = this.picker {
481 let rows = this.choices(picker.of);588 let rows = this.choices(picker.of);
482 if !rows.is_empty() && matches!(key, "up" | "down" | "enter") {589 if !rows.is_empty() && matches!(key, "up" | "down" | "enter") {
@@ -598,107 +705,53 @@ impl Render for Player {
598 // it. Nothing here moves when the state changes -- the regions are705 // it. Nothing here moves when the state changes -- the regions are
599 // fixed and the panels keep their room whether or not anything is706 // fixed and the panels keep their room whether or not anything is
600 // open in them.707 // open in them.
601- .child(self.topbar(window, cx))708+ // Player fullscreen: the picture and nothing else -- what
602- .child(709+ // `Fullscreen` gives every consumer video player. The four-region
603- div()710+ // layout is skipped rather than hidden under it (a hidden library
604- .flex_1()711+ // and inspector would still lay out and take the split's own
605- .min_h(px(0.))712+ // room), and the picture div itself is untouched either way --
606- .flex()713+ // [`Player::picture_area`] is the same call in both arms.
607- .child(self.library(714+ .when(self.player_fullscreen, |d| {
608- self.split_px(Split::Library, window.viewport_size()),715+ d.child(self.picture_area(position, window, cx))
609- cx,716+ })
610- ))717+ .when(!self.player_fullscreen, |d| {
611- // The seams, one per pair of regions: what a hand drags to718+ d.child(self.topbar(window, cx))
612- // give a panel more room and its neighbour less
613- // ([`divider`]).
614- .child(divider(Split::Library, cx))
615 .child(719 .child(
616 div()720 div()
617 .flex_1()721 .flex_1()
618- .min_w(px(0.))722+ .min_h(px(0.))
619 .flex()723 .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))
621 .child(732 .child(
622 div()733 div()
623 .flex_1()734 .flex_1()
624- .min_h(px(0.))735+ .min_w(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()
631 .flex()736 .flex()
632- .justify_center()737+ .flex_col()
633- .items_center()738+ .child(self.picture_area(position, window, cx))
634- .bg(rgb(BG_CANVAS()))739+ .child(self.transport_bar(state, window.viewport_size(), cx)),
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- ),
688 )740 )
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)),
690 )746 )
691- .child(divider(Split::Inspector, cx))747+ // Above the toolbar rather than under it: the toolbar is
692- // The settings cards live in here rather than over the748+ // a fixed strip belonging to the timeline, so the pair
693- // timeline: adjusting a clip must not hide the clip.749+ // moves as one and the edge the hand is pulling is the
694- .child(self.inspector(window.viewport_size(), cx)),750+ // edge under the pointer.
695- )751+ .child(divider(Split::Timeline, cx))
696- // Above the toolbar rather than under it: the toolbar is a fixed752+ .child(self.toolbar(cx))
697- // strip belonging to the timeline, so the pair moves as one and the753+ .child(self.timeline(position, state, window.viewport_size(), cx))
698- // edge the hand is pulling is the edge under the pointer.754+ })
699- .child(divider(Split::Timeline, cx))
700- .child(self.toolbar(cx))
701- .child(self.timeline(position, state, window.viewport_size(), cx))
702 // Over the region they were opened on, and under the modal cards:755 // Over the region they were opened on, and under the modal cards:
703 // they are only ever up while none of those is (`modal`).756 // they are only ever up while none of those is (`modal`).
704 .children(self.context_card(window.viewport_size(), cx))757 .children(self.context_card(window.viewport_size(), cx))
crates/app/src/tests/cards.rsmodified+11 -0
@@ -3,6 +3,17 @@
3 3
4 use super::*;4 use super::*;
5 5
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+
6 #[test]17 #[test]
7 fn only_a_chord_gets_out_of_an_export() {18 fn only_a_chord_gets_out_of_an_export() {
8 use keymap::ActionId;19 use keymap::ActionId;
crates/app/src/tests/mod.rsmodified+1 -0
@@ -25,6 +25,7 @@ use super::{
25 bitrate_detail, bitrate_refusal, can_add, cancels_export, clipboard_after_remove, color_snap, commit_mbps,25 bitrate_detail, bitrate_refusal, can_add, cancels_export, clipboard_after_remove, color_snap, commit_mbps,
26 containers,26 containers,
27 enable, envelope, eq_card_w, eq_freq, eq_freq_label, eq_spectrum, eq_x, eq_y,27 enable, envelope, eq_card_w, eq_freq, eq_freq_label, eq_spectrum, eq_x, eq_y,
28+ escape_leaves_player_fullscreen,
28 estimated_bytes, export_path, export_settings, format_key,29 estimated_bytes, export_path, export_settings, format_key,
29 format_line, format_refusal, fps_choices, fps_label, frac_along, frac_down, frame_at,30 format_line, format_refusal, fps_choices, fps_label, frac_along, frac_down, frame_at,
30 frame_rate_ladder, histogram,31 frame_rate_ladder, histogram,
crates/app/src/ui/toolbar.rsmodified+7 -3
@@ -49,9 +49,13 @@ impl Player {
49 /// write a file on the right. Export is the one accented button in the49 /// write a file on the right. Export is the one accented button in the
50 /// window -- the primary action of an editor, where every consumer editor50 /// window -- the primary action of an editor, where every consumer editor
51 /// puts it -- and it keeps its rect while it is a Cancel.51 /// 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 {
53 let exporting = self.exporting().is_some();53 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;
55 div()59 div()
56 .flex_none()60 .flex_none()
57 .h(px(TOPBAR_H))61 .h(px(TOPBAR_H))
@@ -89,7 +93,7 @@ impl Player {
89 true => "Exit fullscreen",93 true => "Exit fullscreen",
90 false => "Fullscreen",94 false => "Fullscreen",
91 },95 },
92- "fills the screen with the window, or gives it back",96+ "fills the screen with the picture; F11 or Escape gives it back",
93 ActionId::Fullscreen,97 ActionId::Fullscreen,
94 cx.listener(|this, _: &ClickEvent, window, cx| {98 cx.listener(|this, _: &ClickEvent, window, cx| {
95 this.act(ActionId::Fullscreen, window, cx)99 this.act(ActionId::Fullscreen, window, cx)