mirror of
https://github.com/yshui/picom.git
synced 2024-11-11 13:51:02 -05:00
Remove several unnecessary experimental_backends check
Window flags can be set whichever backend we use, we will ignore then in paint_preprocess. free_paint can be called whichever backend we use, they just do nothing if we use experimental backends. Others should rather just check if backend_data is NULL. Making the code slightly more understandable, also making the eventual removal of these checks easier. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
5a8b82f537
commit
7ca843eeeb
2 changed files with 55 additions and 55 deletions
|
@ -475,6 +475,11 @@ static struct managed_win *paint_preprocess(session_t *ps, bool *fade_running) {
|
||||||
rc_region_unref(&w->reg_ignore);
|
rc_region_unref(&w->reg_ignore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear flags if we are not using experimental backends
|
||||||
|
if (!ps->o.experimental_backends) {
|
||||||
|
w->flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// log_trace("%d %d %s", w->a.map_state, w->ever_damaged, w->name);
|
// log_trace("%d %d %s", w->a.map_state, w->ever_damaged, w->name);
|
||||||
|
|
||||||
// Give up if it's not damaged or invisible, or it's unmapped and its
|
// Give up if it's not damaged or invisible, or it's unmapped and its
|
||||||
|
@ -700,7 +705,7 @@ static void destroy_backend(session_t *ps) {
|
||||||
if (!w) {
|
if (!w) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ps->o.experimental_backends) {
|
if (ps->backend_data) {
|
||||||
if (w->state == WSTATE_MAPPED) {
|
if (w->state == WSTATE_MAPPED) {
|
||||||
win_release_image(ps->backend_data, w);
|
win_release_image(ps->backend_data, w);
|
||||||
} else {
|
} else {
|
||||||
|
@ -712,12 +717,11 @@ static void destroy_backend(session_t *ps) {
|
||||||
ps->root_image);
|
ps->root_image);
|
||||||
ps->root_image = NULL;
|
ps->root_image = NULL;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
free_paint(ps, &w->paint);
|
free_paint(ps, &w->paint);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (ps->o.experimental_backends) {
|
if (ps->backend_data) {
|
||||||
// deinit backend
|
// deinit backend
|
||||||
ps->backend_data->ops->deinit(ps->backend_data);
|
ps->backend_data->ops->deinit(ps->backend_data);
|
||||||
ps->backend_data = NULL;
|
ps->backend_data = NULL;
|
||||||
|
@ -762,16 +766,19 @@ void configure_root(session_t *ps, int width, int height) {
|
||||||
log_info("Root configuration changed, new geometry: %dx%d", width, height);
|
log_info("Root configuration changed, new geometry: %dx%d", width, height);
|
||||||
// On root window changes
|
// On root window changes
|
||||||
bool has_root_change = false;
|
bool has_root_change = false;
|
||||||
if (ps->o.experimental_backends && ps->redirected) {
|
if (ps->o.experimental_backends) {
|
||||||
has_root_change = ps->backend_data->ops->root_change != NULL;
|
has_root_change = ps->backend_data->ops->root_change != NULL;
|
||||||
|
} else {
|
||||||
|
// Old backend can handle root change
|
||||||
|
has_root_change = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!has_root_change) {
|
if (!has_root_change) {
|
||||||
// deinit/reinit backend and free up resources if the backend
|
// deinit/reinit backend and free up resources if the backend
|
||||||
// cannot handle root change
|
// cannot handle root change
|
||||||
destroy_backend(ps);
|
destroy_backend(ps);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
free_paint(ps, &ps->tgt_buffer);
|
free_paint(ps, &ps->tgt_buffer);
|
||||||
}
|
|
||||||
|
|
||||||
ps->root_width = width;
|
ps->root_width = width;
|
||||||
ps->root_height = height;
|
ps->root_height = height;
|
||||||
|
@ -796,9 +803,11 @@ void configure_root(session_t *ps, int width, int height) {
|
||||||
glx_on_root_change(ps);
|
glx_on_root_change(ps);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (ps->o.experimental_backends && ps->redirected) {
|
|
||||||
if (has_root_change) {
|
if (has_root_change) {
|
||||||
|
if (ps->backend_data != NULL) {
|
||||||
ps->backend_data->ops->root_change(ps->backend_data, ps);
|
ps->backend_data->ops->root_change(ps->backend_data, ps);
|
||||||
|
}
|
||||||
|
// Old backend's root_change is not a specific function
|
||||||
} else {
|
} else {
|
||||||
if (!initialize_backend(ps)) {
|
if (!initialize_backend(ps)) {
|
||||||
log_fatal("Failed to re-initialize backend after root "
|
log_fatal("Failed to re-initialize backend after root "
|
||||||
|
@ -811,7 +820,6 @@ void configure_root(session_t *ps, int width, int height) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
force_repaint(ps);
|
force_repaint(ps);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -900,7 +908,7 @@ void root_damaged(session_t *ps) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps->o.experimental_backends) {
|
if (ps->backend_data) {
|
||||||
if (ps->root_image) {
|
if (ps->root_image) {
|
||||||
ps->backend_data->ops->release_image(ps->backend_data, ps->root_image);
|
ps->backend_data->ops->release_image(ps->backend_data, ps->root_image);
|
||||||
}
|
}
|
||||||
|
@ -1295,6 +1303,7 @@ static bool redir_start(session_t *ps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps->o.experimental_backends) {
|
if (ps->o.experimental_backends) {
|
||||||
|
assert(ps->backend_data);
|
||||||
ps->ndamage = ps->backend_data->ops->max_buffer_age;
|
ps->ndamage = ps->backend_data->ops->max_buffer_age;
|
||||||
} else {
|
} else {
|
||||||
ps->ndamage = maximum_buffer_age(ps);
|
ps->ndamage = maximum_buffer_age(ps);
|
||||||
|
|
21
src/win.c
21
src/win.c
|
@ -550,7 +550,7 @@ void win_set_shadow(session_t *ps, struct managed_win *w, bool shadow_new) {
|
||||||
|
|
||||||
log_debug("Updating shadow property of window %#010x (%s) to %d", w->base.id,
|
log_debug("Updating shadow property of window %#010x (%s) to %d", w->base.id,
|
||||||
w->name, shadow_new);
|
w->name, shadow_new);
|
||||||
if (ps->o.experimental_backends && ps->redirected &&
|
if (ps->backend_data &&
|
||||||
w->state != WSTATE_UNMAPPED && !(w->flags & WIN_FLAGS_IMAGE_ERROR)) {
|
w->state != WSTATE_UNMAPPED && !(w->flags & WIN_FLAGS_IMAGE_ERROR)) {
|
||||||
assert(!w->shadow_image);
|
assert(!w->shadow_image);
|
||||||
// Create shadow image
|
// Create shadow image
|
||||||
|
@ -783,17 +783,15 @@ void win_on_win_size_change(session_t *ps, struct managed_win *w) {
|
||||||
w->shadow_dy = ps->o.shadow_offset_y;
|
w->shadow_dy = ps->o.shadow_offset_y;
|
||||||
w->shadow_width = w->widthb + ps->o.shadow_radius * 2;
|
w->shadow_width = w->widthb + ps->o.shadow_radius * 2;
|
||||||
w->shadow_height = w->heightb + ps->o.shadow_radius * 2;
|
w->shadow_height = w->heightb + ps->o.shadow_radius * 2;
|
||||||
|
|
||||||
// Invalidate the shadow we built
|
// Invalidate the shadow we built
|
||||||
if (ps->o.experimental_backends && ps->redirected) {
|
|
||||||
if (w->state == WSTATE_MAPPED || w->state == WSTATE_MAPPING ||
|
if (w->state == WSTATE_MAPPED || w->state == WSTATE_MAPPING ||
|
||||||
w->state == WSTATE_FADING) {
|
w->state == WSTATE_FADING) {
|
||||||
w->flags |= WIN_FLAGS_IMAGE_STALE;
|
w->flags |= WIN_FLAGS_IMAGE_STALE;
|
||||||
} else {
|
} else {
|
||||||
assert(w->state == WSTATE_UNMAPPED);
|
assert(w->state == WSTATE_UNMAPPED);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
free_paint(ps, &w->shadow_paint);
|
free_paint(ps, &w->shadow_paint);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1448,19 +1446,15 @@ void win_update_bounding_shape(session_t *ps, struct managed_win *w) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Window shape changed, we should free old wpaint and shadow pict
|
// Window shape changed, we should free old wpaint and shadow pict
|
||||||
if (ps->o.experimental_backends) {
|
|
||||||
// log_trace("free out dated pict");
|
// log_trace("free out dated pict");
|
||||||
// Window shape changed, we should free win_data
|
if (w->state != WSTATE_UNMAPPED) {
|
||||||
if (ps->redirected && w->state != WSTATE_UNMAPPED) {
|
|
||||||
// Note we only do this when screen is redirected, because
|
// Note we only do this when screen is redirected, because
|
||||||
// otherwise win_data is not valid
|
// otherwise win_data is not valid
|
||||||
assert(w->state != WSTATE_UNMAPPING && w->state != WSTATE_DESTROYING);
|
assert(w->state != WSTATE_UNMAPPING && w->state != WSTATE_DESTROYING);
|
||||||
w->flags |= WIN_FLAGS_IMAGE_STALE;
|
w->flags |= WIN_FLAGS_IMAGE_STALE;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
free_paint(ps, &w->paint);
|
free_paint(ps, &w->paint);
|
||||||
free_paint(ps, &w->shadow_paint);
|
free_paint(ps, &w->shadow_paint);
|
||||||
}
|
|
||||||
|
|
||||||
win_on_factor_change(ps, w);
|
win_on_factor_change(ps, w);
|
||||||
}
|
}
|
||||||
|
@ -1557,15 +1551,12 @@ static void finish_unmap_win(session_t *ps, struct managed_win **_w) {
|
||||||
w->reg_ignore_valid = false;
|
w->reg_ignore_valid = false;
|
||||||
w->state = WSTATE_UNMAPPED;
|
w->state = WSTATE_UNMAPPED;
|
||||||
|
|
||||||
if (ps->o.experimental_backends) {
|
// We are in unmap_win, this window definitely was viewable
|
||||||
// We are in unmap_win, we definitely was viewable
|
if (ps->backend_data) {
|
||||||
if (ps->redirected) {
|
|
||||||
win_release_image(ps->backend_data, w);
|
win_release_image(ps->backend_data, w);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
free_paint(ps, &w->paint);
|
free_paint(ps, &w->paint);
|
||||||
free_paint(ps, &w->shadow_paint);
|
free_paint(ps, &w->shadow_paint);
|
||||||
}
|
|
||||||
|
|
||||||
w->flags = 0;
|
w->flags = 0;
|
||||||
}
|
}
|
||||||
|
@ -1898,7 +1889,7 @@ void map_win(session_t *ps, struct managed_win *w) {
|
||||||
w->flags &= ~WIN_FLAGS_IMAGE_STALE;
|
w->flags &= ~WIN_FLAGS_IMAGE_STALE;
|
||||||
|
|
||||||
// Bind image after update_bounding_shape, so the shadow has the correct size.
|
// Bind image after update_bounding_shape, so the shadow has the correct size.
|
||||||
if (ps->redirected && ps->o.experimental_backends) {
|
if (ps->backend_data) {
|
||||||
if (!win_bind_image(ps, w)) {
|
if (!win_bind_image(ps, w)) {
|
||||||
w->flags |= WIN_FLAGS_IMAGE_ERROR;
|
w->flags |= WIN_FLAGS_IMAGE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue