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