diff --git a/.github/issue_template.md b/.github/issue_template.md index cf3a39d..b220221 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -10,7 +10,8 @@ // Tell us something about the desktop environment you are using, for example: i3-gaps, Gnome Shell, etc. ### Compton version -// You can run `compton --version` to get that +// Put the output of `compton --version` here. +// If you are running compton v4 or later, please also include the output of `compton --diagnostics` // Example: v1 ### Compton configuration: diff --git a/README.md b/README.md index 714a284..5cde882 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Assuming you already have all the usual building tools installed (e.g. gcc, meso * xcb-randr * xcb-composite * xcb-image +* xcb-present * xcb-xinerama (optional, disable with `-Dxinerama=false` meson configure flag) * pixman * libdbus (optional, disable with the `-Ddbus=false` meson configure flag) diff --git a/meson.build b/meson.build index 07b50ac..dcddd73 100644 --- a/meson.build +++ b/meson.build @@ -37,7 +37,7 @@ endif add_global_arguments('-D_GNU_SOURCE', language: 'c') -warns = [ 'all', 'extra', 'no-unused-parameter', 'nonnull', 'shadow' ] +warns = [ 'all', 'extra', 'no-unused-parameter', 'nonnull', 'shadow', 'implicit-fallthrough' ] foreach w : warns if cc.has_argument('-W'+w) add_global_arguments('-W'+w, language: 'c') diff --git a/src/common.h b/src/common.h index a601b44..56ec7ec 100644 --- a/src/common.h +++ b/src/common.h @@ -436,6 +436,7 @@ typedef struct ev_session_prepare ev_session_prepare; typedef struct options_t { // === Debugging === bool monitor_repaint; + bool print_diagnostics; // === General === /// The configuration file we used. char *config_file; @@ -864,6 +865,8 @@ typedef struct session { int randr_event; /// Error base number for X RandR extension. int randr_error; + /// Whether X Present extension exists. + bool present_exists; #ifdef CONFIG_OPENGL /// Whether X GLX extension exists. bool glx_exists; diff --git a/src/compton.c b/src/compton.c index ab777ed..ce60fe4 100644 --- a/src/compton.c +++ b/src/compton.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -25,6 +26,7 @@ #include "win.h" #include "x.h" #include "config.h" +#include "diagnostic.h" static void finish_destroy_win(session_t *ps, win **_w); @@ -3696,6 +3698,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) { { "reredir-on-root-change", no_argument, NULL, 731 }, { "glx-reinit-on-root-change", no_argument, NULL, 732 }, { "monitor-repaint", no_argument, NULL, 800 }, + { "diagnostics", no_argument, NULL, 801 }, // Must terminate with a NULL entry { NULL, 0, NULL, 0 }, }; @@ -3983,6 +3986,9 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) { P_CASEBOOL(731, reredir_on_root_change); P_CASEBOOL(732, glx_reinit_on_root_change); P_CASEBOOL(800, monitor_repaint); + case 801: + ps->o.print_diagnostics = true; + break; default: usage(1); break; @@ -5050,6 +5056,7 @@ session_init(session_t *ps_old, int argc, char **argv) { xcb_prefetch_extension_data(ps->c, &xcb_xfixes_id); xcb_prefetch_extension_data(ps->c, &xcb_randr_id); xcb_prefetch_extension_data(ps->c, &xcb_xinerama_id); + xcb_prefetch_extension_data(ps->c, &xcb_present_id); ext_info = xcb_get_extension_data(ps->c, &xcb_render_id); if (!ext_info || !ext_info->present) { @@ -5133,16 +5140,24 @@ session_init(session_t *ps_old, int argc, char **argv) { ps->shape_exists = true; } + ext_info = xcb_get_extension_data(ps->c, &xcb_randr_id); + if (ext_info && ext_info->present) { + ps->randr_exists = true; + ps->randr_event = ext_info->first_event; + ps->randr_error = ext_info->first_error; + } + + ext_info = xcb_get_extension_data(ps->c, &xcb_present_id); + if (ext_info && ext_info->present) { + ps->present_exists = true; + } + // Query X RandR if ((ps->o.sw_opti && !ps->o.refresh_rate) || ps->o.xinerama_shadow_crop) { - ext_info = xcb_get_extension_data(ps->c, &xcb_randr_id); - if (ext_info && ext_info->present) { - ps->randr_exists = true; - ps->randr_event = ext_info->first_event; - ps->randr_error = ext_info->first_error; - } else + if (!ps->randr_exists) { printf_errf("(): No XRandR extension, automatic screen change " "detection impossible."); + } } // Query X Xinerama extension @@ -5161,6 +5176,11 @@ session_init(session_t *ps_old, int argc, char **argv) { // of OpenGL context. init_overlay(ps); + if (ps->o.print_diagnostics) { + print_diagnostics(ps); + exit(0); + } + // Initialize OpenGL as early as possible if (bkend_use_glx(ps)) { #ifdef CONFIG_OPENGL diff --git a/src/diagnostic.c b/src/diagnostic.c new file mode 100644 index 0000000..85d971a --- /dev/null +++ b/src/diagnostic.c @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright (c) 2018 Yuxuan Shui + +#include "diagnostic.h" +#include "common.h" + +void print_diagnostics(session_t *ps) { + printf("**Version:** " COMPTON_VERSION "\n"); + //printf("**CFLAGS:** %s\n", "??"); + printf("\n### Extensions:\n\n"); + printf("* Name Pixmap: %s\n", ps->has_name_pixmap ? "Yes" : "No"); + printf("* Shape: %s\n", ps->shape_exists ? "Yes" : "No"); + 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"); +#ifdef __FAST_MATH__ + printf("* Fast Math: Yes\n"); +#endif +} + +// vim: set noet sw=8 ts=8 : diff --git a/src/diagnostic.h b/src/diagnostic.h new file mode 100644 index 0000000..dd5a964 --- /dev/null +++ b/src/diagnostic.h @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright (c) 2018 Yuxuan Shui + +#pragma once + +typedef struct session session_t; + +void print_diagnostics(session_t *); diff --git a/src/meson.build b/src/meson.build index cd24939..e1749e0 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,14 +1,19 @@ -deps = [ cc.find_library('m'), cc.find_library('ev') ] +deps = [ + cc.find_library('m'), + cc.find_library('ev'), + dependency('xcb', version: '>=1.9.2') +] cflags = [ ] -srcs = ['compton.c', 'win.c', 'c2.c', 'x.c', 'config.c'] +srcs = ['compton.c', 'win.c', 'c2.c', 'x.c', 'config.c', 'diagnostic.c'] -required_package =[ +required_package = [ 'x11', 'x11-xcb', 'xcb-renderutil', 'xcb-render', 'xcb-damage', 'xcb-randr', 'xcb-composite', 'xcb-shape', 'xcb-image', - 'xcb-xfixes', 'xext', 'pixman-1'] + 'xcb-xfixes', 'xcb-present', 'xext', 'pixman-1' +] foreach i : required_package deps += [dependency(i, required: true)]