forge
Explore
Log in

Don't you dare go Hollow

layout: Remember whether to unfullscreen back into floating

Browse files at this commit

f38acfe98848746598233a275ac3ee226f3df658Ivan MolodetskikhParent: 965619d
src/layout/mod.rsmodified+4 -1
@@ -3214,7 +3214,7 @@ impl<W: LayoutElement> Layout<W> {
3214 mut tile,3214 mut tile,
3215 width,3215 width,
3216 is_full_width,3216 is_full_width,
3217- is_floating,3217+ mut is_floating,
3218 } = self.remove_window(window, Transaction::new()).unwrap();3218 } = self.remove_window(window, Transaction::new()).unwrap();
3219 3219
3220 tile.stop_move_animations();3220 tile.stop_move_animations();
@@ -3255,6 +3255,9 @@ impl<W: LayoutElement> Layout<W> {
3255 }3255 }
3256 3256
3257 win.request_size(size, true, None);3257 win.request_size(size, true, None);
3258+
3259+ // If we're unfullscreening to floating, default to the floating layout.
3260+ is_floating = tile.unfullscreen_to_floating();
3258 }3261 }
3259 3262
3260 let mut data = InteractiveMoveData {3263 let mut data = InteractiveMoveData {
src/layout/scrolling.rsmodified+4 -2
@@ -2081,7 +2081,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
2081 cancel_resize_for_column(&mut self.interactive_resize, col);2081 cancel_resize_for_column(&mut self.interactive_resize, col);
2082 }2082 }
2083 2083
2084- pub fn set_fullscreen(&mut self, window: &W::Id, is_fullscreen: bool) {2084+ pub fn set_fullscreen(&mut self, window: &W::Id, is_fullscreen: bool) -> bool {
2085 let (mut col_idx, tile_idx) = self2085 let (mut col_idx, tile_idx) = self
2086 .columns2086 .columns
2087 .iter()2087 .iter()
@@ -2090,7 +2090,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
2090 .unwrap();2090 .unwrap();
2091 2091
2092 if is_fullscreen == self.columns[col_idx].is_fullscreen {2092 if is_fullscreen == self.columns[col_idx].is_fullscreen {
2093- return;2093+ return false;
2094 }2094 }
2095 2095
2096 if is_fullscreen2096 if is_fullscreen
@@ -2138,6 +2138,8 @@ impl<W: LayoutElement> ScrollingSpace<W> {
2138 {2138 {
2139 self.view_offset_before_fullscreen = None;2139 self.view_offset_before_fullscreen = None;
2140 }2140 }
2141+
2142+ true
2141 }2143 }
2142 2144
2143 pub fn render_above_top_layer(&self) -> bool {2145 pub fn render_above_top_layer(&self) -> bool {
src/layout/tile.rsmodified+12 -0
@@ -51,6 +51,9 @@ pub struct Tile<W: LayoutElement> {
51 /// The size we were requested to fullscreen into.51 /// The size we were requested to fullscreen into.
52 fullscreen_size: Size<f64, Logical>,52 fullscreen_size: Size<f64, Logical>,
53 53
54+ /// Whether the tile should float upon unfullscreening.
55+ unfullscreen_to_floating: bool,
56+
54 /// The animation upon opening a window.57 /// The animation upon opening a window.
55 open_animation: Option<OpenAnimation>,58 open_animation: Option<OpenAnimation>,
56 59
@@ -124,6 +127,7 @@ impl<W: LayoutElement> Tile<W> {
124 is_fullscreen: false, // FIXME: up-to-date fullscreen right away, but we need size.127 is_fullscreen: false, // FIXME: up-to-date fullscreen right away, but we need size.
125 fullscreen_backdrop: SolidColorBuffer::new((0., 0.), [0., 0., 0., 1.]),128 fullscreen_backdrop: SolidColorBuffer::new((0., 0.), [0., 0., 0., 1.]),
126 fullscreen_size: Default::default(),129 fullscreen_size: Default::default(),
130+ unfullscreen_to_floating: false,
127 open_animation: None,131 open_animation: None,
128 resize_animation: None,132 resize_animation: None,
129 move_x_animation: None,133 move_x_animation: None,
@@ -923,6 +927,14 @@ impl<W: LayoutElement> Tile<W> {
923 self.unmap_snapshot.take()927 self.unmap_snapshot.take()
924 }928 }
925 929
930+ pub fn unfullscreen_to_floating(&self) -> bool {
931+ self.unfullscreen_to_floating
932+ }
933+
934+ pub fn set_unfullscreen_to_floating(&mut self, value: bool) {
935+ self.unfullscreen_to_floating = value;
936+ }
937+
926 #[cfg(test)]938 #[cfg(test)]
927 pub fn verify_invariants(&self) {939 pub fn verify_invariants(&self) {
928 use approx::assert_abs_diff_eq;940 use approx::assert_abs_diff_eq;
src/layout/workspace.rsmodified+34 -3
@@ -471,12 +471,13 @@ impl<W: LayoutElement> Workspace<W> {
471 is_full_width: bool,471 is_full_width: bool,
472 is_floating: bool,472 is_floating: bool,
473 ) {473 ) {
474- let tile = Tile::new(474+ let mut tile = Tile::new(
475 window,475 window,
476 self.scale.fractional_scale(),476 self.scale.fractional_scale(),
477 self.clock.clone(),477 self.clock.clone(),
478 self.options.clone(),478 self.options.clone(),
479 );479 );
480+ tile.set_unfullscreen_to_floating(is_floating);
480 481
481 if is_floating {482 if is_floating {
482 self.add_floating_tile(tile, None, activate);483 self.add_floating_tile(tile, None, activate);
@@ -541,12 +542,13 @@ impl<W: LayoutElement> Workspace<W> {
541 // TODO: smarter enum, so you can override is_floating = false for floating right_of.542 // TODO: smarter enum, so you can override is_floating = false for floating right_of.
542 is_floating: bool,543 is_floating: bool,
543 ) {544 ) {
544- let tile = Tile::new(545+ let mut tile = Tile::new(
545 window,546 window,
546 self.scale.fractional_scale(),547 self.scale.fractional_scale(),
547 self.clock.clone(),548 self.clock.clone(),
548 self.options.clone(),549 self.options.clone(),
549 );550 );
551+ tile.set_unfullscreen_to_floating(is_floating);
550 self.add_tile_right_of(right_of, tile, width, is_full_width, is_floating);552 self.add_tile_right_of(right_of, tile, width, is_full_width, is_floating);
551 }553 }
552 554
@@ -972,16 +974,45 @@ impl<W: LayoutElement> Workspace<W> {
972 }974 }
973 975
974 pub fn set_fullscreen(&mut self, window: &W::Id, is_fullscreen: bool) {976 pub fn set_fullscreen(&mut self, window: &W::Id, is_fullscreen: bool) {
977+ let mut unfullscreen_to_floating = false;
975 if self.floating.has_window(window) {978 if self.floating.has_window(window) {
976 if is_fullscreen {979 if is_fullscreen {
980+ unfullscreen_to_floating = true;
977 self.toggle_window_floating(Some(window));981 self.toggle_window_floating(Some(window));
978 } else {982 } else {
979 // Floating windows are never fullscreen, so this is an unfullscreen request for an983 // Floating windows are never fullscreen, so this is an unfullscreen request for an
980 // already unfullscreen window.984 // already unfullscreen window.
981 return;985 return;
982 }986 }
987+ } else if !is_fullscreen {
988+ // The window is in the scrolling layout and we're requesting an unfullscreen. If it is
989+ // indeed fullscreen (i.e. this isn't a duplicate unfullscreen request), then we may
990+ // need to unfullscreen into floating.
991+ let tile = self
992+ .scrolling
993+ .tiles()
994+ .find(|tile| tile.window().id() == window)
995+ .unwrap();
996+ if tile.window().is_pending_fullscreen() && tile.unfullscreen_to_floating() {
997+ // Unfullscreen and float in one call so it has a chance to notice and request a
998+ // (0, 0) size, rather than the scrolling column size.
999+ self.toggle_window_floating(Some(window));
1000+ return;
1001+ }
1002+ }
1003+
1004+ let changed = self.scrolling.set_fullscreen(window, is_fullscreen);
1005+
1006+ // When going to fullscreen, remember if we should unfullscreen to floating.
1007+ if changed && is_fullscreen {
1008+ let tile = self
1009+ .scrolling
1010+ .tiles_mut()
1011+ .find(|tile| tile.window().id() == window)
1012+ .unwrap();
1013+
1014+ tile.set_unfullscreen_to_floating(unfullscreen_to_floating);
983 }1015 }
984- self.scrolling.set_fullscreen(window, is_fullscreen);
985 }1016 }
986 1017
987 pub fn toggle_fullscreen(&mut self, window: &W::Id) {1018 pub fn toggle_fullscreen(&mut self, window: &W::Id) {