hyprland/workspaces: break up headers
parent
d73051e980
commit
07c91c200a
|
@ -0,0 +1,61 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <gtkmm/button.h>
|
||||||
|
#include <gtkmm/label.h>
|
||||||
|
#include <json/value.h>
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
|
#include <regex>
|
||||||
|
#include <string>
|
||||||
|
#include <variant>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "AModule.hpp"
|
||||||
|
#include "bar.hpp"
|
||||||
|
#include "modules/hyprland/backend.hpp"
|
||||||
|
#include "util/enum.hpp"
|
||||||
|
#include "util/regex_collection.hpp"
|
||||||
|
|
||||||
|
using WindowAddress = std::string;
|
||||||
|
|
||||||
|
namespace waybar::modules::hyprland {
|
||||||
|
|
||||||
|
class Workspaces;
|
||||||
|
|
||||||
|
class WindowCreationPayload {
|
||||||
|
public:
|
||||||
|
WindowCreationPayload(std::string workspace_name, WindowAddress window_address,
|
||||||
|
std::string window_repr);
|
||||||
|
WindowCreationPayload(std::string workspace_name, WindowAddress window_address,
|
||||||
|
std::string window_class, std::string window_title);
|
||||||
|
WindowCreationPayload(Json::Value const& client_data);
|
||||||
|
|
||||||
|
int incrementTimeSpentUncreated();
|
||||||
|
bool isEmpty(Workspaces& workspace_manager);
|
||||||
|
bool reprIsReady() const { return std::holds_alternative<Repr>(m_window); }
|
||||||
|
std::string repr(Workspaces& workspace_manager);
|
||||||
|
|
||||||
|
std::string getWorkspaceName() const { return m_workspaceName; }
|
||||||
|
WindowAddress getAddress() const { return m_windowAddress; }
|
||||||
|
|
||||||
|
void moveToWorksace(std::string& new_workspace_name);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void clearAddr();
|
||||||
|
void clearWorkspaceName();
|
||||||
|
|
||||||
|
using Repr = std::string;
|
||||||
|
using ClassAndTitle = std::pair<std::string, std::string>;
|
||||||
|
std::variant<Repr, ClassAndTitle> m_window;
|
||||||
|
|
||||||
|
WindowAddress m_windowAddress;
|
||||||
|
std::string m_workspaceName;
|
||||||
|
|
||||||
|
int m_timeSpentUncreated = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace waybar::modules::hyprland
|
|
@ -0,0 +1,88 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <gtkmm/button.h>
|
||||||
|
#include <gtkmm/label.h>
|
||||||
|
#include <json/value.h>
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
|
#include <regex>
|
||||||
|
#include <string>
|
||||||
|
#include <variant>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "AModule.hpp"
|
||||||
|
#include "bar.hpp"
|
||||||
|
#include "modules/hyprland/backend.hpp"
|
||||||
|
#include "modules/hyprland/windowcreationpayload.hpp"
|
||||||
|
#include "util/enum.hpp"
|
||||||
|
#include "util/regex_collection.hpp"
|
||||||
|
|
||||||
|
using WindowAddress = std::string;
|
||||||
|
|
||||||
|
namespace waybar::modules::hyprland {
|
||||||
|
|
||||||
|
class Workspaces;
|
||||||
|
class Workspace {
|
||||||
|
public:
|
||||||
|
explicit Workspace(const Json::Value& workspace_data, Workspaces& workspace_manager,
|
||||||
|
const Json::Value& clients_data = Json::Value::nullRef);
|
||||||
|
std::string& selectIcon(std::map<std::string, std::string>& icons_map);
|
||||||
|
Gtk::Button& button() { return m_button; };
|
||||||
|
|
||||||
|
int id() const { return m_id; };
|
||||||
|
std::string name() const { return m_name; };
|
||||||
|
std::string output() const { return m_output; };
|
||||||
|
bool isActive() const { return m_isActive; };
|
||||||
|
bool isSpecial() const { return m_isSpecial; };
|
||||||
|
bool isPersistent() const { return m_isPersistentRule || m_isPersistentConfig; };
|
||||||
|
bool isPersistentConfig() const { return m_isPersistentConfig; };
|
||||||
|
bool isPersistentRule() const { return m_isPersistentRule; };
|
||||||
|
bool isVisible() const { return m_isVisible; };
|
||||||
|
bool isEmpty() const { return m_windows == 0; };
|
||||||
|
bool isUrgent() const { return m_isUrgent; };
|
||||||
|
|
||||||
|
bool handleClicked(GdkEventButton* bt) const;
|
||||||
|
void setActive(bool value = true) { m_isActive = value; };
|
||||||
|
void setPersistentRule(bool value = true) { m_isPersistentRule = value; };
|
||||||
|
void setPersistentConfig(bool value = true) { m_isPersistentConfig = value; };
|
||||||
|
void setUrgent(bool value = true) { m_isUrgent = value; };
|
||||||
|
void setVisible(bool value = true) { m_isVisible = value; };
|
||||||
|
void setWindows(uint value) { m_windows = value; };
|
||||||
|
void setName(std::string const& value) { m_name = value; };
|
||||||
|
void setOutput(std::string const& value) { m_output = value; };
|
||||||
|
bool containsWindow(WindowAddress const& addr) const { return m_windowMap.contains(addr); }
|
||||||
|
void insertWindow(WindowCreationPayload create_window_paylod);
|
||||||
|
std::string removeWindow(WindowAddress const& addr);
|
||||||
|
void initializeWindowMap(const Json::Value& clients_data);
|
||||||
|
|
||||||
|
bool onWindowOpened(WindowCreationPayload const& create_window_paylod);
|
||||||
|
std::optional<std::string> closeWindow(WindowAddress const& addr);
|
||||||
|
|
||||||
|
void update(const std::string& format, const std::string& icon);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Workspaces& m_workspaceManager;
|
||||||
|
|
||||||
|
int m_id;
|
||||||
|
std::string m_name;
|
||||||
|
std::string m_output;
|
||||||
|
uint m_windows;
|
||||||
|
bool m_isActive = false;
|
||||||
|
bool m_isSpecial = false;
|
||||||
|
bool m_isPersistentRule = false; // represents the persistent state in hyprland
|
||||||
|
bool m_isPersistentConfig = false; // represents the persistent state in the Waybar config
|
||||||
|
bool m_isUrgent = false;
|
||||||
|
bool m_isVisible = false;
|
||||||
|
|
||||||
|
std::map<WindowAddress, std::string> m_windowMap;
|
||||||
|
|
||||||
|
Gtk::Button m_button;
|
||||||
|
Gtk::Box m_content;
|
||||||
|
Gtk::Label m_label;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace waybar::modules::hyprland
|
|
@ -17,6 +17,8 @@
|
||||||
#include "AModule.hpp"
|
#include "AModule.hpp"
|
||||||
#include "bar.hpp"
|
#include "bar.hpp"
|
||||||
#include "modules/hyprland/backend.hpp"
|
#include "modules/hyprland/backend.hpp"
|
||||||
|
#include "modules/hyprland/windowcreationpayload.hpp"
|
||||||
|
#include "modules/hyprland/workspace.hpp"
|
||||||
#include "util/enum.hpp"
|
#include "util/enum.hpp"
|
||||||
#include "util/regex_collection.hpp"
|
#include "util/regex_collection.hpp"
|
||||||
|
|
||||||
|
@ -26,97 +28,6 @@ namespace waybar::modules::hyprland {
|
||||||
|
|
||||||
class Workspaces;
|
class Workspaces;
|
||||||
|
|
||||||
class WindowCreationPayload {
|
|
||||||
public:
|
|
||||||
WindowCreationPayload(std::string workspace_name, WindowAddress window_address,
|
|
||||||
std::string window_repr);
|
|
||||||
WindowCreationPayload(std::string workspace_name, WindowAddress window_address,
|
|
||||||
std::string window_class, std::string window_title);
|
|
||||||
WindowCreationPayload(Json::Value const& client_data);
|
|
||||||
|
|
||||||
int incrementTimeSpentUncreated();
|
|
||||||
bool isEmpty(Workspaces& workspace_manager);
|
|
||||||
bool reprIsReady() const { return std::holds_alternative<Repr>(m_window); }
|
|
||||||
std::string repr(Workspaces& workspace_manager);
|
|
||||||
|
|
||||||
std::string getWorkspaceName() const { return m_workspaceName; }
|
|
||||||
WindowAddress getAddress() const { return m_windowAddress; }
|
|
||||||
|
|
||||||
void moveToWorksace(std::string& new_workspace_name);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void clearAddr();
|
|
||||||
void clearWorkspaceName();
|
|
||||||
|
|
||||||
using Repr = std::string;
|
|
||||||
using ClassAndTitle = std::pair<std::string, std::string>;
|
|
||||||
std::variant<Repr, ClassAndTitle> m_window;
|
|
||||||
|
|
||||||
WindowAddress m_windowAddress;
|
|
||||||
std::string m_workspaceName;
|
|
||||||
|
|
||||||
int m_timeSpentUncreated = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Workspace {
|
|
||||||
public:
|
|
||||||
explicit Workspace(const Json::Value& workspace_data, Workspaces& workspace_manager,
|
|
||||||
const Json::Value& clients_data = Json::Value::nullRef);
|
|
||||||
std::string& selectIcon(std::map<std::string, std::string>& icons_map);
|
|
||||||
Gtk::Button& button() { return m_button; };
|
|
||||||
|
|
||||||
int id() const { return m_id; };
|
|
||||||
std::string name() const { return m_name; };
|
|
||||||
std::string output() const { return m_output; };
|
|
||||||
bool isActive() const { return m_isActive; };
|
|
||||||
bool isSpecial() const { return m_isSpecial; };
|
|
||||||
bool isPersistent() const { return m_isPersistentRule || m_isPersistentConfig; };
|
|
||||||
bool isPersistentConfig() const { return m_isPersistentConfig; };
|
|
||||||
bool isPersistentRule() const { return m_isPersistentRule; };
|
|
||||||
bool isVisible() const { return m_isVisible; };
|
|
||||||
bool isEmpty() const { return m_windows == 0; };
|
|
||||||
bool isUrgent() const { return m_isUrgent; };
|
|
||||||
|
|
||||||
bool handleClicked(GdkEventButton* bt) const;
|
|
||||||
void setActive(bool value = true) { m_isActive = value; };
|
|
||||||
void setPersistentRule(bool value = true) { m_isPersistentRule = value; };
|
|
||||||
void setPersistentConfig(bool value = true) { m_isPersistentConfig = value; };
|
|
||||||
void setUrgent(bool value = true) { m_isUrgent = value; };
|
|
||||||
void setVisible(bool value = true) { m_isVisible = value; };
|
|
||||||
void setWindows(uint value) { m_windows = value; };
|
|
||||||
void setName(std::string const& value) { m_name = value; };
|
|
||||||
void setOutput(std::string const& value) { m_output = value; };
|
|
||||||
bool containsWindow(WindowAddress const& addr) const { return m_windowMap.contains(addr); }
|
|
||||||
void insertWindow(WindowCreationPayload create_window_paylod);
|
|
||||||
std::string removeWindow(WindowAddress const& addr);
|
|
||||||
void initializeWindowMap(const Json::Value& clients_data);
|
|
||||||
|
|
||||||
bool onWindowOpened(WindowCreationPayload const& create_window_paylod);
|
|
||||||
std::optional<std::string> closeWindow(WindowAddress const& addr);
|
|
||||||
|
|
||||||
void update(const std::string& format, const std::string& icon);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Workspaces& m_workspaceManager;
|
|
||||||
|
|
||||||
int m_id;
|
|
||||||
std::string m_name;
|
|
||||||
std::string m_output;
|
|
||||||
uint m_windows;
|
|
||||||
bool m_isActive = false;
|
|
||||||
bool m_isSpecial = false;
|
|
||||||
bool m_isPersistentRule = false; // represents the persistent state in hyprland
|
|
||||||
bool m_isPersistentConfig = false; // represents the persistent state in the Waybar config
|
|
||||||
bool m_isUrgent = false;
|
|
||||||
bool m_isVisible = false;
|
|
||||||
|
|
||||||
std::map<WindowAddress, std::string> m_windowMap;
|
|
||||||
|
|
||||||
Gtk::Button m_button;
|
|
||||||
Gtk::Box m_content;
|
|
||||||
Gtk::Label m_label;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Workspaces : public AModule, public EventHandler {
|
class Workspaces : public AModule, public EventHandler {
|
||||||
public:
|
public:
|
||||||
Workspaces(const std::string&, const waybar::Bar&, const Json::Value&);
|
Workspaces(const std::string&, const waybar::Bar&, const Json::Value&);
|
||||||
|
|
Loading…
Reference in New Issue