core: reuse handle_new_window for pre-existing windows

Reduce code duplication, also handle_new_window handles damage of mapped
windows properly.

Fixes #160

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-04-27 14:25:10 +01:00
parent 1b00eeaf60
commit f50428a18b
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
1 changed files with 2 additions and 19 deletions

View File

@ -2005,30 +2005,13 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
} }
for (int i = 0; i < nchildren; i++) { for (int i = 0; i < nchildren; i++) {
auto w =
add_win_above(ps, children[i], i ? children[i - 1] : XCB_NONE); add_win_above(ps, children[i], i ? children[i - 1] : XCB_NONE);
fill_win(ps, w);
} }
free(reply); free(reply);
HASH_ITER2(ps->windows, w) {
assert(!w->is_new);
if (!w->managed) {
continue;
}
auto mw = (struct managed_win *)w;
if (mw->a.map_state == XCB_MAP_STATE_VIEWABLE) {
map_win(ps, mw);
// This is a pre-existing window, we have no idea if it's
// ever damaged, so assume conservatively that it is.
mw->ever_damaged = true;
}
}
log_trace("Initial stack:"); log_trace("Initial stack:");
list_foreach(struct win, w, &ps->window_stack, stack_neighbour) { list_foreach(struct win, w, &ps->window_stack, stack_neighbour) {
log_trace("%#010x \"%s\"", w->id, log_trace("%#010x", w->id);
w->managed ? ((struct managed_win *)w)->name : "(null)");
} }
} }