mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:07:36 +00:00
WindowServer+Taskbar: Animate window frames on minimize/unminimize
We now show a quick window outline animation when going in/out of minimized state. It's a simple 10 frame animation at 60fps, just to give a visual cue of what's happening with the window. The Taskbar sends over the corresponding button rect for each window to the WindowServer using a new WM_SetWindowTaskbarRect message. Note that when unminimizing, we still *show* the window right away, and don't hold off until the animation has finished. This avoids making the desktop feel slow/sluggish. :^)
This commit is contained in:
parent
51262e7e2d
commit
d111b6ead4
8 changed files with 78 additions and 0 deletions
|
@ -212,6 +212,42 @@ void WSCompositor::compose()
|
|||
draw_geometry_label();
|
||||
}
|
||||
|
||||
static const int minimize_animation_steps = 10;
|
||||
|
||||
wm.for_each_window([&](WSWindow& window) {
|
||||
if (window.in_minimize_animation()) {
|
||||
int animation_index = window.minimize_animation_index();
|
||||
|
||||
auto from_rect = window.is_minimized() ? window.frame().rect() : window.taskbar_rect();
|
||||
auto to_rect = window.is_minimized() ? window.taskbar_rect() : window.frame().rect();
|
||||
|
||||
float x_delta_per_step = (float)(from_rect.x() - to_rect.x()) / minimize_animation_steps;
|
||||
float y_delta_per_step = (float)(from_rect.y() - to_rect.y()) / minimize_animation_steps;
|
||||
float width_delta_per_step = (float)(from_rect.width() - to_rect.width()) / minimize_animation_steps;
|
||||
float height_delta_per_step = (float)(from_rect.height() - to_rect.height()) / minimize_animation_steps;
|
||||
|
||||
Rect rect {
|
||||
from_rect.x() - (int)(x_delta_per_step * animation_index),
|
||||
from_rect.y() - (int)(y_delta_per_step * animation_index),
|
||||
from_rect.width() - (int)(width_delta_per_step * animation_index),
|
||||
from_rect.height() - (int)(height_delta_per_step * animation_index)
|
||||
};
|
||||
|
||||
#ifdef MINIMIZE_ANIMATION_DEBUG
|
||||
dbg() << "Minimize animation from " << from_rect << " to " << to_rect << " frame# " << animation_index << " " << rect;
|
||||
#endif
|
||||
|
||||
m_back_painter->draw_rect(rect, Color::White);
|
||||
|
||||
window.step_minimize_animation();
|
||||
if (window.minimize_animation_index() >= minimize_animation_steps)
|
||||
window.end_minimize_animation();
|
||||
|
||||
invalidate(rect);
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
draw_cursor();
|
||||
|
||||
if (m_flash_flush) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue