Misc: Validate wallpaper pixmap & Documentation update

- Split Pixmap validation out to validate_pixmap(). Validate wallpaper
  Pixmap as well.

- Update README.md and man page.
This commit is contained in:
Richard Grenville 2013-05-01 22:08:43 +08:00
parent a3f6f4442b
commit 7a4f5920d8
4 changed files with 62 additions and 36 deletions

View File

@ -12,9 +12,9 @@ partially doing this out of a desire to learn Xlib.
## Changes from xcompmgr:
* OpenGL backend (`--backend glx`), in addition to the old X Render backend.
* __inactive window transparency / dimming__
* __titlebar/frame transparency__ (specified with `-e`)
* menu transparency (thanks to Dana)
* Inactive window transparency (`-i`) / dimming (`--inactive-dim`).
* Titlebar/frame transparency (`-e`).
* Menu transparency (`-m`, thanks to Dana).
* shadows are now enabled for argb windows, e.g. terminals with transparency
* removed serverside shadows (and simple compositing) to clean the code,
the only option that remains is clientside shadows
@ -64,7 +64,7 @@ __R__ for runtime
To build, make sure you have the dependencies above:
``` bash
```bash
# Make the main program
$ make
# Make the man pages
@ -77,15 +77,17 @@ $ make install
## Known issues
* VSync does not work too well. It's widely reported that tearing still happens on the top of the screen. I do not know how to fix the issue.
* Our [FAQ](wiki/faq) covers some known issues.
* VSync does not work too well. You may check the [VSync Guide](wiki/vsync-guide) for how to get (possibly) better effects.
* If `--unredir-if-possible` is enabled, when compton redirects/unredirects windows, the screen may flicker. Using `--paint-on-overlay` minimizes the problem from my observation, yet I do not know if there's a cure.
* compton may not track focus correctly in all situations. The focus tracking code is experimental. `--use-ewmh-active-win` might be helpful.
* Compton may give ugly shadow to windows with ARGB background if `-z` is enabled, because compton cannot determine their real shapes. One may have to disable shadows on those windows with window-type-specific settings in configuration file or `--shadow-exclude`.
* The performance of blur under X Render backend might be pretty bad. OpenGL backend could be faster.
* The performance of blurring is terrible, probably because of a problem in the X Render implementation. Its behavior is driver-dependent: With nvidia-drivers it works but there are strange 1px lines remaining when you operate on windows (not sure if it's a bug in compton or in the driver); with nouveau it's utterly broken.
* With `--blur-background` you may sometimes see weird lines around damaged area. `--resize-damage YOUR_BLUR_RADISU` might be helpful in the case.
## Usage
@ -99,7 +101,7 @@ Note a sample configuration file `compton.sample.conf` is included in the reposi
* Our (semi?) official IRC channel is #compton on FreeNode.
* Some information is available on the wiki, including (and presently, only includes) a FAQ.
* Some information is available on the wiki, including [FAQ](wiki/faq), [VSync Guide](wiki/vsync-guide), and [Performance Guide](wiki/perf-guide).
## License

View File

@ -178,6 +178,26 @@ OPTIONS
*--blur-background-fixed*::
Use fixed blur strength rather than adjusting according to window opacity.
*--blur-kern* matrix::
Specify the blur convolution kernel, with the following format:
+
----
WIDTH,HEIGHT,ELE1,ELE2,ELE3,ELE4,ELE5...
----
+
The element in the center must not be included, it will be forever 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.
+
A 7x7 Guassian blur kernel (sigma = 0.84089642) looks like:
+
----
--blur-kern '7,7,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0.000003,0.000102,0.003494,0.029143,0.059106,0.029143,0.003494,0.000102,0.000849,0.029143,0.243117,0.493069,0.243117,0.029143,0.000849,0.001723,0.059106,0.493069,0.493069,0.059106,0.001723,0.000849,0.029143,0.243117,0.493069,0.243117,0.029143,0.000849,0.000102,0.003494,0.029143,0.059106,0.029143,0.003494,0.000102,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0.000003'
----
+
May also be one of the predefined kernels: `3x3box` (default), `5x5box`, `7x7box`, `3x3gaussian`, `5x5gaussian`, `7x7gaussian`, `9x9gaussian`, `11x11gaussian`. All Guassian kernels are generated with sigma = 0.84089642 . You may use the accompanied `compton-convgen.py` to generate blur kernels.
*--resize-damage* integer::
Resize damaged region by a specific number of pixels. A positive value enlarges it while a negative one shrinks it. If the value is positive, those additional pixels will not be actually painted to screen, only used in blur calculation, and such. (Due to technical limitations, with *--dbe* or *--glx-swap-method*, those pixels will still be incorrectly painted to screen.) Primarily used to fix the line corruption issues of blur, in which case you should use the blur radius value here (e.g. with a 3x3 kernel, you should use *--resize-damage* 1, with a 5x5 one you use *--resize-damage* 2, and so on). May or may not work with `--glx-no-stencil`. Shrinking doesn't function correctly.
*--invert-color-include* condition::
Specify a list of conditions of windows that should be painted with inverted color. Resource-hogging, and is not well tested.
@ -196,8 +216,8 @@ OPTIONS
*--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).
*--glx-swap-method* undefined/exchange/copy::
GLX backend: GLX buffer swap method we assume. Could be "undefined", "exchange", or "copy". "undefined" is the slowest and the safest; "exchange" and "copy" are faster but may fail on some drivers. Useless with *--glx-use-copysubbuffermesa*. Defaults to "undefined".
*--glx-swap-method* undefined/exchange/copy/3/4/5/6::
GLX backend: GLX buffer swap method we assume. Could be `undefined` (0), `copy` (1), `exchange` (2), 3-6, or `buffer-age` (-1). `undefined` is the slowest and the safest, and the default value. `copy` is fastest, but may fail on some drivers, 2-6 are gradually slower but safer (6 is still faster than 0). Usually, double buffer means 2, triple buffer means 3. `buffer-age` means auto-detect using 'GLX_EXT_buffer_age', supported by some drivers. Useless with *--glx-use-copysubbuffermesa*. Partially breaks `--resize-damage`. Defaults to `undefined`.
*--dbus*::
Enable remote control via D-Bus. See the *D-BUS API* section below for more details.

View File

@ -669,30 +669,6 @@ win_rounded_corners(session_t *ps, win *w) {
cxfree(rects);
}
/**
* Validate pixmap of a window, and destroy pixmap and picture if invalid.
*/
static void
win_validate_pixmap(session_t *ps, win *w) {
if (!w->paint.pixmap)
return;
// Detect whether the pixmap is valid with XGetGeometry. Well, maybe there
// are better ways.
bool invalid = false;
{
Window rroot = None;
int rx = 0, ry = 0;
unsigned rwid = 0, rhei = 0, rborder = 0, rdepth = 0;
invalid = (!XGetGeometry(ps->dpy, w->paint.pixmap, &rroot, &rx, &ry,
&rwid, &rhei, &rborder, &rdepth) || !rwid || !rhei);
}
// Destroy pixmap and picture, if invalid
if (invalid)
free_paint(ps, &w->paint);
}
/**
* Add a pattern to a condition linked list.
*/
@ -840,6 +816,10 @@ get_root_tile(session_t *ps) {
free_winprop(&prop);
}
// Make sure the pixmap we got is valid
if (pixmap && !validate_pixmap(ps, pixmap))
pixmap = None;
// Create a pixmap if there isn't any
if (!pixmap) {
pixmap = XCreatePixmap(ps->dpy, ps->root, 1, 1, ps->depth);

View File

@ -443,8 +443,32 @@ win_is_fullscreen(session_t *ps, const win *w) {
static void
win_rounded_corners(session_t *ps, win *w);
static void
win_validate_pixmap(session_t *ps, win *w);
/**
* Validate a pixmap.
*
* Detect whether the pixmap is valid with XGetGeometry. Well, maybe there
* are better ways.
*/
static inline bool
validate_pixmap(session_t *ps, Pixmap pxmap) {
if (!pxmap) return false;
Window rroot = None;
int rx = 0, ry = 0;
unsigned rwid = 0, rhei = 0, rborder = 0, rdepth = 0;
return XGetGeometry(ps->dpy, pxmap, &rroot, &rx, &ry,
&rwid, &rhei, &rborder, &rdepth) && rwid && rhei;
}
/**
* Validate pixmap of a window, and destroy pixmap and picture if invalid.
*/
static inline void
win_validate_pixmap(session_t *ps, win *w) {
// Destroy pixmap and picture, if invalid
if (!validate_pixmap(ps, w->paint.pixmap))
free_paint(ps, &w->paint);
}
/**
* Wrapper of c2_match().