From b25fa46ac29499c2136592b6c40489c1e26d1bd6 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Sat, 26 Nov 2016 06:14:58 +0100 Subject: [PATCH] wip(xworkspaces): EWMH desktops Ref #84 --- include/modules/xworkspaces.hpp | 68 ++++++++++++ include/x11/ewmh.hpp | 18 ++- src/components/controller.cpp | 3 + src/modules/xworkspaces.cpp | 191 ++++++++++++++++++++++++++++++++ src/x11/ewmh.cpp | 63 +++++++++-- 5 files changed, 328 insertions(+), 15 deletions(-) create mode 100644 include/modules/xworkspaces.hpp create mode 100644 src/modules/xworkspaces.cpp diff --git a/include/modules/xworkspaces.hpp b/include/modules/xworkspaces.hpp new file mode 100644 index 00000000..e76ed350 --- /dev/null +++ b/include/modules/xworkspaces.hpp @@ -0,0 +1,68 @@ +#pragma once + +#include + +#include "components/config.hpp" +#include "modules/meta/static_module.hpp" +#include "x11/events.hpp" +#include "x11/ewmh.hpp" +#include "x11/icccm.hpp" +#include "x11/window.hpp" + +POLYBAR_NS + +class connection; + +namespace modules { + enum class desktop_state { + NONE, + ACTIVE, + URGENT, + EMPTY, + OCCUPIED, + }; + + struct desktop { + explicit desktop(string&& name, desktop_state state) : name(name), state(state) {} + string name; + desktop_state state{desktop_state::NONE}; + label_t label; + }; + + /** + * Module used to display EWMH desktops + */ + class xworkspaces_module : public static_module, public xpp::event::sink { + public: + xworkspaces_module(const bar_settings& bar, const logger& logger, const config& config, string name); + + void setup(); + void teardown(); + void handle(const evt::property_notify& evt); + void update(); + string get_output(); + bool build(builder* builder, const string& tag) const; + + protected: + void rebuild_desktops(); + void set_current_desktop(); + + private: + static constexpr const char* DEFAULT_ICON{"icon-default"}; + static constexpr const char* DEFAULT_LABEL{"%icon% %name%"}; + + static constexpr const char* TAG_LABEL{"