mirror of
https://github.com/YaLTeR/niri.git
synced 2025-10-06 00:23:14 +02:00
Add set-column-display action
This commit is contained in:
@@ -1371,6 +1371,7 @@ pub enum Action {
|
||||
SwapWindowLeft,
|
||||
SwapWindowRight,
|
||||
ToggleColumnTabbedDisplay,
|
||||
SetColumnDisplay(#[knuffel(argument, str)] ColumnDisplay),
|
||||
CenterColumn,
|
||||
CenterWindow,
|
||||
#[knuffel(skip)]
|
||||
@@ -1568,6 +1569,7 @@ impl From<niri_ipc::Action> for Action {
|
||||
niri_ipc::Action::SwapWindowRight {} => Self::SwapWindowRight,
|
||||
niri_ipc::Action::SwapWindowLeft {} => Self::SwapWindowLeft,
|
||||
niri_ipc::Action::ToggleColumnTabbedDisplay {} => Self::ToggleColumnTabbedDisplay,
|
||||
niri_ipc::Action::SetColumnDisplay { display } => Self::SetColumnDisplay(display),
|
||||
niri_ipc::Action::CenterColumn {} => Self::CenterColumn,
|
||||
niri_ipc::Action::CenterWindow { id: None } => Self::CenterWindow,
|
||||
niri_ipc::Action::CenterWindow { id: Some(id) } => Self::CenterWindowById(id),
|
||||
|
@@ -323,6 +323,12 @@ pub enum Action {
|
||||
SwapWindowLeft {},
|
||||
/// Toggle the focused column between normal and tabbed display.
|
||||
ToggleColumnTabbedDisplay {},
|
||||
/// Set the display mode of the focused column.
|
||||
SetColumnDisplay {
|
||||
/// Display mode to set.
|
||||
#[cfg_attr(feature = "clap", arg())]
|
||||
display: ColumnDisplay,
|
||||
},
|
||||
/// Center the focused column on the screen.
|
||||
CenterColumn {},
|
||||
/// Center a window on the screen.
|
||||
|
@@ -1265,6 +1265,12 @@ impl State {
|
||||
// FIXME: granular
|
||||
self.niri.queue_redraw_all();
|
||||
}
|
||||
Action::SetColumnDisplay(display) => {
|
||||
self.niri.layout.set_column_display(display);
|
||||
self.maybe_warp_cursor_to_focus();
|
||||
// FIXME: granular
|
||||
self.niri.queue_redraw_all();
|
||||
}
|
||||
Action::SwitchPresetColumnWidth => {
|
||||
self.niri.layout.toggle_width();
|
||||
}
|
||||
|
@@ -2151,6 +2151,13 @@ impl<W: LayoutElement> Layout<W> {
|
||||
monitor.toggle_column_tabbed_display();
|
||||
}
|
||||
|
||||
pub fn set_column_display(&mut self, display: ColumnDisplay) {
|
||||
let Some(monitor) = self.active_monitor() else {
|
||||
return;
|
||||
};
|
||||
monitor.set_column_display(display);
|
||||
}
|
||||
|
||||
pub fn center_column(&mut self) {
|
||||
let Some(monitor) = self.active_monitor() else {
|
||||
return;
|
||||
|
@@ -2,7 +2,7 @@ use std::cmp::min;
|
||||
use std::rc::Rc;
|
||||
use std::time::Duration;
|
||||
|
||||
use niri_ipc::SizeChange;
|
||||
use niri_ipc::{ColumnDisplay, SizeChange};
|
||||
use smithay::backend::renderer::element::utils::{
|
||||
CropRenderElement, Relocate, RelocateRenderElement,
|
||||
};
|
||||
@@ -736,6 +736,10 @@ impl<W: LayoutElement> Monitor<W> {
|
||||
self.active_workspace().toggle_column_tabbed_display();
|
||||
}
|
||||
|
||||
pub fn set_column_display(&mut self, display: ColumnDisplay) {
|
||||
self.active_workspace().set_column_display(display);
|
||||
}
|
||||
|
||||
pub fn center_column(&mut self) {
|
||||
self.active_workspace().center_column();
|
||||
}
|
||||
|
@@ -1968,8 +1968,26 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
||||
}
|
||||
|
||||
let col = &mut self.columns[self.active_column_idx];
|
||||
let display = match col.display_mode {
|
||||
ColumnDisplay::Normal => ColumnDisplay::Tabbed,
|
||||
ColumnDisplay::Tabbed => ColumnDisplay::Normal,
|
||||
};
|
||||
|
||||
self.set_column_display(display);
|
||||
}
|
||||
|
||||
pub fn set_column_display(&mut self, display: ColumnDisplay) {
|
||||
if self.columns.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
let col = &mut self.columns[self.active_column_idx];
|
||||
if col.display_mode == display {
|
||||
return;
|
||||
}
|
||||
|
||||
cancel_resize_for_column(&mut self.interactive_resize, col);
|
||||
col.toggle_tabbed_display();
|
||||
col.set_column_display(display);
|
||||
|
||||
// Disable fullscreen if needed.
|
||||
if col.display_mode != ColumnDisplay::Tabbed && col.tiles.len() > 1 {
|
||||
@@ -4101,11 +4119,12 @@ impl<W: LayoutElement> Column<W> {
|
||||
self.update_tile_sizes(false);
|
||||
}
|
||||
|
||||
fn toggle_tabbed_display(&mut self) {
|
||||
self.display_mode = match self.display_mode {
|
||||
ColumnDisplay::Normal => ColumnDisplay::Tabbed,
|
||||
ColumnDisplay::Tabbed => ColumnDisplay::Normal,
|
||||
};
|
||||
fn set_column_display(&mut self, display: ColumnDisplay) {
|
||||
if self.display_mode == display {
|
||||
return;
|
||||
}
|
||||
|
||||
self.display_mode = display;
|
||||
self.update_tile_sizes(true);
|
||||
}
|
||||
|
||||
|
@@ -320,6 +320,10 @@ fn arbitrary_scroll_direction() -> impl Strategy<Value = ScrollDirection> {
|
||||
prop_oneof![Just(ScrollDirection::Left), Just(ScrollDirection::Right)]
|
||||
}
|
||||
|
||||
fn arbitrary_column_display() -> impl Strategy<Value = ColumnDisplay> {
|
||||
prop_oneof![Just(ColumnDisplay::Normal), Just(ColumnDisplay::Tabbed)]
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Arbitrary)]
|
||||
enum Op {
|
||||
AddOutput(#[proptest(strategy = "1..=5usize")] usize),
|
||||
@@ -407,6 +411,7 @@ enum Op {
|
||||
ExpelWindowFromColumn,
|
||||
SwapWindowInDirection(#[proptest(strategy = "arbitrary_scroll_direction()")] ScrollDirection),
|
||||
ToggleColumnTabbedDisplay,
|
||||
SetColumnDisplay(#[proptest(strategy = "arbitrary_column_display()")] ColumnDisplay),
|
||||
CenterColumn,
|
||||
CenterWindow {
|
||||
#[proptest(strategy = "proptest::option::of(1..=5usize)")]
|
||||
@@ -971,6 +976,7 @@ impl Op {
|
||||
Op::ExpelWindowFromColumn => layout.expel_from_column(),
|
||||
Op::SwapWindowInDirection(direction) => layout.swap_window_in_direction(direction),
|
||||
Op::ToggleColumnTabbedDisplay => layout.toggle_column_tabbed_display(),
|
||||
Op::SetColumnDisplay(display) => layout.set_column_display(display),
|
||||
Op::CenterColumn => layout.center_column(),
|
||||
Op::CenterWindow { id } => {
|
||||
let id = id.filter(|id| layout.has_window(id));
|
||||
|
@@ -3,7 +3,7 @@ use std::rc::Rc;
|
||||
use std::time::Duration;
|
||||
|
||||
use niri_config::{CenterFocusedColumn, OutputName, PresetSize, Workspace as WorkspaceConfig};
|
||||
use niri_ipc::{PositionChange, SizeChange};
|
||||
use niri_ipc::{ColumnDisplay, PositionChange, SizeChange};
|
||||
use smithay::backend::renderer::gles::GlesRenderer;
|
||||
use smithay::desktop::{layer_map_for_output, Window};
|
||||
use smithay::output::Output;
|
||||
@@ -1029,6 +1029,13 @@ impl<W: LayoutElement> Workspace<W> {
|
||||
self.scrolling.toggle_column_tabbed_display();
|
||||
}
|
||||
|
||||
pub fn set_column_display(&mut self, display: ColumnDisplay) {
|
||||
if self.floating_is_active.get() {
|
||||
return;
|
||||
}
|
||||
self.scrolling.set_column_display(display);
|
||||
}
|
||||
|
||||
pub fn center_column(&mut self) {
|
||||
if self.floating_is_active.get() {
|
||||
self.floating.center_window(None);
|
||||
|
Reference in New Issue
Block a user