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> {
13721372
13731373 for (monitor_idx, mon) in monitors.iter_mut().enumerate() {
13741374 for (workspace_idx, ws) in mon.workspaces.iter_mut().enumerate() {
1375- if ws.has_window(window) {
1375+ if ws.activate_window(window) {
13761376 *active_monitor_idx = monitor_idx;
1377- ws.activate_window(window);
13781377
13791378 // If currently in the middle of a vertical swipe between the target workspace
13801379 // and some other, don't switch the workspace.
src/layout/scrolling.rsmodified+7 -6
@@ -1175,16 +1175,17 @@ impl<W: LayoutElement> ScrollingSpace<W> {
11751175 (from_view_offset - new_view_offset).abs() / self.working_area.size.w
11761176 }
11771177
1178- pub fn activate_window(&mut self, window: &W::Id) {
1179- let column_idx = self
1180- .columns
1181- .iter()
1182- .position(|col| col.contains(window))
1183- .unwrap();
1178+ pub fn activate_window(&mut self, window: &W::Id) -> bool {
1179+ let column_idx = self.columns.iter().position(|col| col.contains(window));
1180+ let Some(column_idx) = column_idx else {
1181+ return false;
1182+ };
11841183 let column = &mut self.columns[column_idx];
11851184
11861185 column.activate_window(window);
11871186 self.activate_column(column_idx);
1187+
1188+ true
11881189 }
11891190
11901191 pub fn start_close_animation_for_window(
src/layout/workspace.rsmodified+2 -2
@@ -840,8 +840,8 @@ impl<W: LayoutElement> Workspace<W> {
840840 self.scrolling.scroll_amount_to_activate(window)
841841 }
842842
843- pub fn activate_window(&mut self, window: &W::Id) {
844- self.scrolling.activate_window(window);
843+ pub fn activate_window(&mut self, window: &W::Id) -> bool {
844+ self.scrolling.activate_window(window)
845845 }
846846
847847 pub fn set_insert_hint(&mut self, insert_hint: InsertHint) {