2012-02-27 12:00:12 +08:00
|
|
|
/**
|
|
|
|
* compton.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Throw everything in here.
|
|
|
|
|
Feature: Issue #29: Alternative shadow blacklist implementation
- Add shadow blacklist feature, but a different implementation from
nicklan's. 5 matching modes (exact, starts-with, contains, wildcard,
PCRE) and 3 matching targets (window name, window class instance,
window general class). Not extensively tested, bugs to be expected.
It's slower for exact matching than nicklan's as it uses linear search
instead of hash table. Also, PCRE's JIT optimization may cause issues
on PaX kernels.
- Add dependency to libpcre. Could be made optional if we have a
graceful way to handle that in Makefile.
- Some matching functions are GNU extensions of glibc. So this version
may have troubles running on platforms not using glibc.
- Fix a bug that access freed memory blocks in set_fade_callcack() and
check_fade_fin(). valgrind found it out.
- Use WM_CLASS to detect client windows instead of WM_STATE. Some client
windows (like notification windows) have WM_CLASS but not WM_STATE.
- Mark the extents as damaged if shadow state changed in
determine_shadow().
- Rewrite wid_get_name(). Code clean-up.
- Two debugging options: DEBUG_WINDATA and DEBUG_WINMATCH.
- As the matching system is ready, it should be rather easy to add other
kinds of blacklists, like fading blacklist.
2012-09-22 11:42:39 +08:00
|
|
|
// === Options ===
|
|
|
|
|
|
|
|
// Debug options, enable them using -D in CFLAGS
|
|
|
|
// #define DEBUG_REPAINT 1
|
|
|
|
// #define DEBUG_EVENTS 1
|
|
|
|
// #define DEBUG_RESTACK 1
|
|
|
|
// #define DEBUG_WINTYPE 1
|
|
|
|
// #define DEBUG_CLIENTWIN 1
|
|
|
|
// #define DEBUG_WINDATA 1
|
|
|
|
// #define DEBUG_WINMATCH 1
|
|
|
|
// #define MONITOR_REPAINT 1
|
|
|
|
|
|
|
|
// Whether to enable PCRE regular expression support in blacklists, enabled
|
|
|
|
// by default
|
2012-09-28 09:10:34 +08:00
|
|
|
// #define CONFIG_REGEX_PCRE 1
|
Feature: Issue #29: Alternative shadow blacklist implementation
- Add shadow blacklist feature, but a different implementation from
nicklan's. 5 matching modes (exact, starts-with, contains, wildcard,
PCRE) and 3 matching targets (window name, window class instance,
window general class). Not extensively tested, bugs to be expected.
It's slower for exact matching than nicklan's as it uses linear search
instead of hash table. Also, PCRE's JIT optimization may cause issues
on PaX kernels.
- Add dependency to libpcre. Could be made optional if we have a
graceful way to handle that in Makefile.
- Some matching functions are GNU extensions of glibc. So this version
may have troubles running on platforms not using glibc.
- Fix a bug that access freed memory blocks in set_fade_callcack() and
check_fade_fin(). valgrind found it out.
- Use WM_CLASS to detect client windows instead of WM_STATE. Some client
windows (like notification windows) have WM_CLASS but not WM_STATE.
- Mark the extents as damaged if shadow state changed in
determine_shadow().
- Rewrite wid_get_name(). Code clean-up.
- Two debugging options: DEBUG_WINDATA and DEBUG_WINMATCH.
- As the matching system is ready, it should be rather easy to add other
kinds of blacklists, like fading blacklist.
2012-09-22 11:42:39 +08:00
|
|
|
// Whether to enable JIT support of libpcre. This may cause problems on PaX
|
|
|
|
// kernels.
|
2012-09-28 09:10:34 +08:00
|
|
|
// #define CONFIG_REGEX_PCRE_JIT 1
|
2012-09-25 10:19:20 +08:00
|
|
|
// Whether to enable parsing of configuration files using libconfig
|
2012-09-28 09:10:34 +08:00
|
|
|
// #define CONFIG_LIBCONFIG 1
|
Feature: #7: VSync
- Add VSync feature. 3 possible VSync methods available: "sw" (software,
not too reliable, but at least you have something to fallback to),
"drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
"opengl" (using SGI_swap_control extension OpenGL, might work on more
drivers than the DRM method). "sw" and "opengl" are briefly tested,
"drm" received utterly no test (because I use the nVidia binary blob).
They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".
- Add --refresh-rate to let user specify a refresh rate for software
VSync, in case the automatic refresh rate detection does not work
well.
- Seemingly the automatic refresh rate detection using X RandR in
software VSync detects refresh rate incorrectly. Need further investigation.
- Fix a few bugs in fading timing.
- Add a workaround for client window detection on Fluxbox, as Fluxbox
(incorrectly?) sets the override-redirect flag upon all frame
windows.
- Software VSync adds dependency on librt (a part of glibc) for
nanosecond-level timing functions, and libXrandr for automatic refresh
rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
but does not link to libdrm; OpenGL VSync adds dependency on libGL.
- Print timing information on DEBUG_REPAINT.
2012-10-08 10:20:01 +08:00
|
|
|
// Whether to enable DRM VSync support
|
|
|
|
// #define CONFIG_VSYNC_DRM 1
|
|
|
|
// Whether to enable OpenGL VSync support
|
|
|
|
// #define CONFIG_VSYNC_OPENGL 1
|
Feature: Issue #29: Alternative shadow blacklist implementation
- Add shadow blacklist feature, but a different implementation from
nicklan's. 5 matching modes (exact, starts-with, contains, wildcard,
PCRE) and 3 matching targets (window name, window class instance,
window general class). Not extensively tested, bugs to be expected.
It's slower for exact matching than nicklan's as it uses linear search
instead of hash table. Also, PCRE's JIT optimization may cause issues
on PaX kernels.
- Add dependency to libpcre. Could be made optional if we have a
graceful way to handle that in Makefile.
- Some matching functions are GNU extensions of glibc. So this version
may have troubles running on platforms not using glibc.
- Fix a bug that access freed memory blocks in set_fade_callcack() and
check_fade_fin(). valgrind found it out.
- Use WM_CLASS to detect client windows instead of WM_STATE. Some client
windows (like notification windows) have WM_CLASS but not WM_STATE.
- Mark the extents as damaged if shadow state changed in
determine_shadow().
- Rewrite wid_get_name(). Code clean-up.
- Two debugging options: DEBUG_WINDATA and DEBUG_WINMATCH.
- As the matching system is ready, it should be rather easy to add other
kinds of blacklists, like fading blacklist.
2012-09-22 11:42:39 +08:00
|
|
|
|
|
|
|
// === Includes ===
|
|
|
|
|
|
|
|
// For some special functions
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
|
2012-02-08 18:31:39 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2012-09-11 22:22:58 +08:00
|
|
|
#include <inttypes.h>
|
2012-02-08 18:31:39 +08:00
|
|
|
#include <math.h>
|
|
|
|
#include <sys/poll.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <getopt.h>
|
Feature: Issue #29: Alternative shadow blacklist implementation
- Add shadow blacklist feature, but a different implementation from
nicklan's. 5 matching modes (exact, starts-with, contains, wildcard,
PCRE) and 3 matching targets (window name, window class instance,
window general class). Not extensively tested, bugs to be expected.
It's slower for exact matching than nicklan's as it uses linear search
instead of hash table. Also, PCRE's JIT optimization may cause issues
on PaX kernels.
- Add dependency to libpcre. Could be made optional if we have a
graceful way to handle that in Makefile.
- Some matching functions are GNU extensions of glibc. So this version
may have troubles running on platforms not using glibc.
- Fix a bug that access freed memory blocks in set_fade_callcack() and
check_fade_fin(). valgrind found it out.
- Use WM_CLASS to detect client windows instead of WM_STATE. Some client
windows (like notification windows) have WM_CLASS but not WM_STATE.
- Mark the extents as damaged if shadow state changed in
determine_shadow().
- Rewrite wid_get_name(). Code clean-up.
- Two debugging options: DEBUG_WINDATA and DEBUG_WINMATCH.
- As the matching system is ready, it should be rather easy to add other
kinds of blacklists, like fading blacklist.
2012-09-22 11:42:39 +08:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <locale.h>
|
Feature: #7: VSync
- Add VSync feature. 3 possible VSync methods available: "sw" (software,
not too reliable, but at least you have something to fallback to),
"drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
"opengl" (using SGI_swap_control extension OpenGL, might work on more
drivers than the DRM method). "sw" and "opengl" are briefly tested,
"drm" received utterly no test (because I use the nVidia binary blob).
They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".
- Add --refresh-rate to let user specify a refresh rate for software
VSync, in case the automatic refresh rate detection does not work
well.
- Seemingly the automatic refresh rate detection using X RandR in
software VSync detects refresh rate incorrectly. Need further investigation.
- Fix a few bugs in fading timing.
- Add a workaround for client window detection on Fluxbox, as Fluxbox
(incorrectly?) sets the override-redirect flag upon all frame
windows.
- Software VSync adds dependency on librt (a part of glibc) for
nanosecond-level timing functions, and libXrandr for automatic refresh
rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
but does not link to libdrm; OpenGL VSync adds dependency on libGL.
- Print timing information on DEBUG_REPAINT.
2012-10-08 10:20:01 +08:00
|
|
|
#include <assert.h>
|
Feature: Issue #29: Alternative shadow blacklist implementation
- Add shadow blacklist feature, but a different implementation from
nicklan's. 5 matching modes (exact, starts-with, contains, wildcard,
PCRE) and 3 matching targets (window name, window class instance,
window general class). Not extensively tested, bugs to be expected.
It's slower for exact matching than nicklan's as it uses linear search
instead of hash table. Also, PCRE's JIT optimization may cause issues
on PaX kernels.
- Add dependency to libpcre. Could be made optional if we have a
graceful way to handle that in Makefile.
- Some matching functions are GNU extensions of glibc. So this version
may have troubles running on platforms not using glibc.
- Fix a bug that access freed memory blocks in set_fade_callcack() and
check_fade_fin(). valgrind found it out.
- Use WM_CLASS to detect client windows instead of WM_STATE. Some client
windows (like notification windows) have WM_CLASS but not WM_STATE.
- Mark the extents as damaged if shadow state changed in
determine_shadow().
- Rewrite wid_get_name(). Code clean-up.
- Two debugging options: DEBUG_WINDATA and DEBUG_WINMATCH.
- As the matching system is ready, it should be rather easy to add other
kinds of blacklists, like fading blacklist.
2012-09-22 11:42:39 +08:00
|
|
|
|
|
|
|
#include <fnmatch.h>
|
2012-09-25 10:19:20 +08:00
|
|
|
|
Feature: Issue #29: Alternative shadow blacklist implementation
- Add shadow blacklist feature, but a different implementation from
nicklan's. 5 matching modes (exact, starts-with, contains, wildcard,
PCRE) and 3 matching targets (window name, window class instance,
window general class). Not extensively tested, bugs to be expected.
It's slower for exact matching than nicklan's as it uses linear search
instead of hash table. Also, PCRE's JIT optimization may cause issues
on PaX kernels.
- Add dependency to libpcre. Could be made optional if we have a
graceful way to handle that in Makefile.
- Some matching functions are GNU extensions of glibc. So this version
may have troubles running on platforms not using glibc.
- Fix a bug that access freed memory blocks in set_fade_callcack() and
check_fade_fin(). valgrind found it out.
- Use WM_CLASS to detect client windows instead of WM_STATE. Some client
windows (like notification windows) have WM_CLASS but not WM_STATE.
- Mark the extents as damaged if shadow state changed in
determine_shadow().
- Rewrite wid_get_name(). Code clean-up.
- Two debugging options: DEBUG_WINDATA and DEBUG_WINMATCH.
- As the matching system is ready, it should be rather easy to add other
kinds of blacklists, like fading blacklist.
2012-09-22 11:42:39 +08:00
|
|
|
#ifdef CONFIG_REGEX_PCRE
|
|
|
|
#include <pcre.h>
|
2012-09-28 09:10:34 +08:00
|
|
|
|
|
|
|
// For compatiblity with <libpcre-8.20
|
|
|
|
#ifndef PCRE_STUDY_JIT_COMPILE
|
|
|
|
#define PCRE_STUDY_JIT_COMPILE 0
|
|
|
|
#endif
|
|
|
|
|
Feature: Issue #29: Alternative shadow blacklist implementation
- Add shadow blacklist feature, but a different implementation from
nicklan's. 5 matching modes (exact, starts-with, contains, wildcard,
PCRE) and 3 matching targets (window name, window class instance,
window general class). Not extensively tested, bugs to be expected.
It's slower for exact matching than nicklan's as it uses linear search
instead of hash table. Also, PCRE's JIT optimization may cause issues
on PaX kernels.
- Add dependency to libpcre. Could be made optional if we have a
graceful way to handle that in Makefile.
- Some matching functions are GNU extensions of glibc. So this version
may have troubles running on platforms not using glibc.
- Fix a bug that access freed memory blocks in set_fade_callcack() and
check_fade_fin(). valgrind found it out.
- Use WM_CLASS to detect client windows instead of WM_STATE. Some client
windows (like notification windows) have WM_CLASS but not WM_STATE.
- Mark the extents as damaged if shadow state changed in
determine_shadow().
- Rewrite wid_get_name(). Code clean-up.
- Two debugging options: DEBUG_WINDATA and DEBUG_WINMATCH.
- As the matching system is ready, it should be rather easy to add other
kinds of blacklists, like fading blacklist.
2012-09-22 11:42:39 +08:00
|
|
|
#endif
|
2012-02-08 18:31:39 +08:00
|
|
|
|
2012-09-25 10:19:20 +08:00
|
|
|
#ifdef CONFIG_LIBCONFIG
|
|
|
|
#include <libgen.h>
|
|
|
|
#include <libconfig.h>
|
|
|
|
#endif
|
|
|
|
|
2012-02-08 18:31:39 +08:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/extensions/Xcomposite.h>
|
|
|
|
#include <X11/extensions/Xdamage.h>
|
|
|
|
#include <X11/extensions/Xrender.h>
|
2012-09-11 21:33:03 +08:00
|
|
|
#include <X11/extensions/shape.h>
|
Feature: #7: VSync
- Add VSync feature. 3 possible VSync methods available: "sw" (software,
not too reliable, but at least you have something to fallback to),
"drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
"opengl" (using SGI_swap_control extension OpenGL, might work on more
drivers than the DRM method). "sw" and "opengl" are briefly tested,
"drm" received utterly no test (because I use the nVidia binary blob).
They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".
- Add --refresh-rate to let user specify a refresh rate for software
VSync, in case the automatic refresh rate detection does not work
well.
- Seemingly the automatic refresh rate detection using X RandR in
software VSync detects refresh rate incorrectly. Need further investigation.
- Fix a few bugs in fading timing.
- Add a workaround for client window detection on Fluxbox, as Fluxbox
(incorrectly?) sets the override-redirect flag upon all frame
windows.
- Software VSync adds dependency on librt (a part of glibc) for
nanosecond-level timing functions, and libXrandr for automatic refresh
rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
but does not link to libdrm; OpenGL VSync adds dependency on libGL.
- Print timing information on DEBUG_REPAINT.
2012-10-08 10:20:01 +08:00
|
|
|
#include <X11/extensions/Xrandr.h>
|
2012-10-23 13:42:20 +08:00
|
|
|
#include <X11/extensions/Xdbe.h>
|
Feature: #7: VSync
- Add VSync feature. 3 possible VSync methods available: "sw" (software,
not too reliable, but at least you have something to fallback to),
"drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
"opengl" (using SGI_swap_control extension OpenGL, might work on more
drivers than the DRM method). "sw" and "opengl" are briefly tested,
"drm" received utterly no test (because I use the nVidia binary blob).
They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".
- Add --refresh-rate to let user specify a refresh rate for software
VSync, in case the automatic refresh rate detection does not work
well.
- Seemingly the automatic refresh rate detection using X RandR in
software VSync detects refresh rate incorrectly. Need further investigation.
- Fix a few bugs in fading timing.
- Add a workaround for client window detection on Fluxbox, as Fluxbox
(incorrectly?) sets the override-redirect flag upon all frame
windows.
- Software VSync adds dependency on librt (a part of glibc) for
nanosecond-level timing functions, and libXrandr for automatic refresh
rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
but does not link to libdrm; OpenGL VSync adds dependency on libGL.
- Print timing information on DEBUG_REPAINT.
2012-10-08 10:20:01 +08:00
|
|
|
|
|
|
|
#ifdef CONFIG_VSYNC_DRM
|
|
|
|
#include <fcntl.h>
|
|
|
|
// We references some definitions in drm.h, which could also be found in
|
|
|
|
// /usr/src/linux/include/drm/drm.h, but that path is probably even less
|
|
|
|
// reliable than libdrm
|
|
|
|
#include <libdrm/drm.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_VSYNC_OPENGL
|
|
|
|
#include <GL/glx.h>
|
|
|
|
#endif
|
2012-02-08 18:31:39 +08:00
|
|
|
|
2012-11-03 10:30:32 +08:00
|
|
|
#ifdef DEBUG_ALLOC_REG
|
|
|
|
static inline XserverRegion
|
|
|
|
XFixesCreateRegion_(Display *dpy, XRectangle *p, int n,
|
|
|
|
const char *func, int line) {
|
|
|
|
XserverRegion reg = XFixesCreateRegion(dpy, p, n);
|
|
|
|
printf("%#010lx: XFixesCreateRegion() in %s():%d\n", reg, func, line);
|
|
|
|
return reg;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
XFixesDestroyRegion_(Display *dpy, XserverRegion reg,
|
|
|
|
const char *func, int line) {
|
|
|
|
XFixesDestroyRegion(dpy, reg);
|
|
|
|
printf("%#010lx: XFixesDestroyRegion() in %s():%d\n", reg, func, line);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define XFixesCreateRegion(dpy, p, n) XFixesCreateRegion_(dpy, p, n, __func__, __LINE__)
|
|
|
|
#define XFixesDestroyRegion(dpy, reg) XFixesDestroyRegion_(dpy, reg, __func__, __LINE__)
|
|
|
|
#endif
|
|
|
|
|
Feature: Issue #29: Alternative shadow blacklist implementation
- Add shadow blacklist feature, but a different implementation from
nicklan's. 5 matching modes (exact, starts-with, contains, wildcard,
PCRE) and 3 matching targets (window name, window class instance,
window general class). Not extensively tested, bugs to be expected.
It's slower for exact matching than nicklan's as it uses linear search
instead of hash table. Also, PCRE's JIT optimization may cause issues
on PaX kernels.
- Add dependency to libpcre. Could be made optional if we have a
graceful way to handle that in Makefile.
- Some matching functions are GNU extensions of glibc. So this version
may have troubles running on platforms not using glibc.
- Fix a bug that access freed memory blocks in set_fade_callcack() and
check_fade_fin(). valgrind found it out.
- Use WM_CLASS to detect client windows instead of WM_STATE. Some client
windows (like notification windows) have WM_CLASS but not WM_STATE.
- Mark the extents as damaged if shadow state changed in
determine_shadow().
- Rewrite wid_get_name(). Code clean-up.
- Two debugging options: DEBUG_WINDATA and DEBUG_WINMATCH.
- As the matching system is ready, it should be rather easy to add other
kinds of blacklists, like fading blacklist.
2012-09-22 11:42:39 +08:00
|
|
|
// === Constants ===
|
2012-10-22 08:16:52 +08:00
|
|
|
#if !(COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR >= 2)
|
|
|
|
#error libXcomposite version unsupported
|
2012-02-08 18:31:39 +08:00
|
|
|
#endif
|
|
|
|
|
2012-10-01 10:34:40 +08:00
|
|
|
#define ROUNDED_PERCENT 0.05
|
|
|
|
#define ROUNDED_PIXELS 10
|
|
|
|
|
2012-09-12 09:08:15 +08:00
|
|
|
// For printing timestamps
|
|
|
|
#include <time.h>
|
|
|
|
extern struct timeval time_start;
|
2012-02-08 18:31:39 +08:00
|
|
|
|
|
|
|
#define OPAQUE 0xffffffff
|
2012-02-09 06:45:08 +08:00
|
|
|
#define REGISTER_PROP "_NET_WM_CM_S"
|
|
|
|
|
Feature: #7: VSync
- Add VSync feature. 3 possible VSync methods available: "sw" (software,
not too reliable, but at least you have something to fallback to),
"drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
"opengl" (using SGI_swap_control extension OpenGL, might work on more
drivers than the DRM method). "sw" and "opengl" are briefly tested,
"drm" received utterly no test (because I use the nVidia binary blob).
They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".
- Add --refresh-rate to let user specify a refresh rate for software
VSync, in case the automatic refresh rate detection does not work
well.
- Seemingly the automatic refresh rate detection using X RandR in
software VSync detects refresh rate incorrectly. Need further investigation.
- Fix a few bugs in fading timing.
- Add a workaround for client window detection on Fluxbox, as Fluxbox
(incorrectly?) sets the override-redirect flag upon all frame
windows.
- Software VSync adds dependency on librt (a part of glibc) for
nanosecond-level timing functions, and libXrandr for automatic refresh
rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
but does not link to libdrm; OpenGL VSync adds dependency on libGL.
- Print timing information on DEBUG_REPAINT.
2012-10-08 10:20:01 +08:00
|
|
|
#define FADE_DELTA_TOLERANCE 0.2
|
2012-10-26 11:12:28 +08:00
|
|
|
#define SW_OPTI_TOLERANCE 1000
|
Feature: #7: VSync
- Add VSync feature. 3 possible VSync methods available: "sw" (software,
not too reliable, but at least you have something to fallback to),
"drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
"opengl" (using SGI_swap_control extension OpenGL, might work on more
drivers than the DRM method). "sw" and "opengl" are briefly tested,
"drm" received utterly no test (because I use the nVidia binary blob).
They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".
- Add --refresh-rate to let user specify a refresh rate for software
VSync, in case the automatic refresh rate detection does not work
well.
- Seemingly the automatic refresh rate detection using X RandR in
software VSync detects refresh rate incorrectly. Need further investigation.
- Fix a few bugs in fading timing.
- Add a workaround for client window detection on Fluxbox, as Fluxbox
(incorrectly?) sets the override-redirect flag upon all frame
windows.
- Software VSync adds dependency on librt (a part of glibc) for
nanosecond-level timing functions, and libXrandr for automatic refresh
rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
but does not link to libdrm; OpenGL VSync adds dependency on libGL.
- Print timing information on DEBUG_REPAINT.
2012-10-08 10:20:01 +08:00
|
|
|
|
|
|
|
#define NS_PER_SEC 1000000000L
|
|
|
|
#define US_PER_SEC 1000000L
|
|
|
|
#define MS_PER_SEC 1000
|
|
|
|
|
2012-09-17 22:15:04 +08:00
|
|
|
// Window flags
|
|
|
|
|
|
|
|
// Window size is changed
|
|
|
|
#define WFLAG_SIZE_CHANGE 0x0001
|
2012-11-01 10:43:15 +08:00
|
|
|
// Window size/position is changed
|
|
|
|
#define WFLAG_POS_CHANGE 0x0002
|
2012-09-17 22:15:04 +08:00
|
|
|
|
2012-02-27 12:00:12 +08:00
|
|
|
/**
|
|
|
|
* Types
|
|
|
|
*/
|
|
|
|
|
2012-09-11 22:22:58 +08:00
|
|
|
typedef uint32_t opacity_t;
|
|
|
|
|
2012-02-08 18:31:39 +08:00
|
|
|
typedef enum {
|
|
|
|
WINTYPE_UNKNOWN,
|
|
|
|
WINTYPE_DESKTOP,
|
|
|
|
WINTYPE_DOCK,
|
|
|
|
WINTYPE_TOOLBAR,
|
|
|
|
WINTYPE_MENU,
|
|
|
|
WINTYPE_UTILITY,
|
|
|
|
WINTYPE_SPLASH,
|
|
|
|
WINTYPE_DIALOG,
|
|
|
|
WINTYPE_NORMAL,
|
|
|
|
WINTYPE_DROPDOWN_MENU,
|
|
|
|
WINTYPE_POPUP_MENU,
|
|
|
|
WINTYPE_TOOLTIP,
|
|
|
|
WINTYPE_NOTIFY,
|
|
|
|
WINTYPE_COMBO,
|
|
|
|
WINTYPE_DND,
|
|
|
|
NUM_WINTYPES
|
|
|
|
} wintype;
|
|
|
|
|
2012-10-31 08:54:09 +08:00
|
|
|
typedef enum {
|
|
|
|
WINDOW_SOLID,
|
|
|
|
WINDOW_TRANS,
|
|
|
|
WINDOW_ARGB
|
|
|
|
} winmode;
|
|
|
|
|
2012-11-04 18:11:08 +08:00
|
|
|
typedef struct {
|
|
|
|
unsigned char *data;
|
|
|
|
int nitems;
|
|
|
|
} winattr_t;
|
|
|
|
|
2012-02-08 18:31:39 +08:00
|
|
|
typedef struct _ignore {
|
|
|
|
struct _ignore *next;
|
|
|
|
unsigned long sequence;
|
|
|
|
} ignore;
|
|
|
|
|
Feature: Issue #29: Alternative shadow blacklist implementation
- Add shadow blacklist feature, but a different implementation from
nicklan's. 5 matching modes (exact, starts-with, contains, wildcard,
PCRE) and 3 matching targets (window name, window class instance,
window general class). Not extensively tested, bugs to be expected.
It's slower for exact matching than nicklan's as it uses linear search
instead of hash table. Also, PCRE's JIT optimization may cause issues
on PaX kernels.
- Add dependency to libpcre. Could be made optional if we have a
graceful way to handle that in Makefile.
- Some matching functions are GNU extensions of glibc. So this version
may have troubles running on platforms not using glibc.
- Fix a bug that access freed memory blocks in set_fade_callcack() and
check_fade_fin(). valgrind found it out.
- Use WM_CLASS to detect client windows instead of WM_STATE. Some client
windows (like notification windows) have WM_CLASS but not WM_STATE.
- Mark the extents as damaged if shadow state changed in
determine_shadow().
- Rewrite wid_get_name(). Code clean-up.
- Two debugging options: DEBUG_WINDATA and DEBUG_WINMATCH.
- As the matching system is ready, it should be rather easy to add other
kinds of blacklists, like fading blacklist.
2012-09-22 11:42:39 +08:00
|
|
|
enum wincond_target {
|
|
|
|
CONDTGT_NAME,
|
|
|
|
CONDTGT_CLASSI,
|
|
|
|
CONDTGT_CLASSG,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum wincond_type {
|
|
|
|
CONDTP_EXACT,
|
|
|
|
CONDTP_ANYWHERE,
|
|
|
|
CONDTP_FROMSTART,
|
|
|
|
CONDTP_WILDCARD,
|
|
|
|
CONDTP_REGEX_PCRE,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define CONDF_IGNORECASE 0x0001
|
|
|
|
|
|
|
|
typedef struct _wincond {
|
|
|
|
enum wincond_target target;
|
|
|
|
enum wincond_type type;
|
|
|
|
char *pattern;
|
|
|
|
#ifdef CONFIG_REGEX_PCRE
|
|
|
|
pcre *regex_pcre;
|
|
|
|
pcre_extra *regex_pcre_extra;
|
|
|
|
#endif
|
|
|
|
int16_t flags;
|
|
|
|
struct _wincond *next;
|
|
|
|
} wincond;
|
|
|
|
|
2012-02-08 18:31:39 +08:00
|
|
|
typedef struct _win {
|
|
|
|
struct _win *next;
|
|
|
|
Window id;
|
|
|
|
Window client_win;
|
|
|
|
Pixmap pixmap;
|
|
|
|
XWindowAttributes a;
|
2012-10-31 08:54:09 +08:00
|
|
|
winmode mode;
|
2012-02-08 18:31:39 +08:00
|
|
|
int damaged;
|
|
|
|
Damage damage;
|
|
|
|
Picture picture;
|
|
|
|
XserverRegion border_size;
|
|
|
|
XserverRegion extents;
|
2012-09-17 22:15:04 +08:00
|
|
|
// Type of the window.
|
|
|
|
wintype window_type;
|
|
|
|
/// Whether the window is focused.
|
|
|
|
Bool focused;
|
|
|
|
Bool destroyed;
|
|
|
|
/// Cached width/height of the window including border.
|
|
|
|
int widthb, heightb;
|
2012-10-01 10:34:40 +08:00
|
|
|
/// Whether the window is bounding-shaped.
|
|
|
|
Bool bounding_shaped;
|
|
|
|
/// Whether the window just have rounded corners.
|
|
|
|
Bool rounded_corners;
|
2012-10-31 08:54:09 +08:00
|
|
|
/// Whether this window is to be painted
|
|
|
|
Bool to_paint;
|
2012-09-17 12:31:01 +08:00
|
|
|
|
Feature: Issue #29: Alternative shadow blacklist implementation
- Add shadow blacklist feature, but a different implementation from
nicklan's. 5 matching modes (exact, starts-with, contains, wildcard,
PCRE) and 3 matching targets (window name, window class instance,
window general class). Not extensively tested, bugs to be expected.
It's slower for exact matching than nicklan's as it uses linear search
instead of hash table. Also, PCRE's JIT optimization may cause issues
on PaX kernels.
- Add dependency to libpcre. Could be made optional if we have a
graceful way to handle that in Makefile.
- Some matching functions are GNU extensions of glibc. So this version
may have troubles running on platforms not using glibc.
- Fix a bug that access freed memory blocks in set_fade_callcack() and
check_fade_fin(). valgrind found it out.
- Use WM_CLASS to detect client windows instead of WM_STATE. Some client
windows (like notification windows) have WM_CLASS but not WM_STATE.
- Mark the extents as damaged if shadow state changed in
determine_shadow().
- Rewrite wid_get_name(). Code clean-up.
- Two debugging options: DEBUG_WINDATA and DEBUG_WINMATCH.
- As the matching system is ready, it should be rather easy to add other
kinds of blacklists, like fading blacklist.
2012-09-22 11:42:39 +08:00
|
|
|
// Blacklist related members
|
|
|
|
char *name;
|
|
|
|
char *class_instance;
|
|
|
|
char *class_general;
|
|
|
|
wincond *cache_sblst;
|
|
|
|
wincond *cache_fblst;
|
|
|
|
|
2012-09-19 20:49:16 +08:00
|
|
|
// Opacity-related members
|
2012-09-17 12:31:01 +08:00
|
|
|
/// Current window opacity.
|
2012-09-11 22:22:58 +08:00
|
|
|
opacity_t opacity;
|
2012-09-19 20:49:16 +08:00
|
|
|
/// Target window opacity.
|
|
|
|
opacity_t opacity_tgt;
|
2012-09-11 22:22:58 +08:00
|
|
|
/// Cached value of opacity window attribute.
|
|
|
|
opacity_t opacity_prop;
|
2012-10-03 21:13:34 +08:00
|
|
|
/// Cached value of opacity window attribute on client window. For
|
|
|
|
/// broken window managers not transferring client window's
|
|
|
|
/// _NET_WM_OPACITY value
|
|
|
|
opacity_t opacity_prop_client;
|
2012-09-17 12:31:01 +08:00
|
|
|
/// Alpha mask Picture to render window with opacity.
|
|
|
|
Picture alpha_pict;
|
|
|
|
|
2012-09-19 20:49:16 +08:00
|
|
|
// Fading-related members
|
|
|
|
/// Do not fade if it's false. Change on window type change.
|
|
|
|
/// Used by fading blacklist in the future.
|
|
|
|
Bool fade;
|
|
|
|
/// Callback to be called after fading completed.
|
|
|
|
void (*fade_callback) (Display *dpy, struct _win *w);
|
|
|
|
|
|
|
|
// Frame-opacity-related members
|
2012-09-17 22:15:04 +08:00
|
|
|
/// Current window frame opacity. Affected by window opacity.
|
2012-09-17 12:31:01 +08:00
|
|
|
double frame_opacity;
|
|
|
|
/// Alpha mask Picture to render window frame with opacity.
|
|
|
|
Picture frame_alpha_pict;
|
2012-09-19 20:49:16 +08:00
|
|
|
/// Frame widths. Determined by client window attributes.
|
|
|
|
unsigned int left_width, right_width, top_width, bottom_width;
|
2012-09-17 12:31:01 +08:00
|
|
|
|
2012-09-19 20:49:16 +08:00
|
|
|
// Shadow-related members
|
2012-09-17 22:15:04 +08:00
|
|
|
/// Whether a window has shadow. Affected by window type.
|
|
|
|
Bool shadow;
|
|
|
|
/// Opacity of the shadow. Affected by window opacity and frame opacity.
|
|
|
|
double shadow_opacity;
|
|
|
|
/// X offset of shadow. Affected by commandline argument.
|
|
|
|
int shadow_dx;
|
|
|
|
/// Y offset of shadow. Affected by commandline argument.
|
|
|
|
int shadow_dy;
|
|
|
|
/// Width of shadow. Affected by window size and commandline argument.
|
|
|
|
int shadow_width;
|
|
|
|
/// Height of shadow. Affected by window size and commandline argument.
|
|
|
|
int shadow_height;
|
2012-09-29 13:15:09 +08:00
|
|
|
/// Picture to render shadow. Affected by window size.
|
2012-09-17 22:15:04 +08:00
|
|
|
Picture shadow_pict;
|
2012-09-29 13:15:09 +08:00
|
|
|
/// Alpha mask Picture to render shadow. Affected by shadow opacity.
|
|
|
|
Picture shadow_alpha_pict;
|
2012-09-17 22:15:04 +08:00
|
|
|
|
2012-09-19 20:49:16 +08:00
|
|
|
// Dim-related members
|
2012-09-12 10:52:52 +08:00
|
|
|
/// Whether the window is to be dimmed.
|
|
|
|
Bool dim;
|
2012-09-17 22:15:04 +08:00
|
|
|
|
|
|
|
/// Window flags. Definitions above.
|
|
|
|
int_fast16_t flags;
|
|
|
|
|
2012-02-08 18:31:39 +08:00
|
|
|
unsigned long damage_sequence; /* sequence when damage was created */
|
|
|
|
|
|
|
|
Bool need_configure;
|
|
|
|
XConfigureEvent queue_configure;
|
2012-10-21 20:44:24 +08:00
|
|
|
/// Region to be ignored when painting. Basically the region where
|
|
|
|
/// higher opaque windows will paint upon. Depends on window frame
|
|
|
|
/// opacity state, window geometry, window mapped/unmapped state,
|
|
|
|
/// window mode, of this and all higher windows.
|
|
|
|
XserverRegion reg_ignore;
|
2012-02-08 18:31:39 +08:00
|
|
|
|
|
|
|
struct _win *prev_trans;
|
|
|
|
} win;
|
|
|
|
|
2012-11-01 10:43:15 +08:00
|
|
|
typedef enum {
|
Feature: #7: VSync
- Add VSync feature. 3 possible VSync methods available: "sw" (software,
not too reliable, but at least you have something to fallback to),
"drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
"opengl" (using SGI_swap_control extension OpenGL, might work on more
drivers than the DRM method). "sw" and "opengl" are briefly tested,
"drm" received utterly no test (because I use the nVidia binary blob).
They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".
- Add --refresh-rate to let user specify a refresh rate for software
VSync, in case the automatic refresh rate detection does not work
well.
- Seemingly the automatic refresh rate detection using X RandR in
software VSync detects refresh rate incorrectly. Need further investigation.
- Fix a few bugs in fading timing.
- Add a workaround for client window detection on Fluxbox, as Fluxbox
(incorrectly?) sets the override-redirect flag upon all frame
windows.
- Software VSync adds dependency on librt (a part of glibc) for
nanosecond-level timing functions, and libXrandr for automatic refresh
rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
but does not link to libdrm; OpenGL VSync adds dependency on libGL.
- Print timing information on DEBUG_REPAINT.
2012-10-08 10:20:01 +08:00
|
|
|
VSYNC_NONE,
|
|
|
|
VSYNC_DRM,
|
|
|
|
VSYNC_OPENGL,
|
|
|
|
} vsync_t;
|
|
|
|
|
|
|
|
#ifdef CONFIG_VSYNC_OPENGL
|
|
|
|
typedef int (*f_WaitVideoSync) (int, int, unsigned *);
|
|
|
|
typedef int (*f_GetVideoSync) (unsigned *);
|
|
|
|
#endif
|
|
|
|
|
2012-09-26 09:53:18 +08:00
|
|
|
typedef struct _options {
|
2012-09-26 18:54:35 +08:00
|
|
|
// General
|
2012-09-26 09:53:18 +08:00
|
|
|
char *display;
|
2012-09-26 18:54:35 +08:00
|
|
|
/// Whether to try to detect WM windows and mark them as focused.
|
|
|
|
Bool mark_wmwin_focused;
|
2012-09-26 19:48:36 +08:00
|
|
|
/// Whether to mark override-redirect windows as focused.
|
|
|
|
Bool mark_ovredir_focused;
|
2012-09-26 18:54:35 +08:00
|
|
|
/// Whether to fork to background.
|
|
|
|
Bool fork_after_register;
|
2012-10-01 10:34:40 +08:00
|
|
|
/// Whether to detect rounded corners.
|
|
|
|
Bool detect_rounded_corners;
|
2012-10-24 10:09:59 +08:00
|
|
|
/// Whether to paint on X Composite overlay window instead of root
|
|
|
|
/// window.
|
|
|
|
Bool paint_on_overlay;
|
2012-10-01 10:34:40 +08:00
|
|
|
/// Whether to work under synchronized mode for debugging.
|
2012-09-26 18:54:35 +08:00
|
|
|
Bool synchronize;
|
|
|
|
|
2012-10-26 11:12:28 +08:00
|
|
|
// VSync and software optimization
|
Feature: #7: VSync
- Add VSync feature. 3 possible VSync methods available: "sw" (software,
not too reliable, but at least you have something to fallback to),
"drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
"opengl" (using SGI_swap_control extension OpenGL, might work on more
drivers than the DRM method). "sw" and "opengl" are briefly tested,
"drm" received utterly no test (because I use the nVidia binary blob).
They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".
- Add --refresh-rate to let user specify a refresh rate for software
VSync, in case the automatic refresh rate detection does not work
well.
- Seemingly the automatic refresh rate detection using X RandR in
software VSync detects refresh rate incorrectly. Need further investigation.
- Fix a few bugs in fading timing.
- Add a workaround for client window detection on Fluxbox, as Fluxbox
(incorrectly?) sets the override-redirect flag upon all frame
windows.
- Software VSync adds dependency on librt (a part of glibc) for
nanosecond-level timing functions, and libXrandr for automatic refresh
rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
but does not link to libdrm; OpenGL VSync adds dependency on libGL.
- Print timing information on DEBUG_REPAINT.
2012-10-08 10:20:01 +08:00
|
|
|
/// User-specified refresh rate.
|
|
|
|
int refresh_rate;
|
2012-10-26 11:12:28 +08:00
|
|
|
/// Whether to enable refresh-rate-based software optimization.
|
|
|
|
Bool sw_opti;
|
Feature: #7: VSync
- Add VSync feature. 3 possible VSync methods available: "sw" (software,
not too reliable, but at least you have something to fallback to),
"drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
"opengl" (using SGI_swap_control extension OpenGL, might work on more
drivers than the DRM method). "sw" and "opengl" are briefly tested,
"drm" received utterly no test (because I use the nVidia binary blob).
They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".
- Add --refresh-rate to let user specify a refresh rate for software
VSync, in case the automatic refresh rate detection does not work
well.
- Seemingly the automatic refresh rate detection using X RandR in
software VSync detects refresh rate incorrectly. Need further investigation.
- Fix a few bugs in fading timing.
- Add a workaround for client window detection on Fluxbox, as Fluxbox
(incorrectly?) sets the override-redirect flag upon all frame
windows.
- Software VSync adds dependency on librt (a part of glibc) for
nanosecond-level timing functions, and libXrandr for automatic refresh
rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
but does not link to libdrm; OpenGL VSync adds dependency on libGL.
- Print timing information on DEBUG_REPAINT.
2012-10-08 10:20:01 +08:00
|
|
|
/// VSync method to use;
|
|
|
|
vsync_t vsync;
|
2012-10-23 13:42:20 +08:00
|
|
|
/// Whether to enable double buffer.
|
|
|
|
Bool dbe;
|
2012-11-01 10:43:15 +08:00
|
|
|
/// Whether to do VSync aggressively.
|
|
|
|
Bool vsync_aggressive;
|
Feature: #7: VSync
- Add VSync feature. 3 possible VSync methods available: "sw" (software,
not too reliable, but at least you have something to fallback to),
"drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
"opengl" (using SGI_swap_control extension OpenGL, might work on more
drivers than the DRM method). "sw" and "opengl" are briefly tested,
"drm" received utterly no test (because I use the nVidia binary blob).
They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".
- Add --refresh-rate to let user specify a refresh rate for software
VSync, in case the automatic refresh rate detection does not work
well.
- Seemingly the automatic refresh rate detection using X RandR in
software VSync detects refresh rate incorrectly. Need further investigation.
- Fix a few bugs in fading timing.
- Add a workaround for client window detection on Fluxbox, as Fluxbox
(incorrectly?) sets the override-redirect flag upon all frame
windows.
- Software VSync adds dependency on librt (a part of glibc) for
nanosecond-level timing functions, and libXrandr for automatic refresh
rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
but does not link to libdrm; OpenGL VSync adds dependency on libGL.
- Print timing information on DEBUG_REPAINT.
2012-10-08 10:20:01 +08:00
|
|
|
|
2012-09-26 18:54:35 +08:00
|
|
|
// Shadow
|
|
|
|
Bool wintype_shadow[NUM_WINTYPES];
|
|
|
|
/// Red, green and blue tone of the shadow.
|
|
|
|
double shadow_red, shadow_green, shadow_blue;
|
2012-09-26 09:53:18 +08:00
|
|
|
int shadow_radius;
|
2012-09-26 18:54:35 +08:00
|
|
|
int shadow_offset_x, shadow_offset_y;
|
2012-09-26 09:53:18 +08:00
|
|
|
double shadow_opacity;
|
2012-09-26 18:54:35 +08:00
|
|
|
Bool clear_shadow;
|
|
|
|
/// Shadow blacklist. A linked list of conditions.
|
|
|
|
wincond *shadow_blacklist;
|
2012-10-01 10:34:40 +08:00
|
|
|
/// Whether bounding-shaped window should be ignored.
|
|
|
|
Bool shadow_ignore_shaped;
|
2012-09-26 09:53:18 +08:00
|
|
|
|
2012-09-26 18:54:35 +08:00
|
|
|
// Fading
|
|
|
|
Bool wintype_fade[NUM_WINTYPES];
|
2012-09-26 09:53:18 +08:00
|
|
|
/// How much to fade in in a single fading step.
|
|
|
|
opacity_t fade_in_step;
|
|
|
|
/// How much to fade out in a single fading step.
|
|
|
|
opacity_t fade_out_step;
|
|
|
|
unsigned long fade_delta;
|
2012-09-26 21:40:48 +08:00
|
|
|
Bool no_fading_openclose;
|
2012-09-26 18:54:35 +08:00
|
|
|
/// Fading blacklist. A linked list of conditions.
|
|
|
|
wincond *fade_blacklist;
|
2012-09-26 09:53:18 +08:00
|
|
|
|
2012-09-26 18:54:35 +08:00
|
|
|
// Opacity
|
|
|
|
double wintype_opacity[NUM_WINTYPES];
|
2012-09-26 09:53:18 +08:00
|
|
|
/// Default opacity for inactive windows.
|
|
|
|
/// 32-bit integer with the format of _NET_WM_OPACITY. 0 stands for
|
|
|
|
/// not enabled, default.
|
|
|
|
opacity_t inactive_opacity;
|
|
|
|
/// Whether inactive_opacity overrides the opacity set by window
|
|
|
|
/// attributes.
|
|
|
|
Bool inactive_opacity_override;
|
2012-10-03 21:13:34 +08:00
|
|
|
/// Frame opacity. Relative to window opacity, also affects shadow
|
|
|
|
/// opacity.
|
2012-09-26 09:53:18 +08:00
|
|
|
double frame_opacity;
|
2012-10-03 21:13:34 +08:00
|
|
|
/// Whether to detect _NET_WM_OPACITY on client windows. Used on window
|
|
|
|
/// managers that don't pass _NET_WM_OPACITY to frame windows.
|
|
|
|
Bool detect_client_opacity;
|
2012-09-26 09:53:18 +08:00
|
|
|
/// How much to dim an inactive window. 0.0 - 1.0, 0 to disable.
|
|
|
|
double inactive_dim;
|
2012-10-13 18:46:59 +08:00
|
|
|
/// Step for pregenerating alpha pictures. 0.01 - 1.0.
|
|
|
|
double alpha_step;
|
2012-11-04 18:11:08 +08:00
|
|
|
/// Whether to use EWMH _NET_ACTIVE_WINDOW to find active window.
|
|
|
|
Bool use_ewmh_active_win;
|
2012-09-26 09:53:18 +08:00
|
|
|
|
2012-09-26 18:54:35 +08:00
|
|
|
// Calculated
|
2012-09-26 09:53:18 +08:00
|
|
|
/// Whether compton needs to track focus changes.
|
|
|
|
Bool track_focus;
|
|
|
|
/// Whether compton needs to track window name and class.
|
|
|
|
Bool track_wdata;
|
|
|
|
|
2012-09-26 18:54:35 +08:00
|
|
|
} options_t;
|
2012-09-26 09:53:18 +08:00
|
|
|
|
2012-09-26 18:54:35 +08:00
|
|
|
struct options_tmp {
|
2012-09-26 09:53:18 +08:00
|
|
|
Bool no_dock_shadow;
|
|
|
|
Bool no_dnd_shadow;
|
|
|
|
double menu_opacity;
|
2012-09-26 18:54:35 +08:00
|
|
|
};
|
2012-09-26 09:53:18 +08:00
|
|
|
|
2012-02-08 18:31:39 +08:00
|
|
|
typedef struct _conv {
|
|
|
|
int size;
|
|
|
|
double *data;
|
|
|
|
} conv;
|
|
|
|
|
2012-09-13 23:24:37 +08:00
|
|
|
typedef enum {
|
|
|
|
WIN_EVMODE_UNKNOWN,
|
|
|
|
WIN_EVMODE_FRAME,
|
|
|
|
WIN_EVMODE_CLIENT
|
|
|
|
} win_evmode_t;
|
|
|
|
|
2012-09-11 21:33:03 +08:00
|
|
|
extern int root_height, root_width;
|
2012-09-13 21:38:55 +08:00
|
|
|
extern Atom atom_client_attr;
|
2012-09-29 22:53:57 +08:00
|
|
|
extern Bool idling;
|
2012-10-01 10:34:40 +08:00
|
|
|
extern Bool shape_exists;
|
2012-10-31 08:54:09 +08:00
|
|
|
extern Bool reg_ignore_expire;
|
2012-09-11 22:22:58 +08:00
|
|
|
|
2012-02-27 12:00:12 +08:00
|
|
|
/**
|
|
|
|
* Functions
|
|
|
|
*/
|
|
|
|
|
2012-09-11 21:57:50 +08:00
|
|
|
// inline functions must be made static to compile correctly under clang:
|
|
|
|
// http://clang.llvm.org/compatibility.html#inline
|
|
|
|
|
2012-09-16 23:12:02 +08:00
|
|
|
// Helper functions
|
|
|
|
|
2012-09-17 16:04:04 +08:00
|
|
|
static void
|
|
|
|
discard_ignore(Display *dpy, unsigned long sequence);
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_ignore(Display *dpy, unsigned long sequence);
|
|
|
|
|
|
|
|
static int
|
|
|
|
should_ignore(Display *dpy, unsigned long sequence);
|
|
|
|
|
Feature: #7: VSync
- Add VSync feature. 3 possible VSync methods available: "sw" (software,
not too reliable, but at least you have something to fallback to),
"drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
"opengl" (using SGI_swap_control extension OpenGL, might work on more
drivers than the DRM method). "sw" and "opengl" are briefly tested,
"drm" received utterly no test (because I use the nVidia binary blob).
They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".
- Add --refresh-rate to let user specify a refresh rate for software
VSync, in case the automatic refresh rate detection does not work
well.
- Seemingly the automatic refresh rate detection using X RandR in
software VSync detects refresh rate incorrectly. Need further investigation.
- Fix a few bugs in fading timing.
- Add a workaround for client window detection on Fluxbox, as Fluxbox
(incorrectly?) sets the override-redirect flag upon all frame
windows.
- Software VSync adds dependency on librt (a part of glibc) for
nanosecond-level timing functions, and libXrandr for automatic refresh
rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
but does not link to libdrm; OpenGL VSync adds dependency on libGL.
- Print timing information on DEBUG_REPAINT.
2012-10-08 10:20:01 +08:00
|
|
|
/**
|
|
|
|
* Subtract two unsigned long values.
|
|
|
|
*
|
|
|
|
* Truncate to 0 if the result is negative.
|
|
|
|
*/
|
|
|
|
static inline unsigned long
|
|
|
|
sub_unslong(unsigned long a, unsigned long b) {
|
|
|
|
return (a > b) ? a - b : 0;
|
|
|
|
}
|
|
|
|
|
2012-09-25 21:04:10 +08:00
|
|
|
/**
|
|
|
|
* Set a Bool array of all wintypes to true.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
wintype_arr_enable(Bool arr[]) {
|
|
|
|
wintype i;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_WINTYPES; ++i) {
|
|
|
|
arr[i] = True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Feature: Issue #29: Alternative shadow blacklist implementation
- Add shadow blacklist feature, but a different implementation from
nicklan's. 5 matching modes (exact, starts-with, contains, wildcard,
PCRE) and 3 matching targets (window name, window class instance,
window general class). Not extensively tested, bugs to be expected.
It's slower for exact matching than nicklan's as it uses linear search
instead of hash table. Also, PCRE's JIT optimization may cause issues
on PaX kernels.
- Add dependency to libpcre. Could be made optional if we have a
graceful way to handle that in Makefile.
- Some matching functions are GNU extensions of glibc. So this version
may have troubles running on platforms not using glibc.
- Fix a bug that access freed memory blocks in set_fade_callcack() and
check_fade_fin(). valgrind found it out.
- Use WM_CLASS to detect client windows instead of WM_STATE. Some client
windows (like notification windows) have WM_CLASS but not WM_STATE.
- Mark the extents as damaged if shadow state changed in
determine_shadow().
- Rewrite wid_get_name(). Code clean-up.
- Two debugging options: DEBUG_WINDATA and DEBUG_WINMATCH.
- As the matching system is ready, it should be rather easy to add other
kinds of blacklists, like fading blacklist.
2012-09-22 11:42:39 +08:00
|
|
|
/**
|
|
|
|
* Allocate the space and copy a string.
|
|
|
|
*/
|
|
|
|
static inline char *
|
|
|
|
mstrcpy(const char *src) {
|
|
|
|
char *str = malloc(sizeof(char) * (strlen(src) + 1));
|
|
|
|
|
|
|
|
strcpy(str, src);
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2012-09-25 10:19:20 +08:00
|
|
|
/**
|
|
|
|
* Allocate the space and join two strings.
|
|
|
|
*/
|
|
|
|
static inline char *
|
|
|
|
mstrjoin(const char *src1, const char *src2) {
|
|
|
|
char *str = malloc(sizeof(char) * (strlen(src1) + strlen(src2) + 1));
|
|
|
|
|
|
|
|
strcpy(str, src1);
|
|
|
|
strcat(str, src2);
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate the space and join two strings;
|
|
|
|
*/
|
|
|
|
static inline char *
|
|
|
|
mstrjoin3(const char *src1, const char *src2, const char *src3) {
|
|
|
|
char *str = malloc(sizeof(char) * (strlen(src1) + strlen(src2)
|
|
|
|
+ strlen(src3) + 1));
|
|
|
|
|
|
|
|
strcpy(str, src1);
|
|
|
|
strcat(str, src2);
|
|
|
|
strcat(str, src3);
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2012-09-12 21:01:06 +08:00
|
|
|
/**
|
|
|
|
* Normalize an int value to a specific range.
|
|
|
|
*
|
|
|
|
* @param i int value to normalize
|
|
|
|
* @param min minimal value
|
|
|
|
* @param max maximum value
|
|
|
|
* @return normalized value
|
|
|
|
*/
|
2012-09-25 10:19:20 +08:00
|
|
|
static inline int
|
2012-09-13 13:58:05 +08:00
|
|
|
normalize_i_range(int i, int min, int max) {
|
|
|
|
if (i > max) return max;
|
|
|
|
if (i < min) return min;
|
2012-09-12 21:01:06 +08:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2012-09-25 10:19:20 +08:00
|
|
|
/**
|
|
|
|
* Select the larger integer of two.
|
|
|
|
*/
|
|
|
|
static inline int
|
|
|
|
max_i(int a, int b) {
|
|
|
|
return (a > b ? a : b);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Select the smaller integer of two.
|
|
|
|
*/
|
|
|
|
static inline int
|
|
|
|
min_i(int a, int b) {
|
|
|
|
return (a > b ? b : a);
|
|
|
|
}
|
|
|
|
|
2012-09-19 20:49:16 +08:00
|
|
|
/**
|
|
|
|
* Normalize a double value to a specific range.
|
|
|
|
*
|
|
|
|
* @param d double value to normalize
|
|
|
|
* @param min minimal value
|
|
|
|
* @param max maximum value
|
|
|
|
* @return normalized value
|
|
|
|
*/
|
|
|
|
static inline double
|
|
|
|
normalize_d_range(double d, double min, double max) {
|
|
|
|
if (d > max) return max;
|
|
|
|
if (d < min) return min;
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
2012-09-11 22:22:58 +08:00
|
|
|
/**
|
|
|
|
* Normalize a double value to 0.\ 0 - 1.\ 0.
|
|
|
|
*
|
|
|
|
* @param d double value to normalize
|
2012-09-19 20:49:16 +08:00
|
|
|
* @return normalized value
|
2012-09-11 22:22:58 +08:00
|
|
|
*/
|
2012-09-13 13:58:05 +08:00
|
|
|
static inline double
|
|
|
|
normalize_d(double d) {
|
2012-09-19 20:49:16 +08:00
|
|
|
return normalize_d_range(d, 0.0, 1.0);
|
2012-09-11 21:57:50 +08:00
|
|
|
}
|
|
|
|
|
2012-09-11 22:22:58 +08:00
|
|
|
/**
|
|
|
|
* Check if a window ID exists in an array of window IDs.
|
|
|
|
*
|
|
|
|
* @param arr the array of window IDs
|
|
|
|
* @param count amount of elements in the array
|
|
|
|
* @param wid window ID to search for
|
|
|
|
*/
|
2012-09-13 13:58:05 +08:00
|
|
|
static inline Bool
|
|
|
|
array_wid_exists(const Window *arr, int count, Window wid) {
|
2012-09-11 22:22:58 +08:00
|
|
|
while (count--) {
|
2012-09-13 13:58:05 +08:00
|
|
|
if (arr[count] == wid) {
|
2012-09-11 22:22:58 +08:00
|
|
|
return True;
|
2012-09-13 13:58:05 +08:00
|
|
|
}
|
2012-09-11 22:22:58 +08:00
|
|
|
}
|
2012-09-13 13:39:43 +08:00
|
|
|
|
2012-09-11 22:22:58 +08:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
2012-09-13 13:39:43 +08:00
|
|
|
/*
|
2012-09-12 09:08:15 +08:00
|
|
|
* Subtracting two struct timeval values.
|
|
|
|
*
|
|
|
|
* Taken from glibc manual.
|
|
|
|
*
|
|
|
|
* Subtract the `struct timeval' values X and Y,
|
|
|
|
* storing the result in RESULT.
|
|
|
|
* Return 1 if the difference is negative, otherwise 0. */
|
2012-09-13 13:58:05 +08:00
|
|
|
static int
|
|
|
|
timeval_subtract(struct timeval *result,
|
|
|
|
struct timeval *x,
|
|
|
|
struct timeval *y) {
|
2012-09-12 09:08:15 +08:00
|
|
|
/* Perform the carry for the later subtraction by updating y. */
|
|
|
|
if (x->tv_usec < y->tv_usec) {
|
|
|
|
int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
|
|
|
|
y->tv_usec -= 1000000 * nsec;
|
|
|
|
y->tv_sec += nsec;
|
|
|
|
}
|
2012-09-13 13:58:05 +08:00
|
|
|
|
2012-09-12 09:08:15 +08:00
|
|
|
if (x->tv_usec - y->tv_usec > 1000000) {
|
|
|
|
int nsec = (x->tv_usec - y->tv_usec) / 1000000;
|
|
|
|
y->tv_usec += 1000000 * nsec;
|
|
|
|
y->tv_sec -= nsec;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compute the time remaining to wait.
|
|
|
|
tv_usec is certainly positive. */
|
|
|
|
result->tv_sec = x->tv_sec - y->tv_sec;
|
|
|
|
result->tv_usec = x->tv_usec - y->tv_usec;
|
|
|
|
|
|
|
|
/* Return 1 if result is negative. */
|
|
|
|
return x->tv_sec < y->tv_sec;
|
|
|
|
}
|
|
|
|
|
Feature: #7: VSync
- Add VSync feature. 3 possible VSync methods available: "sw" (software,
not too reliable, but at least you have something to fallback to),
"drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
"opengl" (using SGI_swap_control extension OpenGL, might work on more
drivers than the DRM method). "sw" and "opengl" are briefly tested,
"drm" received utterly no test (because I use the nVidia binary blob).
They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".
- Add --refresh-rate to let user specify a refresh rate for software
VSync, in case the automatic refresh rate detection does not work
well.
- Seemingly the automatic refresh rate detection using X RandR in
software VSync detects refresh rate incorrectly. Need further investigation.
- Fix a few bugs in fading timing.
- Add a workaround for client window detection on Fluxbox, as Fluxbox
(incorrectly?) sets the override-redirect flag upon all frame
windows.
- Software VSync adds dependency on librt (a part of glibc) for
nanosecond-level timing functions, and libXrandr for automatic refresh
rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
but does not link to libdrm; OpenGL VSync adds dependency on libGL.
- Print timing information on DEBUG_REPAINT.
2012-10-08 10:20:01 +08:00
|
|
|
/*
|
|
|
|
* Subtracting two struct timespec values.
|
|
|
|
*
|
|
|
|
* Taken from glibc manual.
|
|
|
|
*
|
|
|
|
* Subtract the `struct timespec' values X and Y,
|
|
|
|
* storing the result in RESULT.
|
|
|
|
* Return 1 if the difference is negative, otherwise 0.
|
|
|
|
*/
|
|
|
|
static inline int
|
|
|
|
timespec_subtract(struct timespec *result,
|
|
|
|
struct timespec *x,
|
|
|
|
struct timespec *y) {
|
|
|
|
/* Perform the carry for the later subtraction by updating y. */
|
|
|
|
if (x->tv_nsec < y->tv_nsec) {
|
|
|
|
int nsec = (y->tv_nsec - x->tv_nsec) / NS_PER_SEC + 1;
|
|
|
|
y->tv_nsec -= NS_PER_SEC * nsec;
|
|
|
|
y->tv_sec += nsec;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x->tv_nsec - y->tv_nsec > NS_PER_SEC) {
|
|
|
|
int nsec = (x->tv_nsec - y->tv_nsec) / NS_PER_SEC;
|
|
|
|
y->tv_nsec += NS_PER_SEC * nsec;
|
|
|
|
y->tv_sec -= nsec;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Compute the time remaining to wait.
|
|
|
|
tv_nsec is certainly positive. */
|
|
|
|
result->tv_sec = x->tv_sec - y->tv_sec;
|
|
|
|
result->tv_nsec = x->tv_nsec - y->tv_nsec;
|
|
|
|
|
|
|
|
/* Return 1 if result is negative. */
|
|
|
|
return x->tv_sec < y->tv_sec;
|
|
|
|
}
|
|
|
|
|
2012-10-26 11:12:28 +08:00
|
|
|
/**
|
|
|
|
* Get current time in struct timespec.
|
|
|
|
*
|
|
|
|
* Note its starting time is unspecified.
|
|
|
|
*/
|
|
|
|
static inline struct timespec
|
|
|
|
get_time_timespec(void) {
|
|
|
|
struct timespec tm = { 0 };
|
|
|
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &tm);
|
|
|
|
|
|
|
|
// Return a time of all 0 if the call fails
|
|
|
|
return tm;
|
|
|
|
}
|
|
|
|
|
2012-09-12 09:08:15 +08:00
|
|
|
/**
|
|
|
|
* Print time passed since program starts execution.
|
|
|
|
*
|
|
|
|
* Used for debugging.
|
|
|
|
*/
|
2012-09-13 13:58:05 +08:00
|
|
|
static inline void
|
|
|
|
print_timestamp(void) {
|
2012-09-12 09:08:15 +08:00
|
|
|
struct timeval tm, diff;
|
|
|
|
|
2012-09-13 13:58:05 +08:00
|
|
|
if (gettimeofday(&tm, NULL)) return;
|
2012-09-12 09:08:15 +08:00
|
|
|
|
|
|
|
timeval_subtract(&diff, &tm, &time_start);
|
|
|
|
printf("[ %5ld.%02ld ] ", diff.tv_sec, diff.tv_usec / 10000);
|
|
|
|
}
|
|
|
|
|
2012-09-16 23:12:02 +08:00
|
|
|
/**
|
|
|
|
* Destroy a <code>XserverRegion</code>.
|
|
|
|
*/
|
|
|
|
inline static void
|
|
|
|
free_region(Display *dpy, XserverRegion *p) {
|
|
|
|
if (*p) {
|
|
|
|
XFixesDestroyRegion(dpy, *p);
|
|
|
|
*p = None;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroy a <code>Picture</code>.
|
|
|
|
*/
|
|
|
|
inline static void
|
|
|
|
free_picture(Display *dpy, Picture *p) {
|
|
|
|
if (*p) {
|
|
|
|
XRenderFreePicture(dpy, *p);
|
|
|
|
*p = None;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroy a <code>Pixmap</code>.
|
|
|
|
*/
|
|
|
|
inline static void
|
|
|
|
free_pixmap(Display *dpy, Pixmap *p) {
|
|
|
|
if (*p) {
|
|
|
|
XFreePixmap(dpy, *p);
|
|
|
|
*p = None;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroy a <code>Damage</code>.
|
|
|
|
*/
|
|
|
|
inline static void
|
|
|
|
free_damage(Display *dpy, Damage *p) {
|
|
|
|
if (*p) {
|
2012-09-17 16:04:04 +08:00
|
|
|
// BadDamage will be thrown if the window is destroyed
|
|
|
|
set_ignore(dpy, NextRequest(dpy));
|
2012-09-16 23:12:02 +08:00
|
|
|
XDamageDestroy(dpy, *p);
|
|
|
|
*p = None;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-29 22:00:11 +08:00
|
|
|
/**
|
|
|
|
* Get current system clock in milliseconds.
|
|
|
|
*
|
|
|
|
* The return type must be unsigned long because so many milliseconds have
|
|
|
|
* passed since the epoch.
|
|
|
|
*/
|
2012-09-19 20:49:16 +08:00
|
|
|
static unsigned long
|
2012-10-29 22:00:11 +08:00
|
|
|
get_time_ms(void) {
|
|
|
|
struct timeval tv;
|
|
|
|
|
|
|
|
gettimeofday(&tv, NULL);
|
|
|
|
|
|
|
|
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
|
|
|
}
|
2012-02-08 18:31:39 +08:00
|
|
|
|
2012-09-19 20:49:16 +08:00
|
|
|
static int
|
|
|
|
fade_timeout(void);
|
2012-02-08 18:31:39 +08:00
|
|
|
|
2012-02-27 12:00:12 +08:00
|
|
|
static void
|
2012-09-19 20:49:16 +08:00
|
|
|
run_fade(Display *dpy, win *w, unsigned steps);
|
2012-02-08 18:31:39 +08:00
|
|
|
|
|
|
|
static void
|
2012-09-19 20:49:16 +08:00
|
|
|
set_fade_callback(Display *dpy, win *w,
|
|
|
|
void (*callback) (Display *dpy, win *w), Bool exec_callback);
|
2012-02-08 18:31:39 +08:00
|
|
|
|
2012-09-19 20:49:16 +08:00
|
|
|
/**
|
|
|
|
* Execute fade callback of a window if fading finished.
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
check_fade_fin(Display *dpy, win *w) {
|
2012-10-29 22:00:11 +08:00
|
|
|
if (w->fade_callback && w->opacity == w->opacity_tgt) {
|
Feature: Issue #29: Alternative shadow blacklist implementation
- Add shadow blacklist feature, but a different implementation from
nicklan's. 5 matching modes (exact, starts-with, contains, wildcard,
PCRE) and 3 matching targets (window name, window class instance,
window general class). Not extensively tested, bugs to be expected.
It's slower for exact matching than nicklan's as it uses linear search
instead of hash table. Also, PCRE's JIT optimization may cause issues
on PaX kernels.
- Add dependency to libpcre. Could be made optional if we have a
graceful way to handle that in Makefile.
- Some matching functions are GNU extensions of glibc. So this version
may have troubles running on platforms not using glibc.
- Fix a bug that access freed memory blocks in set_fade_callcack() and
check_fade_fin(). valgrind found it out.
- Use WM_CLASS to detect client windows instead of WM_STATE. Some client
windows (like notification windows) have WM_CLASS but not WM_STATE.
- Mark the extents as damaged if shadow state changed in
determine_shadow().
- Rewrite wid_get_name(). Code clean-up.
- Two debugging options: DEBUG_WINDATA and DEBUG_WINMATCH.
- As the matching system is ready, it should be rather easy to add other
kinds of blacklists, like fading blacklist.
2012-09-22 11:42:39 +08:00
|
|
|
// Must be the last line as the callback could destroy w!
|
|
|
|
set_fade_callback(dpy, w, NULL, True);
|
2012-09-19 20:49:16 +08:00
|
|
|
}
|
|
|
|
}
|
2012-02-08 18:31:39 +08:00
|
|
|
|
2012-02-27 12:00:12 +08:00
|
|
|
static void
|
2012-09-19 20:49:16 +08:00
|
|
|
set_fade_callback(Display *dpy, win *w,
|
|
|
|
void (*callback) (Display *dpy, win *w), Bool exec_callback);
|
2012-02-08 18:31:39 +08:00
|
|
|
|
|
|
|
static double
|
|
|
|
gaussian(double r, double x, double y);
|
|
|
|
|
|
|
|
static conv *
|
|
|
|
make_gaussian_map(Display *dpy, double r);
|
|
|
|
|
|
|
|
static unsigned char
|
|
|
|
sum_gaussian(conv *map, double opacity,
|
|
|
|
int x, int y, int width, int height);
|
|
|
|
|
|
|
|
static void
|
|
|
|
presum_gaussian(conv *map);
|
|
|
|
|
|
|
|
static XImage *
|
|
|
|
make_shadow(Display *dpy, double opacity,
|
2012-10-28 17:02:07 +08:00
|
|
|
int width, int height, Bool clear_shadow);
|
2012-02-08 18:31:39 +08:00
|
|
|
|
|
|
|
static Picture
|
2012-10-28 17:02:07 +08:00
|
|
|
shadow_picture(Display *dpy, double opacity, int width, int height,
|
|
|
|
Bool clear_shadow);
|
2012-02-08 18:31:39 +08:00
|
|
|
|
2012-02-27 12:00:12 +08:00
|
|
|
static Picture
|
2012-02-08 18:31:39 +08:00
|
|
|
solid_picture(Display *dpy, Bool argb, double a,
|
|
|
|
double r, double g, double b);
|
|
|
|
|
2012-09-25 10:19:20 +08:00
|
|
|
static inline bool is_normal_win(const win *w) {
|
|
|
|
return (WINTYPE_NORMAL == w->window_type
|
2012-10-02 21:46:37 +08:00
|
|
|
|| WINTYPE_UTILITY == w->window_type);
|
2012-09-25 10:19:20 +08:00
|
|
|
}
|
|
|
|
|
2012-10-01 10:34:40 +08:00
|
|
|
/**
|
|
|
|
* Determine if a window has a specific attribute.
|
|
|
|
*
|
|
|
|
* @param dpy Display to use
|
|
|
|
* @param w window to check
|
|
|
|
* @param atom atom of attribute to check
|
|
|
|
* @return 1 if it has the attribute, 0 otherwise
|
|
|
|
*/
|
|
|
|
static inline Bool
|
|
|
|
wid_has_attr(Display *dpy, Window w, Atom atom) {
|
|
|
|
Atom type = None;
|
|
|
|
int format;
|
|
|
|
unsigned long nitems, after;
|
|
|
|
unsigned char *data;
|
|
|
|
|
|
|
|
if (Success == XGetWindowProperty(dpy, w, atom, 0, 0, False,
|
|
|
|
AnyPropertyType, &type, &format, &nitems, &after, &data)) {
|
|
|
|
XFree(data);
|
|
|
|
if (type) return True;
|
|
|
|
}
|
|
|
|
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
2012-11-04 18:11:08 +08:00
|
|
|
/**
|
|
|
|
* Get a specific attribute of a window.
|
|
|
|
*
|
|
|
|
* Returns a blank structure if the returned type and format does not
|
|
|
|
* match the requested type and format.
|
|
|
|
*
|
|
|
|
* @param dpy Display to use
|
|
|
|
* @param w window
|
|
|
|
* @param atom atom of attribute to fetch
|
|
|
|
* @param length length to read
|
|
|
|
* @param rtype atom of the requested type
|
|
|
|
* @param rformat requested format
|
|
|
|
* @return a <code>winattr_t</code> structure containing the attribute
|
|
|
|
* and number of items. A blank one on failure.
|
|
|
|
*/
|
|
|
|
static winattr_t
|
|
|
|
wid_get_attr(Display *dpy, Window w, Atom atom, long length,
|
|
|
|
Atom rtype, int rformat) {
|
|
|
|
Atom type = None;
|
|
|
|
int format = 0;
|
|
|
|
unsigned long nitems = 0, after = 0;
|
|
|
|
unsigned char *data = NULL;
|
|
|
|
|
|
|
|
// Use two if statements to deal with the sequence point issue.
|
|
|
|
if (Success == XGetWindowProperty(dpy, w, atom, 0L, length, False,
|
|
|
|
rtype, &type, &format, &nitems, &after, &data)) {
|
|
|
|
if (type == rtype && format == rformat) {
|
|
|
|
return (winattr_t) {
|
|
|
|
.data = data,
|
|
|
|
.nitems = nitems
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XFree(data);
|
|
|
|
|
|
|
|
return (winattr_t) {
|
|
|
|
.data = NULL,
|
|
|
|
.nitems = 0
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Free a <code>winattr_t</code>.
|
|
|
|
*
|
|
|
|
* @param pattr pointer to the <code>winattr_t</code> to free.
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
free_winattr(winattr_t *pattr) {
|
|
|
|
// Empty the whole structure to avoid possible issues
|
|
|
|
if (pattr->data) {
|
|
|
|
XFree(pattr->data);
|
|
|
|
pattr->data = NULL;
|
|
|
|
}
|
|
|
|
pattr->nitems = 0;
|
|
|
|
}
|
|
|
|
|
2012-10-01 10:34:40 +08:00
|
|
|
/**
|
|
|
|
* Get the children of a window.
|
|
|
|
*
|
|
|
|
* @param dpy Display to use
|
|
|
|
* @param w window to check
|
|
|
|
* @param children [out] an array of child window IDs
|
|
|
|
* @param nchildren [out] number of children
|
|
|
|
* @return 1 if successful, 0 otherwise
|
|
|
|
*/
|
|
|
|
static inline Bool
|
|
|
|
wid_get_children(Display *dpy, Window w,
|
|
|
|
Window **children, unsigned *nchildren) {
|
|
|
|
Window troot, tparent;
|
|
|
|
|
|
|
|
if (!XQueryTree(dpy, w, &troot, &tparent, children, nchildren)) {
|
|
|
|
*nchildren = 0;
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if a window is bounding-shaped.
|
|
|
|
*/
|
|
|
|
static inline Bool
|
|
|
|
wid_bounding_shaped(Display *dpy, Window wid) {
|
|
|
|
if (shape_exists) {
|
|
|
|
Bool bounding_shaped = False;
|
|
|
|
Bool clip_shaped;
|
|
|
|
int x_bounding, y_bounding, x_clip, y_clip;
|
|
|
|
unsigned int w_bounding, h_bounding, w_clip, h_clip;
|
|
|
|
|
|
|
|
XShapeQueryExtents(dpy, wid, &bounding_shaped,
|
|
|
|
&x_bounding, &y_bounding, &w_bounding, &h_bounding,
|
|
|
|
&clip_shaped, &x_clip, &y_clip, &w_clip, &h_clip);
|
|
|
|
return bounding_shaped;
|
|
|
|
}
|
|
|
|
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
2012-10-31 08:54:09 +08:00
|
|
|
static inline void
|
|
|
|
update_reg_ignore_expire(const win *w) {
|
|
|
|
if (w->to_paint && WINDOW_SOLID == w->mode)
|
|
|
|
reg_ignore_expire = True;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool
|
|
|
|
win_has_frame(const win *w) {
|
|
|
|
return w->top_width || w->left_width || w->right_width
|
|
|
|
|| w->bottom_width;
|
|
|
|
}
|
|
|
|
|
2012-10-01 10:34:40 +08:00
|
|
|
static void
|
|
|
|
win_rounded_corners(Display *dpy, win *w);
|
|
|
|
|
Feature: Issue #29: Alternative shadow blacklist implementation
- Add shadow blacklist feature, but a different implementation from
nicklan's. 5 matching modes (exact, starts-with, contains, wildcard,
PCRE) and 3 matching targets (window name, window class instance,
window general class). Not extensively tested, bugs to be expected.
It's slower for exact matching than nicklan's as it uses linear search
instead of hash table. Also, PCRE's JIT optimization may cause issues
on PaX kernels.
- Add dependency to libpcre. Could be made optional if we have a
graceful way to handle that in Makefile.
- Some matching functions are GNU extensions of glibc. So this version
may have troubles running on platforms not using glibc.
- Fix a bug that access freed memory blocks in set_fade_callcack() and
check_fade_fin(). valgrind found it out.
- Use WM_CLASS to detect client windows instead of WM_STATE. Some client
windows (like notification windows) have WM_CLASS but not WM_STATE.
- Mark the extents as damaged if shadow state changed in
determine_shadow().
- Rewrite wid_get_name(). Code clean-up.
- Two debugging options: DEBUG_WINDATA and DEBUG_WINMATCH.
- As the matching system is ready, it should be rather easy to add other
kinds of blacklists, like fading blacklist.
2012-09-22 11:42:39 +08:00
|
|
|
static bool
|
|
|
|
win_match_once(win *w, const wincond *cond);
|
|
|
|
|
|
|
|
static bool
|
|
|
|
win_match(win *w, wincond *condlst, wincond * *cache);
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
condlst_add(wincond **pcondlst, const char *pattern);
|
|
|
|
|
2012-09-13 23:24:37 +08:00
|
|
|
static long
|
|
|
|
determine_evmask(Display *dpy, Window wid, win_evmode_t mode);
|
|
|
|
|
2012-02-08 18:31:39 +08:00
|
|
|
static win *
|
2012-11-04 18:11:08 +08:00
|
|
|
find_win(Window id);
|
2012-02-08 18:31:39 +08:00
|
|
|
|
|
|
|
static win *
|
2012-11-04 18:11:08 +08:00
|
|
|
find_toplevel(Window id);
|
2012-02-08 18:31:39 +08:00
|
|
|
|
2012-09-13 23:12:54 +08:00
|
|
|
static win *
|
|
|
|
find_toplevel2(Display *dpy, Window wid);
|
|
|
|
|
|
|
|
static win *
|
|
|
|
recheck_focus(Display *dpy);
|
|
|
|
|
2012-02-08 18:31:39 +08:00
|
|
|
static Picture
|
|
|
|
root_tile_f(Display *dpy);
|
|
|
|
|
|
|
|
static void
|
|
|
|
paint_root(Display *dpy);
|
|
|
|
|
|
|
|
static XserverRegion
|
|
|
|
win_extents(Display *dpy, win *w);
|
|
|
|
|
|
|
|
static XserverRegion
|
|
|
|
border_size(Display *dpy, win *w);
|
|
|
|
|
2012-09-13 23:12:54 +08:00
|
|
|
static Window
|
|
|
|
find_client_win(Display *dpy, Window w);
|
2012-09-13 21:38:55 +08:00
|
|
|
|
2012-02-08 18:31:39 +08:00
|
|
|
static void
|
2012-09-20 13:50:27 +08:00
|
|
|
get_frame_extents(Display *dpy, win *w, Window client);
|
2012-02-08 18:31:39 +08:00
|
|
|
|
2012-09-19 20:49:16 +08:00
|
|
|
static win *
|
|
|
|
paint_preprocess(Display *dpy, win *list);
|
|
|
|
|
2012-02-08 18:31:39 +08:00
|
|
|
static void
|
2012-09-19 20:49:16 +08:00
|
|
|
paint_all(Display *dpy, XserverRegion region, win *t);
|
2012-02-08 18:31:39 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
add_damage(Display *dpy, XserverRegion damage);
|
|
|
|
|
|
|
|
static void
|
|
|
|
repair_win(Display *dpy, win *w);
|
|
|
|
|
|
|
|
static wintype
|
|
|
|
get_wintype_prop(Display * dpy, Window w);
|
|
|
|
|
|
|
|
static void
|
|
|
|
map_win(Display *dpy, Window id,
|
|
|
|
unsigned long sequence, Bool fade,
|
|
|
|
Bool override_redirect);
|
|
|
|
|
2012-09-26 21:40:48 +08:00
|
|
|
static void
|
|
|
|
finish_map_win(Display *dpy, win *w);
|
|
|
|
|
2012-02-08 18:31:39 +08:00
|
|
|
static void
|
|
|
|
finish_unmap_win(Display *dpy, win *w);
|
|
|
|
|
|
|
|
static void
|
|
|
|
unmap_callback(Display *dpy, win *w);
|
|
|
|
|
|
|
|
static void
|
|
|
|
unmap_win(Display *dpy, Window id, Bool fade);
|
|
|
|
|
2012-09-13 13:58:05 +08:00
|
|
|
static opacity_t
|
2012-10-03 21:13:34 +08:00
|
|
|
wid_get_opacity_prop(Display *dpy, Window wid, opacity_t def);
|
2012-02-08 18:31:39 +08:00
|
|
|
|
|
|
|
static double
|
|
|
|
get_opacity_percent(Display *dpy, win *w);
|
|
|
|
|
|
|
|
static void
|
|
|
|
determine_mode(Display *dpy, win *w);
|
|
|
|
|
2012-09-13 13:58:05 +08:00
|
|
|
static void
|
|
|
|
calc_opacity(Display *dpy, win *w, Bool refetch_prop);
|
2012-02-08 18:31:39 +08:00
|
|
|
|
2012-09-13 13:58:05 +08:00
|
|
|
static void
|
|
|
|
calc_dim(Display *dpy, win *w);
|
2012-09-12 10:52:52 +08:00
|
|
|
|
2012-09-20 13:50:27 +08:00
|
|
|
static inline void
|
|
|
|
set_focused(Display *dpy, win *w, Bool focused) {
|
|
|
|
w->focused = focused;
|
|
|
|
calc_opacity(dpy, w, False);
|
|
|
|
calc_dim(dpy, w);
|
|
|
|
}
|
|
|
|
|
2012-09-19 20:49:16 +08:00
|
|
|
static void
|
|
|
|
determine_fade(Display *dpy, win *w);
|
|
|
|
|
2012-10-28 17:02:07 +08:00
|
|
|
static void
|
|
|
|
win_update_shape(Display *dpy, win *w);
|
|
|
|
|
2012-09-17 22:15:04 +08:00
|
|
|
static void
|
|
|
|
determine_shadow(Display *dpy, win *w);
|
|
|
|
|
|
|
|
static void
|
|
|
|
calc_win_size(Display *dpy, win *w);
|
|
|
|
|
|
|
|
static void
|
|
|
|
calc_shadow_geometry(Display *dpy, win *w);
|
|
|
|
|
2012-09-14 11:51:46 +08:00
|
|
|
static void
|
|
|
|
mark_client_win(Display *dpy, win *w, Window client);
|
|
|
|
|
2012-02-08 18:31:39 +08:00
|
|
|
static void
|
|
|
|
add_win(Display *dpy, Window id, Window prev, Bool override_redirect);
|
|
|
|
|
2012-02-27 12:00:12 +08:00
|
|
|
static void
|
2012-02-08 18:31:39 +08:00
|
|
|
restack_win(Display *dpy, win *w, Window new_above);
|
|
|
|
|
|
|
|
static void
|
|
|
|
configure_win(Display *dpy, XConfigureEvent *ce);
|
|
|
|
|
|
|
|
static void
|
|
|
|
circulate_win(Display *dpy, XCirculateEvent *ce);
|
|
|
|
|
|
|
|
static void
|
|
|
|
finish_destroy_win(Display *dpy, Window id);
|
|
|
|
|
|
|
|
static void
|
|
|
|
destroy_callback(Display *dpy, win *w);
|
|
|
|
|
|
|
|
static void
|
|
|
|
destroy_win(Display *dpy, Window id, Bool fade);
|
|
|
|
|
|
|
|
static void
|
|
|
|
damage_win(Display *dpy, XDamageNotifyEvent *de);
|
|
|
|
|
|
|
|
static int
|
|
|
|
error(Display *dpy, XErrorEvent *ev);
|
|
|
|
|
|
|
|
static void
|
2012-10-29 22:00:11 +08:00
|
|
|
expose_root(Display *dpy, XRectangle *rects, int nrects);
|
2012-02-08 18:31:39 +08:00
|
|
|
|
Feature: Issue #29: Alternative shadow blacklist implementation
- Add shadow blacklist feature, but a different implementation from
nicklan's. 5 matching modes (exact, starts-with, contains, wildcard,
PCRE) and 3 matching targets (window name, window class instance,
window general class). Not extensively tested, bugs to be expected.
It's slower for exact matching than nicklan's as it uses linear search
instead of hash table. Also, PCRE's JIT optimization may cause issues
on PaX kernels.
- Add dependency to libpcre. Could be made optional if we have a
graceful way to handle that in Makefile.
- Some matching functions are GNU extensions of glibc. So this version
may have troubles running on platforms not using glibc.
- Fix a bug that access freed memory blocks in set_fade_callcack() and
check_fade_fin(). valgrind found it out.
- Use WM_CLASS to detect client windows instead of WM_STATE. Some client
windows (like notification windows) have WM_CLASS but not WM_STATE.
- Mark the extents as damaged if shadow state changed in
determine_shadow().
- Rewrite wid_get_name(). Code clean-up.
- Two debugging options: DEBUG_WINDATA and DEBUG_WINMATCH.
- As the matching system is ready, it should be rather easy to add other
kinds of blacklists, like fading blacklist.
2012-09-22 11:42:39 +08:00
|
|
|
static Bool
|
|
|
|
wid_get_text_prop(Display *dpy, Window wid, Atom prop,
|
|
|
|
char ***pstrlst, int *pnstr);
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
wid_get_name(Display *dpy, Window w, char **name);
|
|
|
|
|
2012-09-13 13:58:05 +08:00
|
|
|
static int
|
Feature: Issue #29: Alternative shadow blacklist implementation
- Add shadow blacklist feature, but a different implementation from
nicklan's. 5 matching modes (exact, starts-with, contains, wildcard,
PCRE) and 3 matching targets (window name, window class instance,
window general class). Not extensively tested, bugs to be expected.
It's slower for exact matching than nicklan's as it uses linear search
instead of hash table. Also, PCRE's JIT optimization may cause issues
on PaX kernels.
- Add dependency to libpcre. Could be made optional if we have a
graceful way to handle that in Makefile.
- Some matching functions are GNU extensions of glibc. So this version
may have troubles running on platforms not using glibc.
- Fix a bug that access freed memory blocks in set_fade_callcack() and
check_fade_fin(). valgrind found it out.
- Use WM_CLASS to detect client windows instead of WM_STATE. Some client
windows (like notification windows) have WM_CLASS but not WM_STATE.
- Mark the extents as damaged if shadow state changed in
determine_shadow().
- Rewrite wid_get_name(). Code clean-up.
- Two debugging options: DEBUG_WINDATA and DEBUG_WINMATCH.
- As the matching system is ready, it should be rather easy to add other
kinds of blacklists, like fading blacklist.
2012-09-22 11:42:39 +08:00
|
|
|
win_get_name(Display *dpy, win *w);
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
win_get_class(Display *dpy, win *w);
|
2012-09-12 09:08:15 +08:00
|
|
|
|
|
|
|
#ifdef DEBUG_EVENTS
|
2012-02-08 18:31:39 +08:00
|
|
|
static int
|
|
|
|
ev_serial(XEvent *ev);
|
|
|
|
|
2012-11-03 05:51:40 +08:00
|
|
|
static const char *
|
2012-02-08 18:31:39 +08:00
|
|
|
ev_name(XEvent *ev);
|
|
|
|
|
|
|
|
static Window
|
|
|
|
ev_window(XEvent *ev);
|
|
|
|
#endif
|
|
|
|
|
2012-02-27 12:00:12 +08:00
|
|
|
static void
|
2012-09-17 16:04:04 +08:00
|
|
|
usage(void);
|
2012-02-08 18:31:39 +08:00
|
|
|
|
|
|
|
static void
|
Feature: #7: VSync
- Add VSync feature. 3 possible VSync methods available: "sw" (software,
not too reliable, but at least you have something to fallback to),
"drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
"opengl" (using SGI_swap_control extension OpenGL, might work on more
drivers than the DRM method). "sw" and "opengl" are briefly tested,
"drm" received utterly no test (because I use the nVidia binary blob).
They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".
- Add --refresh-rate to let user specify a refresh rate for software
VSync, in case the automatic refresh rate detection does not work
well.
- Seemingly the automatic refresh rate detection using X RandR in
software VSync detects refresh rate incorrectly. Need further investigation.
- Fix a few bugs in fading timing.
- Add a workaround for client window detection on Fluxbox, as Fluxbox
(incorrectly?) sets the override-redirect flag upon all frame
windows.
- Software VSync adds dependency on librt (a part of glibc) for
nanosecond-level timing functions, and libXrandr for automatic refresh
rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
but does not link to libdrm; OpenGL VSync adds dependency on libGL.
- Print timing information on DEBUG_REPAINT.
2012-10-08 10:20:01 +08:00
|
|
|
register_cm(Bool want_glxct);
|
2012-02-08 18:31:39 +08:00
|
|
|
|
|
|
|
inline static void
|
|
|
|
ev_focus_in(XFocusChangeEvent *ev);
|
|
|
|
|
|
|
|
inline static void
|
|
|
|
ev_focus_out(XFocusChangeEvent *ev);
|
|
|
|
|
|
|
|
inline static void
|
|
|
|
ev_create_notify(XCreateWindowEvent *ev);
|
|
|
|
|
|
|
|
inline static void
|
|
|
|
ev_configure_notify(XConfigureEvent *ev);
|
|
|
|
|
|
|
|
inline static void
|
|
|
|
ev_destroy_notify(XDestroyWindowEvent *ev);
|
|
|
|
|
|
|
|
inline static void
|
|
|
|
ev_map_notify(XMapEvent *ev);
|
|
|
|
|
|
|
|
inline static void
|
|
|
|
ev_unmap_notify(XUnmapEvent *ev);
|
|
|
|
|
|
|
|
inline static void
|
|
|
|
ev_reparent_notify(XReparentEvent *ev);
|
|
|
|
|
|
|
|
inline static void
|
|
|
|
ev_circulate_notify(XCirculateEvent *ev);
|
|
|
|
|
|
|
|
inline static void
|
|
|
|
ev_expose(XExposeEvent *ev);
|
|
|
|
|
2012-11-04 18:11:08 +08:00
|
|
|
static void
|
|
|
|
update_ewmh_active_win(Display *dpy);
|
|
|
|
|
2012-02-08 18:31:39 +08:00
|
|
|
inline static void
|
|
|
|
ev_property_notify(XPropertyEvent *ev);
|
|
|
|
|
|
|
|
inline static void
|
|
|
|
ev_damage_notify(XDamageNotifyEvent *ev);
|
|
|
|
|
2012-09-13 13:58:05 +08:00
|
|
|
inline static void
|
|
|
|
ev_shape_notify(XShapeEvent *ev);
|
|
|
|
|
2012-09-11 21:33:03 +08:00
|
|
|
/**
|
|
|
|
* Get a region of the screen size.
|
|
|
|
*/
|
2012-09-13 13:58:05 +08:00
|
|
|
inline static XserverRegion
|
|
|
|
get_screen_region(Display *dpy) {
|
2012-09-11 21:33:03 +08:00
|
|
|
XRectangle r;
|
|
|
|
|
|
|
|
r.x = 0;
|
|
|
|
r.y = 0;
|
|
|
|
r.width = root_width;
|
|
|
|
r.height = root_height;
|
|
|
|
return XFixesCreateRegion(dpy, &r, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copies a region
|
|
|
|
*/
|
2012-09-13 13:58:05 +08:00
|
|
|
inline static XserverRegion
|
|
|
|
copy_region(Display *dpy, XserverRegion oldregion) {
|
2012-09-11 21:33:03 +08:00
|
|
|
XserverRegion region = XFixesCreateRegion(dpy, NULL, 0);
|
|
|
|
|
|
|
|
XFixesCopyRegion(dpy, region, oldregion);
|
|
|
|
|
|
|
|
return region;
|
|
|
|
}
|
|
|
|
|
2012-10-21 20:44:24 +08:00
|
|
|
/**
|
|
|
|
* Dump a region.
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
dump_region(Display *dpy, XserverRegion region) {
|
|
|
|
int nrects = 0, i;
|
|
|
|
XRectangle *rects = XFixesFetchRegion(dpy, region, &nrects);
|
|
|
|
if (!rects)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < nrects; ++i)
|
|
|
|
printf("Rect #%d: %8d, %8d, %8d, %8d\n", i, rects[i].x, rects[i].y,
|
|
|
|
rects[i].width, rects[i].height);
|
|
|
|
|
|
|
|
XFree(rects);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if a region is empty.
|
|
|
|
*
|
|
|
|
* Keith Packard said this is slow:
|
|
|
|
* http://lists.freedesktop.org/archives/xorg/2007-November/030467.html
|
|
|
|
*/
|
|
|
|
static inline Bool
|
|
|
|
is_region_empty(Display *dpy, XserverRegion region) {
|
|
|
|
int nrects = 0;
|
|
|
|
XRectangle *rects = XFixesFetchRegion(dpy, region, &nrects);
|
|
|
|
|
|
|
|
XFree(rects);
|
|
|
|
|
|
|
|
return !nrects;
|
|
|
|
}
|
|
|
|
|
2012-09-12 10:52:52 +08:00
|
|
|
/**
|
|
|
|
* Add a window to damaged area.
|
|
|
|
*
|
|
|
|
* @param dpy display in use
|
|
|
|
* @param w struct _win element representing the window
|
|
|
|
*/
|
2012-09-13 13:58:05 +08:00
|
|
|
static inline void
|
|
|
|
add_damage_win(Display *dpy, win *w) {
|
|
|
|
if (w->extents) {
|
2012-09-12 10:52:52 +08:00
|
|
|
add_damage(dpy, copy_region(dpy, w->extents));
|
2012-09-13 13:58:05 +08:00
|
|
|
}
|
2012-09-12 10:52:52 +08:00
|
|
|
}
|
|
|
|
|
2012-02-08 18:31:39 +08:00
|
|
|
inline static void
|
2012-02-27 12:00:12 +08:00
|
|
|
ev_handle(XEvent *ev);
|
|
|
|
|
|
|
|
static void
|
2012-09-17 16:04:04 +08:00
|
|
|
fork_after(void);
|
2012-02-08 18:31:39 +08:00
|
|
|
|
2012-09-25 10:19:20 +08:00
|
|
|
#ifdef CONFIG_LIBCONFIG
|
2012-09-28 09:10:34 +08:00
|
|
|
static inline void
|
2012-09-26 18:54:35 +08:00
|
|
|
lcfg_lookup_bool(const config_t *config, const char *path, Bool *value) {
|
|
|
|
int ival;
|
|
|
|
|
|
|
|
if (config_lookup_bool(config, path, &ival))
|
|
|
|
*value = ival;
|
|
|
|
}
|
|
|
|
|
2012-09-28 09:10:34 +08:00
|
|
|
static inline int
|
|
|
|
lcfg_lookup_int(const config_t *config, const char *path, int *value) {
|
|
|
|
#ifndef CONFIG_LIBCONFIG_LEGACY
|
|
|
|
return config_lookup_int(config, path, value);
|
|
|
|
#else
|
|
|
|
long lval;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if ((ret = config_lookup_int(config, path, &lval)))
|
|
|
|
*value = lval;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-09-25 10:19:20 +08:00
|
|
|
static FILE *
|
|
|
|
open_config_file(char *cpath, char **path);
|
|
|
|
|
|
|
|
static void
|
2012-09-26 18:54:35 +08:00
|
|
|
parse_config(char *cpath, struct options_tmp *pcfgtmp);
|
2012-09-25 10:19:20 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
static void
|
|
|
|
get_cfg(int argc, char *const *argv);
|
|
|
|
|
2012-02-08 18:31:39 +08:00
|
|
|
static void
|
2012-09-17 16:04:04 +08:00
|
|
|
get_atoms(void);
|
Feature: #7: VSync
- Add VSync feature. 3 possible VSync methods available: "sw" (software,
not too reliable, but at least you have something to fallback to),
"drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
"opengl" (using SGI_swap_control extension OpenGL, might work on more
drivers than the DRM method). "sw" and "opengl" are briefly tested,
"drm" received utterly no test (because I use the nVidia binary blob).
They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".
- Add --refresh-rate to let user specify a refresh rate for software
VSync, in case the automatic refresh rate detection does not work
well.
- Seemingly the automatic refresh rate detection using X RandR in
software VSync detects refresh rate incorrectly. Need further investigation.
- Fix a few bugs in fading timing.
- Add a workaround for client window detection on Fluxbox, as Fluxbox
(incorrectly?) sets the override-redirect flag upon all frame
windows.
- Software VSync adds dependency on librt (a part of glibc) for
nanosecond-level timing functions, and libXrandr for automatic refresh
rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
but does not link to libdrm; OpenGL VSync adds dependency on libGL.
- Print timing information on DEBUG_REPAINT.
2012-10-08 10:20:01 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
update_refresh_rate(Display *dpy);
|
|
|
|
|
|
|
|
static Bool
|
2012-10-26 11:12:28 +08:00
|
|
|
sw_opti_init(void);
|
Feature: #7: VSync
- Add VSync feature. 3 possible VSync methods available: "sw" (software,
not too reliable, but at least you have something to fallback to),
"drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
"opengl" (using SGI_swap_control extension OpenGL, might work on more
drivers than the DRM method). "sw" and "opengl" are briefly tested,
"drm" received utterly no test (because I use the nVidia binary blob).
They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".
- Add --refresh-rate to let user specify a refresh rate for software
VSync, in case the automatic refresh rate detection does not work
well.
- Seemingly the automatic refresh rate detection using X RandR in
software VSync detects refresh rate incorrectly. Need further investigation.
- Fix a few bugs in fading timing.
- Add a workaround for client window detection on Fluxbox, as Fluxbox
(incorrectly?) sets the override-redirect flag upon all frame
windows.
- Software VSync adds dependency on librt (a part of glibc) for
nanosecond-level timing functions, and libXrandr for automatic refresh
rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
but does not link to libdrm; OpenGL VSync adds dependency on libGL.
- Print timing information on DEBUG_REPAINT.
2012-10-08 10:20:01 +08:00
|
|
|
|
2012-10-26 11:12:28 +08:00
|
|
|
static int
|
|
|
|
evpoll(struct pollfd *fd, int timeout);
|
Feature: #7: VSync
- Add VSync feature. 3 possible VSync methods available: "sw" (software,
not too reliable, but at least you have something to fallback to),
"drm" (using DRM_IOCTL_WAIT_VBLANK, should work only on DRI drivers),
"opengl" (using SGI_swap_control extension OpenGL, might work on more
drivers than the DRM method). "sw" and "opengl" are briefly tested,
"drm" received utterly no test (because I use the nVidia binary blob).
They are enabled with "--vsync sw" / "--vsync drm" / "--vsync opengl".
- Add --refresh-rate to let user specify a refresh rate for software
VSync, in case the automatic refresh rate detection does not work
well.
- Seemingly the automatic refresh rate detection using X RandR in
software VSync detects refresh rate incorrectly. Need further investigation.
- Fix a few bugs in fading timing.
- Add a workaround for client window detection on Fluxbox, as Fluxbox
(incorrectly?) sets the override-redirect flag upon all frame
windows.
- Software VSync adds dependency on librt (a part of glibc) for
nanosecond-level timing functions, and libXrandr for automatic refresh
rate detection; DRM VSync adds dependency on libdrm to use its drm.h,
but does not link to libdrm; OpenGL VSync adds dependency on libGL.
- Print timing information on DEBUG_REPAINT.
2012-10-08 10:20:01 +08:00
|
|
|
|
|
|
|
static Bool
|
|
|
|
vsync_drm_init(void);
|
|
|
|
|
|
|
|
#ifdef CONFIG_VSYNC_DRM
|
|
|
|
static int
|
|
|
|
vsync_drm_wait(void);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static Bool
|
|
|
|
vsync_opengl_init(void);
|
|
|
|
|
|
|
|
#ifdef CONFIG_VSYNC_OPENGL
|
|
|
|
static void
|
|
|
|
vsync_opengl_wait(void);
|
|
|
|
#endif
|
|
|
|
|
2012-10-26 11:12:28 +08:00
|
|
|
static void
|
|
|
|
vsync_wait(void);
|
2012-10-13 18:46:59 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
init_alpha_picts(Display *dpy);
|
2012-10-24 10:09:59 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
init_dbe(void);
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_overlay(void);
|