1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#ifndef SYSTEM_FADE_HPP
#define SYSTEM_FADE_HPP
#include <wayfire/core.hpp>
#include <wayfire/output.hpp>
#include <wayfire/opengl.hpp>
#include <wayfire/render-manager.hpp>
#include <wayfire/util/duration.hpp>
/* animates wake from suspend/startup by fading in the whole output */
class wf_system_fade
{
wf::animation::simple_animation_t progression;
wf::output_t *output;
wf::effect_hook_t damage_hook, render_hook;
public:
wf_system_fade(wf::output_t *out, wf::animation_description_t dur) :
progression(wf::create_option<wf::animation_description_t>(dur)), output(out)
{
damage_hook = [=] ()
{ output->render->damage_whole(); };
render_hook = [=] ()
{ render(); };
output->render->add_effect(&damage_hook, wf::OUTPUT_EFFECT_PRE);
output->render->add_effect(&render_hook, wf::OUTPUT_EFFECT_OVERLAY);
output->render->set_redraw_always();
this->progression.animate(1, 0);
}
void render()
{
wf::color_t color{0, 0, 0, this->progression};
auto fb = output->render->get_target_framebuffer();
output->render->get_current_pass()->add_rect(color, fb, fb.geometry, fb.geometry);
if (!progression.running())
{
finish();
}
}
void finish()
{
output->render->rem_effect(&damage_hook);
output->render->rem_effect(&render_hook);
output->render->set_redraw_always(false);
delete this;
}
};
#endif
|