added cleanup
This commit is contained in:
parent
30e18aae07
commit
a3ef0be4fc
8 changed files with 42 additions and 36 deletions
|
@ -125,8 +125,6 @@ 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;
|
||||
|
||||
int corner_radius;
|
||||
|
|
|
@ -311,6 +311,8 @@ void view_for_each_popup_surface(struct sway_view *view,
|
|||
void view_init(struct sway_view *view, enum sway_view_type type,
|
||||
const struct sway_view_impl *impl);
|
||||
|
||||
void view_remove_container(struct sway_view *view);
|
||||
|
||||
void view_destroy(struct sway_view *view);
|
||||
|
||||
void view_begin_destroy(struct sway_view *view);
|
||||
|
|
|
@ -256,7 +256,7 @@ static void apply_container_state(struct sway_container *container,
|
|||
|
||||
memcpy(&container->current, state, sizeof(struct sway_container_state));
|
||||
|
||||
if (view && !wl_list_empty(&view->saved_buffers) && !container->is_fading_out) {
|
||||
if (view && !wl_list_empty(&view->saved_buffers) && view->surface) {
|
||||
if (!container->node.destroying || container->node.ntxnrefs == 1) {
|
||||
view_remove_saved_buffer(view);
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ static bool should_configure(struct sway_node *node,
|
|||
if (!node_is_view(node)) {
|
||||
return false;
|
||||
}
|
||||
if (node->sway_container->is_fading_out) {
|
||||
if (!node->sway_container->view->surface) {
|
||||
return false;
|
||||
}
|
||||
if (node->destroying) {
|
||||
|
|
|
@ -281,7 +281,7 @@ static void handle_seat_node_destroy(struct wl_listener *listener, void *data) {
|
|||
while (next_focus == NULL && parent != NULL) {
|
||||
struct sway_container *con =
|
||||
seat_get_focus_inactive_view(seat, parent);
|
||||
next_focus = con ? &con->node : NULL;
|
||||
next_focus = (con && !con->node.destroying) ? &con->node : NULL;
|
||||
|
||||
if (next_focus == NULL && parent->type == N_WORKSPACE) {
|
||||
next_focus = parent;
|
||||
|
@ -1080,6 +1080,9 @@ void seat_configure_xcursor(struct sway_seat *seat) {
|
|||
|
||||
bool seat_is_input_allowed(struct sway_seat *seat,
|
||||
struct wlr_surface *surface) {
|
||||
if (surface == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (server.session_lock.locked) {
|
||||
if (server.session_lock.lock == NULL) {
|
||||
return false;
|
||||
|
@ -1097,7 +1100,7 @@ bool seat_is_input_allowed(struct sway_seat *seat,
|
|||
}
|
||||
|
||||
static void send_unfocus(struct sway_container *con, void *data) {
|
||||
if (con->view && !con->is_fading_out) {
|
||||
if (con->view && con->view->surface) {
|
||||
view_set_activated(con->view, false);
|
||||
}
|
||||
}
|
||||
|
@ -1245,7 +1248,7 @@ static void seat_set_workspace_focus(struct sway_seat *seat, struct sway_node *n
|
|||
}
|
||||
|
||||
// Close any popups on the old focus
|
||||
if (last_focus && node_is_view(last_focus) && !last_focus->sway_container->is_fading_out) {
|
||||
if (last_focus && node_is_view(last_focus) && last_focus->sway_container->view->surface) {
|
||||
view_close_popups(last_focus->sway_container->view);
|
||||
}
|
||||
|
||||
|
|
|
@ -571,7 +571,7 @@ static void check_focus_follows_mouse(struct sway_seat *seat,
|
|||
|
||||
// This is where we handle the common case. We don't want to focus inactive
|
||||
// tabs, hence the view_is_visible check.
|
||||
if (node_is_view(hovered_node) && !hovered_node->sway_container->is_fading_out &&
|
||||
if (node_is_view(hovered_node) && hovered_node->sway_container->view->surface &&
|
||||
view_is_visible(hovered_node->sway_container->view)) {
|
||||
// e->previous_node is the node which the cursor was over previously.
|
||||
// If focus_follows_mouse is yes and the cursor got over the view due
|
||||
|
|
|
@ -52,7 +52,7 @@ static int animation_timer(void *data) {
|
|||
wl_event_source_timer_update(con->animation_present_timer, fastest_output_refresh_s * 1000);
|
||||
} else if (is_closing) { // equal to target and closing
|
||||
printf("done animation; clean up view\n");
|
||||
//con->is_fading_out = false;
|
||||
view_remove_container(con->view);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -77,8 +77,6 @@ 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) {
|
||||
c->pending.children = create_list();
|
||||
|
@ -141,7 +139,7 @@ void container_destroy(struct sway_container *con) {
|
|||
|
||||
void container_begin_destroy(struct sway_container *con) {
|
||||
printf("container begin destroy\n");
|
||||
if (con->view && !con->is_fading_out) {
|
||||
if (con->view) {
|
||||
ipc_event_window(con, "close");
|
||||
}
|
||||
// The workspace must have the fullscreen pointer cleared so that the
|
||||
|
@ -229,7 +227,7 @@ static struct sway_container *surface_at_view(struct sway_container *con, double
|
|||
return NULL;
|
||||
}
|
||||
struct sway_view *view = con->view;
|
||||
if (con->is_fading_out) {
|
||||
if (!view->surface) {
|
||||
return NULL;
|
||||
}
|
||||
double view_sx = lx - con->surface_x + view->geometry.x;
|
||||
|
|
|
@ -76,6 +76,25 @@ void view_destroy(struct sway_view *view) {
|
|||
}
|
||||
}
|
||||
|
||||
void view_remove_container(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);
|
||||
} else if (ws) {
|
||||
workspace_consider_destroy(ws);
|
||||
}
|
||||
|
||||
if (root->fullscreen_global) {
|
||||
// Container may have been a child of the root fullscreen container
|
||||
arrange_root();
|
||||
} else if (ws && !ws->node.destroying) {
|
||||
arrange_workspace(ws);
|
||||
workspace_detect_urgent(ws);
|
||||
}
|
||||
}
|
||||
|
||||
void view_begin_destroy(struct sway_view *view) {
|
||||
printf("view begin destroy\n");
|
||||
if (!sway_assert(view->surface == NULL, "Tried to destroy a mapped view")) {
|
||||
|
@ -171,7 +190,7 @@ void view_get_constraints(struct sway_view *view, double *min_width,
|
|||
|
||||
uint32_t view_configure(struct sway_view *view, double lx, double ly, int width,
|
||||
int height) {
|
||||
if (view->impl->configure && !view->container->is_fading_out) {
|
||||
if (view->impl->configure && view->surface) {
|
||||
return view->impl->configure(view, lx, ly, width, height);
|
||||
}
|
||||
return 0;
|
||||
|
@ -430,7 +449,7 @@ void view_set_tiled(struct sway_view *view, bool tiled) {
|
|||
}
|
||||
|
||||
void view_close(struct sway_view *view) {
|
||||
if (view->impl->close && !view->container->is_fading_out) {
|
||||
if (view->impl->close && view->surface) {
|
||||
view->impl->close(view);
|
||||
}
|
||||
}
|
||||
|
@ -914,7 +933,6 @@ void view_unmap(struct sway_view *view) {
|
|||
|
||||
wl_list_remove(&view->surface_new_subsurface.link);
|
||||
|
||||
/*
|
||||
if (view->urgent_timer) {
|
||||
wl_event_source_remove(view->urgent_timer);
|
||||
view->urgent_timer = NULL;
|
||||
|
@ -925,23 +943,14 @@ void view_unmap(struct sway_view *view) {
|
|||
view->foreign_toplevel = NULL;
|
||||
}
|
||||
|
||||
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);
|
||||
} else if (ws) {
|
||||
workspace_consider_destroy(ws);
|
||||
if (!config->animation_duration) {
|
||||
view_remove_container(view);
|
||||
} else {
|
||||
node_set_dirty(&view->container->node);
|
||||
view->container->target_alpha = 0;
|
||||
wl_event_source_timer_update(view->container->animation_present_timer, 50);
|
||||
}
|
||||
|
||||
if (root->fullscreen_global) {
|
||||
// Container may have been a child of the root fullscreen container
|
||||
arrange_root();
|
||||
} else if (ws && !ws->node.destroying) {
|
||||
arrange_workspace(ws);
|
||||
workspace_detect_urgent(ws);
|
||||
}
|
||||
*/
|
||||
// TODO: deactivate input / focus
|
||||
struct sway_seat *seat;
|
||||
wl_list_for_each(seat, &server.input->seats, link) {
|
||||
|
@ -956,10 +965,6 @@ void view_unmap(struct sway_view *view) {
|
|||
seat_consider_warp_to_focus(seat);
|
||||
}
|
||||
|
||||
node_set_dirty(&view->container->node);
|
||||
view->container->is_fading_out = true;
|
||||
view->container->target_alpha = 0;
|
||||
wl_event_source_timer_update(view->container->animation_present_timer, 50);
|
||||
transaction_commit_dirty();
|
||||
view->surface = NULL;
|
||||
}
|
||||
|
|
|
@ -700,7 +700,7 @@ struct blur_region_data {
|
|||
static void find_blurred_region_iterator(struct sway_container *con, void *data) {
|
||||
struct sway_view *view = con->view;
|
||||
// TODO: proper view cleanup
|
||||
if (!view || con->is_fading_out) {
|
||||
if (!view || !view->surface) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue