LibGUI: Add API to block until window events are available
This commit is contained in:
parent
96496da0ab
commit
f78c7e7926
|
@ -387,10 +387,17 @@ namespace LibGUI
|
|||
return {};
|
||||
}
|
||||
|
||||
#define TRY_OR_BREAK(...) ({ auto&& e = (__VA_ARGS__); if (e.is_error()) break; e.release_value(); })
|
||||
void Window::wait_events()
|
||||
{
|
||||
fd_set fds;
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(m_server_fd, &fds);
|
||||
select(m_server_fd + 1, &fds, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void Window::poll_events()
|
||||
{
|
||||
#define TRY_OR_BREAK(...) ({ auto&& e = (__VA_ARGS__); if (e.is_error()) break; e.release_value(); })
|
||||
for (;;)
|
||||
{
|
||||
fd_set fds;
|
||||
|
@ -444,6 +451,7 @@ namespace LibGUI
|
|||
break;
|
||||
}
|
||||
}
|
||||
#undef TRY_OR_BREAK
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -88,7 +88,9 @@ namespace LibGUI
|
|||
// used on resize to fill empty space
|
||||
void set_bg_color(uint32_t bg_color) { m_bg_color = bg_color; }
|
||||
|
||||
void wait_events();
|
||||
void poll_events();
|
||||
|
||||
void set_socket_error_callback(BAN::Function<void()> callback) { m_socket_error_callback = callback; }
|
||||
void set_close_window_event_callback(BAN::Function<void()> callback) { m_close_window_event_callback = callback; }
|
||||
void set_resize_window_event_callback(BAN::Function<void()> callback) { m_resize_window_event_callback = callback; }
|
||||
|
|
Loading…
Reference in New Issue