2016-11-18 22:03:18 -05:00
|
|
|
#pragma once
|
|
|
|
|
2016-12-22 23:08:19 -05:00
|
|
|
#include "modules/meta/event_handler.hpp"
|
2016-11-20 17:04:31 -05:00
|
|
|
#include "modules/meta/static_module.hpp"
|
2016-11-18 22:03:18 -05:00
|
|
|
#include "x11/ewmh.hpp"
|
|
|
|
#include "x11/icccm.hpp"
|
|
|
|
#include "x11/window.hpp"
|
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS
|
2016-11-18 22:03:18 -05:00
|
|
|
|
2016-11-20 17:04:31 -05:00
|
|
|
class connection;
|
|
|
|
|
2016-11-18 22:03:18 -05:00
|
|
|
namespace modules {
|
|
|
|
class active_window {
|
|
|
|
public:
|
2016-12-22 19:03:38 -05:00
|
|
|
explicit active_window(xcb_connection_t* conn, xcb_window_t win);
|
2016-12-01 02:35:59 -05:00
|
|
|
~active_window();
|
2016-12-22 19:03:38 -05:00
|
|
|
|
2016-12-01 02:35:59 -05:00
|
|
|
bool match(const xcb_window_t win) const;
|
2017-01-24 02:49:27 -05:00
|
|
|
string title() const;
|
2016-11-18 22:03:18 -05:00
|
|
|
|
|
|
|
private:
|
2016-12-22 19:03:38 -05:00
|
|
|
xcb_connection_t* m_connection{nullptr};
|
|
|
|
xcb_window_t m_window{XCB_NONE};
|
2016-11-18 22:03:18 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Module used to display information about the
|
|
|
|
* currently active X window.
|
|
|
|
*/
|
2016-12-22 23:08:19 -05:00
|
|
|
class xwindow_module : public static_module<xwindow_module>, public event_handler<evt::property_notify> {
|
2016-11-18 22:03:18 -05:00
|
|
|
public:
|
2020-05-15 13:59:08 -04:00
|
|
|
enum class state { NONE, ACTIVE, EMPTY };
|
2016-12-09 03:40:46 -05:00
|
|
|
explicit xwindow_module(const bar_settings&, string);
|
2016-11-18 22:03:18 -05:00
|
|
|
|
2016-12-22 19:03:38 -05:00
|
|
|
void update(bool force = false);
|
2016-11-25 07:55:15 -05:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-11-18 22:03:18 -05:00
|
|
|
|
2020-05-15 13:59:08 -04:00
|
|
|
static constexpr auto TYPE = "internal/xwindow";
|
|
|
|
|
2016-12-22 19:03:38 -05:00
|
|
|
protected:
|
2021-01-04 04:38:43 -05:00
|
|
|
void handle(const evt::property_notify& evt) override;
|
2016-12-22 19:03:38 -05:00
|
|
|
|
2016-11-18 22:03:18 -05:00
|
|
|
private:
|
2016-11-26 00:13:20 -05:00
|
|
|
static constexpr const char* TAG_LABEL{"<label>"};
|
2016-11-18 22:03:18 -05:00
|
|
|
|
2016-12-01 02:35:59 -05:00
|
|
|
connection& m_connection;
|
2016-11-18 22:03:18 -05:00
|
|
|
unique_ptr<active_window> m_active;
|
2018-04-01 18:00:16 -04:00
|
|
|
map<state, label_t> m_statelabels;
|
2016-11-18 22:03:18 -05:00
|
|
|
label_t m_label;
|
|
|
|
};
|
2020-05-15 13:59:08 -04:00
|
|
|
} // namespace modules
|
2016-11-18 22:03:18 -05:00
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS_END
|