forge
Explore
Log in

Don't you dare go Hollow

layout: Return bool from activate_window()

Browse files at this commit

27e607ab823c9838452c88bc2c83e91ef5a04191Ivan MolodetskikhParent: a2b27b8
Avoid an extra has_window() call.
src/layout/mod.rsmodified+1 -2
@@ -1372,9 +1372,8 @@ impl<W: LayoutElement> Layout<W> {
1372 1372
1373 for (monitor_idx, mon) in monitors.iter_mut().enumerate() {1373 for (monitor_idx, mon) in monitors.iter_mut().enumerate() {
1374 for (workspace_idx, ws) in mon.workspaces.iter_mut().enumerate() {1374 for (workspace_idx, ws) in mon.workspaces.iter_mut().enumerate() {
1375- if ws.has_window(window) {1375+ if ws.activate_window(window) {
1376 *active_monitor_idx = monitor_idx;1376 *active_monitor_idx = monitor_idx;
1377- ws.activate_window(window);
1378 1377
1379 // If currently in the middle of a vertical swipe between the target workspace1378 // If currently in the middle of a vertical swipe between the target workspace
1380 // and some other, don't switch the workspace.1379 // and some other, don't switch the workspace.
src/layout/scrolling.rsmodified+7 -6
@@ -1175,16 +1175,17 @@ impl<W: LayoutElement> ScrollingSpace<W> {
1175 (from_view_offset - new_view_offset).abs() / self.working_area.size.w1175 (from_view_offset - new_view_offset).abs() / self.working_area.size.w
1176 }1176 }
1177 1177
1178- pub fn activate_window(&mut self, window: &W::Id) {1178+ pub fn activate_window(&mut self, window: &W::Id) -> bool {
1179- let column_idx = self1179+ let column_idx = self.columns.iter().position(|col| col.contains(window));
1180- .columns1180+ let Some(column_idx) = column_idx else {
1181- .iter()1181+ return false;
1182- .position(|col| col.contains(window))1182+ };
1183- .unwrap();
1184 let column = &mut self.columns[column_idx];1183 let column = &mut self.columns[column_idx];
1185 1184
1186 column.activate_window(window);1185 column.activate_window(window);
1187 self.activate_column(column_idx);1186 self.activate_column(column_idx);
1187+
1188+ true
1188 }1189 }
1189 1190
1190 pub fn start_close_animation_for_window(1191 pub fn start_close_animation_for_window(
src/layout/workspace.rsmodified+2 -2
@@ -840,8 +840,8 @@ impl<W: LayoutElement> Workspace<W> {
840 self.scrolling.scroll_amount_to_activate(window)840 self.scrolling.scroll_amount_to_activate(window)
841 }841 }
842 842
843- pub fn activate_window(&mut self, window: &W::Id) {843+ pub fn activate_window(&mut self, window: &W::Id) -> bool {
844- self.scrolling.activate_window(window);844+ self.scrolling.activate_window(window)
845 }845 }
846 846
847 pub fn set_insert_hint(&mut self, insert_hint: InsertHint) {847 pub fn set_insert_hint(&mut self, insert_hint: InsertHint) {