From 6eff9ebf8b8eea8af1dbaa8b17c34417ec9c67f9 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sat, 2 Feb 2019 19:42:05 +0000 Subject: [PATCH] Variable name change win::destroyed to win::destroying, because it make slightly more sense. Signed-off-by: Yuxuan Shui --- src/common.h | 4 ++-- src/compton.c | 27 ++++++++++++++------------- src/dbus.c | 6 +++--- src/win.c | 16 ++++++++-------- src/win.h | 5 +++-- 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/common.h b/src/common.h index abd17252..cfb5977a 100644 --- a/src/common.h +++ b/src/common.h @@ -838,7 +838,7 @@ find_win(session_t *ps, xcb_window_t id) { win *w; for (w = ps->list; w; w = w->next) { - if (w->id == id && !w->destroyed) + if (w->id == id && !w->destroying) return w; } @@ -857,7 +857,7 @@ find_toplevel(session_t *ps, xcb_window_t id) { return NULL; for (win *w = ps->list; w; w = w->next) { - if (w->client_win == id && !w->destroyed) + if (w->client_win == id && !w->destroying) return w; } diff --git a/src/compton.c b/src/compton.c index 66f3ada9..e8346cdb 100644 --- a/src/compton.c +++ b/src/compton.c @@ -610,7 +610,7 @@ paint_preprocess(session_t *ps, win *list) { if (!w->ever_damaged || w->g.x + w->g.width < 1 || w->g.y + w->g.height < 1 || w->g.x >= ps->root_width || w->g.y >= ps->root_height - || ((w->a.map_state == XCB_MAP_STATE_UNMAPPED || w->destroyed) && !w->paint.pixmap) + || ((w->a.map_state == XCB_MAP_STATE_UNMAPPED || w->destroying) && !w->paint.pixmap) || (double) w->opacity / OPAQUE * MAX_ALPHA < 1 || w->paint_excluded) to_paint = false; @@ -680,7 +680,7 @@ paint_preprocess(session_t *ps, win *list) { reg_ignore_valid = reg_ignore_valid && w->reg_ignore_valid; w->reg_ignore_valid = true; - assert(w->destroyed == (w->fade_callback == finish_destroy_win)); + assert(w->destroying == (w->fade_callback == finish_destroy_win)); win_check_fade_finished(ps, &w); // Avoid setting w->to_paint if w is freed @@ -930,7 +930,7 @@ unmap_win(session_t *ps, win **_w) { win *w = *_w; if (!w || w->a.map_state == XCB_MAP_STATE_UNMAPPED) return; - if (w->destroyed) return; + if (w->destroying) return; // Set focus out win_set_focused(ps, w, false); @@ -989,7 +989,7 @@ restack_win(session_t *ps, win *w, xcb_window_t new_above) { // rehook for (prev = &ps->list; *prev; prev = &(*prev)->next) { - if ((*prev)->id == new_above && !(*prev)->destroyed) { + if ((*prev)->id == new_above && !(*prev)->destroying) { found = true; break; } @@ -1024,7 +1024,7 @@ restack_win(session_t *ps, win *w, xcb_window_t new_above) { to_free = ev_window_name(ps, c->id, &window_name); desc = ""; - if (c->destroyed) desc = "(D) "; + if (c->destroying) desc = "(D) "; printf("%#010lx \"%s\" %s", c->id, window_name, desc); if (c->next) printf("-> "); @@ -1161,10 +1161,11 @@ circulate_win(session_t *ps, xcb_circulate_notify_event_t *ce) { restack_win(ps, w, new_above); } +// TODO move to win.c static void finish_destroy_win(session_t *ps, win **_w) { win *w = *_w; - assert(w->destroyed); + assert(w->destroying); win **prev = NULL, *i = NULL; log_trace("(%#010x): Starting...", w->id); @@ -1199,12 +1200,12 @@ static void destroy_win(session_t *ps, xcb_window_t id) { win *w = find_win(ps, id); - log_trace("(%#010x \"%s\"): %p", id, (w ? w->name: NULL), w); + log_trace("%#010x \"%s\": %p", id, (w ? w->name: NULL), w); if (w) { unmap_win(ps, &w); - w->destroyed = true; + w->destroying = true; if (ps->o.no_fading_destroyed_argb) win_determine_fade(ps, w); @@ -3087,18 +3088,18 @@ session_destroy(session_t *ps) { // Free window linked list { win *next = NULL; - for (win *w = ps->list; w; w = next) { - // Must be put here to avoid segfault + win *list = ps->list; + ps->list = NULL; + + for (win *w = list; w; w = next) { next = w->next; - if (w->a.map_state == XCB_MAP_STATE_VIEWABLE && !w->destroyed) + if (w->a.map_state == XCB_MAP_STATE_VIEWABLE && !w->destroying) win_ev_stop(ps, w); free_win_res(ps, w); free(w); } - - ps->list = NULL; } // Free blacklists diff --git a/src/dbus.c b/src/dbus.c index cc79179f..1d36cfbd 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -492,7 +492,7 @@ cdbus_apdarg_wids(session_t *ps, DBusMessage *msg, const void *data) { // Get the number of wids we are to include unsigned count = 0; for (win *w = ps->list; w; w = w->next) { - if (!w->destroyed) + if (!w->destroying) ++count; } @@ -508,7 +508,7 @@ cdbus_apdarg_wids(session_t *ps, DBusMessage *msg, const void *data) { { cdbus_window_t *pcur = arr; for (win *w = ps->list; w; w = w->next) { - if (!w->destroyed) { + if (!w->destroying) { *pcur = w->id; ++pcur; assert(pcur <= arr + count); @@ -811,7 +811,7 @@ cdbus_process_win_get(session_t *ps, DBusMessage *msg) { cdbus_m_win_get_do(mode, cdbus_reply_enum); cdbus_m_win_get_do(client_win, cdbus_reply_wid); cdbus_m_win_get_do(ever_damaged, cdbus_reply_bool); - cdbus_m_win_get_do(destroyed, cdbus_reply_bool); + cdbus_m_win_get_do(destroying, cdbus_reply_bool); cdbus_m_win_get_do(window_type, cdbus_reply_enum); cdbus_m_win_get_do(wmwin, cdbus_reply_bool); cdbus_m_win_get_do(leader, cdbus_reply_wid); diff --git a/src/win.c b/src/win.c index 7af304cd..7cf073a9 100644 --- a/src/win.c +++ b/src/win.c @@ -74,7 +74,7 @@ group_update_focused(session_t *ps, xcb_window_t leader) { return; for (win *w = ps->list; w; w = w->next) { - if (win_get_leader(ps, w) == leader && !w->destroyed) + if (win_get_leader(ps, w) == leader && !w->destroying) win_update_focused(ps, w); } @@ -93,7 +93,7 @@ group_is_focused(session_t *ps, xcb_window_t leader) { return false; for (win *w = ps->list; w; w = w->next) { - if (win_get_leader(ps, w) == leader && !w->destroyed + if (win_get_leader(ps, w) == leader && !w->destroying && win_is_focused_real(ps, w)) return true; } @@ -329,7 +329,7 @@ void win_determine_mode(session_t *ps, win *w) { void win_calc_opacity(session_t *ps, win *w) { opacity_t opacity = OPAQUE; - if (w->destroyed || w->a.map_state != XCB_MAP_STATE_VIEWABLE) + if (w->destroying || w->a.map_state != XCB_MAP_STATE_VIEWABLE) opacity = 0; else { // Try obeying opacity property and window type opacity firstly @@ -360,8 +360,8 @@ void win_calc_opacity(session_t *ps, win *w) { void win_calc_dim(session_t *ps, win *w) { bool dim; - // Make sure we do nothing if the window is unmapped / destroyed - if (w->destroyed || w->a.map_state != XCB_MAP_STATE_VIEWABLE) + // Make sure we do nothing if the window is unmapped / being destroyed + if (w->destroying || w->a.map_state != XCB_MAP_STATE_VIEWABLE) return; if (ps->o.inactive_dim && !(w->focused)) { @@ -386,7 +386,7 @@ void win_determine_fade(session_t *ps, win *w) { w->fade_last = w->fade = w->fade_force; else if (ps->o.no_fading_openclose && w->in_openclose) w->fade_last = w->fade = false; - else if (ps->o.no_fading_destroyed_argb && w->destroyed && + else if (ps->o.no_fading_destroyed_argb && w->destroying && win_has_alpha(w) && w->client_win && w->client_win != w->id) { w->fade_last = w->fade = false; } @@ -756,7 +756,7 @@ bool add_win(session_t *ps, xcb_window_t id, xcb_window_t prev) { .widthb = 0, .heightb = 0, - .destroyed = false, + .destroying = false, .bounding_shaped = false, .rounded_corners = false, .to_paint = false, @@ -831,7 +831,7 @@ bool add_win(session_t *ps, xcb_window_t id, xcb_window_t prev) { win **p = NULL; if (prev) { for (p = &ps->list; *p; p = &(*p)->next) { - if ((*p)->id == prev && !(*p)->destroyed) + if ((*p)->id == prev && !(*p)->destroying) break; } } else { diff --git a/src/win.h b/src/win.h index 39a3eedc..a2841e2d 100644 --- a/src/win.h +++ b/src/win.h @@ -130,8 +130,9 @@ struct win { bool reg_ignore_valid; /// Cached width/height of the window including border. int widthb, heightb; - /// Whether the window has been destroyed. - bool destroyed; + /// Whether the window is being destroyed. This being true means destroy_win + /// is called, but window might still need to be faded out + bool destroying; /// Whether the window is bounding-shaped. bool bounding_shaped; /// Whether the window just have rounded corners.