Fix inconsistancies with the systray toggle
Some checks failed
clang-format / lint (push) Has been cancelled
freebsd / build (push) Has been cancelled
linux / build (c++20, alpine) (push) Has been cancelled
linux / build (c++20, archlinux) (push) Has been cancelled
linux / build (c++20, debian) (push) Has been cancelled
linux / build (c++20, fedora) (push) Has been cancelled
linux / build (c++20, gentoo) (push) Has been cancelled
linux / build (c++20, opensuse) (push) Has been cancelled
Nix-Tests / nix-flake-check (push) Has been cancelled

This commit is contained in:
2026-02-09 02:45:58 -08:00
parent 8e5f7fec42
commit 0abbf221a2
6 changed files with 98 additions and 61 deletions

View File

@ -5,6 +5,8 @@
#include <gdk/gdkwayland.h>
#include <wayland-client.h>
#include <map>
#include "bar.hpp"
#include "config.hpp"
#include "util/css_reload_helper.hpp"
@ -17,35 +19,38 @@ namespace waybar {
class Client {
public:
static Client *inst();
int main(int argc, char *argv[]);
static Client* inst();
int main(int argc, char* argv[]);
void reset();
bool get_signal_state(int signum) const;
void toggle_signal_state(int signum);
Glib::RefPtr<Gtk::Application> gtk_app;
Glib::RefPtr<Gdk::Display> gdk_display;
struct wl_display *wl_display = nullptr;
struct wl_registry *registry = nullptr;
struct zxdg_output_manager_v1 *xdg_output_manager = nullptr;
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager = nullptr;
struct wl_display* wl_display = nullptr;
struct wl_registry* registry = nullptr;
struct zxdg_output_manager_v1* xdg_output_manager = nullptr;
struct zwp_idle_inhibit_manager_v1* idle_inhibit_manager = nullptr;
std::vector<std::unique_ptr<Bar>> bars;
Config config;
std::string bar_id;
private:
Client() = default;
const std::string getStyle(const std::string &style, std::optional<Appearance> appearance);
const std::string getStyle(const std::string& style, std::optional<Appearance> appearance);
void bindInterfaces();
void handleOutput(struct waybar_output &output);
auto setupCss(const std::string &css_file) -> void;
struct waybar_output &getOutput(void *);
std::vector<Json::Value> getOutputConfigs(struct waybar_output &output);
void handleOutput(struct waybar_output& output);
auto setupCss(const std::string& css_file) -> void;
struct waybar_output& getOutput(void*);
std::vector<Json::Value> getOutputConfigs(struct waybar_output& output);
static void handleGlobal(void *data, struct wl_registry *registry, uint32_t name,
const char *interface, uint32_t version);
static void handleGlobalRemove(void *data, struct wl_registry *registry, uint32_t name);
static void handleOutputDone(void *, struct zxdg_output_v1 *);
static void handleOutputName(void *, struct zxdg_output_v1 *, const char *);
static void handleOutputDescription(void *, struct zxdg_output_v1 *, const char *);
static void handleGlobal(void* data, struct wl_registry* registry, uint32_t name,
const char* interface, uint32_t version);
static void handleGlobalRemove(void* data, struct wl_registry* registry, uint32_t name);
static void handleOutputDone(void*, struct zxdg_output_v1*);
static void handleOutputName(void*, struct zxdg_output_v1*, const char*);
static void handleOutputDescription(void*, struct zxdg_output_v1*, const char*);
void handleMonitorAdded(Glib::RefPtr<Gdk::Monitor> monitor);
void handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor> monitor);
void handleDeferredMonitorRemoval(Glib::RefPtr<Gdk::Monitor> monitor);
@ -56,6 +61,8 @@ class Client {
std::list<struct waybar_output> outputs_;
std::unique_ptr<CssReloadHelper> m_cssReloadHelper;
std::string m_cssFile;
std::map<int, bool> signal_toggle_state;
};
} // namespace waybar

View File

@ -13,14 +13,14 @@ namespace waybar {
class Group : public AModule {
public:
Group(const std::string &, const std::string &, const Json::Value &, bool);
Group(const std::string&, const std::string&, const Json::Value&, bool);
~Group() override = default;
auto update() -> void override;
operator Gtk::Widget &() override;
operator Gtk::Widget&() override;
auto refresh(int sig) -> void override;
virtual Gtk::Box &getBox();
void addWidget(Gtk::Widget &widget);
virtual Gtk::Box& getBox();
void addWidget(Gtk::Widget& widget);
protected:
Gtk::Box box;
@ -31,12 +31,19 @@ class Group : public AModule {
bool click_to_reveal = false;
std::optional<int> toggle_signal;
std::string add_class_to_drawer_children;
bool handleMouseEnter(GdkEventCrossing *const &ev) override;
bool handleMouseLeave(GdkEventCrossing *const &ev) override;
bool handleToggle(GdkEventButton *const &ev) override;
bool handleMouseEnter(GdkEventCrossing* const& ev) override;
bool handleMouseLeave(GdkEventCrossing* const& ev) override;
bool handleToggle(GdkEventButton* const& ev) override;
void toggle();
void show_group();
void hide_group();
void set_visible(bool v) {
if (v) {
show_group();
} else {
hide_group();
}
}
};
} // namespace waybar