Since idle_inhibitor's have a surface, we should have one for each inhibitor module. Therefore, the status is stored on the Client, and all modules create or destroy their inhibitors depending on Client's idle_inhibitor_status. Also, when modules are destroyed they remove themselves from Client's idle_inhibitor_modules.

This commit is contained in:
Jordan Leppert
2020-11-01 13:33:28 +00:00
parent aa4fc3dd29
commit 4889e655eb
3 changed files with 33 additions and 22 deletions

View File

@ -23,8 +23,8 @@ class Client {
struct zxdg_output_manager_v1 * xdg_output_manager = nullptr;
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager = nullptr;
struct zwp_idle_inhibitor_v1* idle_inhibitor;
std::vector<waybar::AModule*> idle_inhibitor_modules;
std::list<waybar::AModule*> idle_inhibitor_modules;
std::string idle_inhibitor_status = "deactivated";
std::vector<std::unique_ptr<Bar>> bars;

View File

@ -12,12 +12,12 @@ class IdleInhibitor : public ALabel {
IdleInhibitor(const std::string&, const waybar::Bar&, const Json::Value&);
~IdleInhibitor();
auto update() -> void;
struct zwp_idle_inhibitor_v1* idle_inhibitor_ = nullptr;
private:
bool handleToggle(GdkEventButton* const& e);
const Bar& bar_;
std::string status_;
int pid_;
};