diff options
author | Richard Grenville <pyxlcy@gmail.com> | 2012-09-25 10:19:20 +0800 |
---|---|---|
committer | Richard Grenville <pyxlcy@gmail.com> | 2012-09-25 10:32:41 +0800 |
commit | 0c67b84349c9408b5dc659a5227d599f7a9ed01f (patch) | |
tree | 64e513165c9b424f5168d563b5f5035d95fcc3c8 /compton.h | |
parent | 9a839bc66114c37e86cd6056997317d552619ad6 (diff) | |
download | tdebase-0c67b84349c9408b5dc659a5227d599f7a9ed01f.tar.gz tdebase-0c67b84349c9408b5dc659a5227d599f7a9ed01f.zip |
Feature: Configuration file parsing
- Add support for parsing configuration files using libconfig.
(Dependency on libconfig could be made optional once we get some
better building system.) Few tests has been done, bugs to be expected.
compton searches for a configuration file mostly according to the XDG
standard. Firstly the configuration file requested by --config, then
$XDG_CONFIG_HOME/compton.conf (~/.config/compton.conf, usually), then
~/.compton.conf, then compton.conf under $XDG_DATA_DIRS (often
/etc/xdg/compton.conf). A sample configuration file is supplied as
compton.sample.conf. Configuration file syntax may change in the
future. Commandline switches has higher priority than configuration
file, except for --shadow-exclude. Use --config /dev/null to
temporarily disable configuration file.
- Fix a bug that causes windows to disappear or be partially rendered on
opacity changes.
- Fix a bug that causes some windows to ignore -i (inactive_opacity) and
--inactive-dim, caused by the default window type change in
a5d9955ca4.
Diffstat (limited to 'compton.h')
-rw-r--r-- | compton.h | 71 |
1 files changed, 70 insertions, 1 deletions
@@ -24,6 +24,8 @@ // Whether to enable JIT support of libpcre. This may cause problems on PaX // kernels. #define CONFIG_REGEX_PCRE_JIT 1 +// Whether to enable parsing of configuration files using libconfig +#define CONFIG_LIBCONFIG 1 // === Includes === @@ -44,10 +46,16 @@ #include <locale.h> #include <fnmatch.h> + #ifdef CONFIG_REGEX_PCRE #include <pcre.h> #endif +#ifdef CONFIG_LIBCONFIG +#include <libgen.h> +#include <libconfig.h> +#endif + #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xatom.h> @@ -278,6 +286,34 @@ mstrcpy(const char *src) { } /** + * 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; +} + +/** * Normalize an int value to a specific range. * * @param i int value to normalize @@ -285,7 +321,7 @@ mstrcpy(const char *src) { * @param max maximum value * @return normalized value */ -static inline double +static inline int normalize_i_range(int i, int min, int max) { if (i > max) return max; if (i < min) return min; @@ -293,6 +329,22 @@ normalize_i_range(int i, int min, int max) { } /** + * 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); +} + +/** * Normalize a double value to a specific range. * * @param d double value to normalize @@ -530,6 +582,12 @@ static Picture solid_picture(Display *dpy, Bool argb, double a, double r, double g, double b); +static inline bool is_normal_win(const win *w) { + return (WINTYPE_NORMAL == w->window_type + || WINTYPE_UTILITY == w->window_type + || WINTYPE_UNKNOWN == w->window_type); +} + static bool win_match_once(win *w, const wincond *cond); @@ -789,5 +847,16 @@ ev_handle(XEvent *ev); static void fork_after(void); +#ifdef CONFIG_LIBCONFIG +static FILE * +open_config_file(char *cpath, char **path); + +static void +parse_config(char *cpath); +#endif + +static void +get_cfg(int argc, char *const *argv); + static void get_atoms(void); |