moved to fb approach, much broken
This commit is contained in:
parent
71fa52f695
commit
2c57e2af46
8 changed files with 78 additions and 28 deletions
|
@ -217,6 +217,8 @@ void fx_render_blur(struct fx_renderer *renderer, const float matrix[static 9],
|
|||
struct fx_framebuffer **buffer, struct blur_shader *shader, const struct wlr_box *box,
|
||||
int blur_radius);
|
||||
|
||||
void fx_create_view_snapshot(struct fx_renderer *renderer, struct sway_view *view);
|
||||
void fx_create_container_snapshot(struct fx_renderer *renderer, struct sway_container *con);
|
||||
|
||||
void fx_render_container_snapshot(struct fx_renderer *renderer, struct sway_container *con);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -125,6 +125,7 @@ struct sway_container {
|
|||
float target_alpha;
|
||||
float max_alpha;
|
||||
|
||||
bool is_fading_out;
|
||||
struct fx_framebuffer close_animation_fb;
|
||||
struct wl_event_source *animation_present_timer;
|
||||
|
||||
|
|
|
@ -328,7 +328,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
|
|||
bool fullscreen, struct wlr_output *fullscreen_output, bool decoration);
|
||||
|
||||
void view_unmap(struct sway_view *view);
|
||||
void view_unmap_finish(struct sway_view *view);
|
||||
|
||||
void view_update_size(struct sway_view *view);
|
||||
void view_center_surface(struct sway_view *view);
|
||||
|
@ -381,4 +380,7 @@ void view_assign_ctx(struct sway_view *view, struct launcher_ctx *ctx);
|
|||
|
||||
bool gaps_to_edge(struct sway_view *view);
|
||||
|
||||
|
||||
void view_container_cleanup(struct sway_view *view);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "quad_frag_src.h"
|
||||
#include "quad_round_frag_src.h"
|
||||
#include "stencil_mask_frag_src.h"
|
||||
#include "sway/tree/container.h"
|
||||
#include "sway/tree/node.h"
|
||||
#include "sway/tree/workspace.h"
|
||||
#include "tex_frag_src.h"
|
||||
|
@ -877,8 +878,31 @@ void fx_render_blur(struct fx_renderer *renderer, const float matrix[static 9],
|
|||
glDisableVertexAttribArray(shader->tex_attrib);
|
||||
}
|
||||
|
||||
void fx_create_view_snapshot(struct fx_renderer *renderer, struct sway_view *view) {
|
||||
assert(view);
|
||||
void fx_render_container_snapshot(struct fx_renderer *renderer, struct sway_container *con) {
|
||||
// TODO: move create_deco_data
|
||||
// TODO: render without blur?
|
||||
struct decoration_data deco_data = {
|
||||
.alpha = 1.0f,
|
||||
.dim = 0.0f,
|
||||
.dim_color = config->dim_inactive_colors.unfocused,
|
||||
.corner_radius = 0,
|
||||
.saturation = 1.0f,
|
||||
.has_titlebar = false,
|
||||
.blur = false,
|
||||
.discard_transparent = false,
|
||||
.shadow = false,
|
||||
};
|
||||
struct sway_output *output = con->pending.workspace->output;
|
||||
struct wlr_box dst_box = { 0, 0, output->width, output->height };
|
||||
enum wl_output_transform transform = wlr_output_transform_invert(output->wlr_output->transform);
|
||||
float matrix[9];
|
||||
wlr_matrix_project_box(matrix, &dst_box, transform, 0.0, output->wlr_output->transform_matrix);
|
||||
|
||||
fx_render_texture_with_matrix(renderer, &con->close_animation_fb.texture, &dst_box, matrix, deco_data);
|
||||
}
|
||||
|
||||
void fx_create_container_snapshot(struct fx_renderer *renderer, struct sway_container *con) {
|
||||
assert(con);
|
||||
|
||||
// TODO: move to function? used in creation too
|
||||
if (!eglMakeCurrent(wlr_egl_get_display(renderer->wlr_egl), EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
|
@ -887,11 +911,10 @@ void fx_create_view_snapshot(struct fx_renderer *renderer, struct sway_view *vie
|
|||
return;
|
||||
}
|
||||
|
||||
struct sway_container *con = view->container;
|
||||
struct sway_output *output = con->pending.workspace->output;
|
||||
|
||||
//fx_framebuffer_update(&con->close_animation_fb, output->width, output->height);
|
||||
//fx_framebuffer_bind(&con->close_animation_fb);
|
||||
fx_framebuffer_update(&con->close_animation_fb, output->width, output->height);
|
||||
fx_framebuffer_bind(&con->close_animation_fb);
|
||||
|
||||
// damage whole output to ensure full container is rendered
|
||||
// (temporary, render_container will only render container area)
|
||||
|
@ -901,10 +924,10 @@ void fx_create_view_snapshot(struct fx_renderer *renderer, struct sway_view *vie
|
|||
pixman_region32_init(&damage);
|
||||
pixman_region32_union_rect(&damage, &damage, box.x, box.y, box.width, box.height);
|
||||
|
||||
// TODO: add check to see if container is fading out in render_container
|
||||
// TODO: render without blur?
|
||||
render_container(output, &damage, con, con->current.focused);
|
||||
// render container instead?
|
||||
fx_render_container_snapshot(renderer, con);
|
||||
|
||||
// rebind the main fb
|
||||
//fx_framebuffer_bind(&renderer->wlr_buffer);
|
||||
fx_framebuffer_bind(&renderer->wlr_buffer);
|
||||
printf("snapshot created\n");
|
||||
}
|
||||
|
|
|
@ -1684,6 +1684,11 @@ static void render_containers(struct sway_output *output,
|
|||
|
||||
void render_container(struct sway_output *output,
|
||||
pixman_region32_t *damage, struct sway_container *con, bool focused) {
|
||||
if (con->is_fading_out) {
|
||||
fx_render_container_snapshot(output->renderer, con);
|
||||
return;
|
||||
}
|
||||
|
||||
struct parent_data data = {
|
||||
.layout = con->current.layout,
|
||||
.box = {
|
||||
|
|
|
@ -50,7 +50,11 @@ static int animation_timer(void *data) {
|
|||
|
||||
if (con->alpha != con->target_alpha) {
|
||||
wl_event_source_timer_update(con->animation_present_timer, fastest_output_refresh_s * 1000);
|
||||
} else if (is_closing && con->view->impl->close) {
|
||||
} else if (is_closing) { // equal to target and closing
|
||||
printf("done animation; clean up view\n");
|
||||
con->is_fading_out = false;
|
||||
view_container_cleanup(con->view);
|
||||
return 1;
|
||||
}
|
||||
|
||||
container_damage_whole(con);
|
||||
|
@ -74,6 +78,7 @@ struct sway_container *container_create(struct sway_view *view) {
|
|||
c->shadow_enabled = config->shadow_enabled;
|
||||
c->blur_enabled = config->blur_enabled;
|
||||
c->corner_radius = config->corner_radius;
|
||||
c->is_fading_out = false;
|
||||
c->close_animation_fb = fx_framebuffer_create();
|
||||
|
||||
if (!view) {
|
||||
|
@ -125,10 +130,13 @@ void container_destroy(struct sway_container *con) {
|
|||
|
||||
wl_event_source_remove(con->animation_present_timer);
|
||||
|
||||
printf("alive 0\n");
|
||||
if (con->view && con->view->container == con) {
|
||||
con->view->container = NULL;
|
||||
if (con->view->destroying) {
|
||||
printf("alive\n");
|
||||
view_destroy(con->view);
|
||||
printf("alive 2\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,8 +144,9 @@ void container_destroy(struct sway_container *con) {
|
|||
}
|
||||
|
||||
void container_begin_destroy(struct sway_container *con) {
|
||||
printf("beginning container destroy\n");
|
||||
if (con->view) {
|
||||
printf("container begin destroy\n");
|
||||
// TODO; better way of deleting view
|
||||
if (con->view && !con->is_fading_out) {
|
||||
ipc_event_window(con, "close");
|
||||
}
|
||||
// The workspace must have the fullscreen pointer cleared so that the
|
||||
|
@ -149,6 +158,8 @@ void container_begin_destroy(struct sway_container *con) {
|
|||
container_fullscreen_disable(con);
|
||||
}
|
||||
|
||||
// TODO: problem here
|
||||
printf("about to emit signal\n");
|
||||
wl_signal_emit_mutable(&con->node.events.destroy, &con->node);
|
||||
|
||||
container_end_mouse_operation(con);
|
||||
|
|
|
@ -428,9 +428,8 @@ void view_set_tiled(struct sway_view *view, bool tiled) {
|
|||
}
|
||||
|
||||
void view_close(struct sway_view *view) {
|
||||
if (view->impl->close) {
|
||||
view->impl->close(view);
|
||||
}
|
||||
view->container->target_alpha = 0;
|
||||
wl_event_source_timer_update(view->container->animation_present_timer, 1);
|
||||
}
|
||||
|
||||
void view_close_popups(struct sway_view *view) {
|
||||
|
@ -906,16 +905,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
|
|||
}
|
||||
}
|
||||
|
||||
void view_unmap(struct sway_view *view) {
|
||||
printf("unmap view\n");
|
||||
// take a snapshot for fade-out animation
|
||||
struct sway_workspace *ws = view->container->pending.workspace;
|
||||
if (ws) {
|
||||
fx_create_view_snapshot(ws->output->renderer, view);
|
||||
}
|
||||
|
||||
wl_signal_emit_mutable(&view->events.unmap, view);
|
||||
|
||||
void view_container_cleanup(struct sway_view *view) {
|
||||
wl_list_remove(&view->surface_new_subsurface.link);
|
||||
|
||||
if (view->urgent_timer) {
|
||||
|
@ -929,6 +919,7 @@ void view_unmap(struct sway_view *view) {
|
|||
}
|
||||
|
||||
struct sway_container *parent = view->container->pending.parent;
|
||||
struct sway_workspace *ws = view->container->pending.workspace;
|
||||
container_begin_destroy(view->container);
|
||||
if (parent) {
|
||||
container_reap_empty(parent);
|
||||
|
@ -961,6 +952,20 @@ void view_unmap(struct sway_view *view) {
|
|||
view->surface = NULL;
|
||||
}
|
||||
|
||||
void view_unmap(struct sway_view *view) {
|
||||
wl_signal_emit_mutable(&view->events.unmap, view);
|
||||
struct sway_workspace *ws = view->container->pending.workspace;
|
||||
if (ws && config->animation_duration > 0) {
|
||||
printf("starting fade out animation");
|
||||
view->container->is_fading_out = true;
|
||||
fx_render_container_snapshot(ws->output->renderer, view->container);
|
||||
view->container->target_alpha = 0;
|
||||
wl_event_source_timer_update(view->container->animation_present_timer, 50);
|
||||
} else {
|
||||
view_container_cleanup(view);
|
||||
}
|
||||
}
|
||||
|
||||
void view_update_size(struct sway_view *view) {
|
||||
struct sway_container *con = view->container;
|
||||
con->pending.content_width = view->geometry.width;
|
||||
|
|
|
@ -699,7 +699,8 @@ struct blur_region_data {
|
|||
|
||||
static void find_blurred_region_iterator(struct sway_container *con, void *data) {
|
||||
struct sway_view *view = con->view;
|
||||
if (!view) {
|
||||
// TODO: proper view cleanup
|
||||
if (!view || con->is_fading_out) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue