2016-11-26 00:14:58 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <bitset>
|
|
|
|
|
|
|
|
#include "components/config.hpp"
|
2016-11-26 03:38:55 -05:00
|
|
|
#include "components/types.hpp"
|
2016-12-22 23:08:19 -05:00
|
|
|
#include "modules/meta/event_handler.hpp"
|
2016-12-21 02:38:44 -05:00
|
|
|
#include "modules/meta/input_handler.hpp"
|
2016-11-26 00:14:58 -05:00
|
|
|
#include "modules/meta/static_module.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,
|
|
|
|
};
|
|
|
|
|
2016-11-26 03:38:55 -05:00
|
|
|
enum class viewport_state {
|
|
|
|
NONE,
|
|
|
|
FOCUSED,
|
|
|
|
UNFOCUSED,
|
|
|
|
};
|
|
|
|
|
2016-12-03 07:45:22 -05:00
|
|
|
struct desktop {
|
2017-01-24 21:29:11 -05:00
|
|
|
explicit desktop(unsigned int index, unsigned int offset, desktop_state state, label_t&& label)
|
|
|
|
: index(index), offset(offset), state(state), label(label) {}
|
|
|
|
unsigned int index;
|
|
|
|
unsigned int offset;
|
2016-12-03 07:45:22 -05:00
|
|
|
desktop_state state;
|
|
|
|
label_t label;
|
|
|
|
};
|
|
|
|
|
2016-11-26 03:38:55 -05:00
|
|
|
struct viewport {
|
|
|
|
position pos;
|
2016-11-26 00:14:58 -05:00
|
|
|
string name;
|
2016-12-03 07:45:22 -05:00
|
|
|
vector<unique_ptr<desktop>> desktops;
|
2016-11-26 03:38:55 -05:00
|
|
|
viewport_state state;
|
2016-11-26 00:14:58 -05:00
|
|
|
label_t label;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Module used to display EWMH desktops
|
|
|
|
*/
|
2016-12-21 02:38:44 -05:00
|
|
|
class xworkspaces_module : public static_module<xworkspaces_module>,
|
2016-12-22 23:08:19 -05:00
|
|
|
public event_handler<evt::property_notify>,
|
2016-12-21 02:38:44 -05:00
|
|
|
public input_handler {
|
2016-11-26 00:14:58 -05:00
|
|
|
public:
|
2016-12-21 02:00:09 -05:00
|
|
|
explicit xworkspaces_module(const bar_settings& bar, string name_);
|
2016-11-26 00:14:58 -05:00
|
|
|
|
|
|
|
void update();
|
|
|
|
string get_output();
|
|
|
|
bool build(builder* builder, const string& tag) const;
|
|
|
|
|
|
|
|
protected:
|
2016-12-22 23:08:19 -05:00
|
|
|
void handle(const evt::property_notify& evt);
|
2017-01-24 21:29:11 -05:00
|
|
|
|
|
|
|
void rebuild_clientlist();
|
2016-11-26 00:14:58 -05:00
|
|
|
void rebuild_desktops();
|
2017-01-24 21:29:11 -05:00
|
|
|
void rebuild_desktop_states();
|
2017-02-20 02:25:19 -05:00
|
|
|
void set_desktop_urgent(xcb_window_t window);
|
2017-01-24 21:29:11 -05:00
|
|
|
|
2016-12-23 14:43:52 -05:00
|
|
|
bool input(string&& cmd);
|
2019-02-08 07:32:31 -05:00
|
|
|
vector<string> get_desktop_names();
|
2016-11-26 00:14:58 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
static constexpr const char* DEFAULT_ICON{"icon-default"};
|
2016-11-26 03:38:55 -05:00
|
|
|
static constexpr const char* DEFAULT_LABEL_STATE{"%icon% %name%"};
|
|
|
|
static constexpr const char* DEFAULT_LABEL_MONITOR{"%name%"};
|
2016-11-26 00:14:58 -05:00
|
|
|
|
2016-11-26 03:38:55 -05:00
|
|
|
static constexpr const char* TAG_LABEL_MONITOR{"<label-monitor>"};
|
|
|
|
static constexpr const char* TAG_LABEL_STATE{"<label-state>"};
|
2016-11-26 00:14:58 -05:00
|
|
|
|
2016-11-26 04:33:32 -05:00
|
|
|
static constexpr const char* EVENT_PREFIX{"xworkspaces-"};
|
|
|
|
static constexpr const char* EVENT_CLICK{"focus="};
|
|
|
|
static constexpr const char* EVENT_SCROLL_UP{"next"};
|
|
|
|
static constexpr const char* EVENT_SCROLL_DOWN{"prev"};
|
|
|
|
|
2016-11-26 00:14:58 -05:00
|
|
|
connection& m_connection;
|
|
|
|
ewmh_connection_t m_ewmh;
|
2017-01-24 21:29:11 -05:00
|
|
|
|
2016-11-26 03:38:55 -05:00
|
|
|
vector<monitor_t> m_monitors;
|
|
|
|
bool m_monitorsupport{true};
|
2016-11-26 00:14:58 -05:00
|
|
|
|
2017-01-24 21:29:11 -05:00
|
|
|
vector<string> m_desktop_names;
|
|
|
|
unsigned int m_current_desktop;
|
|
|
|
|
|
|
|
vector<xcb_window_t> m_clientlist;
|
2016-11-26 03:38:55 -05:00
|
|
|
vector<unique_ptr<viewport>> m_viewports;
|
2016-11-26 00:14:58 -05:00
|
|
|
map<desktop_state, label_t> m_labels;
|
2016-11-26 03:38:55 -05:00
|
|
|
label_t m_monitorlabel;
|
2016-11-26 00:14:58 -05:00
|
|
|
iconset_t m_icons;
|
2016-11-26 03:38:55 -05:00
|
|
|
bool m_pinworkspaces{false};
|
2016-11-26 04:33:32 -05:00
|
|
|
bool m_click{true};
|
|
|
|
bool m_scroll{true};
|
2016-11-26 00:14:58 -05:00
|
|
|
size_t m_index{0};
|
2017-01-24 21:29:11 -05:00
|
|
|
|
|
|
|
event_timer m_timer{0L, 25L};
|
2016-11-26 00:14:58 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
POLYBAR_NS_END
|