From 495b63d7dcfd2c67b66b67ed24d77bc54305de6c Mon Sep 17 00:00:00 2001 From: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> Date: Sat, 15 Jul 2023 17:44:57 +0000 Subject: [PATCH] workspaces.hpp --- include/modules/hyprland/workspaces.hpp | 41 ++++++++++++++++--------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/include/modules/hyprland/workspaces.hpp b/include/modules/hyprland/workspaces.hpp index 500bbe36..12590fcd 100644 --- a/include/modules/hyprland/workspaces.hpp +++ b/include/modules/hyprland/workspaces.hpp @@ -9,27 +9,30 @@ namespace waybar::modules::hyprland { -struct WorkspaceDto { - int id; - - static WorkspaceDto parse(const Json::Value& value); -}; - class Workspace { public: - Workspace(int id); - Workspace(WorkspaceDto dto); - int id() const { return id_; }; - int active() const { return active_; }; + Workspace(const Json::Value& value); std::string& select_icon(std::map& icons_map); - void set_active(bool value = true) { active_ = value; }; Gtk::Button& button() { return button_; }; + int id() const { return id_; }; + std::string name() const { return name_; }; + std::string monitor() const { return monitor_; }; + int active() const { return active_; }; + bool is_special() const { return is_special_; }; + + auto handle_clicked(GdkEventButton* bt) -> bool; + void set_active(bool value) { active_ = value; }; + void update(const std::string& format, const std::string& icon); private: int id_; + std::string name_; + std::string monitor_; + int windows_; bool active_; + bool is_special_; Gtk::Button button_; Gtk::Box content_; @@ -43,19 +46,27 @@ class Workspaces : public AModule, public EventHandler { void update() override; void init(); + auto all_outputs() const -> bool { return all_outputs_; } + auto show_special() const -> bool { return show_special_; } + + auto get_bar_output() const -> std::string { return bar_.output->name; } + private: void onEvent(const std::string&) override; void sort_workspaces(); - void create_workspace(int id); - void remove_workspace(int id); + void create_workspace(const Json::Value& value); + void remove_workspace(std::string name); + + bool all_outputs_ = false; + bool show_special_ = false; std::string format_; std::map icons_map_; bool with_icon_; - int active_workspace_id; + std::string active_workspace_name; std::vector> workspaces_; std::vector workspaces_to_create_; - std::vector workspaces_to_remove_; + std::vector workspaces_to_remove_; std::mutex mutex_; const Bar& bar_; Gtk::Box box_;