Merge remote-tracking branch 'origin/master' into pr-3311
# Conflicts: # src/modules/river/layout.cpp
This commit is contained in:
@@ -7,48 +7,48 @@
|
||||
|
||||
namespace waybar::modules::river {
|
||||
|
||||
static void listen_focused_tags(void *data, struct zriver_output_status_v1 *zriver_output_status_v1,
|
||||
static void listen_focused_tags(void* data, struct zriver_output_status_v1* zriver_output_status_v1,
|
||||
uint32_t tags) {
|
||||
// Intentionally empty
|
||||
}
|
||||
|
||||
static void listen_view_tags(void *data, struct zriver_output_status_v1 *zriver_output_status_v1,
|
||||
struct wl_array *tags) {
|
||||
static void listen_view_tags(void* data, struct zriver_output_status_v1* zriver_output_status_v1,
|
||||
struct wl_array* tags) {
|
||||
// Intentionally empty
|
||||
}
|
||||
|
||||
static void listen_urgent_tags(void *data, struct zriver_output_status_v1 *zriver_output_status_v1,
|
||||
static void listen_urgent_tags(void* data, struct zriver_output_status_v1* zriver_output_status_v1,
|
||||
uint32_t tags) {
|
||||
// Intentionally empty
|
||||
}
|
||||
|
||||
static void listen_layout_name(void *data, struct zriver_output_status_v1 *zriver_output_status_v1,
|
||||
const char *layout) {
|
||||
static_cast<Layout *>(data)->handle_name(layout);
|
||||
static void listen_layout_name(void* data, struct zriver_output_status_v1* zriver_output_status_v1,
|
||||
const char* layout) {
|
||||
static_cast<Layout*>(data)->handle_name(layout);
|
||||
}
|
||||
|
||||
static void listen_layout_name_clear(void *data,
|
||||
struct zriver_output_status_v1 *zriver_output_status_v1) {
|
||||
static_cast<Layout *>(data)->handle_clear();
|
||||
static void listen_layout_name_clear(void* data,
|
||||
struct zriver_output_status_v1* zriver_output_status_v1) {
|
||||
static_cast<Layout*>(data)->handle_clear();
|
||||
}
|
||||
|
||||
static void listen_focused_output(void *data, struct zriver_seat_status_v1 *zriver_seat_status_v1,
|
||||
struct wl_output *output) {
|
||||
static_cast<Layout *>(data)->handle_focused_output(output);
|
||||
static void listen_focused_output(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1,
|
||||
struct wl_output* output) {
|
||||
static_cast<Layout*>(data)->handle_focused_output(output);
|
||||
}
|
||||
|
||||
static void listen_unfocused_output(void *data, struct zriver_seat_status_v1 *zriver_seat_status_v1,
|
||||
struct wl_output *output) {
|
||||
static_cast<Layout *>(data)->handle_unfocused_output(output);
|
||||
static void listen_unfocused_output(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1,
|
||||
struct wl_output* output) {
|
||||
static_cast<Layout*>(data)->handle_unfocused_output(output);
|
||||
}
|
||||
|
||||
static void listen_focused_view(void *data, struct zriver_seat_status_v1 *zriver_seat_status_v1,
|
||||
const char *title) {
|
||||
static void listen_focused_view(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1,
|
||||
const char* title) {
|
||||
// Intentionally empty
|
||||
}
|
||||
|
||||
static void listen_mode(void *data, struct zriver_seat_status_v1 *zriver_seat_status_v1,
|
||||
const char *mode) {
|
||||
static void listen_mode(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1,
|
||||
const char* mode) {
|
||||
// Intentionally empty
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@ static const zriver_seat_status_v1_listener seat_status_listener_impl{
|
||||
.mode = listen_mode,
|
||||
};
|
||||
|
||||
static void handle_global(void *data, struct wl_registry *registry, uint32_t name,
|
||||
const char *interface, uint32_t version) {
|
||||
static void handle_global(void* data, struct wl_registry* registry, uint32_t name,
|
||||
const char* interface, uint32_t version) {
|
||||
if (std::strcmp(interface, zriver_status_manager_v1_interface.name) == 0) {
|
||||
version = std::min<uint32_t>(version, 4);
|
||||
|
||||
@@ -80,32 +80,32 @@ static void handle_global(void *data, struct wl_registry *registry, uint32_t nam
|
||||
std::to_string(version));
|
||||
return;
|
||||
}
|
||||
static_cast<Layout *>(data)->status_manager_ = static_cast<struct zriver_status_manager_v1 *>(
|
||||
static_cast<Layout*>(data)->status_manager_ = static_cast<struct zriver_status_manager_v1*>(
|
||||
wl_registry_bind(registry, name, &zriver_status_manager_v1_interface, version));
|
||||
}
|
||||
|
||||
if (std::strcmp(interface, wl_seat_interface.name) == 0) {
|
||||
version = std::min<uint32_t>(version, 1);
|
||||
static_cast<Layout *>(data)->seat_ = static_cast<struct wl_seat *>(
|
||||
wl_registry_bind(registry, name, &wl_seat_interface, version));
|
||||
static_cast<Layout*>(data)->seat_ =
|
||||
static_cast<struct wl_seat*>(wl_registry_bind(registry, name, &wl_seat_interface, version));
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) {
|
||||
static void handle_global_remove(void* data, struct wl_registry* registry, uint32_t name) {
|
||||
// Nobody cares
|
||||
}
|
||||
|
||||
static const wl_registry_listener registry_listener_impl = {.global = handle_global,
|
||||
.global_remove = handle_global_remove};
|
||||
|
||||
Layout::Layout(const std::string &id, const waybar::Bar &bar, const Json::Value &config)
|
||||
Layout::Layout(const std::string& id, const waybar::Bar& bar, const Json::Value& config)
|
||||
: waybar::ALabel(config, "layout", id, "{}"),
|
||||
status_manager_{nullptr},
|
||||
seat_{nullptr},
|
||||
bar_(bar),
|
||||
output_status_{nullptr} {
|
||||
struct wl_display *display = Client::inst()->wl_display;
|
||||
struct wl_registry *registry = wl_display_get_registry(display);
|
||||
struct wl_display* display = Client::inst()->wl_display;
|
||||
struct wl_registry* registry = wl_display_get_registry(display);
|
||||
wl_registry_add_listener(registry, ®istry_listener_impl, this);
|
||||
wl_display_roundtrip(display);
|
||||
|
||||
@@ -118,6 +118,7 @@ Layout::Layout(const std::string &id, const waybar::Bar &bar, const Json::Value
|
||||
|
||||
if (!seat_) {
|
||||
spdlog::error("wl_seat not advertised");
|
||||
return;
|
||||
}
|
||||
|
||||
label_.hide();
|
||||
@@ -141,14 +142,21 @@ Layout::~Layout() {
|
||||
}
|
||||
}
|
||||
|
||||
void Layout::handle_name(const char *name) {
|
||||
void Layout::handle_name(const char* name) {
|
||||
if (std::strcmp(name, "") == 0 || format_.empty()) {
|
||||
label_.hide(); // hide empty labels or labels with empty format
|
||||
} else {
|
||||
label_.show();
|
||||
label_.set_markup(fmt::format(fmt::runtime(format_), fmt::arg("layout", name),
|
||||
if (!name_.empty()) {
|
||||
label_.get_style_context()->remove_class(name_);
|
||||
}
|
||||
|
||||
label_.get_style_context()->add_class(name);
|
||||
label_.set_markup(fmt::format(fmt::runtime(format_),
|
||||
fmt::arg("layout", Glib::Markup::escape_text(name).raw()),
|
||||
fmt::arg("icon", getIcon(0, name))));
|
||||
label_.show();
|
||||
}
|
||||
name_ = name;
|
||||
ALabel::update();
|
||||
}
|
||||
|
||||
@@ -157,7 +165,7 @@ void Layout::handle_clear() {
|
||||
ALabel::update();
|
||||
}
|
||||
|
||||
void Layout::handle_focused_output(struct wl_output *output) {
|
||||
void Layout::handle_focused_output(struct wl_output* output) {
|
||||
if (output_ == output) { // if we focused the output this bar belongs to
|
||||
label_.get_style_context()->add_class("focused");
|
||||
ALabel::update();
|
||||
@@ -165,7 +173,7 @@ void Layout::handle_focused_output(struct wl_output *output) {
|
||||
focused_output_ = output;
|
||||
}
|
||||
|
||||
void Layout::handle_unfocused_output(struct wl_output *output) {
|
||||
void Layout::handle_unfocused_output(struct wl_output* output) {
|
||||
if (output_ == output) { // if we unfocused the output this bar belongs to
|
||||
label_.get_style_context()->remove_class("focused");
|
||||
ALabel::update();
|
||||
|
||||
+19
-18
@@ -7,23 +7,23 @@
|
||||
|
||||
namespace waybar::modules::river {
|
||||
|
||||
static void listen_focused_output(void *data, struct zriver_seat_status_v1 *seat_status,
|
||||
struct wl_output *output) {
|
||||
static void listen_focused_output(void* data, struct zriver_seat_status_v1* seat_status,
|
||||
struct wl_output* output) {
|
||||
// Intentionally empty
|
||||
}
|
||||
|
||||
static void listen_unfocused_output(void *data, struct zriver_seat_status_v1 *seat_status,
|
||||
struct wl_output *output) {
|
||||
static void listen_unfocused_output(void* data, struct zriver_seat_status_v1* seat_status,
|
||||
struct wl_output* output) {
|
||||
// Intentionally empty
|
||||
}
|
||||
|
||||
static void listen_focused_view(void *data, struct zriver_seat_status_v1 *seat_status,
|
||||
const char *title) {
|
||||
static void listen_focused_view(void* data, struct zriver_seat_status_v1* seat_status,
|
||||
const char* title) {
|
||||
// Intentionally empty
|
||||
}
|
||||
|
||||
static void listen_mode(void *data, struct zriver_seat_status_v1 *seat_status, const char *mode) {
|
||||
static_cast<Mode *>(data)->handle_mode(mode);
|
||||
static void listen_mode(void* data, struct zriver_seat_status_v1* seat_status, const char* mode) {
|
||||
static_cast<Mode*>(data)->handle_mode(mode);
|
||||
}
|
||||
|
||||
static const zriver_seat_status_v1_listener seat_status_listener_impl = {
|
||||
@@ -33,8 +33,8 @@ static const zriver_seat_status_v1_listener seat_status_listener_impl = {
|
||||
.mode = listen_mode,
|
||||
};
|
||||
|
||||
static void handle_global(void *data, struct wl_registry *registry, uint32_t name,
|
||||
const char *interface, uint32_t version) {
|
||||
static void handle_global(void* data, struct wl_registry* registry, uint32_t name,
|
||||
const char* interface, uint32_t version) {
|
||||
if (std::strcmp(interface, zriver_status_manager_v1_interface.name) == 0) {
|
||||
version = std::min<uint32_t>(version, 3);
|
||||
if (version < ZRIVER_SEAT_STATUS_V1_MODE_SINCE_VERSION) {
|
||||
@@ -42,31 +42,31 @@ static void handle_global(void *data, struct wl_registry *registry, uint32_t nam
|
||||
"river server does not support the \"mode\" event; the module will be disabled");
|
||||
return;
|
||||
}
|
||||
static_cast<Mode *>(data)->status_manager_ = static_cast<struct zriver_status_manager_v1 *>(
|
||||
static_cast<Mode*>(data)->status_manager_ = static_cast<struct zriver_status_manager_v1*>(
|
||||
wl_registry_bind(registry, name, &zriver_status_manager_v1_interface, version));
|
||||
} else if (std::strcmp(interface, wl_seat_interface.name) == 0) {
|
||||
version = std::min<uint32_t>(version, 1);
|
||||
static_cast<Mode *>(data)->seat_ = static_cast<struct wl_seat *>(
|
||||
wl_registry_bind(registry, name, &wl_seat_interface, version));
|
||||
static_cast<Mode*>(data)->seat_ =
|
||||
static_cast<struct wl_seat*>(wl_registry_bind(registry, name, &wl_seat_interface, version));
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) {
|
||||
static void handle_global_remove(void* data, struct wl_registry* registry, uint32_t name) {
|
||||
// Nobody cares
|
||||
}
|
||||
|
||||
static const wl_registry_listener registry_listener_impl = {.global = handle_global,
|
||||
.global_remove = handle_global_remove};
|
||||
|
||||
Mode::Mode(const std::string &id, const waybar::Bar &bar, const Json::Value &config)
|
||||
Mode::Mode(const std::string& id, const waybar::Bar& bar, const Json::Value& config)
|
||||
: waybar::ALabel(config, "mode", id, "{}"),
|
||||
status_manager_{nullptr},
|
||||
seat_{nullptr},
|
||||
bar_(bar),
|
||||
mode_{""},
|
||||
seat_status_{nullptr} {
|
||||
struct wl_display *display = Client::inst()->wl_display;
|
||||
struct wl_registry *registry = wl_display_get_registry(display);
|
||||
struct wl_display* display = Client::inst()->wl_display;
|
||||
struct wl_registry* registry = wl_display_get_registry(display);
|
||||
wl_registry_add_listener(registry, ®istry_listener_impl, this);
|
||||
wl_display_roundtrip(display);
|
||||
|
||||
@@ -77,6 +77,7 @@ Mode::Mode(const std::string &id, const waybar::Bar &bar, const Json::Value &con
|
||||
|
||||
if (!seat_) {
|
||||
spdlog::error("wl_seat not advertised");
|
||||
return;
|
||||
}
|
||||
|
||||
label_.hide();
|
||||
@@ -94,7 +95,7 @@ Mode::~Mode() {
|
||||
}
|
||||
}
|
||||
|
||||
void Mode::handle_mode(const char *mode) {
|
||||
void Mode::handle_mode(const char* mode) {
|
||||
if (format_.empty()) {
|
||||
label_.hide();
|
||||
} else {
|
||||
|
||||
+104
-35
@@ -12,19 +12,19 @@
|
||||
|
||||
namespace waybar::modules::river {
|
||||
|
||||
static void listen_focused_tags(void *data, struct zriver_output_status_v1 *zriver_output_status_v1,
|
||||
static void listen_focused_tags(void* data, struct zriver_output_status_v1* zriver_output_status_v1,
|
||||
uint32_t tags) {
|
||||
static_cast<Tags *>(data)->handle_focused_tags(tags);
|
||||
static_cast<Tags*>(data)->handle_focused_tags(tags);
|
||||
}
|
||||
|
||||
static void listen_view_tags(void *data, struct zriver_output_status_v1 *zriver_output_status_v1,
|
||||
struct wl_array *tags) {
|
||||
static_cast<Tags *>(data)->handle_view_tags(tags);
|
||||
static void listen_view_tags(void* data, struct zriver_output_status_v1* zriver_output_status_v1,
|
||||
struct wl_array* tags) {
|
||||
static_cast<Tags*>(data)->handle_view_tags(tags);
|
||||
}
|
||||
|
||||
static void listen_urgent_tags(void *data, struct zriver_output_status_v1 *zriver_output_status_v1,
|
||||
static void listen_urgent_tags(void* data, struct zriver_output_status_v1* zriver_output_status_v1,
|
||||
uint32_t tags) {
|
||||
static_cast<Tags *>(data)->handle_urgent_tags(tags);
|
||||
static_cast<Tags*>(data)->handle_urgent_tags(tags);
|
||||
}
|
||||
|
||||
static const zriver_output_status_v1_listener output_status_listener_impl{
|
||||
@@ -33,15 +33,42 @@ static const zriver_output_status_v1_listener output_status_listener_impl{
|
||||
.urgent_tags = listen_urgent_tags,
|
||||
};
|
||||
|
||||
static void listen_command_success(void *data,
|
||||
struct zriver_command_callback_v1 *zriver_command_callback_v1,
|
||||
const char *output) {
|
||||
static void listen_focused_output(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1,
|
||||
struct wl_output* output) {
|
||||
static_cast<Tags*>(data)->handle_focused_output(output);
|
||||
}
|
||||
|
||||
static void listen_unfocused_output(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1,
|
||||
struct wl_output* output) {
|
||||
static_cast<Tags*>(data)->handle_unfocused_output(output);
|
||||
}
|
||||
|
||||
static void listen_focused_view(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1,
|
||||
const char* title) {
|
||||
// This module doesn't care
|
||||
}
|
||||
|
||||
static void listen_mode(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1,
|
||||
const char* mode) {
|
||||
// This module doesn't care
|
||||
}
|
||||
|
||||
static const zriver_seat_status_v1_listener seat_status_listener_impl{
|
||||
.focused_output = listen_focused_output,
|
||||
.unfocused_output = listen_unfocused_output,
|
||||
.focused_view = listen_focused_view,
|
||||
.mode = listen_mode,
|
||||
};
|
||||
|
||||
static void listen_command_success(void* data,
|
||||
struct zriver_command_callback_v1* zriver_command_callback_v1,
|
||||
const char* output) {
|
||||
// Do nothing but keep listener to avoid crashing when command was successful
|
||||
}
|
||||
|
||||
static void listen_command_failure(void *data,
|
||||
struct zriver_command_callback_v1 *zriver_command_callback_v1,
|
||||
const char *output) {
|
||||
static void listen_command_failure(void* data,
|
||||
struct zriver_command_callback_v1* zriver_command_callback_v1,
|
||||
const char* output) {
|
||||
spdlog::error("failure when selecting/toggling tags {}", output);
|
||||
}
|
||||
|
||||
@@ -50,47 +77,49 @@ static const zriver_command_callback_v1_listener command_callback_listener_impl{
|
||||
.failure = listen_command_failure,
|
||||
};
|
||||
|
||||
static void handle_global(void *data, struct wl_registry *registry, uint32_t name,
|
||||
const char *interface, uint32_t version) {
|
||||
static void handle_global(void* data, struct wl_registry* registry, uint32_t name,
|
||||
const char* interface, uint32_t version) {
|
||||
if (std::strcmp(interface, zriver_status_manager_v1_interface.name) == 0) {
|
||||
version = std::min(version, 2u);
|
||||
if (version < ZRIVER_OUTPUT_STATUS_V1_URGENT_TAGS_SINCE_VERSION) {
|
||||
spdlog::warn("river server does not support urgent tags");
|
||||
}
|
||||
static_cast<Tags *>(data)->status_manager_ = static_cast<struct zriver_status_manager_v1 *>(
|
||||
static_cast<Tags*>(data)->status_manager_ = static_cast<struct zriver_status_manager_v1*>(
|
||||
wl_registry_bind(registry, name, &zriver_status_manager_v1_interface, version));
|
||||
}
|
||||
|
||||
if (std::strcmp(interface, zriver_control_v1_interface.name) == 0) {
|
||||
version = std::min(version, 1u);
|
||||
static_cast<Tags *>(data)->control_ = static_cast<struct zriver_control_v1 *>(
|
||||
static_cast<Tags*>(data)->control_ = static_cast<struct zriver_control_v1*>(
|
||||
wl_registry_bind(registry, name, &zriver_control_v1_interface, version));
|
||||
}
|
||||
|
||||
if (std::strcmp(interface, wl_seat_interface.name) == 0) {
|
||||
version = std::min(version, 1u);
|
||||
static_cast<Tags *>(data)->seat_ = static_cast<struct wl_seat *>(
|
||||
wl_registry_bind(registry, name, &wl_seat_interface, version));
|
||||
static_cast<Tags*>(data)->seat_ =
|
||||
static_cast<struct wl_seat*>(wl_registry_bind(registry, name, &wl_seat_interface, version));
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) {
|
||||
static void handle_global_remove(void* data, struct wl_registry* registry, uint32_t name) {
|
||||
/* Ignore event */
|
||||
}
|
||||
|
||||
static const wl_registry_listener registry_listener_impl = {.global = handle_global,
|
||||
.global_remove = handle_global_remove};
|
||||
|
||||
Tags::Tags(const std::string &id, const waybar::Bar &bar, const Json::Value &config)
|
||||
Tags::Tags(const std::string& id, const waybar::Bar& bar, const Json::Value& config)
|
||||
: waybar::AModule(config, "tags", id, false, false),
|
||||
status_manager_{nullptr},
|
||||
control_{nullptr},
|
||||
seat_{nullptr},
|
||||
bar_(bar),
|
||||
output_{nullptr},
|
||||
box_{bar.orientation, 0},
|
||||
output_status_{nullptr} {
|
||||
struct wl_display *display = Client::inst()->wl_display;
|
||||
struct wl_registry *registry = wl_display_get_registry(display);
|
||||
output_status_{nullptr},
|
||||
seat_status_{nullptr} {
|
||||
struct wl_display* display = Client::inst()->wl_display;
|
||||
struct wl_registry* registry = wl_display_get_registry(display);
|
||||
wl_registry_add_listener(registry, ®istry_listener_impl, this);
|
||||
wl_display_roundtrip(display);
|
||||
|
||||
@@ -101,12 +130,19 @@ Tags::Tags(const std::string &id, const waybar::Bar &bar, const Json::Value &con
|
||||
|
||||
if (!control_) {
|
||||
spdlog::error("river_control_v1 not advertised");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!seat_) {
|
||||
spdlog::error("wl_seat not advertised");
|
||||
return;
|
||||
}
|
||||
|
||||
// Store the output this module belongs to; the river_output_status and
|
||||
// river_seat_status objects (and their listeners) are created lazily in
|
||||
// handle_show() to avoid leaking objects without listeners here.
|
||||
output_ = gdk_wayland_monitor_get_wl_output(bar_.output->monitor->gobj());
|
||||
|
||||
box_.set_name("tags");
|
||||
if (!id.empty()) {
|
||||
box_.get_style_context()->add_class(id);
|
||||
@@ -129,7 +165,7 @@ Tags::Tags(const std::string &id, const waybar::Bar &bar, const Json::Value &con
|
||||
buttons_.emplace_back(std::to_string(tag + 1));
|
||||
}
|
||||
|
||||
auto &button = buttons_[tag];
|
||||
auto& button = buttons_[tag];
|
||||
button.set_relief(Gtk::RELIEF_NONE);
|
||||
box_.pack_start(button, false, false, 0);
|
||||
|
||||
@@ -147,14 +183,11 @@ Tags::Tags(const std::string &id, const waybar::Bar &bar, const Json::Value &con
|
||||
button.signal_button_press_event().connect(
|
||||
sigc::bind(sigc::mem_fun(*this, &Tags::handle_button_press), (1 << tag)));
|
||||
}
|
||||
button.get_style_context()->add_class("tag-" + std::to_string(tag + 1));
|
||||
button.show();
|
||||
}
|
||||
|
||||
struct wl_output *output = gdk_wayland_monitor_get_wl_output(bar_.output->monitor->gobj());
|
||||
output_status_ = zriver_status_manager_v1_get_river_output_status(status_manager_, output);
|
||||
zriver_output_status_v1_add_listener(output_status_, &output_status_listener_impl, this);
|
||||
|
||||
zriver_status_manager_v1_destroy(status_manager_);
|
||||
box_.signal_show().connect(sigc::mem_fun(*this, &Tags::handle_show));
|
||||
}
|
||||
|
||||
Tags::~Tags() {
|
||||
@@ -162,24 +195,44 @@ Tags::~Tags() {
|
||||
zriver_output_status_v1_destroy(output_status_);
|
||||
}
|
||||
|
||||
if (seat_status_) {
|
||||
zriver_seat_status_v1_destroy(seat_status_);
|
||||
}
|
||||
|
||||
if (control_) {
|
||||
zriver_control_v1_destroy(control_);
|
||||
}
|
||||
|
||||
if (status_manager_) {
|
||||
zriver_status_manager_v1_destroy(status_manager_);
|
||||
}
|
||||
}
|
||||
|
||||
void Tags::handle_show() {
|
||||
if (!status_manager_) return;
|
||||
output_status_ = zriver_status_manager_v1_get_river_output_status(status_manager_, output_);
|
||||
zriver_output_status_v1_add_listener(output_status_, &output_status_listener_impl, this);
|
||||
|
||||
seat_status_ = zriver_status_manager_v1_get_river_seat_status(status_manager_, seat_);
|
||||
zriver_seat_status_v1_add_listener(seat_status_, &seat_status_listener_impl, this);
|
||||
|
||||
zriver_status_manager_v1_destroy(status_manager_);
|
||||
status_manager_ = nullptr;
|
||||
}
|
||||
|
||||
void Tags::handle_primary_clicked(uint32_t tag) {
|
||||
// Send river command to select tag on left mouse click
|
||||
zriver_command_callback_v1 *callback;
|
||||
zriver_command_callback_v1* callback;
|
||||
zriver_control_v1_add_argument(control_, "set-focused-tags");
|
||||
zriver_control_v1_add_argument(control_, std::to_string(tag).c_str());
|
||||
callback = zriver_control_v1_run_command(control_, seat_);
|
||||
zriver_command_callback_v1_add_listener(callback, &command_callback_listener_impl, nullptr);
|
||||
}
|
||||
|
||||
bool Tags::handle_button_press(GdkEventButton *event_button, uint32_t tag) {
|
||||
bool Tags::handle_button_press(GdkEventButton* event_button, uint32_t tag) {
|
||||
if (event_button->type == GDK_BUTTON_PRESS && event_button->button == 3) {
|
||||
// Send river command to toggle tag on right mouse click
|
||||
zriver_command_callback_v1 *callback;
|
||||
zriver_command_callback_v1* callback;
|
||||
zriver_control_v1_add_argument(control_, "toggle-focused-tags");
|
||||
zriver_control_v1_add_argument(control_, std::to_string(tag).c_str());
|
||||
callback = zriver_control_v1_run_command(control_, seat_);
|
||||
@@ -208,9 +261,9 @@ void Tags::handle_focused_tags(uint32_t tags) {
|
||||
}
|
||||
}
|
||||
|
||||
void Tags::handle_view_tags(struct wl_array *view_tags) {
|
||||
void Tags::handle_view_tags(struct wl_array* view_tags) {
|
||||
uint32_t tags = 0;
|
||||
auto view_tag = reinterpret_cast<uint32_t *>(view_tags->data);
|
||||
auto view_tag = reinterpret_cast<uint32_t*>(view_tags->data);
|
||||
auto end = view_tag + (view_tags->size / sizeof(uint32_t));
|
||||
for (; view_tag < end; ++view_tag) {
|
||||
tags |= *view_tag;
|
||||
@@ -254,4 +307,20 @@ void Tags::handle_urgent_tags(uint32_t tags) {
|
||||
}
|
||||
}
|
||||
|
||||
void Tags::handle_focused_output(struct wl_output* output) {
|
||||
if (output_ == output) {
|
||||
for (size_t i = 0; i < buttons_.size(); ++i) {
|
||||
buttons_[i].get_style_context()->add_class("output");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Tags::handle_unfocused_output(struct wl_output* output) {
|
||||
if (output_ == output) {
|
||||
for (size_t i = 0; i < buttons_.size(); ++i) {
|
||||
buttons_[i].get_style_context()->remove_class("output");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace waybar::modules::river */
|
||||
|
||||
@@ -9,23 +9,23 @@
|
||||
|
||||
namespace waybar::modules::river {
|
||||
|
||||
static void listen_focused_view(void *data, struct zriver_seat_status_v1 *zriver_seat_status_v1,
|
||||
const char *title) {
|
||||
static_cast<Window *>(data)->handle_focused_view(title);
|
||||
static void listen_focused_view(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1,
|
||||
const char* title) {
|
||||
static_cast<Window*>(data)->handle_focused_view(title);
|
||||
}
|
||||
|
||||
static void listen_focused_output(void *data, struct zriver_seat_status_v1 *zriver_seat_status_v1,
|
||||
struct wl_output *output) {
|
||||
static_cast<Window *>(data)->handle_focused_output(output);
|
||||
static void listen_focused_output(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1,
|
||||
struct wl_output* output) {
|
||||
static_cast<Window*>(data)->handle_focused_output(output);
|
||||
}
|
||||
|
||||
static void listen_unfocused_output(void *data, struct zriver_seat_status_v1 *zriver_seat_status_v1,
|
||||
struct wl_output *output) {
|
||||
static_cast<Window *>(data)->handle_unfocused_output(output);
|
||||
static void listen_unfocused_output(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1,
|
||||
struct wl_output* output) {
|
||||
static_cast<Window*>(data)->handle_unfocused_output(output);
|
||||
}
|
||||
|
||||
static void listen_mode(void *data, struct zriver_seat_status_v1 *zriver_seat_status_v1,
|
||||
const char *mode) {
|
||||
static void listen_mode(void* data, struct zriver_seat_status_v1* zriver_seat_status_v1,
|
||||
const char* mode) {
|
||||
// This module doesn't care
|
||||
}
|
||||
|
||||
@@ -36,36 +36,36 @@ static const zriver_seat_status_v1_listener seat_status_listener_impl{
|
||||
.mode = listen_mode,
|
||||
};
|
||||
|
||||
static void handle_global(void *data, struct wl_registry *registry, uint32_t name,
|
||||
const char *interface, uint32_t version) {
|
||||
static void handle_global(void* data, struct wl_registry* registry, uint32_t name,
|
||||
const char* interface, uint32_t version) {
|
||||
if (std::strcmp(interface, zriver_status_manager_v1_interface.name) == 0) {
|
||||
version = std::min<uint32_t>(version, 2);
|
||||
static_cast<Window *>(data)->status_manager_ = static_cast<struct zriver_status_manager_v1 *>(
|
||||
static_cast<Window*>(data)->status_manager_ = static_cast<struct zriver_status_manager_v1*>(
|
||||
wl_registry_bind(registry, name, &zriver_status_manager_v1_interface, version));
|
||||
}
|
||||
|
||||
if (std::strcmp(interface, wl_seat_interface.name) == 0) {
|
||||
version = std::min<uint32_t>(version, 1);
|
||||
static_cast<Window *>(data)->seat_ = static_cast<struct wl_seat *>(
|
||||
wl_registry_bind(registry, name, &wl_seat_interface, version));
|
||||
static_cast<Window*>(data)->seat_ =
|
||||
static_cast<struct wl_seat*>(wl_registry_bind(registry, name, &wl_seat_interface, version));
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) {
|
||||
static void handle_global_remove(void* data, struct wl_registry* registry, uint32_t name) {
|
||||
/* Ignore event */
|
||||
}
|
||||
|
||||
static const wl_registry_listener registry_listener_impl = {.global = handle_global,
|
||||
.global_remove = handle_global_remove};
|
||||
|
||||
Window::Window(const std::string &id, const waybar::Bar &bar, const Json::Value &config)
|
||||
Window::Window(const std::string& id, const waybar::Bar& bar, const Json::Value& config)
|
||||
: waybar::ALabel(config, "window", id, "{}", 30),
|
||||
status_manager_{nullptr},
|
||||
seat_{nullptr},
|
||||
bar_(bar),
|
||||
seat_status_{nullptr} {
|
||||
struct wl_display *display = Client::inst()->wl_display;
|
||||
struct wl_registry *registry = wl_display_get_registry(display);
|
||||
struct wl_display* display = Client::inst()->wl_display;
|
||||
struct wl_registry* registry = wl_display_get_registry(display);
|
||||
wl_registry_add_listener(registry, ®istry_listener_impl, this);
|
||||
wl_display_roundtrip(display);
|
||||
|
||||
@@ -78,6 +78,7 @@ Window::Window(const std::string &id, const waybar::Bar &bar, const Json::Value
|
||||
|
||||
if (!seat_) {
|
||||
spdlog::error("wl_seat not advertised");
|
||||
return;
|
||||
}
|
||||
|
||||
label_.hide(); // hide the label until populated
|
||||
@@ -95,7 +96,7 @@ Window::~Window() {
|
||||
}
|
||||
}
|
||||
|
||||
void Window::handle_focused_view(const char *title) {
|
||||
void Window::handle_focused_view(const char* title) {
|
||||
// don't change the label on unfocused outputs.
|
||||
// this makes the current output report its currently focused view, and unfocused outputs will
|
||||
// report their last focused views. when freshly starting the bar, unfocused outputs don't have a
|
||||
@@ -116,7 +117,7 @@ void Window::handle_focused_view(const char *title) {
|
||||
ALabel::update();
|
||||
}
|
||||
|
||||
void Window::handle_focused_output(struct wl_output *output) {
|
||||
void Window::handle_focused_output(struct wl_output* output) {
|
||||
if (output_ == output) { // if we focused the output this bar belongs to
|
||||
label_.get_style_context()->add_class("focused");
|
||||
ALabel::update();
|
||||
@@ -124,7 +125,7 @@ void Window::handle_focused_output(struct wl_output *output) {
|
||||
focused_output_ = output;
|
||||
}
|
||||
|
||||
void Window::handle_unfocused_output(struct wl_output *output) {
|
||||
void Window::handle_unfocused_output(struct wl_output* output) {
|
||||
if (output_ == output) { // if we unfocused the output this bar belongs to
|
||||
label_.get_style_context()->remove_class("focused");
|
||||
ALabel::update();
|
||||
|
||||
Reference in New Issue
Block a user