hyprshell_windows_lib/overview/
update.rs

1use crate::global::WindowsOverviewData;
2use crate::next::{find_next_client, find_next_workspace};
3use adw::gtk::prelude::*;
4use core_lib::transfer::{Direction, SwitchOverviewConfig};
5use tracing::{debug_span, error};
6
7pub fn update_overview(data: &mut WindowsOverviewData, config: &SwitchOverviewConfig) {
8    let _span = debug_span!("update_overview").entered();
9
10    let active = if config.workspace {
11        find_next_workspace(
12            &config.direction,
13            false,
14            &data.hypr_data,
15            data.active,
16            data.config.items_per_row,
17        )
18    } else {
19        if config.direction == Direction::Up || config.direction == Direction::Down {
20            error!(
21                "Clients in overview can only be switched left and right (forwards and backwards)"
22            );
23            return;
24        }
25        find_next_client(
26            &config.direction,
27            false,
28            &data.hypr_data,
29            data.active,
30            data.config.items_per_row,
31        )
32    };
33    data.active = active;
34
35    for monitor_data in data.window_list.values_mut() {
36        if config.workspace {
37            for button in monitor_data.clients.values_mut() {
38                button.remove_css_class("active");
39            }
40            for (id, button) in &mut monitor_data.workspaces {
41                button.remove_css_class("active");
42                if active.workspace == *id {
43                    button.add_css_class("active");
44                }
45            }
46        } else {
47            for button in monitor_data.workspaces.values_mut() {
48                button.remove_css_class("active");
49            }
50            for (id, button) in &mut monitor_data.clients {
51                button.remove_css_class("active");
52                if active.client == Some(*id) {
53                    button.add_css_class("active");
54                }
55            }
56        }
57    }
58}