Auto calling of connection::prepare_to_event_handling
This commit is contained in:
@@ -25,9 +25,6 @@ int main() {
|
||||
}
|
||||
});
|
||||
|
||||
// Don't forget this:
|
||||
conn.prepare_to_event_handling();
|
||||
|
||||
while (true) {
|
||||
conn.handle_event();
|
||||
}
|
||||
|
||||
@@ -258,12 +258,6 @@ public:
|
||||
*/
|
||||
bool subscribe(const int32_t events);
|
||||
|
||||
/**
|
||||
* Prepare connection to the handling of i3's events
|
||||
* @note Used only in main()
|
||||
*/
|
||||
void prepare_to_event_handling();
|
||||
|
||||
/**
|
||||
* Handle an event from i3
|
||||
* @note Used only in main()
|
||||
@@ -294,6 +288,8 @@ public:
|
||||
sigc::signal<void> signal_barconfig_update_event; ///< Barconfig update event signal
|
||||
sigc::signal<void, const binding_t&> signal_binding_event; ///< Binding event signal
|
||||
sigc::signal<void, EventType, const std::shared_ptr<const buf_t>&> signal_event; ///< i3 event signal @note Default handler routes event to signal according to type
|
||||
protected:
|
||||
void prepare_to_event_handling();
|
||||
private:
|
||||
const int32_t m_main_socket;
|
||||
int32_t m_event_socket;
|
||||
|
||||
@@ -329,9 +329,10 @@ void connection::prepare_to_event_handling() {
|
||||
m_event_socket = i3_connect(m_socket_path);
|
||||
this->subscribe(m_subscriptions);
|
||||
}
|
||||
|
||||
void connection::handle_event() {
|
||||
if (m_event_socket <= 0) {
|
||||
throw std::runtime_error("event_socket_fd <= 0");
|
||||
this->prepare_to_event_handling();
|
||||
}
|
||||
auto buf = i3_recv(m_event_socket);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user