2018-10-03 17:14:51 -04:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
// Copyright (c) 2012-2014 Richard Grenville <pyxlcy@gmail.com>
|
|
|
|
|
2018-08-22 07:58:49 -04:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2019-01-20 16:15:20 -05:00
|
|
|
#include <string.h>
|
2018-08-22 07:58:49 -04:00
|
|
|
|
|
|
|
#include <libgen.h>
|
|
|
|
#include <libconfig.h>
|
2018-12-15 14:44:11 -05:00
|
|
|
#include <basedir_fs.h>
|
2018-08-22 07:58:49 -04:00
|
|
|
|
2019-02-12 21:04:05 -05:00
|
|
|
#include "err.h"
|
2018-08-22 07:58:49 -04:00
|
|
|
#include "common.h"
|
2019-01-20 11:53:39 -05:00
|
|
|
#include "compiler.h"
|
2018-08-22 07:58:49 -04:00
|
|
|
#include "config.h"
|
2018-12-15 12:42:37 -05:00
|
|
|
#include "string_utils.h"
|
2018-12-21 11:25:28 -05:00
|
|
|
#include "options.h"
|
2018-12-15 12:53:17 -05:00
|
|
|
#include "log.h"
|
2019-01-20 11:53:39 -05:00
|
|
|
#include "utils.h"
|
|
|
|
#include "win.h"
|
2018-08-22 07:58:49 -04:00
|
|
|
|
2018-12-21 11:25:28 -05:00
|
|
|
#pragma GCC diagnostic error "-Wunused-parameter"
|
|
|
|
|
2018-08-22 07:58:49 -04:00
|
|
|
/**
|
|
|
|
* Wrapper of libconfig's <code>config_lookup_int</code>.
|
|
|
|
*
|
2018-10-23 17:12:42 -04:00
|
|
|
* So it takes a pointer to bool.
|
2018-08-22 07:58:49 -04:00
|
|
|
*/
|
2018-10-23 17:12:42 -04:00
|
|
|
static inline int
|
|
|
|
lcfg_lookup_bool(const config_t *config, const char *path, bool *value) {
|
2018-08-22 07:58:49 -04:00
|
|
|
int ival;
|
|
|
|
|
2018-10-23 17:12:42 -04:00
|
|
|
int ret = config_lookup_bool(config, path, &ival);
|
|
|
|
if (ret)
|
2018-08-22 07:58:49 -04:00
|
|
|
*value = ival;
|
|
|
|
|
2018-10-23 17:12:42 -04:00
|
|
|
return ret;
|
2018-08-22 07:58:49 -04:00
|
|
|
}
|
|
|
|
|
2019-01-29 19:27:14 -05:00
|
|
|
/// Search for config file under a base directory
|
|
|
|
FILE *
|
|
|
|
open_config_file_at(const char *base, char **out_path) {
|
|
|
|
static const char *config_paths[] = {
|
|
|
|
"/compton.conf",
|
|
|
|
"/compton/compton.conf"
|
|
|
|
};
|
|
|
|
for (size_t i = 0; i < ARR_SIZE(config_paths); i++) {
|
|
|
|
char *path = mstrjoin(base, config_paths[i]);
|
|
|
|
FILE *ret = fopen(path, "r");
|
|
|
|
if (ret && out_path) {
|
|
|
|
*out_path = path;
|
|
|
|
} else {
|
|
|
|
free(path);
|
|
|
|
}
|
|
|
|
if (ret) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-08-22 07:58:49 -04:00
|
|
|
/**
|
|
|
|
* Get a file stream of the configuration file to read.
|
|
|
|
*
|
|
|
|
* Follows the XDG specification to search for the configuration file.
|
|
|
|
*/
|
|
|
|
FILE *
|
2018-12-21 11:25:28 -05:00
|
|
|
open_config_file(const char *cpath, char **ppath) {
|
2018-12-15 14:44:11 -05:00
|
|
|
static const char config_filename_legacy[] = "/.compton.conf";
|
|
|
|
|
|
|
|
if (cpath) {
|
|
|
|
FILE *ret = fopen(cpath, "r");
|
|
|
|
if (ret && ppath)
|
2018-12-21 11:25:28 -05:00
|
|
|
*ppath = strdup(cpath);
|
2018-12-15 14:44:11 -05:00
|
|
|
return ret;
|
2018-08-22 07:58:49 -04:00
|
|
|
}
|
|
|
|
|
2019-01-29 19:27:14 -05:00
|
|
|
// First search for config file in user config directory
|
|
|
|
auto config_home = xdgConfigHome(NULL);
|
|
|
|
auto ret = open_config_file_at(config_home, ppath);
|
|
|
|
free((void *)config_home);
|
|
|
|
if (ret) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fall back to legacy config file in user home directory
|
|
|
|
const char *home = getenv("HOME");
|
|
|
|
if (home && strlen(home)) {
|
|
|
|
auto path = mstrjoin(home, config_filename_legacy);
|
|
|
|
ret = fopen(path, "r");
|
2018-12-15 19:52:37 -05:00
|
|
|
if (ret && ppath) {
|
2019-01-29 19:27:14 -05:00
|
|
|
*ppath = path;
|
|
|
|
} else {
|
|
|
|
free(path);
|
2018-12-15 14:44:11 -05:00
|
|
|
}
|
|
|
|
if (ret) {
|
|
|
|
return ret;
|
2018-08-22 07:58:49 -04:00
|
|
|
}
|
|
|
|
}
|
2018-12-15 14:44:11 -05:00
|
|
|
|
2019-01-29 19:27:14 -05:00
|
|
|
// Fall back to config file in system config directory
|
|
|
|
auto config_dirs = xdgConfigDirectories(NULL);
|
|
|
|
for (int i = 0; config_dirs[i]; i++) {
|
|
|
|
ret = open_config_file_at(config_dirs[i], ppath);
|
|
|
|
if (ret) {
|
|
|
|
free((void *)config_dirs);
|
|
|
|
return ret;
|
|
|
|
}
|
2018-08-22 07:58:49 -04:00
|
|
|
}
|
2019-01-29 19:27:14 -05:00
|
|
|
free((void *)config_dirs);
|
|
|
|
|
2018-08-22 07:58:49 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse a condition list in configuration file.
|
|
|
|
*/
|
|
|
|
void
|
2018-12-21 11:25:28 -05:00
|
|
|
parse_cfg_condlst(const config_t *pcfg, c2_lptr_t **pcondlst,
|
2018-08-22 07:58:49 -04:00
|
|
|
const char *name) {
|
|
|
|
config_setting_t *setting = config_lookup(pcfg, name);
|
|
|
|
if (setting) {
|
|
|
|
// Parse an array of options
|
|
|
|
if (config_setting_is_array(setting)) {
|
|
|
|
int i = config_setting_length(setting);
|
|
|
|
while (i--)
|
2018-12-21 11:25:28 -05:00
|
|
|
condlst_add(pcondlst, config_setting_get_string_elem(setting, i));
|
2018-08-22 07:58:49 -04:00
|
|
|
}
|
|
|
|
// Treat it as a single pattern if it's a string
|
|
|
|
else if (CONFIG_TYPE_STRING == config_setting_type(setting)) {
|
2018-12-21 11:25:28 -05:00
|
|
|
condlst_add(pcondlst, config_setting_get_string(setting));
|
2018-08-22 07:58:49 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse an opacity rule list in configuration file.
|
|
|
|
*/
|
|
|
|
static inline void
|
2018-12-21 11:25:28 -05:00
|
|
|
parse_cfg_condlst_opct(options_t *opt, const config_t *pcfg, const char *name) {
|
2018-08-22 07:58:49 -04:00
|
|
|
config_setting_t *setting = config_lookup(pcfg, name);
|
|
|
|
if (setting) {
|
|
|
|
// Parse an array of options
|
|
|
|
if (config_setting_is_array(setting)) {
|
|
|
|
int i = config_setting_length(setting);
|
|
|
|
while (i--)
|
2018-12-21 11:25:28 -05:00
|
|
|
if (!parse_rule_opacity(&opt->opacity_rules,
|
|
|
|
config_setting_get_string_elem(setting, i)))
|
2018-08-22 07:58:49 -04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
// Treat it as a single pattern if it's a string
|
2018-12-21 11:25:28 -05:00
|
|
|
else if (config_setting_type(setting) == CONFIG_TYPE_STRING) {
|
|
|
|
if (!parse_rule_opacity(&opt->opacity_rules, config_setting_get_string(setting)))
|
|
|
|
exit(1);
|
2018-08-22 07:58:49 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse a configuration file from default location.
|
2018-12-21 11:25:28 -05:00
|
|
|
*
|
|
|
|
* Returns the actually config_file name
|
2018-08-22 07:58:49 -04:00
|
|
|
*/
|
2018-12-21 11:25:28 -05:00
|
|
|
char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shadow_enable,
|
|
|
|
bool *fading_enable, bool *conv_kern_hasneg, win_option_mask_t *winopt_mask)
|
2018-12-04 08:44:16 -05:00
|
|
|
{
|
2018-08-22 07:58:49 -04:00
|
|
|
char *path = NULL;
|
|
|
|
FILE *f;
|
|
|
|
config_t cfg;
|
|
|
|
int ival = 0;
|
2018-10-23 17:12:42 -04:00
|
|
|
bool bval;
|
2018-08-22 07:58:49 -04:00
|
|
|
double dval = 0.0;
|
|
|
|
// libconfig manages string memory itself, so no need to manually free
|
|
|
|
// anything
|
|
|
|
const char *sval = NULL;
|
|
|
|
|
2018-12-21 11:25:28 -05:00
|
|
|
f = open_config_file(config_file, &path);
|
2018-08-22 07:58:49 -04:00
|
|
|
if (!f) {
|
2019-02-12 21:04:05 -05:00
|
|
|
free(path);
|
2018-12-21 11:25:28 -05:00
|
|
|
if (config_file) {
|
|
|
|
log_fatal("Failed to read configuration file \"%s\".", config_file);
|
2019-02-12 21:04:05 -05:00
|
|
|
return ERR_PTR(-1);
|
2018-08-22 07:58:49 -04:00
|
|
|
}
|
2018-12-21 11:25:28 -05:00
|
|
|
return NULL;
|
2018-08-22 07:58:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
config_init(&cfg);
|
|
|
|
{
|
|
|
|
// dirname() could modify the original string, thus we must pass a
|
|
|
|
// copy
|
2018-12-15 14:07:14 -05:00
|
|
|
char *path2 = strdup(path);
|
2018-08-22 07:58:49 -04:00
|
|
|
char *parent = dirname(path2);
|
|
|
|
|
|
|
|
if (parent)
|
|
|
|
config_set_include_dir(&cfg, parent);
|
|
|
|
|
|
|
|
free(path2);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
int read_result = config_read(&cfg, f);
|
|
|
|
fclose(f);
|
|
|
|
f = NULL;
|
2018-12-15 14:44:11 -05:00
|
|
|
if (read_result == CONFIG_FALSE) {
|
2019-02-12 21:04:05 -05:00
|
|
|
log_fatal("Error when reading configuration file \"%s\", line %d: %s",
|
2018-12-20 12:35:45 -05:00
|
|
|
path, config_error_line(&cfg), config_error_text(&cfg));
|
2019-02-12 21:04:05 -05:00
|
|
|
goto err;
|
2018-08-22 07:58:49 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
config_set_auto_convert(&cfg, 1);
|
|
|
|
|
|
|
|
// Get options from the configuration file. We don't do range checking
|
|
|
|
// right now. It will be done later
|
|
|
|
|
|
|
|
// -D (fade_delta)
|
2018-10-23 17:12:42 -04:00
|
|
|
if (config_lookup_int(&cfg, "fade-delta", &ival))
|
2018-12-21 11:25:28 -05:00
|
|
|
opt->fade_delta = ival;
|
2018-08-22 07:58:49 -04:00
|
|
|
// -I (fade_in_step)
|
|
|
|
if (config_lookup_float(&cfg, "fade-in-step", &dval))
|
2018-12-21 11:25:28 -05:00
|
|
|
opt->fade_in_step = normalize_d(dval) * OPAQUE;
|
2018-08-22 07:58:49 -04:00
|
|
|
// -O (fade_out_step)
|
|
|
|
if (config_lookup_float(&cfg, "fade-out-step", &dval))
|
2018-12-21 11:25:28 -05:00
|
|
|
opt->fade_out_step = normalize_d(dval) * OPAQUE;
|
2018-08-22 07:58:49 -04:00
|
|
|
// -r (shadow_radius)
|
2018-12-21 11:25:28 -05:00
|
|
|
config_lookup_int(&cfg, "shadow-radius", &opt->shadow_radius);
|
2018-08-22 07:58:49 -04:00
|
|
|
// -o (shadow_opacity)
|
2018-12-21 11:25:28 -05:00
|
|
|
config_lookup_float(&cfg, "shadow-opacity", &opt->shadow_opacity);
|
2018-08-22 07:58:49 -04:00
|
|
|
// -l (shadow_offset_x)
|
2018-12-21 11:25:28 -05:00
|
|
|
config_lookup_int(&cfg, "shadow-offset-x", &opt->shadow_offset_x);
|
2018-08-22 07:58:49 -04:00
|
|
|
// -t (shadow_offset_y)
|
2018-12-21 11:25:28 -05:00
|
|
|
config_lookup_int(&cfg, "shadow-offset-y", &opt->shadow_offset_y);
|
2018-08-22 07:58:49 -04:00
|
|
|
// -i (inactive_opacity)
|
|
|
|
if (config_lookup_float(&cfg, "inactive-opacity", &dval))
|
2018-12-21 11:25:28 -05:00
|
|
|
opt->inactive_opacity = normalize_d(dval) * OPAQUE;
|
2018-08-22 07:58:49 -04:00
|
|
|
// --active_opacity
|
|
|
|
if (config_lookup_float(&cfg, "active-opacity", &dval))
|
2018-12-21 11:25:28 -05:00
|
|
|
opt->active_opacity = normalize_d(dval) * OPAQUE;
|
2018-08-22 07:58:49 -04:00
|
|
|
// -e (frame_opacity)
|
2018-12-21 11:25:28 -05:00
|
|
|
config_lookup_float(&cfg, "frame-opacity", &opt->frame_opacity);
|
2018-08-22 07:58:49 -04:00
|
|
|
// -c (shadow_enable)
|
2018-12-04 08:44:16 -05:00
|
|
|
if (config_lookup_bool(&cfg, "shadow", &ival))
|
|
|
|
*shadow_enable = ival;
|
2018-08-22 07:58:49 -04:00
|
|
|
// -C (no_dock_shadow)
|
2018-12-04 08:44:16 -05:00
|
|
|
if (config_lookup_bool(&cfg, "no-dock-shadow", &ival)) {
|
2018-12-20 12:35:45 -05:00
|
|
|
log_warn("Option `no-dock-shadow` is deprecated, and will be removed."
|
|
|
|
" Please use the wintype option `shadow` of `dock` instead.");
|
2018-12-21 11:25:28 -05:00
|
|
|
opt->wintype_option[WINTYPE_DOCK].shadow = false;
|
2018-12-04 08:44:16 -05:00
|
|
|
winopt_mask[WINTYPE_DOCK].shadow = true;
|
|
|
|
}
|
2018-08-22 07:58:49 -04:00
|
|
|
// -G (no_dnd_shadow)
|
2018-12-04 08:44:16 -05:00
|
|
|
if (config_lookup_bool(&cfg, "no-dnd-shadow", &ival)) {
|
2018-12-20 12:35:45 -05:00
|
|
|
log_warn("Option `no-dnd-shadow` is deprecated, and will be removed."
|
|
|
|
" Please use the wintype option `shadow` of `dnd` instead.");
|
2018-12-21 11:25:28 -05:00
|
|
|
opt->wintype_option[WINTYPE_DND].shadow = false;
|
2018-12-04 08:44:16 -05:00
|
|
|
winopt_mask[WINTYPE_DND].shadow = true;
|
|
|
|
};
|
2018-08-22 07:58:49 -04:00
|
|
|
// -m (menu_opacity)
|
2018-12-04 08:44:16 -05:00
|
|
|
if (config_lookup_float(&cfg, "menu-opacity", &dval)) {
|
2018-12-20 12:35:45 -05:00
|
|
|
log_warn("Option `menu-opacity` is deprecated, and will be removed.Please use the "
|
|
|
|
"wintype option `opacity` of `popup_menu` and `dropdown_menu` instead.");
|
2018-12-21 11:25:28 -05:00
|
|
|
opt->wintype_option[WINTYPE_DROPDOWN_MENU].opacity = dval;
|
|
|
|
opt->wintype_option[WINTYPE_POPUP_MENU].opacity = dval;
|
2018-12-04 08:44:16 -05:00
|
|
|
winopt_mask[WINTYPE_DROPDOWN_MENU].opacity = true;
|
|
|
|
winopt_mask[WINTYPE_POPUP_MENU].opacity = true;
|
|
|
|
}
|
2018-08-22 07:58:49 -04:00
|
|
|
// -f (fading_enable)
|
2018-12-04 08:44:16 -05:00
|
|
|
if (config_lookup_bool(&cfg, "fading", &ival))
|
|
|
|
*fading_enable = ival;
|
2018-08-22 07:58:49 -04:00
|
|
|
// --no-fading-open-close
|
2018-12-21 11:25:28 -05:00
|
|
|
lcfg_lookup_bool(&cfg, "no-fading-openclose", &opt->no_fading_openclose);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --no-fading-destroyed-argb
|
|
|
|
lcfg_lookup_bool(&cfg, "no-fading-destroyed-argb",
|
2018-12-21 11:25:28 -05:00
|
|
|
&opt->no_fading_destroyed_argb);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --shadow-red
|
2018-12-21 11:25:28 -05:00
|
|
|
config_lookup_float(&cfg, "shadow-red", &opt->shadow_red);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --shadow-green
|
2018-12-21 11:25:28 -05:00
|
|
|
config_lookup_float(&cfg, "shadow-green", &opt->shadow_green);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --shadow-blue
|
2018-12-21 11:25:28 -05:00
|
|
|
config_lookup_float(&cfg, "shadow-blue", &opt->shadow_blue);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --shadow-exclude-reg
|
Convert XfixesRegion to pixman region
Re-did the painting logic, and document it.
It is unclear to me what is the previous painting logic. But the current
one is basically this:
1. Go through all windows top to bottom, and put visible windows (not
unmapped, opacity > 0, etc) into a linked list, from bottom to top
2. Accumulate a region of ignore on each window, which is basically the
region of screen that is obscured by all the windows above current
one.
3. Paint all the visible windows from bottom to top. Subtract the region
of ignore from the painting region. If we need to paint shadow, we
subtract the body of the window from the shadow painting region too,
because we don't want shadow behind the window.
4. region of ignore is invalidated when window stack change, an
window on top moved or changed shape, when window changed between
opaque and transparent, etc.
Notes:
It is unclear whether all the different shapes of a window (extents,
noframe, border, bounding shape, etc) are calculated correctly or not.
It is unclear if window shape related events are handled correctly or
not. Need more testing.
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
2018-09-29 23:56:00 -04:00
|
|
|
if (config_lookup_string(&cfg, "shadow-exclude-reg", &sval))
|
2018-12-21 11:25:28 -05:00
|
|
|
opt->shadow_exclude_reg_str = strdup(sval);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --inactive-opacity-override
|
|
|
|
lcfg_lookup_bool(&cfg, "inactive-opacity-override",
|
2018-12-21 11:25:28 -05:00
|
|
|
&opt->inactive_opacity_override);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --inactive-dim
|
2018-12-21 11:25:28 -05:00
|
|
|
config_lookup_float(&cfg, "inactive-dim", &opt->inactive_dim);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --mark-wmwin-focused
|
2018-12-21 11:25:28 -05:00
|
|
|
lcfg_lookup_bool(&cfg, "mark-wmwin-focused", &opt->mark_wmwin_focused);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --mark-ovredir-focused
|
|
|
|
lcfg_lookup_bool(&cfg, "mark-ovredir-focused",
|
2018-12-21 11:25:28 -05:00
|
|
|
&opt->mark_ovredir_focused);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --shadow-ignore-shaped
|
|
|
|
lcfg_lookup_bool(&cfg, "shadow-ignore-shaped",
|
2018-12-21 11:25:28 -05:00
|
|
|
&opt->shadow_ignore_shaped);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --detect-rounded-corners
|
|
|
|
lcfg_lookup_bool(&cfg, "detect-rounded-corners",
|
2018-12-21 11:25:28 -05:00
|
|
|
&opt->detect_rounded_corners);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --xinerama-shadow-crop
|
|
|
|
lcfg_lookup_bool(&cfg, "xinerama-shadow-crop",
|
2018-12-21 11:25:28 -05:00
|
|
|
&opt->xinerama_shadow_crop);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --detect-client-opacity
|
|
|
|
lcfg_lookup_bool(&cfg, "detect-client-opacity",
|
2018-12-21 11:25:28 -05:00
|
|
|
&opt->detect_client_opacity);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --refresh-rate
|
2018-12-21 11:25:28 -05:00
|
|
|
config_lookup_int(&cfg, "refresh-rate", &opt->refresh_rate);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --vsync
|
2018-12-21 11:25:28 -05:00
|
|
|
if (config_lookup_string(&cfg, "vsync", &sval)) {
|
|
|
|
opt->vsync = parse_vsync(sval);
|
|
|
|
if (opt->vsync >= NUM_VSYNC) {
|
|
|
|
log_fatal("Cannot parse vsync");
|
2019-02-12 21:04:05 -05:00
|
|
|
goto err;
|
2018-12-21 11:25:28 -05:00
|
|
|
}
|
2018-12-20 12:35:45 -05:00
|
|
|
}
|
2018-08-22 07:58:49 -04:00
|
|
|
// --backend
|
2018-12-21 11:25:28 -05:00
|
|
|
if (config_lookup_string(&cfg, "backend", &sval)) {
|
|
|
|
opt->backend = parse_backend(sval);
|
|
|
|
if (opt->backend >= NUM_BKEND) {
|
|
|
|
log_fatal("Cannot parse backend");
|
2019-02-12 21:04:05 -05:00
|
|
|
goto err;
|
2018-12-21 11:25:28 -05:00
|
|
|
}
|
2018-12-20 12:35:45 -05:00
|
|
|
}
|
2018-12-19 20:21:51 -05:00
|
|
|
// --log-level
|
|
|
|
if (config_lookup_string(&cfg, "log-level", &sval)) {
|
|
|
|
auto level = string_to_log_level(sval);
|
|
|
|
if (level == LOG_LEVEL_INVALID) {
|
|
|
|
log_warn("Invalid log level, defaults to WARN");
|
|
|
|
} else {
|
|
|
|
log_set_level_tls(level);
|
|
|
|
}
|
|
|
|
}
|
2018-12-21 17:49:42 -05:00
|
|
|
// --log-file
|
|
|
|
if (config_lookup_string(&cfg, "log-file", &sval)) {
|
|
|
|
if (*sval != '/') {
|
|
|
|
log_warn("The log-file in your configuration file is not an absolute path");
|
|
|
|
}
|
|
|
|
opt->logpath = strdup(sval);
|
|
|
|
}
|
2018-08-22 07:58:49 -04:00
|
|
|
// --sw-opti
|
2018-12-21 11:25:28 -05:00
|
|
|
lcfg_lookup_bool(&cfg, "sw-opti", &opt->sw_opti);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --use-ewmh-active-win
|
|
|
|
lcfg_lookup_bool(&cfg, "use-ewmh-active-win",
|
2018-12-21 11:25:28 -05:00
|
|
|
&opt->use_ewmh_active_win);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --unredir-if-possible
|
|
|
|
lcfg_lookup_bool(&cfg, "unredir-if-possible",
|
2018-12-21 11:25:28 -05:00
|
|
|
&opt->unredir_if_possible);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --unredir-if-possible-delay
|
2018-10-23 17:12:42 -04:00
|
|
|
if (config_lookup_int(&cfg, "unredir-if-possible-delay", &ival))
|
2018-12-21 11:25:28 -05:00
|
|
|
opt->unredir_if_possible_delay = ival;
|
2018-08-22 07:58:49 -04:00
|
|
|
// --inactive-dim-fixed
|
2018-12-21 11:25:28 -05:00
|
|
|
lcfg_lookup_bool(&cfg, "inactive-dim-fixed", &opt->inactive_dim_fixed);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --detect-transient
|
2018-12-21 11:25:28 -05:00
|
|
|
lcfg_lookup_bool(&cfg, "detect-transient", &opt->detect_transient);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --detect-client-leader
|
|
|
|
lcfg_lookup_bool(&cfg, "detect-client-leader",
|
2018-12-21 11:25:28 -05:00
|
|
|
&opt->detect_client_leader);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --shadow-exclude
|
2018-12-21 11:25:28 -05:00
|
|
|
parse_cfg_condlst(&cfg, &opt->shadow_blacklist, "shadow-exclude");
|
2018-08-22 07:58:49 -04:00
|
|
|
// --fade-exclude
|
2018-12-21 11:25:28 -05:00
|
|
|
parse_cfg_condlst(&cfg, &opt->fade_blacklist, "fade-exclude");
|
2018-08-22 07:58:49 -04:00
|
|
|
// --focus-exclude
|
2018-12-21 11:25:28 -05:00
|
|
|
parse_cfg_condlst(&cfg, &opt->focus_blacklist, "focus-exclude");
|
2018-08-22 07:58:49 -04:00
|
|
|
// --invert-color-include
|
2018-12-21 11:25:28 -05:00
|
|
|
parse_cfg_condlst(&cfg, &opt->invert_color_list, "invert-color-include");
|
2018-08-22 07:58:49 -04:00
|
|
|
// --blur-background-exclude
|
2018-12-21 11:25:28 -05:00
|
|
|
parse_cfg_condlst(&cfg, &opt->blur_background_blacklist, "blur-background-exclude");
|
2018-08-22 07:58:49 -04:00
|
|
|
// --opacity-rule
|
2018-12-21 11:25:28 -05:00
|
|
|
parse_cfg_condlst_opct(opt, &cfg, "opacity-rule");
|
2018-08-22 07:58:49 -04:00
|
|
|
// --unredir-if-possible-exclude
|
2018-12-21 11:25:28 -05:00
|
|
|
parse_cfg_condlst(&cfg, &opt->unredir_if_possible_blacklist, "unredir-if-possible-exclude");
|
2018-08-22 07:58:49 -04:00
|
|
|
// --blur-background
|
2018-12-21 11:25:28 -05:00
|
|
|
lcfg_lookup_bool(&cfg, "blur-background", &opt->blur_background);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --blur-background-frame
|
|
|
|
lcfg_lookup_bool(&cfg, "blur-background-frame",
|
2018-12-21 11:25:28 -05:00
|
|
|
&opt->blur_background_frame);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --blur-background-fixed
|
|
|
|
lcfg_lookup_bool(&cfg, "blur-background-fixed",
|
2018-12-21 11:25:28 -05:00
|
|
|
&opt->blur_background_fixed);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --blur-kern
|
2018-12-21 11:25:28 -05:00
|
|
|
if (config_lookup_string(&cfg, "blur-kern", &sval) &&
|
|
|
|
!parse_conv_kern_lst(sval, opt->blur_kerns, MAX_BLUR_PASS, conv_kern_hasneg)) {
|
2018-12-20 12:35:45 -05:00
|
|
|
log_fatal("Cannot parse \"blur-kern\"");
|
2019-02-12 21:04:05 -05:00
|
|
|
goto err;
|
2018-12-20 12:35:45 -05:00
|
|
|
}
|
2018-08-22 07:58:49 -04:00
|
|
|
// --resize-damage
|
2018-12-21 11:25:28 -05:00
|
|
|
config_lookup_int(&cfg, "resize-damage", &opt->resize_damage);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --glx-no-stencil
|
2018-12-21 11:25:28 -05:00
|
|
|
lcfg_lookup_bool(&cfg, "glx-no-stencil", &opt->glx_no_stencil);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --glx-no-rebind-pixmap
|
2018-12-21 11:25:28 -05:00
|
|
|
lcfg_lookup_bool(&cfg, "glx-no-rebind-pixmap", &opt->glx_no_rebind_pixmap);
|
2018-08-22 07:58:49 -04:00
|
|
|
// --glx-swap-method
|
2018-12-21 11:25:28 -05:00
|
|
|
if (config_lookup_string(&cfg, "glx-swap-method", &sval)) {
|
|
|
|
opt->glx_swap_method = parse_glx_swap_method(sval);
|
|
|
|
if (opt->glx_swap_method == -2) {
|
|
|
|
log_fatal("Cannot parse \"glx-swap-method\"");
|
2019-02-12 21:04:05 -05:00
|
|
|
goto err;
|
2018-12-21 11:25:28 -05:00
|
|
|
}
|
2018-12-20 12:35:45 -05:00
|
|
|
}
|
2018-08-22 07:58:49 -04:00
|
|
|
// --glx-use-gpushader4
|
2018-12-21 11:25:28 -05:00
|
|
|
lcfg_lookup_bool(&cfg, "glx-use-gpushader4", &opt->glx_use_gpushader4);
|
2018-11-08 09:53:13 -05:00
|
|
|
// --xrender-sync
|
2018-12-30 02:06:47 -05:00
|
|
|
if (config_lookup_bool(&cfg, "xrender-sync", &ival) && ival) {
|
|
|
|
log_warn("Please use xrender-sync-fence instead of xrender-sync.");
|
|
|
|
opt->xrender_sync_fence = true;
|
|
|
|
}
|
2018-11-08 09:53:13 -05:00
|
|
|
// --xrender-sync-fence
|
2018-12-21 11:25:28 -05:00
|
|
|
lcfg_lookup_bool(&cfg, "xrender-sync-fence", &opt->xrender_sync_fence);
|
2018-10-23 17:12:42 -04:00
|
|
|
|
|
|
|
if (lcfg_lookup_bool(&cfg, "clear-shadow", &bval))
|
2018-12-20 12:35:45 -05:00
|
|
|
log_warn("\"clear-shadow\" is removed as an option, and is always"
|
|
|
|
" enabled now. Consider removing it from your config file");
|
2018-11-03 10:04:18 -04:00
|
|
|
if (lcfg_lookup_bool(&cfg, "paint-on-overlay", &bval))
|
2018-12-20 12:35:45 -05:00
|
|
|
log_warn("\"paint-on-overlay\" has been removed as an option, and "
|
|
|
|
"is enabled whenever possible");
|
2018-10-23 17:12:42 -04:00
|
|
|
|
2018-11-10 07:48:36 -05:00
|
|
|
if (config_lookup_float(&cfg, "alpha-step", &dval))
|
2018-12-20 12:35:45 -05:00
|
|
|
log_warn("\"alpha-step\" has been removed, compton now tries to make use"
|
|
|
|
" of all alpha values");
|
2018-11-10 07:48:36 -05:00
|
|
|
|
2018-10-23 17:12:42 -04:00
|
|
|
const char *deprecation_message = "has been removed. If you encounter problems "
|
2018-11-10 07:48:36 -05:00
|
|
|
"without this feature, please feel free to open a bug report";
|
2018-10-23 17:12:42 -04:00
|
|
|
if (lcfg_lookup_bool(&cfg, "glx-use-copysubbuffermesa", &bval) && bval)
|
2018-12-20 12:35:45 -05:00
|
|
|
log_warn("\"glx-use-copysubbuffermesa\" %s", deprecation_message);
|
2018-10-23 17:12:42 -04:00
|
|
|
if (lcfg_lookup_bool(&cfg, "glx-copy-from-front", &bval) && bval)
|
2018-12-20 12:35:45 -05:00
|
|
|
log_warn("\"glx-copy-from-front\" %s", deprecation_message);
|
2018-10-23 17:12:42 -04:00
|
|
|
|
2018-08-22 07:58:49 -04:00
|
|
|
// Wintype settings
|
|
|
|
|
2018-11-09 14:56:05 -05:00
|
|
|
// XXX ! Refactor all the wintype_* arrays into a struct
|
2018-08-22 07:58:49 -04:00
|
|
|
for (wintype_t i = 0; i < NUM_WINTYPES; ++i) {
|
|
|
|
char *str = mstrjoin("wintypes.", WINTYPES[i]);
|
|
|
|
config_setting_t *setting = config_lookup(&cfg, str);
|
|
|
|
free(str);
|
2018-12-04 08:44:16 -05:00
|
|
|
|
2018-12-21 11:25:28 -05:00
|
|
|
win_option_t *o = &opt->wintype_option[i];
|
2018-12-04 08:44:16 -05:00
|
|
|
win_option_mask_t *mask = &winopt_mask[i];
|
2018-08-22 07:58:49 -04:00
|
|
|
if (setting) {
|
2018-12-04 08:44:16 -05:00
|
|
|
if (config_setting_lookup_bool(setting, "shadow", &ival)) {
|
|
|
|
o->shadow = ival;
|
|
|
|
mask->shadow = true;
|
|
|
|
}
|
|
|
|
if (config_setting_lookup_bool(setting, "fade", &ival)) {
|
|
|
|
o->fade = ival;
|
|
|
|
mask->fade = true;
|
|
|
|
}
|
|
|
|
if (config_setting_lookup_bool(setting, "focus", &ival)) {
|
|
|
|
o->focus = ival;
|
|
|
|
mask->focus = true;
|
|
|
|
}
|
|
|
|
if (config_setting_lookup_bool(setting, "full-shadow", &ival)) {
|
|
|
|
o->full_shadow = ival;
|
|
|
|
mask->full_shadow = true;
|
|
|
|
}
|
2018-12-04 10:30:07 -05:00
|
|
|
if (config_setting_lookup_bool(setting, "redir-ignore", &ival)) {
|
|
|
|
o->redir_ignore = ival;
|
|
|
|
mask->redir_ignore = true;
|
|
|
|
}
|
2018-08-22 07:58:49 -04:00
|
|
|
|
|
|
|
double fval;
|
2018-12-04 08:44:16 -05:00
|
|
|
if (config_setting_lookup_float(setting, "opacity", &fval)) {
|
|
|
|
o->opacity = normalize_d(fval);
|
|
|
|
mask->opacity = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-22 07:58:49 -04:00
|
|
|
config_destroy(&cfg);
|
2018-12-21 11:25:28 -05:00
|
|
|
return path;
|
2019-02-12 21:04:05 -05:00
|
|
|
|
|
|
|
err:
|
|
|
|
config_destroy(&cfg);
|
|
|
|
free(path);
|
|
|
|
return ERR_PTR(-1);
|
2018-08-22 07:58:49 -04:00
|
|
|
}
|