2016-12-05 14:41:00 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common.hpp"
|
|
|
|
#include "components/types.hpp"
|
|
|
|
|
|
|
|
POLYBAR_NS
|
|
|
|
|
|
|
|
namespace signals {
|
|
|
|
namespace detail {
|
|
|
|
class signal {
|
|
|
|
public:
|
|
|
|
explicit signal() = default;
|
|
|
|
virtual ~signal() {}
|
|
|
|
virtual size_t size() const = 0;
|
|
|
|
};
|
|
|
|
|
2017-01-01 14:29:38 -05:00
|
|
|
template <typename Derived>
|
2016-12-05 14:41:00 -05:00
|
|
|
class base_signal : public signal {
|
|
|
|
public:
|
2017-01-01 14:29:38 -05:00
|
|
|
using base_type = base_signal<Derived>;
|
2016-12-05 14:41:00 -05:00
|
|
|
|
|
|
|
explicit base_signal() = default;
|
|
|
|
virtual ~base_signal() {}
|
|
|
|
|
|
|
|
virtual size_t size() const override {
|
|
|
|
return sizeof(Derived);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-01-01 14:29:38 -05:00
|
|
|
template <typename Derived, typename ValueType>
|
|
|
|
class value_signal : public base_signal<Derived> {
|
2016-12-05 14:41:00 -05:00
|
|
|
public:
|
2017-01-01 14:29:38 -05:00
|
|
|
using base_type = value_signal<Derived, ValueType>;
|
2016-12-05 14:41:00 -05:00
|
|
|
|
2017-01-09 12:49:22 -05:00
|
|
|
explicit value_signal(void* data) : m_ptr(data) {}
|
2022-01-22 14:35:37 -05:00
|
|
|
explicit value_signal(const ValueType&& data) : m_ptr(&data) {}
|
|
|
|
explicit value_signal(const ValueType& data) : m_ptr(&data) {}
|
2017-01-01 14:29:38 -05:00
|
|
|
|
2017-01-09 12:49:22 -05:00
|
|
|
virtual ~value_signal() {}
|
2016-12-05 14:41:00 -05:00
|
|
|
|
2022-01-22 14:35:37 -05:00
|
|
|
inline const ValueType cast() const {
|
|
|
|
return *static_cast<const ValueType*>(m_ptr);
|
2016-12-16 01:10:45 -05:00
|
|
|
}
|
2016-12-05 14:41:00 -05:00
|
|
|
|
|
|
|
private:
|
2022-01-22 14:35:37 -05:00
|
|
|
const void* m_ptr;
|
2016-12-05 14:41:00 -05:00
|
|
|
};
|
2022-03-20 14:09:45 -04:00
|
|
|
} // namespace detail
|
2016-12-05 14:41:00 -05:00
|
|
|
|
2016-12-19 23:05:43 -05:00
|
|
|
namespace eventqueue {
|
2017-01-01 14:29:38 -05:00
|
|
|
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;
|
|
|
|
};
|
2017-01-09 08:27:55 -05:00
|
|
|
struct notify_forcechange : public detail::base_signal<notify_forcechange> {
|
2017-01-01 14:29:38 -05:00
|
|
|
using base_type::base_type;
|
|
|
|
};
|
2017-01-09 08:27:55 -05:00
|
|
|
struct check_state : public detail::base_signal<check_state> {
|
2017-01-01 14:29:38 -05:00
|
|
|
using base_type::base_type;
|
|
|
|
};
|
2022-03-20 14:09:45 -04:00
|
|
|
} // namespace eventqueue
|
2016-12-05 14:41:00 -05:00
|
|
|
|
|
|
|
namespace ipc {
|
2017-01-01 14:29:38 -05: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;
|
|
|
|
};
|
2022-03-20 14:09:45 -04:00
|
|
|
} // namespace ipc
|
2016-12-05 14:41:00 -05:00
|
|
|
|
|
|
|
namespace ui {
|
2017-01-25 17:36:34 -05:00
|
|
|
struct changed : public detail::base_signal<changed> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
2017-01-01 14:29:38 -05:00
|
|
|
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;
|
|
|
|
};
|
2017-01-24 00:59:58 -05:00
|
|
|
struct request_snapshot : public detail::value_signal<request_snapshot, string> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
2018-08-13 12:42:43 -04:00
|
|
|
/// emitted whenever the desktop background slice changes
|
2017-05-23 15:32:34 -04:00
|
|
|
struct update_background : public detail::base_signal<update_background> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
2018-08-13 12:42:43 -04:00
|
|
|
/// emitted when the bar geometry changes (such as position of the bar on the screen)
|
2017-08-31 12:26:38 -04:00
|
|
|
struct update_geometry : public detail::base_signal<update_geometry> {
|
|
|
|
using base_type::base_type;
|
|
|
|
};
|
2022-03-20 14:09:45 -04:00
|
|
|
} // namespace ui
|
2017-01-01 14:29:38 -05:00
|
|
|
|
|
|
|
namespace ui_tray {
|
2017-01-25 17:36:34 -05:00
|
|
|
struct mapped_clients : public detail::value_signal<mapped_clients, unsigned int> {
|
2017-01-01 14:29:38 -05:00
|
|
|
using base_type::base_type;
|
|
|
|
};
|
2022-03-20 14:09:45 -04:00
|
|
|
} // namespace ui_tray
|
|
|
|
} // namespace signals
|
2016-12-05 14:41:00 -05:00
|
|
|
|
|
|
|
POLYBAR_NS_END
|