1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:28:10 +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

@ -496,7 +496,8 @@ 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,
Optional<Gfx::IntSize> const& resize_aspect_ratio, i32 type, String const& title, i32 parent_window_id)
Optional<Gfx::IntSize> const& resize_aspect_ratio, i32 type, String const& title, i32 parent_window_id,
Gfx::IntRect const& launch_origin_rect)
{
Window* parent_window = nullptr;
if (parent_window_id) {
@ -519,6 +520,9 @@ void ClientConnection::create_window(i32 window_id, Gfx::IntRect const& rect,
auto window = Window::construct(*this, (WindowType)type, window_id, modal, minimizable, frameless, resizable, fullscreen, accessory, parent_window);
if (!launch_origin_rect.is_empty())
window->start_launch_animation(launch_origin_rect);
window->set_has_alpha_channel(has_alpha_channel);
window->set_title(title);
if (!fullscreen) {