2016-12-05 19:41:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common.hpp"
|
|
|
|
|
|
|
|
#include "components/ipc.hpp"
|
2016-12-15 16:14:56 +00:00
|
|
|
#include "components/parser.hpp"
|
2016-12-05 19:41:00 +00:00
|
|
|
#include "components/types.hpp"
|
|
|
|
#include "utils/functional.hpp"
|
|
|
|
|
|
|
|
POLYBAR_NS
|
|
|
|
|
2017-01-01 19:29:38 +00:00
|
|
|
// fwd
|
2016-12-05 19:41:00 +00:00
|
|
|
enum class mousebtn : uint8_t;
|
|
|
|
enum class syntaxtag : uint8_t;
|
|
|
|
enum class alignment : uint8_t;
|
|
|
|
enum class attribute : uint8_t;
|
|
|
|
|
|
|
|
namespace signals {
|
|
|
|
namespace detail {
|
|
|
|
class signal {
|
|
|
|
public:
|
|
|
|
explicit signal() = default;
|
|
|
|
virtual ~signal() {}
|
|
|
|
virtual size_t size() const = 0;
|
|
|
|
};
|
|
|
|
|
2017-01-01 19:29:38 +00:00
|
|
|
template <typename Derived>
|
2016-12-05 19:41:00 +00:00
|
|
|
class base_signal : public signal {
|
|
|
|
public:
|
2017-01-01 19:29:38 +00:00
|
|
|
using base_type = base_signal<Derived>;
|
2016-12-05 19:41:00 +00:00
|
|
|
|
|
|
|
explicit base_signal() = default;
|
|
|
|
virtual ~base_signal() {}
|
|
|
|
|
|
|
|
virtual size_t size() const override {
|
|
|
|
return sizeof(Derived);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-01-01 19:29:38 +00:00
|
|
|
template <typename Derived, typename ValueType>
|
|
|
|
class value_signal : public base_signal<Derived> {
|
2016-12-05 19:41:00 +00:00
|
|
|
public:
|
2017-01-01 19:29:38 +00:00
|
|
|
using base_type = value_signal<Derived, ValueType>;
|
2016-12-05 19:41:00 +00:00
|
|
|
using value_type = ValueType;
|
|
|
|
|
2017-01-01 19:29:38 +00:00
|
|
|
template <size_t Size = sizeof(ValueType)>
|
|
|
|
explicit value_signal(void* data) : m_data(data), m_size(Size) {}
|
|
|
|
|
|
|
|
template <size_t Size = sizeof(ValueType)>
|
|
|
|
explicit value_signal(ValueType data) : m_size(Size) {
|
|
|
|
m_data = new char[Size];
|
|
|
|
m_alloced = true;
|
|
|
|
memcpy(m_data, static_cast<void*>(&data), Size);
|
2016-12-05 19:41:00 +00:00
|
|
|
}
|
|
|
|
|
2017-01-01 19:29:38 +00:00
|
|
|
virtual ~value_signal() {
|
|
|
|
if (m_alloced) {
|
|
|
|
delete[] static_cast<char*>(m_data);
|
|
|
|
}
|
|
|
|
}
|
2016-12-05 19:41:00 +00:00
|
|
|
|
2017-01-01 19:29:38 +00:00
|
|
|
void* data() const {
|
|
|
|
return m_data;
|
|
|
|
}
|
|
|
|
size_t size() const {
|
|
|
|
return m_size;
|
2016-12-05 19:41:00 +00:00
|
|
|
}
|
2017-01-01 19:29:38 +00:00
|
|
|
inline ValueType cast() const {
|
|
|
|
return *static_cast<ValueType*>(m_data);
|
2016-12-16 06:10:45 +00:00
|
|
|
}
|
2016-12-05 19:41:00 +00:00
|
|
|
|
|
|
|
private:
|
2017-01-01 19:29:38 +00:00
|
|
|
void* m_data;
|
|
|
|
size_t m_size;
|
|
|
|
bool m_alloced{false};
|
2016-12-05 19:41:00 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-12-20 04:05:43 +00:00
|
|
|
namespace eventqueue {
|
2017-01-01 19:29:38 +00:00
|
|
|
struct exit_terminate : public detail::base_signal<exit_terminate> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct exit_reload : public detail::base_signal<exit_reload> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct notify_change : public detail::base_signal<notify_change> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct check_state : public detail::base_signal<check_state> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct update : public detail::base_signal<update> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
2016-12-05 19:41:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace ipc {
|
2017-01-01 19:29:38 +00:00
|
|
|
struct command : public detail::value_signal<command, string> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct hook : public detail::value_signal<hook, string> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct action : public detail::value_signal<action, string> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
2016-12-05 19:41:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace ui {
|
2017-01-01 19:29:38 +00:00
|
|
|
struct tick : public detail::base_signal<tick> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct button_press : public detail::value_signal<button_press, string> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct visibility_change : public detail::value_signal<visibility_change, bool> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct dim_window : public detail::value_signal<dim_window, double> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct shade_window : public detail::base_signal<shade_window> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct unshade_window : public detail::base_signal<unshade_window> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace ui_tray {
|
|
|
|
struct mapped_clients : public detail::value_signal<mapped_clients, size_t> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
2016-12-05 19:41:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace parser {
|
2017-01-01 19:29:38 +00:00
|
|
|
struct change_background : public detail::value_signal<change_background, uint32_t> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct change_foreground : public detail::value_signal<change_foreground, uint32_t> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct change_underline : public detail::value_signal<change_underline, uint32_t> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct change_overline : public detail::value_signal<change_overline, uint32_t> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct change_font : public detail::value_signal<change_font, uint8_t> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct change_alignment : public detail::value_signal<change_alignment, alignment> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct offset_pixel : public detail::value_signal<offset_pixel, int16_t> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct attribute_set : public detail::value_signal<attribute_set, attribute> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct attribute_unset : public detail::value_signal<attribute_unset, attribute> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct attribute_toggle : public detail::value_signal<attribute_toggle, attribute> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct action_begin : public detail::value_signal<action_begin, action> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct action_end : public detail::value_signal<action_end, mousebtn> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct write_text_ascii : public detail::value_signal<write_text_ascii, uint16_t> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct write_text_unicode : public detail::value_signal<write_text_unicode, uint16_t> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
|
|
|
struct write_text_string : public detail::value_signal<write_text_string, polybar::parser::packet> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
2016-12-05 19:41:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
POLYBAR_NS_END
|