libui: Add option to run event processing in a loop instead of in app.run()
All checks were successful
continuous-integration/drone/pr Build is passing
All checks were successful
continuous-integration/drone/pr Build is passing
This commit is contained in:
parent
ff525c9044
commit
dce7b92c95
@ -35,6 +35,8 @@ namespace ui
|
|||||||
m_should_close = b;
|
m_should_close = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_nonblocking();
|
||||||
|
|
||||||
void set_main_window(Window* window)
|
void set_main_window(Window* window)
|
||||||
{
|
{
|
||||||
check(!m_main_window);
|
check(!m_main_window);
|
||||||
@ -51,6 +53,8 @@ namespace ui
|
|||||||
|
|
||||||
Result<void> handle_ipc_event(u8 id);
|
Result<void> handle_ipc_event(u8 id);
|
||||||
|
|
||||||
|
bool process_events();
|
||||||
|
|
||||||
static App& the();
|
static App& the();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -50,8 +50,8 @@ namespace ui
|
|||||||
|
|
||||||
Result<int> App::run()
|
Result<int> App::run()
|
||||||
{
|
{
|
||||||
check(m_main_window);
|
while (process_events())
|
||||||
while (!m_should_close) { TRY(os::IPC::check_for_messages(*m_client)); }
|
;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,4 +135,16 @@ namespace ui
|
|||||||
default: fail("Unexpected IPC request from server!");
|
default: fail("Unexpected IPC request from server!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void App::set_nonblocking()
|
||||||
|
{
|
||||||
|
fcntl(m_client->fd(), F_SETFL, O_NONBLOCK);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool App::process_events()
|
||||||
|
{
|
||||||
|
check(m_main_window);
|
||||||
|
os::IPC::check_for_messages(*m_client).release_value();
|
||||||
|
return !m_should_close;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user