2016-12-20 04:05:43 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
2016-12-23 21:19:42 +00:00
|
|
|
#include "common.hpp"
|
|
|
|
|
|
|
|
POLYBAR_NS
|
|
|
|
|
2017-01-19 10:11:28 +00:00
|
|
|
enum class event_type {
|
2016-12-20 04:05:43 +00:00
|
|
|
NONE = 0,
|
|
|
|
UPDATE,
|
|
|
|
CHECK,
|
|
|
|
INPUT,
|
|
|
|
QUIT,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct event {
|
2017-01-19 10:11:28 +00:00
|
|
|
int type{0};
|
2016-12-20 04:05:43 +00:00
|
|
|
bool flag{false};
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace {
|
2017-01-19 10:11:28 +00:00
|
|
|
inline bool operator==(int id, event_type type) {
|
|
|
|
return id == static_cast<int>(type);
|
2016-12-23 21:19:42 +00:00
|
|
|
}
|
2017-01-19 10:11:28 +00:00
|
|
|
inline bool operator!=(int id, event_type type) {
|
|
|
|
return !(id == static_cast<int>(type));
|
2017-01-19 04:38:42 +00:00
|
|
|
}
|
2016-12-23 21:19:42 +00:00
|
|
|
|
2021-09-11 09:46:37 +00:00
|
|
|
/**
|
|
|
|
* Create QUIT event
|
|
|
|
*/
|
|
|
|
inline event make_none_evt() {
|
|
|
|
return event{static_cast<int>(event_type::NONE)};
|
|
|
|
}
|
|
|
|
|
2016-12-20 04:05:43 +00:00
|
|
|
/**
|
|
|
|
* Create QUIT event
|
|
|
|
*/
|
|
|
|
inline event make_quit_evt(bool reload = false) {
|
2017-01-19 10:11:28 +00:00
|
|
|
return event{static_cast<int>(event_type::QUIT), reload};
|
2016-12-20 04:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create UPDATE event
|
|
|
|
*/
|
|
|
|
inline event make_update_evt(bool force = false) {
|
2017-01-19 10:11:28 +00:00
|
|
|
return event{static_cast<int>(event_type::UPDATE), force};
|
2016-12-20 04:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create INPUT event
|
|
|
|
*/
|
|
|
|
inline event make_input_evt() {
|
2017-01-19 10:11:28 +00:00
|
|
|
return event{static_cast<int>(event_type::INPUT)};
|
2016-12-20 04:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create CHECK event
|
|
|
|
*/
|
|
|
|
inline event make_check_evt() {
|
2017-01-19 10:11:28 +00:00
|
|
|
return event{static_cast<int>(event_type::CHECK)};
|
2016-12-20 04:05:43 +00:00
|
|
|
}
|
|
|
|
}
|
2016-12-23 21:19:42 +00:00
|
|
|
|
|
|
|
POLYBAR_NS_END
|