Merge branch 'Alexays:master' into hyprland/windowcount
This commit is contained in:
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2018 Alex
|
Copyright (c) 2025 Alex
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
12
flake.lock
generated
12
flake.lock
generated
@ -3,11 +3,11 @@
|
|||||||
"flake-compat": {
|
"flake-compat": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1732722421,
|
"lastModified": 1733328505,
|
||||||
"narHash": "sha256-HRJ/18p+WoXpWJkcdsk9St5ZiukCqSDgbOGFa8Okehg=",
|
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
|
||||||
"owner": "edolstra",
|
"owner": "edolstra",
|
||||||
"repo": "flake-compat",
|
"repo": "flake-compat",
|
||||||
"rev": "9ed2ac151eada2306ca8c418ebd97807bb08f6ac",
|
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -18,11 +18,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1732837521,
|
"lastModified": 1735471104,
|
||||||
"narHash": "sha256-jNRNr49UiuIwaarqijgdTR2qLPifxsVhlJrKzQ8XUIE=",
|
"narHash": "sha256-0q9NGQySwDQc7RhAV2ukfnu7Gxa5/ybJ2ANT8DQrQrs=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "970e93b9f82e2a0f3675757eb0bfc73297cc6370",
|
"rev": "88195a94f390381c6afcdaa933c2f6ff93959cb4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -49,7 +49,6 @@ class Workspaces : public AModule, public sigc::trackable {
|
|||||||
std::vector<std::string> workspaces_order_;
|
std::vector<std::string> workspaces_order_;
|
||||||
Gtk::Box box_;
|
Gtk::Box box_;
|
||||||
std::string m_formatWindowSeperator;
|
std::string m_formatWindowSeperator;
|
||||||
std::string m_windowRewriteDefault;
|
|
||||||
util::RegexCollection m_windowRewriteRules;
|
util::RegexCollection m_windowRewriteRules;
|
||||||
util::JsonParser parser_;
|
util::JsonParser parser_;
|
||||||
std::unordered_map<std::string, Gtk::Button> buttons_;
|
std::unordered_map<std::string, Gtk::Button> buttons_;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "client.hpp"
|
#include "client.hpp"
|
||||||
#include "dwl-ipc-unstable-v2-client-protocol.h"
|
#include "dwl-ipc-unstable-v2-client-protocol.h"
|
||||||
|
#include "glibmm/markup.h"
|
||||||
#include "util/rewrite_string.hpp"
|
#include "util/rewrite_string.hpp"
|
||||||
|
|
||||||
namespace waybar::modules::dwl {
|
namespace waybar::modules::dwl {
|
||||||
@ -97,11 +98,17 @@ Window::~Window() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::handle_title(const char *title) { title_ = title; }
|
void Window::handle_title(const char *title) {
|
||||||
|
title_ = Glib::Markup::escape_text(title);
|
||||||
|
}
|
||||||
|
|
||||||
void Window::handle_appid(const char *appid) { appid_ = appid; }
|
void Window::handle_appid(const char *appid) {
|
||||||
|
appid_ = Glib::Markup::escape_text(appid);
|
||||||
|
}
|
||||||
|
|
||||||
void Window::handle_layout_symbol(const char *layout_symbol) { layout_symbol_ = layout_symbol; }
|
void Window::handle_layout_symbol(const char *layout_symbol) {
|
||||||
|
layout_symbol_ = Glib::Markup::escape_text(layout_symbol);
|
||||||
|
}
|
||||||
|
|
||||||
void Window::handle_layout(const uint32_t layout) { layout_ = layout; }
|
void Window::handle_layout(const uint32_t layout) { layout_ = layout; }
|
||||||
|
|
||||||
|
@ -12,10 +12,18 @@
|
|||||||
#include "util/rewrite_string.hpp"
|
#include "util/rewrite_string.hpp"
|
||||||
#include "util/sanitize_str.hpp"
|
#include "util/sanitize_str.hpp"
|
||||||
|
|
||||||
|
#include <shared_mutex>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
namespace waybar::modules::hyprland {
|
namespace waybar::modules::hyprland {
|
||||||
|
|
||||||
|
std::shared_mutex windowIpcSmtx;
|
||||||
|
|
||||||
Window::Window(const std::string& id, const Bar& bar, const Json::Value& config)
|
Window::Window(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||||
: AAppIconLabel(config, "window", id, "{title}", 0, true), bar_(bar) {
|
: AAppIconLabel(config, "window", id, "{title}", 0, true), bar_(bar) {
|
||||||
|
|
||||||
|
std::unique_lock<std::shared_mutex> windowIpcUniqueLock(windowIpcSmtx);
|
||||||
|
|
||||||
modulesReady = true;
|
modulesReady = true;
|
||||||
separateOutputs_ = config["separate-outputs"].asBool();
|
separateOutputs_ = config["separate-outputs"].asBool();
|
||||||
|
|
||||||
@ -23,27 +31,28 @@ Window::Window(const std::string& id, const Bar& bar, const Json::Value& config)
|
|||||||
gIPC = std::make_unique<IPC>();
|
gIPC = std::make_unique<IPC>();
|
||||||
}
|
}
|
||||||
|
|
||||||
queryActiveWorkspace();
|
|
||||||
update();
|
|
||||||
dp.emit();
|
|
||||||
|
|
||||||
// register for hyprland ipc
|
// register for hyprland ipc
|
||||||
gIPC->registerForIPC("activewindow", this);
|
gIPC->registerForIPC("activewindow", this);
|
||||||
gIPC->registerForIPC("closewindow", this);
|
gIPC->registerForIPC("closewindow", this);
|
||||||
gIPC->registerForIPC("movewindow", this);
|
gIPC->registerForIPC("movewindow", this);
|
||||||
gIPC->registerForIPC("changefloatingmode", this);
|
gIPC->registerForIPC("changefloatingmode", this);
|
||||||
gIPC->registerForIPC("fullscreen", this);
|
gIPC->registerForIPC("fullscreen", this);
|
||||||
|
|
||||||
|
windowIpcUniqueLock.unlock();
|
||||||
|
|
||||||
|
queryActiveWorkspace();
|
||||||
|
update();
|
||||||
|
dp.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::~Window() {
|
Window::~Window() {
|
||||||
|
std::unique_lock<std::shared_mutex> windowIpcUniqueLock(windowIpcSmtx);
|
||||||
gIPC->unregisterForIPC(this);
|
gIPC->unregisterForIPC(this);
|
||||||
// wait for possible event handler to finish
|
|
||||||
std::lock_guard<std::mutex> lg(mutex_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Window::update() -> void {
|
auto Window::update() -> void {
|
||||||
// fix ampersands
|
|
||||||
std::lock_guard<std::mutex> lg(mutex_);
|
std::shared_lock<std::shared_mutex> windowIpcShareLock(windowIpcSmtx);
|
||||||
|
|
||||||
std::string windowName = waybar::util::sanitize_string(workspace_.last_window_title);
|
std::string windowName = waybar::util::sanitize_string(workspace_.last_window_title);
|
||||||
std::string windowAddress = workspace_.last_window;
|
std::string windowAddress = workspace_.last_window;
|
||||||
@ -144,7 +153,8 @@ auto Window::WindowData::parse(const Json::Value& value) -> Window::WindowData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Window::queryActiveWorkspace() {
|
void Window::queryActiveWorkspace() {
|
||||||
std::lock_guard<std::mutex> lg(mutex_);
|
|
||||||
|
std::shared_lock<std::shared_mutex> windowIpcShareLock(windowIpcSmtx);
|
||||||
|
|
||||||
if (separateOutputs_) {
|
if (separateOutputs_) {
|
||||||
workspace_ = getActiveWorkspace(this->bar_.output->name);
|
workspace_ = getActiveWorkspace(this->bar_.output->name);
|
||||||
|
@ -62,14 +62,13 @@ Workspaces::Workspaces(const std::string &id, const Bar &bar, const Json::Value
|
|||||||
m_formatWindowSeperator = " ";
|
m_formatWindowSeperator = " ";
|
||||||
}
|
}
|
||||||
const Json::Value &windowRewrite = config["window-rewrite"];
|
const Json::Value &windowRewrite = config["window-rewrite"];
|
||||||
|
if (windowRewrite.isObject()) {
|
||||||
const Json::Value &windowRewriteDefaultConfig = config["window-rewrite-default"];
|
const Json::Value &windowRewriteDefaultConfig = config["window-rewrite-default"];
|
||||||
m_windowRewriteDefault =
|
std::string windowRewriteDefault =
|
||||||
windowRewriteDefaultConfig.isString() ? windowRewriteDefaultConfig.asString() : "?";
|
windowRewriteDefaultConfig.isString() ? windowRewriteDefaultConfig.asString() : "?";
|
||||||
|
|
||||||
m_windowRewriteRules = waybar::util::RegexCollection(
|
m_windowRewriteRules = waybar::util::RegexCollection(
|
||||||
windowRewrite, m_windowRewriteDefault,
|
windowRewrite, std::move(windowRewriteDefault), windowRewritePriorityFunction);
|
||||||
[](std::string &window_rule) { return windowRewritePriorityFunction(window_rule); });
|
}
|
||||||
ipc_.subscribe(R"(["workspace"])");
|
ipc_.subscribe(R"(["workspace"])");
|
||||||
ipc_.subscribe(R"(["window"])");
|
ipc_.subscribe(R"(["window"])");
|
||||||
ipc_.signal_event.connect(sigc::mem_fun(*this, &Workspaces::onEvent));
|
ipc_.signal_event.connect(sigc::mem_fun(*this, &Workspaces::onEvent));
|
||||||
|
Reference in New Issue
Block a user