Skip to content

Commit

Permalink
core: move debug window initialization to after root geometry query
Browse files Browse the repository at this point in the history
Signed-off-by: Yuxuan Shui <[email protected]>
  • Loading branch information
yshui committed Jun 27, 2024
1 parent 13959bc commit 779d042
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions src/picom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,8 @@ static void handle_new_window_attributes_reply(struct x_connection * /*c*/,

auto toplevel = wm_ref_toplevel_of(ps->wm, new_window);
if (toplevel != new_window) {
log_debug("Newly created window %#010x was moved away from toplevel while "
log_debug("Newly created window %#010x was moved away from toplevel "
"while "
"we were waiting for its attributes",
wid);
return;
Expand Down Expand Up @@ -2286,8 +2287,6 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
goto err;
}

rebuild_screen_reg(ps);

bool compositor_running = false;
if (session_redirection_mode(ps) == XCB_COMPOSITE_REDIRECT_MANUAL) {
// We are running in the manual redirection mode, meaning we are running
Expand All @@ -2299,44 +2298,10 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
// Create registration window
int ret = register_cm(ps);
if (ret == -1) {
exit(1);
goto err;
}

compositor_running = ret == 1;
if (compositor_running) {
// Don't take the overlay when there is another compositor
// running, so we don't disrupt it.

// If we are printing diagnostic, we will continue a bit further
// to get more diagnostic information, otherwise we will exit.
if (!ps->o.print_diagnostics) {
log_fatal("Another composite manager is already running");
exit(1);
}
} else {
if (!init_overlay(ps)) {
goto err;
}
}
} else {
// We are here if we don't really function as a compositor, so we are not
// taking over the screen, and we don't need to register as a compositor

// If we are in debug mode, we need to create a window for rendering if
// the backend supports presenting.

// The old backends doesn't have a automatic redirection mode
log_info("The compositor is started in automatic redirection mode.");
assert(!ps->o.use_legacy_backends);

if (backend_can_present(ps->o.backend)) {
// If the backend has `present`, we couldn't be in automatic
// redirection mode unless we are in debug mode.
assert(ps->o.debug_mode);
if (!init_debug_window(ps)) {
goto err;
}
}
}

ps->drivers = detect_driver(ps->c.c, ps->backend_data, ps->c.screen_info->root);
Expand Down Expand Up @@ -2478,6 +2443,41 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
exit(1);
}

if (session_redirection_mode(ps) == XCB_COMPOSITE_REDIRECT_MANUAL && compositor_running) {
// Don't take the overlay when there is another compositor
// running, so we don't disrupt it.

// If we are printing diagnostic, we will continue a bit further
// to get more diagnostic information, otherwise we will exit.
log_fatal("Another composite manager is already running");
goto err;
}

if (session_redirection_mode(ps) == XCB_COMPOSITE_REDIRECT_MANUAL && !init_overlay(ps)) {
goto err;
}

if (session_redirection_mode(ps) == XCB_COMPOSITE_REDIRECT_AUTOMATIC) {
// We are here if we don't really function as a compositor, so we are not
// taking over the screen, and we don't need to register as a compositor

// If we are in debug mode, we need to create a window for rendering if
// the backend supports presenting.

// The old backends doesn't have a automatic redirection mode
log_info("The compositor is started in automatic redirection mode.");
assert(!ps->o.use_legacy_backends);

if (backend_can_present(ps->o.backend)) {
// If the backend has `present`, we couldn't be in automatic
// redirection mode unless we are in debug mode.
assert(ps->o.debug_mode);
if (!init_debug_window(ps)) {
goto err;
}
}
}

ps->pending_updates = true;

write_pid(ps);
Expand Down

0 comments on commit 779d042

Please sign in to comment.