1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:38:11 +00:00

WindowServer+LibGUI: Allow specifying a "launch origin" for new windows

The launch_origin_rect parameter to create_window() specifies where on
screen the window was launched from. It's optional, but if you provide
it, the new window will have a short wireframe animation from the origin
to the initial window frame rect.

GUI::Window looks for the "__libgui_launch_origin_rect" environment
variable. Put your launch origin rect in there with the format
"<x>,<y>,<width>,<height>" and the first GUI::Window shown by the app
will use that as the launch origin rect.

Also it looks pretty neat, although I'm sure we can improve it. :^)
This commit is contained in:
Andreas Kling 2021-06-27 17:07:31 +02:00
parent 75f870a93f
commit 6a132d8672
6 changed files with 46 additions and 4 deletions

View file

@ -122,6 +122,20 @@ void Window::show()
m_window_id = s_window_id_allocator.allocate();
Gfx::IntRect launch_origin_rect;
if (auto* launch_origin_rect_string = getenv("__libgui_launch_origin_rect")) {
auto parts = StringView(launch_origin_rect_string).split_view(',');
if (parts.size() == 4) {
launch_origin_rect = Gfx::IntRect {
parts[0].to_int().value_or(0),
parts[1].to_int().value_or(0),
parts[2].to_int().value_or(0),
parts[3].to_int().value_or(0),
};
}
unsetenv("__libgui_launch_origin_rect");
}
WindowServerConnection::the().async_create_window(
m_window_id,
m_rect_when_windowless,
@ -141,7 +155,8 @@ void Window::show()
m_resize_aspect_ratio,
(i32)m_window_type,
m_title_when_windowless,
parent_window ? parent_window->window_id() : 0);
parent_window ? parent_window->window_id() : 0,
launch_origin_rect);
m_visible = true;
apply_icon();