| 12 | namespace waybar::modules::wayfire { |
| 13 | |
| 14 | Workspaces::Workspaces(const std::string& id, const Bar& bar, const Json::Value& config) |
| 15 | : AModule{config, "workspaces", id, false, !config["disable-scroll"].asBool()}, |
| 16 | ipc{IPC::get_instance()}, |
| 17 | handler{[this](const auto&) { dp.emit(); }}, |
| 18 | bar_{bar} { |
| 19 | // init box_ |
| 20 | box_.set_name("workspaces"); |
| 21 | if (!id.empty()) box_.get_style_context()->add_class(id); |
| 22 | box_.get_style_context()->add_class(MODULE_CLASS); |
| 23 | event_box_.add(box_); |
| 24 | |
| 25 | // scroll events |
| 26 | if (!config_["disable-scroll"].asBool()) { |
| 27 | auto& target = config_["enable-bar-scroll"].asBool() ? const_cast<Bar&>(bar_).window |
| 28 | : dynamic_cast<Gtk::Widget&>(box_); |
| 29 | target.add_events(Gdk::SCROLL_MASK | Gdk::SMOOTH_SCROLL_MASK); |
| 30 | target.signal_scroll_event().connect(sigc::mem_fun(*this, &Workspaces::handleScroll)); |
| 31 | } |
| 32 | |
| 33 | // listen events |
| 34 | ipc->register_handler("view-mapped", handler); |
| 35 | ipc->register_handler("view-unmapped", handler); |
| 36 | ipc->register_handler("view-wset-changed", handler); |
| 37 | ipc->register_handler("output-gain-focus", handler); |
| 38 | ipc->register_handler("view-sticky", handler); |
| 39 | ipc->register_handler("view-workspace-changed", handler); |
| 40 | ipc->register_handler("output-wset-changed", handler); |
| 41 | ipc->register_handler("wset-workspace-changed", handler); |
| 42 | |
| 43 | ipc->register_handler("window-rules/list-views", handler); |
| 44 | ipc->register_handler("window-rules/list-outputs", handler); |
| 45 | ipc->register_handler("window-rules/list-wsets", handler); |
| 46 | ipc->register_handler("window-rules/get-focused-output", handler); |
| 47 | |
| 48 | // initial render |
| 49 | dp.emit(); |
| 50 | } |
| 51 | |
| 52 | Workspaces::~Workspaces() { ipc->unregister_handler(handler); } |
| 53 |
nothing calls this directly
no test coverage detected