Renaming idle_inhibitor_modules and idle_inhibitor_status to shorter, more convenient names.
parent
071cb86b45
commit
a9dae931c7
|
@ -21,9 +21,7 @@ class Client {
|
||||||
struct wl_registry * registry = nullptr;
|
struct wl_registry * registry = nullptr;
|
||||||
struct zwlr_layer_shell_v1 * layer_shell = nullptr;
|
struct zwlr_layer_shell_v1 * layer_shell = nullptr;
|
||||||
struct zxdg_output_manager_v1 * xdg_output_manager = nullptr;
|
struct zxdg_output_manager_v1 * xdg_output_manager = nullptr;
|
||||||
|
|
||||||
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager = nullptr;
|
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager = nullptr;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Bar>> bars;
|
std::vector<std::unique_ptr<Bar>> bars;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -12,8 +12,8 @@ class IdleInhibitor : public ALabel {
|
||||||
IdleInhibitor(const std::string&, const waybar::Bar&, const Json::Value&);
|
IdleInhibitor(const std::string&, const waybar::Bar&, const Json::Value&);
|
||||||
~IdleInhibitor();
|
~IdleInhibitor();
|
||||||
auto update() -> void;
|
auto update() -> void;
|
||||||
static std::list<waybar::AModule*> idle_inhibitor_modules;
|
static std::list<waybar::AModule*> modules;
|
||||||
static std::string idle_inhibitor_status;
|
static std::string status;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool handleToggle(GdkEventButton* const& e);
|
bool handleToggle(GdkEventButton* const& e);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "modules/idle_inhibitor.hpp"
|
#include "modules/idle_inhibitor.hpp"
|
||||||
#include "util/command.hpp"
|
#include "util/command.hpp"
|
||||||
|
|
||||||
std::list<waybar::AModule*> waybar::modules::IdleInhibitor::idle_inhibitor_modules;
|
std::list<waybar::AModule*> waybar::modules::IdleInhibitor::modules;
|
||||||
std::string waybar::modules::IdleInhibitor::idle_inhibitor_status = "deactivated";
|
std::string waybar::modules::IdleInhibitor::status = "deactivated";
|
||||||
|
|
||||||
waybar::modules::IdleInhibitor::IdleInhibitor(const std::string& id, const Bar& bar,
|
waybar::modules::IdleInhibitor::IdleInhibitor(const std::string& id, const Bar& bar,
|
||||||
const Json::Value& config)
|
const Json::Value& config)
|
||||||
|
@ -14,8 +14,8 @@ waybar::modules::IdleInhibitor::IdleInhibitor(const std::string& id, const Bar&
|
||||||
event_box_.signal_button_press_event().connect(
|
event_box_.signal_button_press_event().connect(
|
||||||
sigc::mem_fun(*this, &IdleInhibitor::handleToggle));
|
sigc::mem_fun(*this, &IdleInhibitor::handleToggle));
|
||||||
|
|
||||||
// Add this to the Client's idle_inhibitor_modules
|
// Add this to the modules list
|
||||||
waybar::modules::IdleInhibitor::idle_inhibitor_modules.push_back(this);
|
waybar::modules::IdleInhibitor::modules.push_back(this);
|
||||||
|
|
||||||
dp.emit();
|
dp.emit();
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@ waybar::modules::IdleInhibitor::~IdleInhibitor() {
|
||||||
idle_inhibitor_ = nullptr;
|
idle_inhibitor_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove this from the Client's idle_inhibitor_modules
|
// Remove this from the modules list
|
||||||
waybar::modules::IdleInhibitor::idle_inhibitor_modules.remove(this);
|
waybar::modules::IdleInhibitor::modules.remove(this);
|
||||||
|
|
||||||
if (pid_ != -1) {
|
if (pid_ != -1) {
|
||||||
kill(-pid_, 9);
|
kill(-pid_, 9);
|
||||||
|
@ -37,7 +37,7 @@ waybar::modules::IdleInhibitor::~IdleInhibitor() {
|
||||||
|
|
||||||
auto waybar::modules::IdleInhibitor::update() -> void {
|
auto waybar::modules::IdleInhibitor::update() -> void {
|
||||||
// Check status
|
// Check status
|
||||||
std::string status = waybar::modules::IdleInhibitor::idle_inhibitor_status;
|
std::string status = waybar::modules::IdleInhibitor::status;
|
||||||
if (status == "activated") {
|
if (status == "activated") {
|
||||||
if (idle_inhibitor_ == nullptr) {
|
if (idle_inhibitor_ == nullptr) {
|
||||||
idle_inhibitor_ = zwp_idle_inhibit_manager_v1_create_inhibitor(
|
idle_inhibitor_ = zwp_idle_inhibit_manager_v1_create_inhibitor(
|
||||||
|
@ -62,18 +62,18 @@ auto waybar::modules::IdleInhibitor::update() -> void {
|
||||||
|
|
||||||
bool waybar::modules::IdleInhibitor::handleToggle(GdkEventButton* const& e) {
|
bool waybar::modules::IdleInhibitor::handleToggle(GdkEventButton* const& e) {
|
||||||
if (e->button == 1) {
|
if (e->button == 1) {
|
||||||
std::string status = waybar::modules::IdleInhibitor::idle_inhibitor_status;
|
std::string status = waybar::modules::IdleInhibitor::status;
|
||||||
label_.get_style_context()->remove_class(status);
|
label_.get_style_context()->remove_class(status);
|
||||||
if (status == "activated") {
|
if (status == "activated") {
|
||||||
status = "deactivated";
|
status = "deactivated";
|
||||||
} else {
|
} else {
|
||||||
status = "activated";
|
status = "activated";
|
||||||
}
|
}
|
||||||
waybar::modules::IdleInhibitor::idle_inhibitor_status = status;
|
waybar::modules::IdleInhibitor::status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make all other idle inhibitor modules update
|
// Make all other idle inhibitor modules update
|
||||||
for (auto const& module : waybar::modules::IdleInhibitor::idle_inhibitor_modules) {
|
for (auto const& module : waybar::modules::IdleInhibitor::modules) {
|
||||||
if (module != this) {
|
if (module != this) {
|
||||||
module->update();
|
module->update();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue