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