mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:07:35 +00:00
WindowServer+LibGUI: Make window creation asynchronous :^)
Let clients manage their own window ID's. If you try to create a new window with an existing ID, WindowServer will simply disconnect you for misbehaving. This removes the need for window creation to be synchronous, which means that most GUI applications can now batch their entire GUI initialization sequence without having to block waiting for responses.
This commit is contained in:
parent
77c2db4183
commit
0a98964600
4 changed files with 17 additions and 10 deletions
|
@ -460,7 +460,7 @@ Window* ClientConnection::window_from_id(i32 window_id)
|
|||
return it->value.ptr();
|
||||
}
|
||||
|
||||
Messages::WindowServer::CreateWindowResponse ClientConnection::create_window(Gfx::IntRect const& rect,
|
||||
void ClientConnection::create_window(i32 window_id, Gfx::IntRect const& rect,
|
||||
bool auto_position, bool has_alpha_channel, bool modal, bool minimizable, bool resizable,
|
||||
bool fullscreen, bool frameless, bool accessory, float opacity, float alpha_hit_threshold,
|
||||
Gfx::IntSize const& base_size, Gfx::IntSize const& size_increment, Gfx::IntSize const& minimum_size,
|
||||
|
@ -471,16 +471,20 @@ Messages::WindowServer::CreateWindowResponse ClientConnection::create_window(Gfx
|
|||
parent_window = window_from_id(parent_window_id);
|
||||
if (!parent_window) {
|
||||
did_misbehave("CreateWindow with bad parent_window_id");
|
||||
return nullptr;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (type < 0 || type >= (i32)WindowType::_Count) {
|
||||
did_misbehave("CreateWindow with a bad type");
|
||||
return nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_windows.contains(window_id)) {
|
||||
did_misbehave("CreateWindow with already-used window ID");
|
||||
return;
|
||||
}
|
||||
|
||||
int window_id = m_next_window_id++;
|
||||
auto window = Window::construct(*this, (WindowType)type, window_id, modal, minimizable, frameless, resizable, fullscreen, accessory, parent_window);
|
||||
|
||||
window->set_has_alpha_channel(has_alpha_channel);
|
||||
|
@ -513,7 +517,6 @@ Messages::WindowServer::CreateWindowResponse ClientConnection::create_window(Gfx
|
|||
if (window->type() == WindowType::Applet)
|
||||
AppletManager::the().add_applet(*window);
|
||||
m_windows.set(window_id, move(window));
|
||||
return window_id;
|
||||
}
|
||||
|
||||
void ClientConnection::destroy_window(Window& window, Vector<i32>& destroyed_window_ids)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue