Add --diagnostics option

It will cause compton to print out some rudimentary diagnostics.

Also small improvements of the meson.build.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2018-11-03 22:15:38 +00:00
parent e142993bb5
commit 332a873729
8 changed files with 72 additions and 12 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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')

View File

@ -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;

View File

@ -12,6 +12,7 @@
#include <ctype.h>
#include <string.h>
#include <xcb/randr.h>
#include <xcb/present.h>
#include <xcb/damage.h>
#include <xcb/render.h>
#include <xcb/xcb_image.h>
@ -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,17 +5140,25 @@ session_init(session_t *ps_old, int argc, char **argv) {
ps->shape_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
}
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) {
if (!ps->randr_exists) {
printf_errf("(): No XRandR extension, automatic screen change "
"detection impossible.");
}
}
// Query X Xinerama extension
if (ps->o.xinerama_shadow_crop) {
@ -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

22
src/diagnostic.c Normal file
View File

@ -0,0 +1,22 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2018 Yuxuan Shui <yshuiv7@gmail.com>
#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 :

8
src/diagnostic.h Normal file
View File

@ -0,0 +1,8 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2018 Yuxuan Shui <yshuiv7@gmail.com>
#pragma once
typedef struct session session_t;
void print_diagnostics(session_t *);

View File

@ -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 = [
'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)]