mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
layout: Return bool from activate_window()
Avoid an extra has_window() call.
This commit is contained in:
+1
-2
@@ -1372,9 +1372,8 @@ impl<W: LayoutElement> Layout<W> {
|
||||
|
||||
for (monitor_idx, mon) in monitors.iter_mut().enumerate() {
|
||||
for (workspace_idx, ws) in mon.workspaces.iter_mut().enumerate() {
|
||||
if ws.has_window(window) {
|
||||
if ws.activate_window(window) {
|
||||
*active_monitor_idx = monitor_idx;
|
||||
ws.activate_window(window);
|
||||
|
||||
// If currently in the middle of a vertical swipe between the target workspace
|
||||
// and some other, don't switch the workspace.
|
||||
|
||||
@@ -1175,16 +1175,17 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
||||
(from_view_offset - new_view_offset).abs() / self.working_area.size.w
|
||||
}
|
||||
|
||||
pub fn activate_window(&mut self, window: &W::Id) {
|
||||
let column_idx = self
|
||||
.columns
|
||||
.iter()
|
||||
.position(|col| col.contains(window))
|
||||
.unwrap();
|
||||
pub fn activate_window(&mut self, window: &W::Id) -> bool {
|
||||
let column_idx = self.columns.iter().position(|col| col.contains(window));
|
||||
let Some(column_idx) = column_idx else {
|
||||
return false;
|
||||
};
|
||||
let column = &mut self.columns[column_idx];
|
||||
|
||||
column.activate_window(window);
|
||||
self.activate_column(column_idx);
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
pub fn start_close_animation_for_window(
|
||||
|
||||
@@ -840,8 +840,8 @@ impl<W: LayoutElement> Workspace<W> {
|
||||
self.scrolling.scroll_amount_to_activate(window)
|
||||
}
|
||||
|
||||
pub fn activate_window(&mut self, window: &W::Id) {
|
||||
self.scrolling.activate_window(window);
|
||||
pub fn activate_window(&mut self, window: &W::Id) -> bool {
|
||||
self.scrolling.activate_window(window)
|
||||
}
|
||||
|
||||
pub fn set_insert_hint(&mut self, insert_hint: InsertHint) {
|
||||
|
||||
Reference in New Issue
Block a user