Merge pull request #4997 from sewaustav/feat/niri-workspaces-taskbar
feat(niri): add workspace-taskbar support
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm/button.h>
|
||||
#include <gtkmm/image.h>
|
||||
#include <gtkmm/label.h>
|
||||
#include <json/value.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace waybar::modules::niri {
|
||||
|
||||
class Workspaces;
|
||||
|
||||
class Workspace {
|
||||
public:
|
||||
Workspace(const Json::Value& workspace_data, Workspaces& manager);
|
||||
~Workspace() = default;
|
||||
|
||||
Workspace(const Workspace&) = delete;
|
||||
Workspace& operator=(const Workspace&) = delete;
|
||||
|
||||
Gtk::Button& button() { return button_; }
|
||||
uint64_t id() const { return id_; }
|
||||
|
||||
void update(const Json::Value& workspace_data, const std::vector<Json::Value>& all_windows,
|
||||
const std::string& windows_str, std::size_t total);
|
||||
|
||||
private:
|
||||
void rebuildTaskbar(const std::vector<Json::Value>& my_windows);
|
||||
|
||||
Glib::RefPtr<Gdk::Pixbuf> loadIcon(const std::string& app_id, int size);
|
||||
|
||||
Workspaces& manager_;
|
||||
uint64_t id_;
|
||||
|
||||
// Layout: button_
|
||||
// └─ box_ (horizontal)
|
||||
// ├─ label_ workspace label / icon
|
||||
// └─ taskbar_box_ app icon buttons (shown only when taskbar enabled)
|
||||
Gtk::Button button_;
|
||||
Gtk::Box box_;
|
||||
Gtk::Label label_;
|
||||
Gtk::Box taskbar_box_;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::niri
|
||||
@@ -1,41 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtkmm/button.h>
|
||||
#include <gtkmm/box.h>
|
||||
#include <json/value.h>
|
||||
|
||||
#include <memory>
|
||||
#include <regex>
|
||||
#include <vector>
|
||||
|
||||
#include "AModule.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "modules/niri/backend.hpp"
|
||||
#include "util/regex_collection.hpp" // Added for rewrite rules
|
||||
#include "modules/niri/workspace.hpp"
|
||||
#include "util/regex_collection.hpp" // Added for rewrite rules
|
||||
|
||||
namespace waybar::modules::niri {
|
||||
|
||||
class Workspaces : public AModule, public EventHandler {
|
||||
public:
|
||||
Workspaces(const std::string&, const Bar&, const Json::Value&);
|
||||
Workspaces(const std::string& id, const Bar& bar, const Json::Value& config);
|
||||
~Workspaces() override;
|
||||
|
||||
void update() override;
|
||||
|
||||
const Json::Value& config() const { return config_; }
|
||||
const Bar& bar() const { return bar_; }
|
||||
|
||||
std::string getIcon(const std::string& value, const Json::Value& ws) const;
|
||||
|
||||
private:
|
||||
void onEvent(const Json::Value& ev) override;
|
||||
void doUpdate();
|
||||
void sortWorkspaces(std::vector<Json::Value>& workspaces) const;
|
||||
Gtk::Button& addButton(const Json::Value& ws);
|
||||
std::string getIcon(const std::string& value, const Json::Value& ws);
|
||||
void createWorkspace(const Json::Value& workspace_data);
|
||||
void sortWorkspaces(std::vector<const Json::Value*>& workspaces) const;
|
||||
bool isWorkspaceIgnored(const std::string& name);
|
||||
bool handleScroll(GdkEventScroll* /*unused*/) override;
|
||||
// Added for window rewrite
|
||||
void populateWindowRewriteConfig();
|
||||
void populateFormatWindowSeparatorConfig();
|
||||
std::string getRewrite(const std::string& app_id, const std::string& title);
|
||||
std::string getWindowsRepresentation(const Json::Value& ws);
|
||||
|
||||
const Bar& bar_;
|
||||
Gtk::Box box_;
|
||||
// Map from niri workspace id to button.
|
||||
std::unordered_map<uint64_t, Gtk::Button> buttons_;
|
||||
|
||||
std::vector<std::unique_ptr<Workspace>> workspaces_;
|
||||
|
||||
// Vec of regex rules to ignore workspaces.
|
||||
std::vector<std::regex> ignoreWorkspaces_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user