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
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:
5
.dir-locals.el
Normal file
5
.dir-locals.el
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
;;; Directory Local Variables -*- no-byte-compile: t -*-
|
||||||
|
;;; For more information see (info "(emacs) Directory Variables")
|
||||||
|
|
||||||
|
((nil . ((ff-search-directories . ("../include/*/" "../../include/*/"
|
||||||
|
"../src/*/" "../../src/*/")))))
|
||||||
@@ -5,6 +5,8 @@
|
|||||||
#include <gdk/gdkwayland.h>
|
#include <gdk/gdkwayland.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "bar.hpp"
|
#include "bar.hpp"
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "util/css_reload_helper.hpp"
|
#include "util/css_reload_helper.hpp"
|
||||||
@@ -21,6 +23,9 @@ class Client {
|
|||||||
int main(int argc, char* argv[]);
|
int main(int argc, char* argv[]);
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
bool get_signal_state(int signum) const;
|
||||||
|
void toggle_signal_state(int signum);
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::Application> gtk_app;
|
Glib::RefPtr<Gtk::Application> gtk_app;
|
||||||
Glib::RefPtr<Gdk::Display> gdk_display;
|
Glib::RefPtr<Gdk::Display> gdk_display;
|
||||||
struct wl_display* wl_display = nullptr;
|
struct wl_display* wl_display = nullptr;
|
||||||
@@ -56,6 +61,8 @@ class Client {
|
|||||||
std::list<struct waybar_output> outputs_;
|
std::list<struct waybar_output> outputs_;
|
||||||
std::unique_ptr<CssReloadHelper> m_cssReloadHelper;
|
std::unique_ptr<CssReloadHelper> m_cssReloadHelper;
|
||||||
std::string m_cssFile;
|
std::string m_cssFile;
|
||||||
|
|
||||||
|
std::map<int, bool> signal_toggle_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace waybar
|
} // namespace waybar
|
||||||
|
|||||||
@@ -37,6 +37,13 @@ class Group : public AModule {
|
|||||||
void toggle();
|
void toggle();
|
||||||
void show_group();
|
void show_group();
|
||||||
void hide_group();
|
void hide_group();
|
||||||
|
void set_visible(bool v) {
|
||||||
|
if (v) {
|
||||||
|
show_group();
|
||||||
|
} else {
|
||||||
|
hide_group();
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace waybar
|
} // namespace waybar
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <stdexcept>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "gtkmm/icontheme.h"
|
#include "gtkmm/icontheme.h"
|
||||||
@@ -290,6 +291,8 @@ int waybar::Client::main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signal_toggle_state.clear();
|
||||||
|
|
||||||
bindInterfaces();
|
bindInterfaces();
|
||||||
gtk_app->hold();
|
gtk_app->hold();
|
||||||
gtk_app->run();
|
gtk_app->run();
|
||||||
@@ -303,3 +306,16 @@ void waybar::Client::reset() {
|
|||||||
// delete signal handler for css changes
|
// delete signal handler for css changes
|
||||||
portal->signal_appearance_changed().clear();
|
portal->signal_appearance_changed().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool waybar::Client::get_signal_state(int signum) const {
|
||||||
|
try {
|
||||||
|
return signal_toggle_state.at(signum);
|
||||||
|
} catch (const std::out_of_range&) {
|
||||||
|
// default signal states to false
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void waybar::Client::toggle_signal_state(int signum) {
|
||||||
|
signal_toggle_state[signum] = !get_signal_state(signum);
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <util/command.hpp>
|
#include <util/command.hpp>
|
||||||
|
|
||||||
|
#include "client.hpp"
|
||||||
#include "gtkmm/enums.h"
|
#include "gtkmm/enums.h"
|
||||||
#include "gtkmm/widget.h"
|
#include "gtkmm/widget.h"
|
||||||
|
|
||||||
@@ -134,7 +135,7 @@ auto Group::update() -> void {
|
|||||||
|
|
||||||
void Group::refresh(int sig) {
|
void Group::refresh(int sig) {
|
||||||
if (toggle_signal.has_value() && sig == SIGRTMIN + toggle_signal.value()) {
|
if (toggle_signal.has_value() && sig == SIGRTMIN + toggle_signal.value()) {
|
||||||
toggle();
|
set_visible(waybar::Client::inst()->get_signal_state(sig));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ void handleUserSignal(int signal, bool& reload) {
|
|||||||
// `true` or `false`, respectively, into `reload`.
|
// `true` or `false`, respectively, into `reload`.
|
||||||
static void handleSignalMainThread(int signum, bool& reload) {
|
static void handleSignalMainThread(int signum, bool& reload) {
|
||||||
if (signum >= SIGRTMIN + 1 && signum <= SIGRTMAX) {
|
if (signum >= SIGRTMIN + 1 && signum <= SIGRTMAX) {
|
||||||
|
waybar::Client::inst()->toggle_signal_state(signum);
|
||||||
for (auto& bar : waybar::Client::inst()->bars) {
|
for (auto& bar : waybar::Client::inst()->bars) {
|
||||||
bar->handleSignal(signum);
|
bar->handleSignal(signum);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user