Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
yshui committed Jul 18, 2019
2 parents 3bf86b3 + d45ed14 commit d907e31
Show file tree
Hide file tree
Showing 62 changed files with 5,371 additions and 3,577 deletions.
73 changes: 51 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
defaults: &defaults
docker:
- image: yshui/comptonci
cached-checkout: &ccheckout
just-build: &build
executors:
e:
docker:
- image: yshui/comptonci
working_directory: "/tmp/workspace"
environment:
UBSAN_OPTIONS: "halt_on_error=1"

version: 2.1
commands:
build:
parameters:
build-config:
type: string
default:
default: ""
cc:
type: string
default: cc
Expand All @@ -27,10 +29,10 @@ commands:
- ".git"
- run:
name: config
command: CC=<< parameters.cc >> meson << parameters.build-config >> --werror . build
command: CC=<< parameters.cc >> meson << parameters.build-config >> -Dunittest=true --werror . build
- run:
name: build
command: ninja -C build
command: ninja -vC build
test-xvfb:
steps:
- run:
Expand All @@ -40,48 +42,72 @@ commands:

jobs:
basic:
<<: *defaults
executor: e
steps:
- build:
build-config: -Dbuild_docs=true
build-config: -Dbuild_docs=true -Db_coverage=true
- persist_to_workspace:
root: .
paths:
- .
test:
executor: e
steps:
- attach_workspace:
at: /tmp/workspace
- run:
name: unit test
command: ninja -vC build test
- run:
name: test config file parsing
command: xvfb-run -s "-screen 0 640x480x24" build/src/compton --config compton.sample.conf --vsync=none --diagnostics
- run:
name: generate coverage reports
command: cd build; find -name '*.gcno' -exec gcov -pb {} +
- run:
name: download codecov scripts
command: curl -s https://codecov.io/bash > codecov.sh
- run:
name: upload coverage reports
command: bash ./codecov.sh -X gcov

minimal:
<<: *defaults
executor: e
steps:
- build:
build-config: -Dopengl=false -Ddbus=false -Dregex=false -Dconfig_file=false
nogl:
<<: *defaults
executor: e
steps:
- build:
build-config: -Dopengl=false
noregex:
<<: *defaults
executor: e
steps:
- build:
build-config: -Dregex=false
clang_basic:
<<: *defaults
executor: e
steps:
- build:
cc: clang-6.0
build-config:
cc: clang
clang_minimal:
<<: *defaults
executor: e
steps:
- build:
cc: clang-6.0
cc: clang
build-config: -Dopengl=false -Ddbus=false -Dregex=false -Dconfig_file=false
clang_nogl:
<<: *defaults
executor: e
steps:
- build:
cc: clang-6.0
cc: clang
build-config: -Dopengl=false
clang_noregex:
<<: *defaults
executor: e
steps:
- build:
cc: clang-6.0
cc: clang
build-config: -Dregex=false

workflows:
Expand All @@ -93,6 +119,9 @@ workflows:
- clang_minimal
- nogl
- clang_nogl
- test:
requires:
- basic
# - test-xvfb

# vim: set sw=2 ts=8 et:
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "subprojects/test.h"]
path = subprojects/test.h
url = https://github.com/yshui/test.h
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,21 @@ We also try to fix bugs.

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

## Changelog
## Call for testers

### `--experimental-backends`

This flag enables the refactored/partially rewritten backends.

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.

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.

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.

To report issues with the new backends, please state explicitly you are using the new backends in your report.

## Change Log

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

Expand All @@ -33,26 +47,43 @@ Assuming you already have all the usual building tools installed (e.g. gcc, meso
* xcb-composite
* xcb-image
* xcb-present
* xcb-xinerama (optional, disable with the `-Dxinerama=false` meson configure flag)
* xcb-xinerama
* pixman
* libdbus (optional, disable with the `-Ddbus=false` meson configure flag)
* libconfig (optional, disable with the `-Dconfig_file=false` meson configure flag)
* libxdg-basedir (optional, disable with the `-Dconfig_file=false` meson configure flag)
* libGL (optional, disable with the `-Dopengl=false` meson configure flag)
* libpcre (optional, disable with the `-Dregex=false` meson configure flag)
* libev
* uthash

To build the documents, you need `asciidoc`

### To build

```bash
$ git submodule update --init --recursive
$ meson --buildtype=release . build
$ ninja -C build
```

Built binary can be found in `build/src`

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.

You can do that by setting the `CPPFLAGS` and `LDFLAGS` environment variables when running `meson`. Like this:

```bash
$ LDFLAGS="-L/path/to/libraries" CPPFLAGS="-I/path/to/headers" meson --buildtype=release . build

```

As an example, on FreeBSD, you might have to run meson with:
```bash
$ LDFLAGS="-L/usr/local/include" CPPFLAGS="-I/usr/local/include" meson --buildtype=release . build
$ ninja -C build
```

### To install

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

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.

Contributions to the documents and wiki will also be appreciated.

## Contributors

See [CONTRIBUTORS](CONTRIBUTORS)
3 changes: 0 additions & 3 deletions dbus-examples/cdbus-driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ type_enum='uint16'
# List all window ID compton manages (except destroyed ones)
dbus-send --print-reply --dest="$service" "$object" "${interface}.list_win"

# Ensure we are tracking focus
dbus-send --print-reply --dest="$service" "$object" "${interface}.opts_set" string:track_focus boolean:true

# Get window ID of currently focused window
focused=$(dbus-send --print-reply --dest="$service" "$object" "${interface}.find_win" string:focused | $SED -n 's/^[[:space:]]*'${type_win}'[[:space:]]*\([[:digit:]]*\).*/\1/p')

Expand Down
1 change: 0 additions & 1 deletion dbus-examples/inverter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ if [ -z "$1" -o "$1" = "selected" ]; then
window=$(xwininfo -frame | sed -n 's/^xwininfo: Window id: \(0x[[:xdigit:]][[:xdigit:]]*\).*/\1/p') # Select window by mouse
elif [ "$1" = "focused" ]; then
# Ensure we are tracking focus
${compton_dbus}opts_set string:track_focus boolean:true &
window=$(${compton_dbus}find_win string:focused | $SED -n 's/^[[:space:]]*'${type_win}'[[:space:]]*\([[:digit:]]*\).*/\1/p') # Query compton for the active window
elif echo "$1" | grep -Eiq '^([[:digit:]][[:digit:]]*|0x[[:xdigit:]][[:xdigit:]]*)$'; then
window="$1" # Accept user-specified window-id if the format is correct
Expand Down
40 changes: 36 additions & 4 deletions man/compton.1.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ OPTIONS
Daemonize process. Fork to background after initialization. Causes issues with certain (badly-written) drivers.

*--log-level*::
Set the log level. Possible values are "TRACE", "DEBUG", "INFO", "WARN", "ERROR", in increasing level of importance. Case doesn't matter.
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.

*--log-file*::
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.
Expand Down Expand Up @@ -169,6 +169,9 @@ OPTIONS
*--detect-client-leader*::
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.

*--blur-method, --blur-size, --blur-deviation*::
Parameters for background blurring, see the *BLUR* section for more information.

*--blur-background*::
Blur background of semi-transparent / ARGB windows. Bad in performance, with driver-dependent behavior. The name of the switch may change without prior notifications.

Expand All @@ -187,9 +190,9 @@ WIDTH,HEIGHT,ELE1,ELE2,ELE3,ELE4,ELE5...
+
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.
+
The elements are finite floating point numbers. The decimal pointer has to be '.' (a period), and scientific notation is not supported.
The elements are finite floating point numbers. The decimal pointer has to be '.' (a period), scientific notation is not supported.
+
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.
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.
+
A 7x7 Gaussian blur kernel (sigma = 0.84089642) looks like:
+
Expand Down Expand Up @@ -232,7 +235,7 @@ May also be one of the predefined kernels: `3x3box` (default), `5x5box`, `7x7box
*--glx-no-rebind-pixmap*::
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.

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

*--xrender-sync-fence*::
Expand Down Expand Up @@ -371,6 +374,35 @@ Following per window-type options are available: ::
redir-ignore:::
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`.

BLUR
----
You can configure how the window background is blurred using a 'blur' section in your configuration file. Here is an example:
--------
blur:
{
method = "gaussian";
size = 10;
deviation = 5.0;
};
--------
Available options of the 'blur' section are: ::
*method*:::
A string. Controls the blur method. Corresponds to the `--blur-method` command line option. Available choices are:
'none' to disable blurring; 'gaussian' for gaussian blur; 'box' for box blur; 'kernel' for convolution blur with a custom kernel.
Note: 'gaussian' and 'box' blur methods are only supported by the experimental backends.
*size*:::
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.
*deviation*:::
A floating point number. The standard deviation for the 'gaussian' blur method. Corresponds to the `--blur-deviation` command line option.
*kernel*:::
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.
SIGNALS
-------

Expand Down
18 changes: 14 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project('compton', 'c', version: '6',
project('compton', 'c', version: '7',
default_options: ['c_std=c11'])

cc = meson.get_compiler('c')
Expand Down Expand Up @@ -31,6 +31,9 @@ if get_option('sanitize')
endif
add_global_arguments('-fsanitize='+','.join(sanitizers), language: 'c')
add_global_link_arguments('-fsanitize='+','.join(sanitizers), language: 'c')
if cc.has_argument('-fno-sanitize=unsigned-integer-overflow')
add_global_arguments('-fno-sanitize=unsigned-integer-overflow', language: 'c')
endif
endif

if get_option('modularize')
Expand All @@ -46,18 +49,25 @@ endif

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

warns = [ 'all', 'extra', 'no-unused-parameter', 'nonnull', 'shadow',
'implicit-fallthrough', 'no-unknown-warning-option', 'no-missing-braces' ]
if cc.has_header('stdc-predef.h')
add_global_arguments('-DHAS_STDC_PREDEF_H', language: 'c')
endif

warns = [ 'all', 'extra', 'no-unused-parameter', 'nonnull', 'shadow', 'no-type-limits',
'implicit-fallthrough', 'no-unknown-warning-option', 'no-missing-braces', 'conversion' ]
foreach w : warns
if cc.has_argument('-W'+w)
add_global_arguments('-W'+w, language: 'c')
endif
endforeach

test_h_dep = subproject('test.h').get_variable('test_h_dep')

subdir('src')
subdir('man')

install_subdir('bin', install_dir: '')
install_data(['bin/compton-convgen.py', 'bin/compton-trans'],
install_dir: get_option('bindir'))
install_data('compton.desktop', install_dir: 'share/applications')
install_data('media/icons/48x48/compton.png',
install_dir: 'share/icons/hicolor/48x48/apps')
Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ option('xrescheck', type: 'boolean', value: false, description: 'Enable X resour
option('build_docs', type: 'boolean', value: false, description: 'Build documentation and man pages')

option('modularize', type: 'boolean', value: false, description: 'Build with clang\'s module system')

option('unittest', type: 'boolean', value: false, description: 'Enable unittests in the code')
34 changes: 34 additions & 0 deletions src/atom.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <xcb/xcb.h>

#include "atom.h"
#include "common.h"
#include "utils.h"

static inline void *atom_getter(void *ud, const char *atom_name, int *err) {
xcb_connection_t *c = ud;
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(
c, xcb_intern_atom(c, 0, to_u16_checked(strlen(atom_name)), atom_name), NULL);

xcb_atom_t atom = XCB_NONE;
if (reply) {
log_debug("Atom %s is %d", atom_name, reply->atom);
atom = reply->atom;
free(reply);
} else {
log_error("Failed to intern atoms");
*err = 1;
}
return (void *)(intptr_t)atom;
}

/**
* Create a new atom structure and fetch all predefined atoms
*/
struct atom *init_atoms(xcb_connection_t *c) {
auto atoms = ccalloc(1, struct atom);
atoms->c = new_cache((void *)c, atom_getter, NULL);
#define ATOM_GET(x) atoms->a##x = (xcb_atom_t)(intptr_t)cache_get(atoms->c, #x, NULL)
LIST_APPLY(ATOM_GET, SEP_COLON, ATOM_LIST);
#undef ATOM_GET
return atoms;
}
Loading

0 comments on commit d907e31

Please sign in to comment.