Skip to content

Commit

Permalink
animate: Add squeezimize animation (#2408)
Browse files Browse the repository at this point in the history
* animate: Add squeeimize animation

* Fix clipping

* Fix minimize to bottom

* Improve squeezimize animation

* Fix minimize to bottom (again)

* Initialize last_direction variable

This fixes disappearing windows on animation start after
reversing the animation once.

* Fixup object lifetime

* Add options for squeezimize

* Compute bounding box for animation damage

* Port to shader

* Fix downward squeezimize

* Drop squeezimize line height option

This optimization is no longer needed since we are using a fast fragment shader now.

* Fix builtins

* Omit unnecessary conditional in shader

* Simplify animation initialization function

* Fix squeezimize for shaded views

* squeezimize: Update animation geometry each frame

This makes it so it doesn't get the wrong clipping area when other
transformations are applied.

* Use more unique name for transformer name variable

This will help avoid conflicts of the same variable name in scope.

* squeezimize: Update according to suggestions in review

* squeezimize: Drop damage pre_hook

This is taken care of in transform_damage_region().

* squeezimize: Avoid storing view on transformer

* squeezimize: Fix typo

* animate: Set default squeezimize duration to 150ms

* animate: Minimize to bottom center of output if target is not set
  • Loading branch information
soreau authored Aug 27, 2024
1 parent 43532cc commit 4985fa1
Show file tree
Hide file tree
Showing 3 changed files with 415 additions and 2 deletions.
22 changes: 22 additions & 0 deletions metadata/animate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@
<_name>Fire</_name>
</desc>
</option>
<option name="minimize_animation" type="string">
<_short>Minimze animation</_short>
<_long>Specifies the type of animation when minimizing a window.</_long>
<default>squeezimize</default>
<desc>
<value>none</value>
<_name>None</_name>
</desc>
<desc>
<value>zoom</value>
<_name>Zoom</_name>
</desc>
<desc>
<value>squeezimize</value>
<_name>Squeezimize</_name>
</desc>
</option>
<!-- Preferred animation -->
<option name="enabled_for" type="string">
<_short>Animation enabled for specified window types</_short>
Expand Down Expand Up @@ -116,5 +133,10 @@
<_long>Sets the color of the fire effects, alpha is ignored</_long>
<default>#b22303ff</default>
</option>
<option name="squeezimize_duration" type="animation">
<_short>Squeezimize duration</_short>
<_long>Sets the duration of the squeezimize animation in milliseconds.</_long>
<default>150ms linear</default>
</option>
</plugin>
</wayfire>
24 changes: 22 additions & 2 deletions plugins/animate/animate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "animate.hpp"
#include "system_fade.hpp"
#include "basic_animations.hpp"
#include "squeezimize.hpp"
#include "fire/fire.hpp"
#include "unmapped-view-node.hpp"
#include "wayfire/plugin.hpp"
Expand Down Expand Up @@ -266,6 +267,7 @@ class wayfire_animation : public wf::plugin_interface_t, private wf::per_output_
{
wf::option_wrapper_t<std::string> open_animation{"animate/open_animation"};
wf::option_wrapper_t<std::string> close_animation{"animate/close_animation"};
wf::option_wrapper_t<std::string> minimize_animation{"animate/minimize_animation"};

wf::option_wrapper_t<wf::animation_description_t> default_duration{"animate/duration"};
wf::option_wrapper_t<wf::animation_description_t> fade_duration{"animate/fade_duration"};
Expand Down Expand Up @@ -444,10 +446,28 @@ class wayfire_animation : public wf::plugin_interface_t, private wf::per_output_
{
if (ev->state)
{
set_animation<zoom_animation>(ev->view, ANIMATION_TYPE_MINIMIZE, default_duration, "minimize");
if (std::string(minimize_animation) == "squeezimize")
{
set_animation<wf::squeezimize::squeezimize_animation>(ev->view, ANIMATION_TYPE_MINIMIZE,
default_duration,
"minimize");
} else if (std::string(minimize_animation) == "zoom")
{
set_animation<zoom_animation>(ev->view, ANIMATION_TYPE_MINIMIZE, default_duration,
"minimize");
}
} else
{
set_animation<zoom_animation>(ev->view, ANIMATION_TYPE_RESTORE, default_duration, "minimize");
if (std::string(minimize_animation) == "squeezimize")
{
set_animation<wf::squeezimize::squeezimize_animation>(ev->view, ANIMATION_TYPE_RESTORE,
default_duration,
"minimize");
} else if (std::string(minimize_animation) == "zoom")
{
set_animation<zoom_animation>(ev->view, ANIMATION_TYPE_RESTORE, default_duration,
"minimize");
}
}

// ev->carried_out should remain false, so that core also does the automatic minimize/restore and
Expand Down
Loading

0 comments on commit 4985fa1

Please sign in to comment.