This commit is contained in:
dmitry
2021-11-23 03:10:44 +03:00
parent ef4c6a9ba3
commit 23991b6543
4 changed files with 183 additions and 85 deletions

View File

@ -5,6 +5,7 @@
#include <gtkmm/image.h>
#include <gtkmm/label.h>
#include <functional>
#include <map>
#include <memory>
#include <vector>
@ -37,25 +38,24 @@ class Workspace {
auto handle_done() -> void;
auto handle_clicked(GdkEventButton *bt) -> bool;
auto show() -> void { button_.show(); }
auto hide() -> void { button_.hide(); }
auto show() -> void;
auto hide() -> void;
auto get_button_ref() -> Gtk::Button & { return button_; }
auto get_name() -> std::string & { return name_; }
auto get_coords() -> std::vector<uint32_t> & { return coordinates_; }
enum class State
{
ACTIVE = 1 << 0,
URGENT = 1 << 1,
HIDDEN = 1 << 2,
enum class State {
ACTIVE = (1 << 0),
URGENT = (1 << 1),
HIDDEN = (1 << 2),
};
private:
auto get_icon() -> std::string;
const Bar & bar_;
const Bar &bar_;
const Json::Value &config_;
WorkspaceGroup & workspace_group_;
WorkspaceGroup &workspace_group_;
// wlr stuff
zext_workspace_handle_v1 *workspace_handle_;
@ -84,35 +84,36 @@ class WorkspaceGroup {
auto id() const -> uint32_t { return id_; }
auto is_visible() const -> bool;
auto remove_workspace(uint32_t id_) -> void;
auto active_only() const -> bool;
auto creation_delayed() const -> bool;
auto workspaces() -> std::vector<std::unique_ptr<Workspace>> & { return workspaces_; }
auto sort_workspaces() -> void;
auto set_need_to_sort() -> void { need_to_sort = true; }
auto add_button(Gtk::Button &button) -> void;
auto remove_button(Gtk::Button &button) -> void;
// wlr stuff
auto handle_workspace_create(zext_workspace_handle_v1 *workspace_handle) -> void;
auto handle_remove() -> void;
auto handle_output_enter(wl_output *output) -> void;
auto handle_output_leave() -> void;
auto add_button(Gtk::Button &button) -> void;
auto remove_button(Gtk::Button &button) -> void;
auto handle_done() -> void;
auto commit() -> void;
auto sort_workspaces() -> void;
auto set_need_to_sort() -> void { need_to_sort = true; }
private:
static uint32_t workspace_global_id;
const waybar::Bar &bar_;
Gtk::Box & box_;
Gtk::Box &box_;
const Json::Value &config_;
WorkspaceManager & workspace_manager_;
WorkspaceManager &workspace_manager_;
// wlr stuff
zext_workspace_group_handle_v1 *workspace_group_handle_;
wl_output * output_ = nullptr;
wl_output *output_ = nullptr;
uint32_t id_;
std::vector<std::unique_ptr<Workspace>> workspaces_;
bool sort_by_name = true;
bool sort_by_coordinates = true;
bool need_to_sort = false;
};
@ -122,6 +123,13 @@ class WorkspaceManager : public AModule {
~WorkspaceManager() override;
auto update() -> void override;
auto all_outputs() const -> bool { return all_outputs_; }
auto active_only() const -> bool { return active_only_; }
auto workspace_comparator() const
-> std::function<bool(std::unique_ptr<Workspace> &, std::unique_ptr<Workspace> &)>;
auto creation_delayed() const -> bool { return creation_delayed_; }
auto sort_workspaces() -> void;
auto remove_workspace_group(uint32_t id_) -> void;
// wlr stuff
@ -130,11 +138,10 @@ class WorkspaceManager : public AModule {
-> void;
auto handle_done() -> void;
auto handle_finished() -> void;
auto commit() -> void;
private:
const waybar::Bar & bar_;
const waybar::Bar &bar_;
Gtk::Box box_;
std::vector<std::unique_ptr<WorkspaceGroup>> groups_;
@ -142,6 +149,12 @@ class WorkspaceManager : public AModule {
zext_workspace_manager_v1 *workspace_manager_ = nullptr;
static uint32_t group_global_id;
bool sort_by_name_ = true;
bool sort_by_coordinates_ = true;
bool all_outputs_ = false;
bool active_only_ = false;
bool creation_delayed_ = false;
};
} // namespace waybar::modules::wlr