mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
Make move-window-to-workspace focus=false work across monitors too
This commit is contained in:
+7
-3
@@ -76,6 +76,7 @@ use smithay::{
|
||||
};
|
||||
|
||||
pub use crate::handlers::xdg_shell::KdeDecorationsModeState;
|
||||
use crate::layout::ActivateWindow;
|
||||
use crate::niri::{DndIcon, NewClient, State};
|
||||
use crate::protocols::foreign_toplevel::{
|
||||
self, ForeignToplevelHandler, ForeignToplevelManagerState,
|
||||
@@ -551,9 +552,12 @@ impl ForeignToplevelHandler for State {
|
||||
|
||||
if let Some(requested_output) = wl_output.as_ref().and_then(Output::from_resource) {
|
||||
if Some(&requested_output) != current_output {
|
||||
self.niri
|
||||
.layout
|
||||
.move_to_output(Some(&window), &requested_output, None);
|
||||
self.niri.layout.move_to_output(
|
||||
Some(&window),
|
||||
&requested_output,
|
||||
None,
|
||||
ActivateWindow::Smart,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ use crate::input::resize_grab::ResizeGrab;
|
||||
use crate::input::touch_move_grab::TouchMoveGrab;
|
||||
use crate::input::touch_resize_grab::TouchResizeGrab;
|
||||
use crate::input::{PointerOrTouchStartData, DOUBLE_CLICK_TIME};
|
||||
use crate::layout::ActivateWindow;
|
||||
use crate::niri::{CastTarget, PopupGrabState, State};
|
||||
use crate::utils::transaction::Transaction;
|
||||
use crate::utils::{
|
||||
@@ -445,9 +446,12 @@ impl XdgShellHandler for State {
|
||||
|
||||
if let Some(requested_output) = requested_output {
|
||||
if Some(&requested_output) != current_output {
|
||||
self.niri
|
||||
.layout
|
||||
.move_to_output(Some(&window), &requested_output, None);
|
||||
self.niri.layout.move_to_output(
|
||||
Some(&window),
|
||||
&requested_output,
|
||||
None,
|
||||
ActivateWindow::Smart,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+55
-27
@@ -1104,18 +1104,25 @@ impl State {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(output) = output {
|
||||
self.niri.layout.move_to_output(None, &output, Some(index));
|
||||
let activate = if focus {
|
||||
ActivateWindow::Smart
|
||||
} else {
|
||||
ActivateWindow::No
|
||||
};
|
||||
|
||||
if !self.maybe_warp_cursor_to_focus_centered() {
|
||||
self.move_cursor_to_output(&output);
|
||||
if let Some(output) = output {
|
||||
self.niri
|
||||
.layout
|
||||
.move_to_output(None, &output, Some(index), activate);
|
||||
|
||||
if focus {
|
||||
if !self.maybe_warp_cursor_to_focus_centered() {
|
||||
self.move_cursor_to_output(&output);
|
||||
}
|
||||
} else {
|
||||
self.maybe_warp_cursor_to_focus();
|
||||
}
|
||||
} else {
|
||||
let activate = if focus {
|
||||
ActivateWindow::Smart
|
||||
} else {
|
||||
ActivateWindow::No
|
||||
};
|
||||
self.niri.layout.move_to_workspace(None, index, activate);
|
||||
self.maybe_warp_cursor_to_focus();
|
||||
}
|
||||
@@ -1141,10 +1148,19 @@ impl State {
|
||||
.active_output()
|
||||
.is_some_and(|active| output.as_ref() == Some(active));
|
||||
|
||||
let activate = if focus {
|
||||
ActivateWindow::Smart
|
||||
} else {
|
||||
ActivateWindow::No
|
||||
};
|
||||
|
||||
if let Some(output) = output {
|
||||
self.niri
|
||||
.layout
|
||||
.move_to_output(Some(&window), &output, Some(index));
|
||||
self.niri.layout.move_to_output(
|
||||
Some(&window),
|
||||
&output,
|
||||
Some(index),
|
||||
activate,
|
||||
);
|
||||
|
||||
// If the active output changed (window was moved and focused).
|
||||
#[allow(clippy::collapsible_if)]
|
||||
@@ -1156,11 +1172,6 @@ impl State {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let activate = if focus {
|
||||
ActivateWindow::Smart
|
||||
} else {
|
||||
ActivateWindow::No
|
||||
};
|
||||
self.niri
|
||||
.layout
|
||||
.move_to_workspace(Some(&window), index, activate);
|
||||
@@ -1458,7 +1469,9 @@ impl State {
|
||||
}
|
||||
Action::MoveWindowToMonitorLeft => {
|
||||
if let Some(output) = self.niri.output_left() {
|
||||
self.niri.layout.move_to_output(None, &output, None);
|
||||
self.niri
|
||||
.layout
|
||||
.move_to_output(None, &output, None, ActivateWindow::Smart);
|
||||
self.niri.layout.focus_output(&output);
|
||||
if !self.maybe_warp_cursor_to_focus_centered() {
|
||||
self.move_cursor_to_output(&output);
|
||||
@@ -1467,7 +1480,9 @@ impl State {
|
||||
}
|
||||
Action::MoveWindowToMonitorRight => {
|
||||
if let Some(output) = self.niri.output_right() {
|
||||
self.niri.layout.move_to_output(None, &output, None);
|
||||
self.niri
|
||||
.layout
|
||||
.move_to_output(None, &output, None, ActivateWindow::Smart);
|
||||
self.niri.layout.focus_output(&output);
|
||||
if !self.maybe_warp_cursor_to_focus_centered() {
|
||||
self.move_cursor_to_output(&output);
|
||||
@@ -1476,7 +1491,9 @@ impl State {
|
||||
}
|
||||
Action::MoveWindowToMonitorDown => {
|
||||
if let Some(output) = self.niri.output_down() {
|
||||
self.niri.layout.move_to_output(None, &output, None);
|
||||
self.niri
|
||||
.layout
|
||||
.move_to_output(None, &output, None, ActivateWindow::Smart);
|
||||
self.niri.layout.focus_output(&output);
|
||||
if !self.maybe_warp_cursor_to_focus_centered() {
|
||||
self.move_cursor_to_output(&output);
|
||||
@@ -1485,7 +1502,9 @@ impl State {
|
||||
}
|
||||
Action::MoveWindowToMonitorUp => {
|
||||
if let Some(output) = self.niri.output_up() {
|
||||
self.niri.layout.move_to_output(None, &output, None);
|
||||
self.niri
|
||||
.layout
|
||||
.move_to_output(None, &output, None, ActivateWindow::Smart);
|
||||
self.niri.layout.focus_output(&output);
|
||||
if !self.maybe_warp_cursor_to_focus_centered() {
|
||||
self.move_cursor_to_output(&output);
|
||||
@@ -1494,7 +1513,9 @@ impl State {
|
||||
}
|
||||
Action::MoveWindowToMonitorPrevious => {
|
||||
if let Some(output) = self.niri.output_previous() {
|
||||
self.niri.layout.move_to_output(None, &output, None);
|
||||
self.niri
|
||||
.layout
|
||||
.move_to_output(None, &output, None, ActivateWindow::Smart);
|
||||
self.niri.layout.focus_output(&output);
|
||||
if !self.maybe_warp_cursor_to_focus_centered() {
|
||||
self.move_cursor_to_output(&output);
|
||||
@@ -1503,7 +1524,9 @@ impl State {
|
||||
}
|
||||
Action::MoveWindowToMonitorNext => {
|
||||
if let Some(output) = self.niri.output_next() {
|
||||
self.niri.layout.move_to_output(None, &output, None);
|
||||
self.niri
|
||||
.layout
|
||||
.move_to_output(None, &output, None, ActivateWindow::Smart);
|
||||
self.niri.layout.focus_output(&output);
|
||||
if !self.maybe_warp_cursor_to_focus_centered() {
|
||||
self.move_cursor_to_output(&output);
|
||||
@@ -1512,7 +1535,9 @@ impl State {
|
||||
}
|
||||
Action::MoveWindowToMonitor(output) => {
|
||||
if let Some(output) = self.niri.output_by_name_match(&output).cloned() {
|
||||
self.niri.layout.move_to_output(None, &output, None);
|
||||
self.niri
|
||||
.layout
|
||||
.move_to_output(None, &output, None, ActivateWindow::Smart);
|
||||
self.niri.layout.focus_output(&output);
|
||||
if !self.maybe_warp_cursor_to_focus_centered() {
|
||||
self.move_cursor_to_output(&output);
|
||||
@@ -1531,9 +1556,12 @@ impl State {
|
||||
.active_output()
|
||||
.is_some_and(|active| output == *active);
|
||||
|
||||
self.niri
|
||||
.layout
|
||||
.move_to_output(Some(&window), &output, None);
|
||||
self.niri.layout.move_to_output(
|
||||
Some(&window),
|
||||
&output,
|
||||
None,
|
||||
ActivateWindow::Smart,
|
||||
);
|
||||
|
||||
// If the active output changed (window was moved and focused).
|
||||
#[allow(clippy::collapsible_if)]
|
||||
|
||||
+7
-4
@@ -3199,6 +3199,7 @@ impl<W: LayoutElement> Layout<W> {
|
||||
window: Option<&W::Id>,
|
||||
output: &Output,
|
||||
target_ws_idx: Option<usize>,
|
||||
activate: ActivateWindow,
|
||||
) {
|
||||
if let Some(InteractiveMoveState::Moving(move_)) = &mut self.interactive_move {
|
||||
if window.is_none() || window == Some(move_.tile.window().id()) {
|
||||
@@ -3241,9 +3242,11 @@ impl<W: LayoutElement> Layout<W> {
|
||||
let ws_id = monitors[new_idx].workspaces[workspace_idx].id();
|
||||
|
||||
let mon = &mut monitors[mon_idx];
|
||||
let activate = window.map_or(true, |win| {
|
||||
mon_idx == *active_monitor_idx
|
||||
&& mon.active_window().map(|win| win.id()) == Some(win)
|
||||
let activate = activate.map_smart(|| {
|
||||
window.map_or(true, |win| {
|
||||
mon_idx == *active_monitor_idx
|
||||
&& mon.active_window().map(|win| win.id()) == Some(win)
|
||||
})
|
||||
});
|
||||
let activate = if activate {
|
||||
ActivateWindow::Yes
|
||||
@@ -3302,7 +3305,7 @@ impl<W: LayoutElement> Layout<W> {
|
||||
let ws = current.active_workspace();
|
||||
|
||||
if ws.floating_is_active() {
|
||||
self.move_to_output(None, output, None);
|
||||
self.move_to_output(None, output, None, ActivateWindow::Smart);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -1081,7 +1081,12 @@ impl Op {
|
||||
|
||||
let window_id = window_id.filter(|id| layout.has_window(id));
|
||||
let target_ws_idx = target_ws_idx.filter(|idx| mon.workspaces.len() > *idx);
|
||||
layout.move_to_output(window_id.as_ref(), &output, target_ws_idx);
|
||||
layout.move_to_output(
|
||||
window_id.as_ref(),
|
||||
&output,
|
||||
target_ws_idx,
|
||||
ActivateWindow::Smart,
|
||||
);
|
||||
}
|
||||
Op::MoveColumnToOutput(id) => {
|
||||
let name = format!("output{id}");
|
||||
|
||||
Reference in New Issue
Block a user