1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-10-27 05:23:39 -04:00
polybar/include/events/types.hpp

60 lines
998 B
C++
Raw Normal View History

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