forge
Explore
Log in

Don't you dare go Hollow

Implement tabbed column display mode

Browse files at this commit

f90eb0cbe4ca8f59b9664bac54f8c8b8a0cbd526Ivan MolodetskikhParent: 55e2ea0
niri-config/src/lib.rsmodified+18 -0
@@ -458,6 +458,8 @@ pub struct Layout {
458 pub always_center_single_column: bool,458 pub always_center_single_column: bool,
459 #[knuffel(child)]459 #[knuffel(child)]
460 pub empty_workspace_above_first: bool,460 pub empty_workspace_above_first: bool,
461+ #[knuffel(child, unwrap(argument), default)]
462+ pub default_column_display: ColumnDisplay,
461 #[knuffel(child, unwrap(argument), default = Self::default().gaps)]463 #[knuffel(child, unwrap(argument), default = Self::default().gaps)]
462 pub gaps: FloatOrInt<0, 65535>,464 pub gaps: FloatOrInt<0, 65535>,
463 #[knuffel(child, default)]465 #[knuffel(child, default)]
@@ -476,6 +478,7 @@ impl Default for Layout {
476 center_focused_column: Default::default(),478 center_focused_column: Default::default(),
477 always_center_single_column: false,479 always_center_single_column: false,
478 empty_workspace_above_first: false,480 empty_workspace_above_first: false,
481+ default_column_display: Default::default(),
479 gaps: FloatOrInt(16.),482 gaps: FloatOrInt(16.),
480 struts: Default::default(),483 struts: Default::default(),
481 preset_window_heights: Default::default(),484 preset_window_heights: Default::default(),
@@ -794,6 +797,16 @@ impl From<PresetSize> for SizeChange {
794 #[derive(Debug, Clone, Copy, PartialEq)]797 #[derive(Debug, Clone, Copy, PartialEq)]
795 pub struct DefaultPresetSize(pub Option<PresetSize>);798 pub struct DefaultPresetSize(pub Option<PresetSize>);
796 799
800+/// How windows display in a column.
801+#[derive(knuffel::DecodeScalar, Debug, Default, Clone, Copy, PartialEq, Eq)]
802+pub enum ColumnDisplay {
803+ /// Windows arranged vertically, spread across the working area height.
804+ #[default]
805+ Normal,
806+ /// Windows are in tabs.
807+ Tabbed,
808+}
809+
797 #[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq)]810 #[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq)]
798 pub struct Struts {811 pub struct Struts {
799 #[knuffel(child, unwrap(argument), default)]812 #[knuffel(child, unwrap(argument), default)]
@@ -1367,6 +1380,7 @@ pub enum Action {
1367 ExpelWindowFromColumn,1380 ExpelWindowFromColumn,
1368 SwapWindowLeft,1381 SwapWindowLeft,
1369 SwapWindowRight,1382 SwapWindowRight,
1383+ ToggleColumnTabbedDisplay,
1370 CenterColumn,1384 CenterColumn,
1371 CenterWindow,1385 CenterWindow,
1372 #[knuffel(skip)]1386 #[knuffel(skip)]
@@ -1563,6 +1577,7 @@ impl From<niri_ipc::Action> for Action {
1563 niri_ipc::Action::ExpelWindowFromColumn {} => Self::ExpelWindowFromColumn,1577 niri_ipc::Action::ExpelWindowFromColumn {} => Self::ExpelWindowFromColumn,
1564 niri_ipc::Action::SwapWindowRight {} => Self::SwapWindowRight,1578 niri_ipc::Action::SwapWindowRight {} => Self::SwapWindowRight,
1565 niri_ipc::Action::SwapWindowLeft {} => Self::SwapWindowLeft,1579 niri_ipc::Action::SwapWindowLeft {} => Self::SwapWindowLeft,
1580+ niri_ipc::Action::ToggleColumnTabbedDisplay {} => Self::ToggleColumnTabbedDisplay,
1566 niri_ipc::Action::CenterColumn {} => Self::CenterColumn,1581 niri_ipc::Action::CenterColumn {} => Self::CenterColumn,
1567 niri_ipc::Action::CenterWindow { id: None } => Self::CenterWindow,1582 niri_ipc::Action::CenterWindow { id: None } => Self::CenterWindow,
1568 niri_ipc::Action::CenterWindow { id: Some(id) } => Self::CenterWindowById(id),1583 niri_ipc::Action::CenterWindow { id: Some(id) } => Self::CenterWindowById(id),
@@ -3490,6 +3505,8 @@ mod tests {
3490 3505
3491 center-focused-column "on-overflow"3506 center-focused-column "on-overflow"
3492 3507
3508+ default-column-display "tabbed"
3509+
3493 insert-hint {3510 insert-hint {
3494 color "rgb(255, 200, 127)"3511 color "rgb(255, 200, 127)"
3495 gradient from="rgba(10, 20, 30, 1.0)" to="#0080ffff" relative-to="workspace-view"3512 gradient from="rgba(10, 20, 30, 1.0)" to="#0080ffff" relative-to="workspace-view"
@@ -3754,6 +3771,7 @@ mod tests {
3754 bottom: FloatOrInt(0.),3771 bottom: FloatOrInt(0.),
3755 },3772 },
3756 center_focused_column: CenterFocusedColumn::OnOverflow,3773 center_focused_column: CenterFocusedColumn::OnOverflow,
3774+ default_column_display: ColumnDisplay::Tabbed,
3757 always_center_single_column: false,3775 always_center_single_column: false,
3758 empty_workspace_above_first: false,3776 empty_workspace_above_first: false,
3759 },3777 },
niri-ipc/src/lib.rsmodified+2 -0
@@ -321,6 +321,8 @@ pub enum Action {
321 SwapWindowRight {},321 SwapWindowRight {},
322 /// Swap focused window with one to the left322 /// Swap focused window with one to the left
323 SwapWindowLeft {},323 SwapWindowLeft {},
324+ /// Toggle the focused column between normal and tabbed display.
325+ ToggleColumnTabbedDisplay {},
324 /// Center the focused column on the screen.326 /// Center the focused column on the screen.
325 CenterColumn {},327 CenterColumn {},
326 /// Center a window on the screen.328 /// Center a window on the screen.
resources/default-config.kdlmodified+5 -0
@@ -525,6 +525,11 @@ binds {
525 Mod+V { toggle-window-floating; }525 Mod+V { toggle-window-floating; }
526 Mod+Shift+V { switch-focus-between-floating-and-tiling; }526 Mod+Shift+V { switch-focus-between-floating-and-tiling; }
527 527
528+ // Toggle tabbed column display mode.
529+ // Windows in this column will appear as vertical tabs,
530+ // rather than stacked on top of each other.
531+ Mod+W { toggle-column-tabbed-display; }
532+
528 // Actions to switch layouts.533 // Actions to switch layouts.
529 // Note: if you uncomment these, make sure you do NOT have534 // Note: if you uncomment these, make sure you do NOT have
530 // a matching layout switch hotkey configured in xkb options above.535 // a matching layout switch hotkey configured in xkb options above.
src/input/mod.rsmodified+6 -0
@@ -1259,6 +1259,12 @@ impl State {
1259 // FIXME: granular1259 // FIXME: granular
1260 self.niri.queue_redraw_all();1260 self.niri.queue_redraw_all();
1261 }1261 }
1262+ Action::ToggleColumnTabbedDisplay => {
1263+ self.niri.layout.toggle_column_tabbed_display();
1264+ self.maybe_warp_cursor_to_focus();
1265+ // FIXME: granular
1266+ self.niri.queue_redraw_all();
1267+ }
1262 Action::SwitchPresetColumnWidth => {1268 Action::SwitchPresetColumnWidth => {
1263 self.niri.layout.toggle_width();1269 self.niri.layout.toggle_width();
1264 }1270 }
src/layout/mod.rsmodified+11 -1
@@ -39,7 +39,7 @@ use std::time::Duration;
39 39
40 use monitor::MonitorAddWindowTarget;40 use monitor::MonitorAddWindowTarget;
41 use niri_config::{41 use niri_config::{
42- CenterFocusedColumn, Config, CornerRadius, FloatOrInt, PresetSize, Struts,42+ CenterFocusedColumn, ColumnDisplay, Config, CornerRadius, FloatOrInt, PresetSize, Struts,
43 Workspace as WorkspaceConfig, WorkspaceReference,43 Workspace as WorkspaceConfig, WorkspaceReference,
44 };44 };
45 use niri_ipc::{PositionChange, SizeChange};45 use niri_ipc::{PositionChange, SizeChange};
@@ -316,6 +316,7 @@ pub struct Options {
316 pub center_focused_column: CenterFocusedColumn,316 pub center_focused_column: CenterFocusedColumn,
317 pub always_center_single_column: bool,317 pub always_center_single_column: bool,
318 pub empty_workspace_above_first: bool,318 pub empty_workspace_above_first: bool,
319+ pub default_column_display: ColumnDisplay,
319 /// Column or window widths that `toggle_width()` switches between.320 /// Column or window widths that `toggle_width()` switches between.
320 pub preset_column_widths: Vec<PresetSize>,321 pub preset_column_widths: Vec<PresetSize>,
321 /// Initial width for new columns.322 /// Initial width for new columns.
@@ -340,6 +341,7 @@ impl Default for Options {
340 center_focused_column: Default::default(),341 center_focused_column: Default::default(),
341 always_center_single_column: false,342 always_center_single_column: false,
342 empty_workspace_above_first: false,343 empty_workspace_above_first: false,
344+ default_column_display: Default::default(),
343 preset_column_widths: vec![345 preset_column_widths: vec![
344 PresetSize::Proportion(1. / 3.),346 PresetSize::Proportion(1. / 3.),
345 PresetSize::Proportion(0.5),347 PresetSize::Proportion(0.5),
@@ -552,6 +554,7 @@ impl Options {
552 center_focused_column: layout.center_focused_column,554 center_focused_column: layout.center_focused_column,
553 always_center_single_column: layout.always_center_single_column,555 always_center_single_column: layout.always_center_single_column,
554 empty_workspace_above_first: layout.empty_workspace_above_first,556 empty_workspace_above_first: layout.empty_workspace_above_first,
557+ default_column_display: layout.default_column_display,
555 preset_column_widths,558 preset_column_widths,
556 default_column_width,559 default_column_width,
557 animations: config.animations.clone(),560 animations: config.animations.clone(),
@@ -2141,6 +2144,13 @@ impl<W: LayoutElement> Layout<W> {
2141 monitor.swap_window_in_direction(direction);2144 monitor.swap_window_in_direction(direction);
2142 }2145 }
2143 2146
2147+ pub fn toggle_column_tabbed_display(&mut self) {
2148+ let Some(monitor) = self.active_monitor() else {
2149+ return;
2150+ };
2151+ monitor.toggle_column_tabbed_display();
2152+ }
2153+
2144 pub fn center_column(&mut self) {2154 pub fn center_column(&mut self) {
2145 let Some(monitor) = self.active_monitor() else {2155 let Some(monitor) = self.active_monitor() else {
2146 return;2156 return;
src/layout/monitor.rsmodified+4 -0
@@ -732,6 +732,10 @@ impl<W: LayoutElement> Monitor<W> {
732 self.active_workspace().swap_window_in_direction(direction);732 self.active_workspace().swap_window_in_direction(direction);
733 }733 }
734 734
735+ pub fn toggle_column_tabbed_display(&mut self) {
736+ self.active_workspace().toggle_column_tabbed_display();
737+ }
738+
735 pub fn center_column(&mut self) {739 pub fn center_column(&mut self) {
736 self.active_workspace().center_column();740 self.active_workspace().center_column();
737 }741 }
src/layout/scrolling.rsmodified+192 -52
@@ -3,7 +3,7 @@ use std::iter::{self, zip};
3 use std::rc::Rc;3 use std::rc::Rc;
4 use std::time::Duration;4 use std::time::Duration;
5 5
6-use niri_config::{CenterFocusedColumn, CornerRadius, PresetSize, Struts};6+use niri_config::{CenterFocusedColumn, ColumnDisplay, CornerRadius, PresetSize, Struts};
7 use niri_ipc::SizeChange;7 use niri_ipc::SizeChange;
8 use ordered_float::NotNan;8 use ordered_float::NotNan;
9 use smithay::backend::renderer::gles::GlesRenderer;9 use smithay::backend::renderer::gles::GlesRenderer;
@@ -171,6 +171,9 @@ pub struct Column<W: LayoutElement> {
171 /// Whether this column contains a single full-screened window.171 /// Whether this column contains a single full-screened window.
172 is_fullscreen: bool,172 is_fullscreen: bool,
173 173
174+ /// How this column displays and arranges windows.
175+ display_mode: ColumnDisplay,
176+
174 /// Animation of the render offset during window swapping.177 /// Animation of the render offset during window swapping.
175 move_animation: Option<Animation>,178 move_animation: Option<Animation>,
176 179
@@ -744,15 +747,28 @@ impl<W: LayoutElement> ScrollingSpace<W> {
744 747
745 // Find the closest gap between tiles.748 // Find the closest gap between tiles.
746 let col = &self.columns[col_idx];749 let col = &self.columns[col_idx];
747- let (closest_tile_idx, tile_off) = col750+
748- .tile_offsets()751+ let (closest_tile_idx, tile_y) = if col.display_mode == ColumnDisplay::Tabbed {
749- .enumerate()752+ // In tabbed mode, there's only one tile visible, and we want to check its top and
750- .min_by_key(|(_, tile_off)| NotNan::new((tile_off.y - y).abs()).unwrap())753+ // bottom.
751- .unwrap();754+ let top = col.tile_offsets().nth(col.active_tile_idx).unwrap().y;
755+ let bottom = top + col.data[col.active_tile_idx].size.h;
756+ if (top - y).abs() <= (bottom - y).abs() {
757+ (col.active_tile_idx, top)
758+ } else {
759+ (col.active_tile_idx + 1, bottom)
760+ }
761+ } else {
762+ col.tile_offsets()
763+ .map(|tile_off| tile_off.y)
764+ .enumerate()
765+ .min_by_key(|(_, tile_y)| NotNan::new((tile_y - y).abs()).unwrap())
766+ .unwrap()
767+ };
752 768
753 // Return the closest among the vertical and the horizontal gap.769 // Return the closest among the vertical and the horizontal gap.
754 let vert_dist = (col_x - x).abs();770 let vert_dist = (col_x - x).abs();
755- let hor_dist = (tile_off.y - y).abs();771+ let hor_dist = (tile_y - y).abs();
756 if vert_dist <= hor_dist {772 if vert_dist <= hor_dist {
757 InsertPosition::NewColumn(closest_col_idx)773 InsertPosition::NewColumn(closest_col_idx)
758 } else {774 } else {
@@ -1288,6 +1304,11 @@ impl<W: LayoutElement> ScrollingSpace<W> {
1288 let col = &self.columns[col_idx];1304 let col = &self.columns[col_idx];
1289 let removing_last = col.tiles.len() == 1;1305 let removing_last = col.tiles.len() == 1;
1290 1306
1307+ // Skip closing animation for invisible tiles in a tabbed column.
1308+ if col.display_mode == ColumnDisplay::Tabbed && tile_idx != col.active_tile_idx {
1309+ return;
1310+ }
1311+
1291 tile_pos.x += self.view_pos();1312 tile_pos.x += self.view_pos();
1292 1313
1293 if col_idx < self.active_column_idx {1314 if col_idx < self.active_column_idx {
@@ -1936,6 +1957,16 @@ impl<W: LayoutElement> ScrollingSpace<W> {
1936 self.activate_column(target_column_idx);1957 self.activate_column(target_column_idx);
1937 }1958 }
1938 1959
1960+ pub fn toggle_column_tabbed_display(&mut self) {
1961+ if self.columns.is_empty() {
1962+ return;
1963+ }
1964+
1965+ let col = &mut self.columns[self.active_column_idx];
1966+ cancel_resize_for_column(&mut self.interactive_resize, col);
1967+ col.toggle_tabbed_display();
1968+ }
1969+
1939 pub fn center_column(&mut self) {1970 pub fn center_column(&mut self) {
1940 if self.columns.is_empty() {1971 if self.columns.is_empty() {
1941 return;1972 return;
@@ -2054,19 +2085,21 @@ impl<W: LayoutElement> ScrollingSpace<W> {
2054 2085
2055 pub fn tiles_with_render_positions(2086 pub fn tiles_with_render_positions(
2056 &self,2087 &self,
2057- ) -> impl Iterator<Item = (&Tile<W>, Point<f64, Logical>)> {2088+ ) -> impl Iterator<Item = (&Tile<W>, Point<f64, Logical>, bool)> {
2058 let scale = self.scale;2089 let scale = self.scale;
2059 let view_off = Point::from((-self.view_pos(), 0.));2090 let view_off = Point::from((-self.view_pos(), 0.));
2060 self.columns_in_render_order()2091 self.columns_in_render_order()
2061 .flat_map(move |(col, col_x)| {2092 .flat_map(move |(col, col_x)| {
2062 let col_off = Point::from((col_x, 0.));2093 let col_off = Point::from((col_x, 0.));
2063 let col_render_off = col.render_offset();2094 let col_render_off = col.render_offset();
2064- col.tiles_in_render_order().map(move |(tile, tile_off)| {2095+ col.tiles_in_render_order()
2065- let pos = view_off + col_off + col_render_off + tile_off + tile.render_offset();2096+ .map(move |(tile, tile_off, visible)| {
2066- // Round to physical pixels.2097+ let pos =
2067- let pos = pos.to_physical_precise_round(scale).to_logical(scale);2098+ view_off + col_off + col_render_off + tile_off + tile.render_offset();
2068- (tile, pos)2099+ // Round to physical pixels.
2069- })2100+ let pos = pos.to_physical_precise_round(scale).to_logical(scale);
2101+ (tile, pos, visible)
2102+ })
2070 })2103 })
2071 }2104 }
2072 2105
@@ -2132,18 +2165,29 @@ impl<W: LayoutElement> ScrollingSpace<W> {
2132 return None;2165 return None;
2133 }2166 }
2134 2167
2135- let (height, y) = if tile_index == 0 {2168+ let is_tabbed = col.display_mode == ColumnDisplay::Tabbed;
2136- (150., col.tile_offset(tile_index).y)2169+
2137- } else if tile_index == col.tiles.len() {2170+ let (height, y) = if is_tabbed {
2138- (2171+ // In tabbed mode, there's only one tile visible, and we want to draw the hint
2139- 150.,2172+ // at its top or bottom.
2140- col.tile_offset(tile_index).y - self.options.gaps - 150.,2173+ let top = col.tile_offset(col.active_tile_idx).y;
2141- )2174+ let bottom = top + col.data[col.active_tile_idx].size.h;
2175+
2176+ if tile_index <= col.active_tile_idx {
2177+ (150., top)
2178+ } else {
2179+ (150., bottom - 150.)
2180+ }
2142 } else {2181 } else {
2143- (2182+ let top = col.tile_offset(tile_index).y;
2144- 300.,2183+
2145- col.tile_offset(tile_index).y - self.options.gaps / 2. - 150.,2184+ if tile_index == 0 {
2146- )2185+ (150., top)
2186+ } else if tile_index == col.tiles.len() {
2187+ (150., top - self.options.gaps - 150.)
2188+ } else {
2189+ (300., top - self.options.gaps / 2. - 150.)
2190+ }
2147 };2191 };
2148 2192
2149 let size = Size::from((self.data[column_index].width, height));2193 let size = Size::from((self.data[column_index].width, height));
@@ -2455,11 +2499,15 @@ impl<W: LayoutElement> ScrollingSpace<W> {
2455 }2499 }
2456 2500
2457 let mut first = true;2501 let mut first = true;
2458- for (tile, tile_pos) in self.tiles_with_render_positions() {2502+ for (tile, tile_pos, visible) in self.tiles_with_render_positions() {
2459 // For the active tile (which comes first), draw the focus ring.2503 // For the active tile (which comes first), draw the focus ring.
2460 let focus_ring = focus_ring && first;2504 let focus_ring = focus_ring && first;
2461 first = false;2505 first = false;
2462 2506
2507+ if !visible {
2508+ continue;
2509+ }
2510+
2463 rv.extend(2511 rv.extend(
2464 tile.render(renderer, tile_pos, scale, focus_ring, target)2512 tile.render(renderer, tile_pos, scale, focus_ring, target)
2465 .map(Into::into),2513 .map(Into::into),
@@ -2909,11 +2957,18 @@ impl<W: LayoutElement> ScrollingSpace<W> {
2909 }2957 }
2910 }2958 }
2911 2959
2960+ let is_tabbed = col.display_mode == ColumnDisplay::Tabbed;
2961+
2962+ // If transactions are disabled, also disable combined throttling, for more intuitive
2963+ // behavior. In tabbed display mode, only one window is visible, so individual
2964+ // throttling makes more sense.
2965+ let individual_throttling = self.options.disable_transactions || is_tabbed;
2966+
2912 let intent = if self.options.disable_resize_throttling {2967 let intent = if self.options.disable_resize_throttling {
2913 ConfigureIntent::CanSend2968 ConfigureIntent::CanSend
2914- } else if self.options.disable_transactions {2969+ } else if individual_throttling {
2915- // When transactions are disabled, we don't use combined throttling, but rather2970+ // In this case, we don't use combined throttling, but rather compute throttling
2916- // compute throttling individually below.2971+ // individually below.
2917 ConfigureIntent::CanSend2972 ConfigureIntent::CanSend
2918 } else {2973 } else {
2919 col.tiles2974 col.tiles
@@ -2937,7 +2992,11 @@ impl<W: LayoutElement> ScrollingSpace<W> {
2937 win.set_active_in_column(active_in_column);2992 win.set_active_in_column(active_in_column);
2938 win.set_floating(false);2993 win.set_floating(false);
2939 2994
2940- let active = is_active && self.active_column_idx == col_idx && active_in_column;2995+ let active = is_active
2996+ && self.active_column_idx == col_idx
2997+ // In tabbed mode, all tabs have activated state to reduce unnecessary
2998+ // animations when switching tabs.
2999+ && (active_in_column || is_tabbed);
2941 win.set_activated(active);3000 win.set_activated(active);
2942 3001
2943 win.set_interactive_resize(col_resize_data);3002 win.set_interactive_resize(col_resize_data);
@@ -2950,9 +3009,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
2950 );3009 );
2951 win.set_bounds(bounds);3010 win.set_bounds(bounds);
2952 3011
2953- // If transactions are disabled, also disable combined throttling, for more3012+ let intent = if individual_throttling {
2954- // intuitive behavior.
2955- let intent = if self.options.disable_transactions {
2956 win.configure_intent()3013 win.configure_intent()
2957 } else {3014 } else {
2958 intent3015 intent
@@ -3166,6 +3223,8 @@ impl<W: LayoutElement> Column<W> {
3166 is_full_width: bool,3223 is_full_width: bool,
3167 animate_resize: bool,3224 animate_resize: bool,
3168 ) -> Self {3225 ) -> Self {
3226+ let options = tile.options.clone();
3227+
3169 let mut rv = Self {3228 let mut rv = Self {
3170 tiles: vec![],3229 tiles: vec![],
3171 data: vec![],3230 data: vec![],
@@ -3174,12 +3233,13 @@ impl<W: LayoutElement> Column<W> {
3174 preset_width_idx: None,3233 preset_width_idx: None,
3175 is_full_width,3234 is_full_width,
3176 is_fullscreen: false,3235 is_fullscreen: false,
3236+ display_mode: options.default_column_display,
3177 move_animation: None,3237 move_animation: None,
3178 view_size,3238 view_size,
3179 working_area,3239 working_area,
3180 scale,3240 scale,
3181 clock: tile.clock.clone(),3241 clock: tile.clock.clone(),
3182- options: tile.options.clone(),3242+ options,
3183 };3243 };
3184 3244
3185 let is_pending_fullscreen = tile.window().is_pending_fullscreen();3245 let is_pending_fullscreen = tile.window().is_pending_fullscreen();
@@ -3373,13 +3433,15 @@ impl<W: LayoutElement> Column<W> {
3373 tile.update_window();3433 tile.update_window();
3374 self.data[tile_idx].update(tile);3434 self.data[tile_idx].update(tile);
3375 3435
3436+ let is_tabbed = self.display_mode == ColumnDisplay::Tabbed;
3437+
3376 // Move windows below in tandem with resizing.3438 // Move windows below in tandem with resizing.
3377 //3439 //
3378 // FIXME: in always-centering mode, window resizing will affect the offsets of all other3440 // FIXME: in always-centering mode, window resizing will affect the offsets of all other
3379 // windows in the column, so they should all be animated. How should this interact with3441 // windows in the column, so they should all be animated. How should this interact with
3380 // animated vs. non-animated resizes? For example, an animated +20 resize followed by two3442 // animated vs. non-animated resizes? For example, an animated +20 resize followed by two
3381 // non-animated -10 resizes.3443 // non-animated -10 resizes.
3382- if tile.resize_animation().is_some() && offset != 0. {3444+ if !is_tabbed && tile.resize_animation().is_some() && offset != 0. {
3383 for tile in &mut self.tiles[tile_idx + 1..] {3445 for tile in &mut self.tiles[tile_idx + 1..] {
3384 tile.animate_move_y_from_with_config(3446 tile.animate_move_y_from_with_config(
3385 offset,3447 offset,
@@ -3417,6 +3479,8 @@ impl<W: LayoutElement> Column<W> {
3417 return;3479 return;
3418 }3480 }
3419 3481
3482+ let is_tabbed = self.display_mode == ColumnDisplay::Tabbed;
3483+
3420 let min_size: Vec<_> = self3484 let min_size: Vec<_> = self
3421 .tiles3485 .tiles
3422 .iter()3486 .iter()
@@ -3466,7 +3530,7 @@ impl<W: LayoutElement> Column<W> {
3466 // If there are multiple windows in a column, clamp the non-auto window's height according3530 // If there are multiple windows in a column, clamp the non-auto window's height according
3467 // to other windows' min sizes.3531 // to other windows' min sizes.
3468 let mut max_non_auto_window_height = None;3532 let mut max_non_auto_window_height = None;
3469- if self.tiles.len() > 1 {3533+ if self.tiles.len() > 1 && !is_tabbed {
3470 if let Some(non_auto_idx) = self3534 if let Some(non_auto_idx) = self
3471 .data3535 .data
3472 .iter()3536 .iter()
@@ -3522,6 +3586,39 @@ impl<W: LayoutElement> Column<W> {
3522 })3586 })
3523 .collect::<Vec<_>>();3587 .collect::<Vec<_>>();
3524 3588
3589+ // In tabbed display mode, fill fixed heights right away.
3590+ if is_tabbed {
3591+ // All tiles have the same height, equal to the height of the only fixed tile (if any).
3592+ let tabbed_height = heights
3593+ .iter()
3594+ .find_map(|h| {
3595+ if let WindowHeight::Fixed(h) = h {
3596+ Some(*h)
3597+ } else {
3598+ None
3599+ }
3600+ })
3601+ .unwrap_or(max_tile_height);
3602+
3603+ // We also take min height of all tabs into account.
3604+ let min_height = min_size
3605+ .iter()
3606+ .map(|size| NotNan::new(size.h).unwrap())
3607+ .max()
3608+ .map(NotNan::into_inner)
3609+ .unwrap();
3610+ // But, if there's a larger-than-workspace tab, we don't want to force all tabs to that
3611+ // size.
3612+ let min_height = f64::min(max_tile_height, min_height);
3613+ let tabbed_height = f64::max(tabbed_height, min_height);
3614+
3615+ for h in &mut heights {
3616+ *h = WindowHeight::Fixed(tabbed_height);
3617+ }
3618+
3619+ // The following logic will apply individual min/max height, etc.
3620+ }
3621+
3525 let gaps_left = self.options.gaps * (self.tiles.len() + 1) as f64;3622 let gaps_left = self.options.gaps * (self.tiles.len() + 1) as f64;
3526 let mut height_left = working_size.h - gaps_left;3623 let mut height_left = working_size.h - gaps_left;
3527 let mut auto_tiles_left = self.tiles.len();3624 let mut auto_tiles_left = self.tiles.len();
@@ -3633,13 +3730,22 @@ impl<W: LayoutElement> Column<W> {
3633 assert_eq!(auto_tiles_left, 0);3730 assert_eq!(auto_tiles_left, 0);
3634 }3731 }
3635 3732
3636- for (tile, h) in zip(&mut self.tiles, heights) {3733+ for (tile_idx, (tile, h)) in zip(&mut self.tiles, heights).enumerate() {
3637 let WindowHeight::Fixed(height) = h else {3734 let WindowHeight::Fixed(height) = h else {
3638 unreachable!()3735 unreachable!()
3639 };3736 };
3640 3737
3641 let size = Size::from((width, height));3738 let size = Size::from((width, height));
3642- tile.request_tile_size(size, animate, Some(transaction.clone()));3739+
3740+ // In tabbed mode, only the visible window participates in the transaction.
3741+ let is_active = tile_idx == self.active_tile_idx;
3742+ let transaction = if self.display_mode == ColumnDisplay::Tabbed && !is_active {
3743+ None
3744+ } else {
3745+ Some(transaction.clone())
3746+ };
3747+
3748+ tile.request_tile_size(size, animate, transaction);
3643 }3749 }
3644 }3750 }
3645 3751
@@ -3860,13 +3966,16 @@ impl<W: LayoutElement> Column<W> {
3860 };3966 };
3861 3967
3862 // Clamp the height according to other windows' min sizes, or simply to working area height.3968 // Clamp the height according to other windows' min sizes, or simply to working area height.
3863- let min_height_taken = self3969+ let min_height_taken = if self.display_mode == ColumnDisplay::Tabbed {
3864- .tiles3970+ 0.
3865- .iter()3971+ } else {
3866- .enumerate()3972+ self.tiles
3867- .filter(|(idx, _)| *idx != tile_idx)3973+ .iter()
3868- .map(|(_, tile)| f64::max(1., tile.min_size().h) + self.options.gaps)3974+ .enumerate()
3869- .sum::<f64>();3975+ .filter(|(idx, _)| *idx != tile_idx)
3976+ .map(|(_, tile)| f64::max(1., tile.min_size().h) + gaps)
3977+ .sum::<f64>()
3978+ };
3870 let height_left = working_size - gaps - min_height_taken - gaps;3979 let height_left = working_size - gaps - min_height_taken - gaps;
3871 let height_left = f64::max(1., tile.window_height_for_tile_height(height_left));3980 let height_left = f64::max(1., tile.window_height_for_tile_height(height_left));
3872 window_height = f64::min(height_left, window_height);3981 window_height = f64::min(height_left, window_height);
@@ -3888,8 +3997,17 @@ impl<W: LayoutElement> Column<W> {
3888 }3997 }
3889 3998
3890 fn reset_window_height(&mut self, tile_idx: Option<usize>, animate: bool) {3999 fn reset_window_height(&mut self, tile_idx: Option<usize>, animate: bool) {
3891- let tile_idx = tile_idx.unwrap_or(self.active_tile_idx);4000+ if self.display_mode == ColumnDisplay::Tabbed {
3892- self.data[tile_idx].height = WindowHeight::auto_1();4001+ // When tabbed, reset window height should work on any window, not just the fixed-size
4002+ // one.
4003+ for data in &mut self.data {
4004+ data.height = WindowHeight::auto_1();
4005+ }
4006+ } else {
4007+ let tile_idx = tile_idx.unwrap_or(self.active_tile_idx);
4008+ self.data[tile_idx].height = WindowHeight::auto_1();
4009+ }
4010+
3893 self.update_tile_sizes(animate);4011 self.update_tile_sizes(animate);
3894 }4012 }
3895 4013
@@ -3965,6 +4083,14 @@ impl<W: LayoutElement> Column<W> {
3965 self.update_tile_sizes(false);4083 self.update_tile_sizes(false);
3966 }4084 }
3967 4085
4086+ fn toggle_tabbed_display(&mut self) {
4087+ self.display_mode = match self.display_mode {
4088+ ColumnDisplay::Normal => ColumnDisplay::Tabbed,
4089+ ColumnDisplay::Tabbed => ColumnDisplay::Normal,
4090+ };
4091+ self.update_tile_sizes(true);
4092+ }
4093+
3968 fn popup_target_rect(&self, id: &W::Id) -> Option<Rectangle<f64, Logical>> {4094 fn popup_target_rect(&self, id: &W::Id) -> Option<Rectangle<f64, Logical>> {
3969 for (tile, pos) in self.tiles() {4095 for (tile, pos) in self.tiles() {
3970 if tile.window().id() == id {4096 if tile.window().id() == id {
@@ -4007,6 +4133,7 @@ impl<W: LayoutElement> Column<W> {
4007 // the workspace or some other reason.4133 // the workspace or some other reason.
4008 let center = self.options.center_focused_column == CenterFocusedColumn::Always;4134 let center = self.options.center_focused_column == CenterFocusedColumn::Always;
4009 let gaps = self.options.gaps;4135 let gaps = self.options.gaps;
4136+ let tabbed = self.display_mode == ColumnDisplay::Tabbed;
4010 let col_width = if self.tiles.is_empty() {4137 let col_width = if self.tiles.is_empty() {
4011 0.4138 0.
4012 } else {4139 } else {
@@ -4031,7 +4158,9 @@ impl<W: LayoutElement> Column<W> {
4031 pos.x += col_width - data.size.w;4158 pos.x += col_width - data.size.w;
4032 }4159 }
4033 4160
4034- origin.y += data.size.h + gaps;4161+ if !tabbed {
4162+ origin.y += data.size.h + gaps;
4163+ }
4035 4164
4036 pos4165 pos
4037 })4166 })
@@ -4068,14 +4197,22 @@ impl<W: LayoutElement> Column<W> {
4068 zip(&mut self.tiles, offsets)4197 zip(&mut self.tiles, offsets)
4069 }4198 }
4070 4199
4071- fn tiles_in_render_order(&self) -> impl Iterator<Item = (&Tile<W>, Point<f64, Logical>)> + '_ {4200+ fn tiles_in_render_order(
4201+ &self,
4202+ ) -> impl Iterator<Item = (&Tile<W>, Point<f64, Logical>, bool)> + '_ {
4072 let offsets = self.tile_offsets_in_render_order(self.data.iter().copied());4203 let offsets = self.tile_offsets_in_render_order(self.data.iter().copied());
4073 4204
4074 let (first, rest) = self.tiles.split_at(self.active_tile_idx);4205 let (first, rest) = self.tiles.split_at(self.active_tile_idx);
4075 let (active, rest) = rest.split_at(1);4206 let (active, rest) = rest.split_at(1);
4076 4207
4077- let tiles = active.iter().chain(first).chain(rest);4208+ let active = active.iter().map(|tile| (tile, true));
4078- zip(tiles, offsets)4209+
4210+ let rest_visible = self.display_mode != ColumnDisplay::Tabbed;
4211+ let rest = first.iter().chain(rest);
4212+ let rest = rest.map(move |tile| (tile, rest_visible));
4213+
4214+ let tiles = active.chain(rest);
4215+ zip(tiles, offsets).map(|((tile, visible), pos)| (tile, pos, visible))
4079 }4216 }
4080 4217
4081 fn tiles_in_render_order_mut(4218 fn tiles_in_render_order_mut(
@@ -4104,6 +4241,8 @@ impl<W: LayoutElement> Column<W> {
4104 assert!(idx < self.options.preset_column_widths.len());4241 assert!(idx < self.options.preset_column_widths.len());
4105 }4242 }
4106 4243
4244+ let is_tabbed = self.display_mode == ColumnDisplay::Tabbed;
4245+
4107 let tile_count = self.tiles.len();4246 let tile_count = self.tiles.len();
4108 if tile_count == 1 {4247 if tile_count == 1 {
4109 if let WindowHeight::Auto { weight } = self.data[0].height {4248 if let WindowHeight::Auto { weight } = self.data[0].height {
@@ -4168,7 +4307,8 @@ impl<W: LayoutElement> Column<W> {
4168 total_min_height += min_tile_height;4307 total_min_height += min_tile_height;
4169 }4308 }
4170 4309
4171- if tile_count > 14310+ if !is_tabbed
4311+ && tile_count > 1
4172 && self.scale.round() == self.scale4312 && self.scale.round() == self.scale
4173 && working_size.h.round() == working_size.h4313 && working_size.h.round() == working_size.h
4174 && gaps.round() == gaps4314 && gaps.round() == gaps
src/layout/tests.rsmodified+4 -0
@@ -406,6 +406,7 @@ enum Op {
406 ConsumeWindowIntoColumn,406 ConsumeWindowIntoColumn,
407 ExpelWindowFromColumn,407 ExpelWindowFromColumn,
408 SwapWindowInDirection(#[proptest(strategy = "arbitrary_scroll_direction()")] ScrollDirection),408 SwapWindowInDirection(#[proptest(strategy = "arbitrary_scroll_direction()")] ScrollDirection),
409+ ToggleColumnTabbedDisplay,
409 CenterColumn,410 CenterColumn,
410 CenterWindow {411 CenterWindow {
411 #[proptest(strategy = "proptest::option::of(1..=5usize)")]412 #[proptest(strategy = "proptest::option::of(1..=5usize)")]
@@ -969,6 +970,7 @@ impl Op {
969 Op::ConsumeWindowIntoColumn => layout.consume_into_column(),970 Op::ConsumeWindowIntoColumn => layout.consume_into_column(),
970 Op::ExpelWindowFromColumn => layout.expel_from_column(),971 Op::ExpelWindowFromColumn => layout.expel_from_column(),
971 Op::SwapWindowInDirection(direction) => layout.swap_window_in_direction(direction),972 Op::SwapWindowInDirection(direction) => layout.swap_window_in_direction(direction),
973+ Op::ToggleColumnTabbedDisplay => layout.toggle_column_tabbed_display(),
972 Op::CenterColumn => layout.center_column(),974 Op::CenterColumn => layout.center_column(),
973 Op::CenterWindow { id } => {975 Op::CenterWindow { id } => {
974 let id = id.filter(|id| layout.has_window(id));976 let id = id.filter(|id| layout.has_window(id));
@@ -1462,6 +1464,7 @@ fn operations_dont_panic() {
1462 Op::ConsumeOrExpelWindowLeft { id: None },1464 Op::ConsumeOrExpelWindowLeft { id: None },
1463 Op::ConsumeOrExpelWindowRight { id: None },1465 Op::ConsumeOrExpelWindowRight { id: None },
1464 Op::MoveWorkspaceToOutput(1),1466 Op::MoveWorkspaceToOutput(1),
1467+ Op::ToggleColumnTabbedDisplay,
1465 ];1468 ];
1466 1469
1467 for third in every_op {1470 for third in every_op {
@@ -1636,6 +1639,7 @@ fn operations_from_starting_state_dont_panic() {
1636 Op::MoveWindowUpOrToWorkspaceUp,1639 Op::MoveWindowUpOrToWorkspaceUp,
1637 Op::ConsumeOrExpelWindowLeft { id: None },1640 Op::ConsumeOrExpelWindowLeft { id: None },
1638 Op::ConsumeOrExpelWindowRight { id: None },1641 Op::ConsumeOrExpelWindowRight { id: None },
1642+ Op::ToggleColumnTabbedDisplay,
1639 ];1643 ];
1640 1644
1641 for third in every_op {1645 for third in every_op {
src/layout/workspace.rsmodified+9 -3
@@ -577,10 +577,10 @@ impl<W: LayoutElement> Workspace<W> {
577 self.floating.add_tile_above(next_to, tile, activate);577 self.floating.add_tile_above(next_to, tile, activate);
578 } else {578 } else {
579 // FIXME: use static pos579 // FIXME: use static pos
580- let (next_to_tile, render_pos) = self580+ let (next_to_tile, render_pos, _visible) = self
581 .scrolling581 .scrolling
582 .tiles_with_render_positions()582 .tiles_with_render_positions()
583- .find(|(tile, _)| tile.window().id() == next_to)583+ .find(|(tile, _, _)| tile.window().id() == next_to)
584 .unwrap();584 .unwrap();
585 585
586 // Position the new tile in the center above the next_to tile. Think a586 // Position the new tile in the center above the next_to tile. Think a
@@ -1022,6 +1022,13 @@ impl<W: LayoutElement> Workspace<W> {
1022 self.scrolling.swap_window_in_direction(direction);1022 self.scrolling.swap_window_in_direction(direction);
1023 }1023 }
1024 1024
1025+ pub fn toggle_column_tabbed_display(&mut self) {
1026+ if self.floating_is_active.get() {
1027+ return;
1028+ }
1029+ self.scrolling.toggle_column_tabbed_display();
1030+ }
1031+
1025 pub fn center_column(&mut self) {1032 pub fn center_column(&mut self) {
1026 if self.floating_is_active.get() {1033 if self.floating_is_active.get() {
1027 self.floating.center_window(None);1034 self.floating.center_window(None);
@@ -1336,7 +1343,6 @@ impl<W: LayoutElement> Workspace<W> {
1336 &self,1343 &self,
1337 ) -> impl Iterator<Item = (&Tile<W>, Point<f64, Logical>, bool)> {1344 ) -> impl Iterator<Item = (&Tile<W>, Point<f64, Logical>, bool)> {
1338 let scrolling = self.scrolling.tiles_with_render_positions();1345 let scrolling = self.scrolling.tiles_with_render_positions();
1339- let scrolling = scrolling.map(|(tile, pos)| (tile, pos, true));
1340 1346
1341 let floating = self.floating.tiles_with_render_positions();1347 let floating = self.floating.tiles_with_render_positions();
1342 let visible = self.is_floating_visible();1348 let visible = self.is_floating_visible();
wiki/Configuration:-Layout.mdmodified+15 -0
@@ -10,6 +10,7 @@ layout {
10 center-focused-column "never"10 center-focused-column "never"
11 always-center-single-column11 always-center-single-column
12 empty-workspace-above-first12 empty-workspace-above-first
13+ default-column-display "tabbed"
13 14
14 preset-column-widths {15 preset-column-widths {
15 proportion 0.3333316 proportion 0.33333
@@ -123,6 +124,20 @@ layout {
123 }124 }
124 ```125 ```
125 126
127+### `default-column-display`
128+
129+<sup>Since: next release</sup>
130+
131+Sets the default display mode for new columns.
132+Can be `normal` or `tabbed`.
133+
134+```kdl
135+// Make all new columns tabbed by default.
136+layout {
137+ default-column-display "tabbed"
138+}
139+```
140+
126 ### `preset-column-widths`141 ### `preset-column-widths`
127 142
128 Set the widths that the `switch-preset-column-width` action (Mod+R) toggles between.143 Set the widths that the `switch-preset-column-width` action (Mod+R) toggles between.