picom: make sure --diagnostics works when another picom is running

Currently picom fails at register_cm(), which is before
print_diagnostics(), so we don't see anything.

This commit makes sure we keep going when there is another compositor
already running. However, in this case we need to be careful to not take
the overlay window, otherwise a poorly implemented compositor (for
example, picom) will stop working.

Also restructured the target window initialization logic and added some
comments explaining the logic.

Fixes #333
This commit is contained in:
Yuxuan Shui
2020-03-11 19:15:26 +00:00
parent 9547d7af70
commit d757d45d1e
4 changed files with 77 additions and 27 deletions

View File

@@ -3,13 +3,15 @@
#include <stdio.h>
#include <xcb/xcb.h>
#include <xcb/composite.h>
#include "backend/driver.h"
#include "diagnostic.h"
#include "config.h"
#include "picom.h"
#include "common.h"
void print_diagnostics(session_t *ps, const char *config_file) {
void print_diagnostics(session_t *ps, const char *config_file, bool compositor_running) {
printf("**Version:** " COMPTON_VERSION "\n");
//printf("**CFLAGS:** %s\n", "??");
printf("\n### Extensions:\n\n");
@@ -17,7 +19,16 @@ void print_diagnostics(session_t *ps, const char *config_file) {
printf("* XRandR: %s\n", ps->randr_exists ? "Yes" : "No");
printf("* Present: %s\n", ps->present_exists ? "Present" : "Not Present");
printf("\n### Misc:\n\n");
printf("* Use Overlay: %s\n", ps->overlay != XCB_NONE ? "Yes" : "No");
printf("* Use Overlay: %s", ps->overlay != XCB_NONE ? "Yes" : "No");
if (ps->overlay == XCB_NONE) {
if (compositor_running) {
printf(" (Another compositor is already running)\n");
} else if (session_redirection_mode(ps) != XCB_COMPOSITE_REDIRECT_MANUAL) {
printf(" (Not in manual redirection mode)\n");
} else {
printf("\n");
}
}
#ifdef __FAST_MATH__
printf("* Fast Math: Yes\n");
#endif