mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
added move window to monitor by id
This commit is contained in:
committed by
Ivan Molodetskikh
parent
50a99f6356
commit
8737067af5
+12
-1
@@ -1576,6 +1576,11 @@ pub enum Action {
|
|||||||
MoveWindowToMonitorPrevious,
|
MoveWindowToMonitorPrevious,
|
||||||
MoveWindowToMonitorNext,
|
MoveWindowToMonitorNext,
|
||||||
MoveWindowToMonitor(#[knuffel(argument)] String),
|
MoveWindowToMonitor(#[knuffel(argument)] String),
|
||||||
|
#[knuffel(skip)]
|
||||||
|
MoveWindowToMonitorById {
|
||||||
|
id: u64,
|
||||||
|
output: String,
|
||||||
|
},
|
||||||
MoveColumnToMonitorLeft,
|
MoveColumnToMonitorLeft,
|
||||||
MoveColumnToMonitorRight,
|
MoveColumnToMonitorRight,
|
||||||
MoveColumnToMonitorDown,
|
MoveColumnToMonitorDown,
|
||||||
@@ -1780,7 +1785,13 @@ impl From<niri_ipc::Action> for Action {
|
|||||||
niri_ipc::Action::MoveWindowToMonitorUp {} => Self::MoveWindowToMonitorUp,
|
niri_ipc::Action::MoveWindowToMonitorUp {} => Self::MoveWindowToMonitorUp,
|
||||||
niri_ipc::Action::MoveWindowToMonitorPrevious {} => Self::MoveWindowToMonitorPrevious,
|
niri_ipc::Action::MoveWindowToMonitorPrevious {} => Self::MoveWindowToMonitorPrevious,
|
||||||
niri_ipc::Action::MoveWindowToMonitorNext {} => Self::MoveWindowToMonitorNext,
|
niri_ipc::Action::MoveWindowToMonitorNext {} => Self::MoveWindowToMonitorNext,
|
||||||
niri_ipc::Action::MoveWindowToMonitor { output } => Self::MoveWindowToMonitor(output),
|
niri_ipc::Action::MoveWindowToMonitor { id: None, output } => {
|
||||||
|
Self::MoveWindowToMonitor(output)
|
||||||
|
}
|
||||||
|
niri_ipc::Action::MoveWindowToMonitor {
|
||||||
|
id: Some(id),
|
||||||
|
output,
|
||||||
|
} => Self::MoveWindowToMonitorById { id, output },
|
||||||
niri_ipc::Action::MoveColumnToMonitorLeft {} => Self::MoveColumnToMonitorLeft,
|
niri_ipc::Action::MoveColumnToMonitorLeft {} => Self::MoveColumnToMonitorLeft,
|
||||||
niri_ipc::Action::MoveColumnToMonitorRight {} => Self::MoveColumnToMonitorRight,
|
niri_ipc::Action::MoveColumnToMonitorRight {} => Self::MoveColumnToMonitorRight,
|
||||||
niri_ipc::Action::MoveColumnToMonitorDown {} => Self::MoveColumnToMonitorDown,
|
niri_ipc::Action::MoveColumnToMonitorDown {} => Self::MoveColumnToMonitorDown,
|
||||||
|
|||||||
+11
-1
@@ -475,8 +475,18 @@ pub enum Action {
|
|||||||
MoveWindowToMonitorPrevious {},
|
MoveWindowToMonitorPrevious {},
|
||||||
/// Move the focused window to the next monitor.
|
/// Move the focused window to the next monitor.
|
||||||
MoveWindowToMonitorNext {},
|
MoveWindowToMonitorNext {},
|
||||||
/// Move the focused window to a specific monitor.
|
/// Move a window to a specific monitor.
|
||||||
|
#[cfg_attr(
|
||||||
|
feature = "clap",
|
||||||
|
clap(about = "Move the focused window to a specific monitor")
|
||||||
|
)]
|
||||||
MoveWindowToMonitor {
|
MoveWindowToMonitor {
|
||||||
|
/// Id of the window to move.
|
||||||
|
///
|
||||||
|
/// If `None`, uses the focused window.
|
||||||
|
#[cfg_attr(feature = "clap", arg(long))]
|
||||||
|
id: Option<u64>,
|
||||||
|
|
||||||
/// The target output name.
|
/// The target output name.
|
||||||
#[cfg_attr(feature = "clap", arg())]
|
#[cfg_attr(feature = "clap", arg())]
|
||||||
output: String,
|
output: String,
|
||||||
|
|||||||
@@ -1458,6 +1458,32 @@ impl State {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Action::MoveWindowToMonitorById { id, output } => {
|
||||||
|
if let Some(output) = self.niri.output_by_name_match(&output).cloned() {
|
||||||
|
let window = self.niri.layout.windows().find(|(_, m)| m.id().get() == id);
|
||||||
|
let window = window.map(|(_, m)| m.window.clone());
|
||||||
|
|
||||||
|
if let Some(window) = window {
|
||||||
|
let target_was_active = self
|
||||||
|
.niri
|
||||||
|
.layout
|
||||||
|
.active_output()
|
||||||
|
.is_some_and(|active| output == *active);
|
||||||
|
|
||||||
|
self.niri
|
||||||
|
.layout
|
||||||
|
.move_to_output(Some(&window), &output, None);
|
||||||
|
|
||||||
|
// If the active output changed (window was moved and focused).
|
||||||
|
#[allow(clippy::collapsible_if)]
|
||||||
|
if !target_was_active && self.niri.layout.active_output() == Some(&output) {
|
||||||
|
if !self.maybe_warp_cursor_to_focus_centered() {
|
||||||
|
self.move_cursor_to_output(&output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Action::MoveColumnToMonitorLeft => {
|
Action::MoveColumnToMonitorLeft => {
|
||||||
if let Some(output) = self.niri.output_left() {
|
if let Some(output) = self.niri.output_left() {
|
||||||
self.niri.layout.move_column_to_output(&output);
|
self.niri.layout.move_column_to_output(&output);
|
||||||
|
|||||||
Reference in New Issue
Block a user