polybar-dwm/include/events/types.hpp

67 lines
1.1 KiB
C++
Raw Normal View History

#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 {
NONE = 0,
UPDATE,
CHECK,
INPUT,
QUIT,
};
struct event {
2017-01-19 10:11:28 +00:00
int type{0};
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)};
}
/**
* 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};
}
/**
* 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};
}
/**
* Create INPUT event
*/
inline event make_input_evt() {
2017-01-19 10:11:28 +00:00
return event{static_cast<int>(event_type::INPUT)};
}
/**
* 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-23 21:19:42 +00:00
POLYBAR_NS_END