polybar-dwm/include/events/types.hpp

60 lines
998 B
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
/**
* 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