diff options
author | Richard Grenville <[email protected]> | 2013-05-01 22:08:43 +0800 |
---|---|---|
committer | Richard Grenville <[email protected]> | 2013-05-01 22:08:43 +0800 |
commit | c742c97a8c68dc168cca8b135609eb1501ac3225 (patch) | |
tree | 312c46bd16fc302c3962bcc34463bd5b5a3c3f48 /compton.h | |
parent | e94746bbbb104fd11dec9c0a218b0d8f9f5c9252 (diff) | |
download | tdebase-c742c97a8c68dc168cca8b135609eb1501ac3225.tar.gz tdebase-c742c97a8c68dc168cca8b135609eb1501ac3225.zip |
Misc: Validate wallpaper pixmap & Documentation update
- Split Pixmap validation out to validate_pixmap(). Validate wallpaper
Pixmap as well.
- Update README.md and man page.
Diffstat (limited to 'compton.h')
-rw-r--r-- | compton.h | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -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(). |