1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2025-04-14 17:53:25 -04:00

wm/win: remove WIN_FLAGS_PIXMAP_NONE

The way we set and use it, it's completely equivalent to checking if
w->win_image == NULL. So it's redundant.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2024-06-27 11:08:47 +01:00
parent 6cbd94ed62
commit a2ddda3ab5
No known key found for this signature in database
GPG key ID: D3A4405BE6CC17F4
3 changed files with 11 additions and 23 deletions

View file

@ -50,8 +50,6 @@ enum win_flags {
/// pixmap is out of date, will be update in win_process_flags
WIN_FLAGS_PIXMAP_STALE = 1,
/// window does not have pixmap bound
WIN_FLAGS_PIXMAP_NONE = 2,
/// there was an error trying to bind the images
WIN_FLAGS_IMAGE_ERROR = 4,
/// the client window needs to be updated

View file

@ -310,13 +310,10 @@ void add_damage_from_win(session_t *ps, const struct win *w) {
/// Release the images attached to this window
static inline void win_release_pixmap(backend_t *base, struct win *w) {
log_debug("Releasing pixmap of window %#010x (%s)", win_id(w), w->name);
assert(w->win_image);
if (w->win_image) {
xcb_pixmap_t pixmap = XCB_NONE;
pixmap = base->ops.release_image(base, w->win_image);
w->win_image = NULL;
// Bypassing win_set_flags, because `w` might have been destroyed
w->flags |= WIN_FLAGS_PIXMAP_NONE;
if (pixmap != XCB_NONE) {
xcb_free_pixmap(base->c->c, pixmap);
}
@ -366,7 +363,6 @@ static inline bool win_bind_pixmap(struct backend_base *b, struct win *w) {
return false;
}
win_clear_flags(w, WIN_FLAGS_PIXMAP_NONE);
return true;
}
@ -374,12 +370,9 @@ void win_release_images(struct backend_base *backend, struct win *w) {
// We don't want to decide what we should do if the image we want to
// release is stale (do we clear the stale flags or not?) But if we are
// not releasing any images anyway, we don't care about the stale flags.
assert(w->win_image == NULL || !win_check_flags_all(w, WIN_FLAGS_PIXMAP_STALE));
if (!win_check_flags_all(w, WIN_FLAGS_PIXMAP_NONE)) {
assert(!win_check_flags_all(w, WIN_FLAGS_PIXMAP_STALE));
win_release_pixmap(backend, w);
}
win_release_pixmap(backend, w);
win_release_shadow(backend, w);
win_release_mask(backend, w);
}
@ -583,11 +576,10 @@ void win_process_image_flags(session_t *ps, struct win *w) {
// otherwise we won't be able to rebind pixmap after
// releasing it, yet we might still need the pixmap for
// rendering.
if (!win_check_flags_all(w, WIN_FLAGS_PIXMAP_NONE)) {
// Must release images first, otherwise breaks
// NVIDIA driver
win_release_pixmap(ps->backend_data, w);
}
// Must release images first, otherwise breaks
// NVIDIA driver
win_release_pixmap(ps->backend_data, w);
win_bind_pixmap(ps->backend_data, w);
}
@ -846,9 +838,7 @@ void unmap_win_finish(session_t *ps, struct win *w) {
if (ps->backend_data) {
// Only the pixmap needs to be freed and reacquired when mapping.
// Shadow image can be preserved.
if (!win_check_flags_all(w, WIN_FLAGS_PIXMAP_NONE)) {
win_release_pixmap(ps->backend_data, w);
}
win_release_pixmap(ps->backend_data, w);
} else {
assert(!w->win_image);
assert(!w->shadow_image);
@ -1390,9 +1380,9 @@ struct win *win_maybe_allocate(session_t *ps, struct wm_ref *cursor) {
.frame_opacity = 1.0,
.in_openclose = true, // set to false after first map is done,
// true here because window is just created
.flags = WIN_FLAGS_PIXMAP_NONE, // updated by
// property/attributes/etc
// change
.flags = 0, // updated by
// property/attributes/etc
// change
// Runtime variables, updated by dbus
.fade_force = UNSET,

View file

@ -355,7 +355,7 @@ void win_destroy_start(session_t *ps, struct win *w);
void win_map_start(struct win *w);
/// Release images bound with a window, set the *_NONE flags on the window. Only to be
/// used when de-initializing the backend outside of win.c
void win_release_images(struct backend_base *base, struct win *w);
void win_release_images(struct backend_base *backend, struct win *w);
winmode_t attr_pure win_calc_mode_raw(const struct win *w);
// TODO(yshui) `win_calc_mode` is only used by legacy backends
winmode_t attr_pure win_calc_mode(const struct win *w);