Skip to content

Commit d907e31

Browse files
committed
Merge branch 'next'
2 parents 3bf86b3 + d45ed14 commit d907e31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+5371
-3577
lines changed

.circleci/config.yml

+51-22
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
defaults: &defaults
2-
docker:
3-
- image: yshui/comptonci
4-
cached-checkout: &ccheckout
5-
just-build: &build
1+
executors:
2+
e:
3+
docker:
4+
- image: yshui/comptonci
5+
working_directory: "/tmp/workspace"
6+
environment:
7+
UBSAN_OPTIONS: "halt_on_error=1"
68

79
version: 2.1
810
commands:
911
build:
1012
parameters:
1113
build-config:
1214
type: string
13-
default:
15+
default: ""
1416
cc:
1517
type: string
1618
default: cc
@@ -27,10 +29,10 @@ commands:
2729
- ".git"
2830
- run:
2931
name: config
30-
command: CC=<< parameters.cc >> meson << parameters.build-config >> --werror . build
32+
command: CC=<< parameters.cc >> meson << parameters.build-config >> -Dunittest=true --werror . build
3133
- run:
3234
name: build
33-
command: ninja -C build
35+
command: ninja -vC build
3436
test-xvfb:
3537
steps:
3638
- run:
@@ -40,48 +42,72 @@ commands:
4042

4143
jobs:
4244
basic:
43-
<<: *defaults
45+
executor: e
4446
steps:
4547
- build:
46-
build-config: -Dbuild_docs=true
48+
build-config: -Dbuild_docs=true -Db_coverage=true
49+
- persist_to_workspace:
50+
root: .
51+
paths:
52+
- .
53+
test:
54+
executor: e
55+
steps:
56+
- attach_workspace:
57+
at: /tmp/workspace
58+
- run:
59+
name: unit test
60+
command: ninja -vC build test
61+
- run:
62+
name: test config file parsing
63+
command: xvfb-run -s "-screen 0 640x480x24" build/src/compton --config compton.sample.conf --vsync=none --diagnostics
64+
- run:
65+
name: generate coverage reports
66+
command: cd build; find -name '*.gcno' -exec gcov -pb {} +
67+
- run:
68+
name: download codecov scripts
69+
command: curl -s https://codecov.io/bash > codecov.sh
70+
- run:
71+
name: upload coverage reports
72+
command: bash ./codecov.sh -X gcov
73+
4774
minimal:
48-
<<: *defaults
75+
executor: e
4976
steps:
5077
- build:
5178
build-config: -Dopengl=false -Ddbus=false -Dregex=false -Dconfig_file=false
5279
nogl:
53-
<<: *defaults
80+
executor: e
5481
steps:
5582
- build:
5683
build-config: -Dopengl=false
5784
noregex:
58-
<<: *defaults
85+
executor: e
5986
steps:
6087
- build:
6188
build-config: -Dregex=false
6289
clang_basic:
63-
<<: *defaults
90+
executor: e
6491
steps:
6592
- build:
66-
cc: clang-6.0
67-
build-config:
93+
cc: clang
6894
clang_minimal:
69-
<<: *defaults
95+
executor: e
7096
steps:
7197
- build:
72-
cc: clang-6.0
98+
cc: clang
7399
build-config: -Dopengl=false -Ddbus=false -Dregex=false -Dconfig_file=false
74100
clang_nogl:
75-
<<: *defaults
101+
executor: e
76102
steps:
77103
- build:
78-
cc: clang-6.0
104+
cc: clang
79105
build-config: -Dopengl=false
80106
clang_noregex:
81-
<<: *defaults
107+
executor: e
82108
steps:
83109
- build:
84-
cc: clang-6.0
110+
cc: clang
85111
build-config: -Dregex=false
86112

87113
workflows:
@@ -93,6 +119,9 @@ workflows:
93119
- clang_minimal
94120
- nogl
95121
- clang_nogl
122+
- test:
123+
requires:
124+
- basic
96125
# - test-xvfb
97126

98127
# vim: set sw=2 ts=8 et:

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "subprojects/test.h"]
2+
path = subprojects/test.h
3+
url = https://github.com/yshui/test.h

README.md

+35-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,21 @@ We also try to fix bugs.
99

1010
The original README can be found [here](README_orig.md)
1111

12-
## Changelog
12+
## Call for testers
13+
14+
### `--experimental-backends`
15+
16+
This flag enables the refactored/partially rewritten backends.
17+
18+
Currently new backends features better vsync with the xrender backend, improved input lag with the glx backend (for non-NVIDIA users). The performance should be on par with the old backends.
19+
20+
New backend features will only be implemented on the new backends from now on, and the old backends will eventually be phased out after the new backends stabilizes.
21+
22+
To test the new backends, add the `--experimental-backends` flag to the command line you used to run compton. This flag is not available from the configuration file.
23+
24+
To report issues with the new backends, please state explicitly you are using the new backends in your report.
25+
26+
## Change Log
1327

1428
See [Releases](https://github.com/yshui/compton/releases)
1529

@@ -33,26 +47,43 @@ Assuming you already have all the usual building tools installed (e.g. gcc, meso
3347
* xcb-composite
3448
* xcb-image
3549
* xcb-present
36-
* xcb-xinerama (optional, disable with the `-Dxinerama=false` meson configure flag)
50+
* xcb-xinerama
3751
* pixman
3852
* libdbus (optional, disable with the `-Ddbus=false` meson configure flag)
3953
* libconfig (optional, disable with the `-Dconfig_file=false` meson configure flag)
4054
* libxdg-basedir (optional, disable with the `-Dconfig_file=false` meson configure flag)
4155
* libGL (optional, disable with the `-Dopengl=false` meson configure flag)
4256
* libpcre (optional, disable with the `-Dregex=false` meson configure flag)
4357
* libev
58+
* uthash
4459

4560
To build the documents, you need `asciidoc`
4661

4762
### To build
4863

4964
```bash
65+
$ git submodule update --init --recursive
5066
$ meson --buildtype=release . build
5167
$ ninja -C build
5268
```
5369

5470
Built binary can be found in `build/src`
5571

72+
If you have libraries and/or headers installed at non-default location (e.g. under `/usr/local/`), you might need to tell meson about them, since meson doesn't look for dependencies there by default.
73+
74+
You can do that by setting the `CPPFLAGS` and `LDFLAGS` environment variables when running `meson`. Like this:
75+
76+
```bash
77+
$ LDFLAGS="-L/path/to/libraries" CPPFLAGS="-I/path/to/headers" meson --buildtype=release . build
78+
79+
```
80+
81+
As an example, on FreeBSD, you might have to run meson with:
82+
```bash
83+
$ LDFLAGS="-L/usr/local/include" CPPFLAGS="-I/usr/local/include" meson --buildtype=release . build
84+
$ ninja -C build
85+
```
86+
5687
### To install
5788

5889
``` bash
@@ -71,6 +102,8 @@ You can look at the [Projects](https://github.com/yshui/compton/projects) page,
71102

72103
Even if you don't want to contribute code, you can still contribute by compiling and running this branch, and report any issue you can find.
73104

105+
Contributions to the documents and wiki will also be appreciated.
106+
74107
## Contributors
75108

76109
See [CONTRIBUTORS](CONTRIBUTORS)

dbus-examples/cdbus-driver.sh

-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ type_enum='uint16'
2525
# List all window ID compton manages (except destroyed ones)
2626
dbus-send --print-reply --dest="$service" "$object" "${interface}.list_win"
2727

28-
# Ensure we are tracking focus
29-
dbus-send --print-reply --dest="$service" "$object" "${interface}.opts_set" string:track_focus boolean:true
30-
3128
# Get window ID of currently focused window
3229
focused=$(dbus-send --print-reply --dest="$service" "$object" "${interface}.find_win" string:focused | $SED -n 's/^[[:space:]]*'${type_win}'[[:space:]]*\([[:digit:]]*\).*/\1/p')
3330

dbus-examples/inverter.sh

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ if [ -z "$1" -o "$1" = "selected" ]; then
4343
window=$(xwininfo -frame | sed -n 's/^xwininfo: Window id: \(0x[[:xdigit:]][[:xdigit:]]*\).*/\1/p') # Select window by mouse
4444
elif [ "$1" = "focused" ]; then
4545
# Ensure we are tracking focus
46-
${compton_dbus}opts_set string:track_focus boolean:true &
4746
window=$(${compton_dbus}find_win string:focused | $SED -n 's/^[[:space:]]*'${type_win}'[[:space:]]*\([[:digit:]]*\).*/\1/p') # Query compton for the active window
4847
elif echo "$1" | grep -Eiq '^([[:digit:]][[:digit:]]*|0x[[:xdigit:]][[:xdigit:]]*)$'; then
4948
window="$1" # Accept user-specified window-id if the format is correct

man/compton.1.asciidoc

+36-4
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ OPTIONS
7171
Daemonize process. Fork to background after initialization. Causes issues with certain (badly-written) drivers.
7272

7373
*--log-level*::
74-
Set the log level. Possible values are "TRACE", "DEBUG", "INFO", "WARN", "ERROR", in increasing level of importance. Case doesn't matter.
74+
Set the log level. Possible values are "TRACE", "DEBUG", "INFO", "WARN", "ERROR", in increasing level of importance. Case doesn't matter. If using the "TRACE" log level, it's better to log into a file using *--log-file*, since it can generate a huge stream of logs.
7575

7676
*--log-file*::
7777
Set the log file. If *--log-file* is never specified, logs will be written to stderr. Otherwise, logs will to written to the given file, though some of the early logs might still be written to the stderr. When setting this option from the config file, it is recommended to use an absolute path.
@@ -169,6 +169,9 @@ OPTIONS
169169
*--detect-client-leader*::
170170
Use 'WM_CLIENT_LEADER' to group windows, and consider windows in the same group focused at the same time. 'WM_TRANSIENT_FOR' has higher priority if *--detect-transient* is enabled, too.
171171

172+
*--blur-method, --blur-size, --blur-deviation*::
173+
Parameters for background blurring, see the *BLUR* section for more information.
174+
172175
*--blur-background*::
173176
Blur background of semi-transparent / ARGB windows. Bad in performance, with driver-dependent behavior. The name of the switch may change without prior notifications.
174177

@@ -187,9 +190,9 @@ WIDTH,HEIGHT,ELE1,ELE2,ELE3,ELE4,ELE5...
187190
+
188191
In other words, the matrix is formatted as a list of comma separated numbers. The first two numbers must be integers, which specify the width and height of the matrix. They must be odd numbers. Then, the following 'width * height - 1' numbers specifies the numbers in the matrix, row by row, excluding the center element.
189192
+
190-
The elements are finite floating point numbers. The decimal pointer has to be '.' (a period), and scientific notation is not supported.
193+
The elements are finite floating point numbers. The decimal pointer has to be '.' (a period), scientific notation is not supported.
191194
+
192-
The element in the center will either be 1.0 or changing based on opacity, depending on whether you have `--blur-background-fixed`. Yet the automatic adjustment of blur factor may not work well with a custom blur kernel.
195+
The element in the center will either be 1.0 or varying based on opacity, depending on whether you have `--blur-background-fixed`. Yet the automatic adjustment of blur factor may not work well with a custom blur kernel.
193196
+
194197
A 7x7 Gaussian blur kernel (sigma = 0.84089642) looks like:
195198
+
@@ -232,7 +235,7 @@ May also be one of the predefined kernels: `3x3box` (default), `5x5box`, `7x7box
232235
*--glx-no-rebind-pixmap*::
233236
GLX backend: Avoid rebinding pixmap on window damage. Probably could improve performance on rapid window content changes, but is known to break things on some drivers (LLVMpipe, xf86-video-intel, etc.). Recommended if it works.
234237

235-
*-use-damage*::
238+
*--use-damage*::
236239
Use the damage information to limit rendering to parts of the screen that has actually changed. Potentially improves the performance.
237240

238241
*--xrender-sync-fence*::
@@ -371,6 +374,35 @@ Following per window-type options are available: ::
371374
redir-ignore:::
372375
Controls whether this type of windows should cause screen to become redirected again after been unredirected. If you have *--unredir-if-possible* set, and doesn't want certain window to cause unnecessary screen redirection, you can set this to `true`.
373376

377+
BLUR
378+
----
379+
You can configure how the window background is blurred using a 'blur' section in your configuration file. Here is an example:
380+
381+
--------
382+
blur:
383+
{
384+
method = "gaussian";
385+
size = 10;
386+
deviation = 5.0;
387+
};
388+
--------
389+
390+
Available options of the 'blur' section are: ::
391+
392+
*method*:::
393+
A string. Controls the blur method. Corresponds to the `--blur-method` command line option. Available choices are:
394+
'none' to disable blurring; 'gaussian' for gaussian blur; 'box' for box blur; 'kernel' for convolution blur with a custom kernel.
395+
Note: 'gaussian' and 'box' blur methods are only supported by the experimental backends.
396+
397+
*size*:::
398+
An integer. The size of the blur kernel, required by 'gaussian' and 'box' blur methods. For the 'kernel' method, the size is included in the kernel. Corresponds to the `--blur-size` command line option.
399+
400+
*deviation*:::
401+
A floating point number. The standard deviation for the 'gaussian' blur method. Corresponds to the `--blur-deviation` command line option.
402+
403+
*kernel*:::
404+
A string. The kernel to use for the 'kernel' blur method, specified in the same format as the `--blur-kerns` option. Corresponds to the `--blur-kerns` command line option.
405+
374406
SIGNALS
375407
-------
376408

meson.build

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
project('compton', 'c', version: '6',
1+
project('compton', 'c', version: '7',
22
default_options: ['c_std=c11'])
33

44
cc = meson.get_compiler('c')
@@ -31,6 +31,9 @@ if get_option('sanitize')
3131
endif
3232
add_global_arguments('-fsanitize='+','.join(sanitizers), language: 'c')
3333
add_global_link_arguments('-fsanitize='+','.join(sanitizers), language: 'c')
34+
if cc.has_argument('-fno-sanitize=unsigned-integer-overflow')
35+
add_global_arguments('-fno-sanitize=unsigned-integer-overflow', language: 'c')
36+
endif
3437
endif
3538

3639
if get_option('modularize')
@@ -46,18 +49,25 @@ endif
4649

4750
add_global_arguments('-D_GNU_SOURCE', language: 'c')
4851

49-
warns = [ 'all', 'extra', 'no-unused-parameter', 'nonnull', 'shadow',
50-
'implicit-fallthrough', 'no-unknown-warning-option', 'no-missing-braces' ]
52+
if cc.has_header('stdc-predef.h')
53+
add_global_arguments('-DHAS_STDC_PREDEF_H', language: 'c')
54+
endif
55+
56+
warns = [ 'all', 'extra', 'no-unused-parameter', 'nonnull', 'shadow', 'no-type-limits',
57+
'implicit-fallthrough', 'no-unknown-warning-option', 'no-missing-braces', 'conversion' ]
5158
foreach w : warns
5259
if cc.has_argument('-W'+w)
5360
add_global_arguments('-W'+w, language: 'c')
5461
endif
5562
endforeach
5663

64+
test_h_dep = subproject('test.h').get_variable('test_h_dep')
65+
5766
subdir('src')
5867
subdir('man')
5968

60-
install_subdir('bin', install_dir: '')
69+
install_data(['bin/compton-convgen.py', 'bin/compton-trans'],
70+
install_dir: get_option('bindir'))
6171
install_data('compton.desktop', install_dir: 'share/applications')
6272
install_data('media/icons/48x48/compton.png',
6373
install_dir: 'share/icons/hicolor/48x48/apps')

meson_options.txt

+2
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ option('xrescheck', type: 'boolean', value: false, description: 'Enable X resour
1212
option('build_docs', type: 'boolean', value: false, description: 'Build documentation and man pages')
1313

1414
option('modularize', type: 'boolean', value: false, description: 'Build with clang\'s module system')
15+
16+
option('unittest', type: 'boolean', value: false, description: 'Enable unittests in the code')

src/atom.c

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <xcb/xcb.h>
2+
3+
#include "atom.h"
4+
#include "common.h"
5+
#include "utils.h"
6+
7+
static inline void *atom_getter(void *ud, const char *atom_name, int *err) {
8+
xcb_connection_t *c = ud;
9+
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(
10+
c, xcb_intern_atom(c, 0, to_u16_checked(strlen(atom_name)), atom_name), NULL);
11+
12+
xcb_atom_t atom = XCB_NONE;
13+
if (reply) {
14+
log_debug("Atom %s is %d", atom_name, reply->atom);
15+
atom = reply->atom;
16+
free(reply);
17+
} else {
18+
log_error("Failed to intern atoms");
19+
*err = 1;
20+
}
21+
return (void *)(intptr_t)atom;
22+
}
23+
24+
/**
25+
* Create a new atom structure and fetch all predefined atoms
26+
*/
27+
struct atom *init_atoms(xcb_connection_t *c) {
28+
auto atoms = ccalloc(1, struct atom);
29+
atoms->c = new_cache((void *)c, atom_getter, NULL);
30+
#define ATOM_GET(x) atoms->a##x = (xcb_atom_t)(intptr_t)cache_get(atoms->c, #x, NULL)
31+
LIST_APPLY(ATOM_GET, SEP_COLON, ATOM_LIST);
32+
#undef ATOM_GET
33+
return atoms;
34+
}

0 commit comments

Comments
 (0)