options: refactor option parsing

The main objective is to remove the need to worry about option value
assignment. Because of the way getopt works, we need to assign a number
to each option, and later match the return value of getopt in a big
switch. We have to make sure to not assign the same number to two
options, and we have to carefully make sure the same number is used in
two different places (once in the options table, once in the switch).
And that is just annoying.

With this commit everything is in one place, and the compiler will yell
at us if we assigned duplicated numbers.

Maybe this can also be a stepping stone for unifying command line
options parsing and config file parsing.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2024-05-12 15:12:47 +01:00
parent 4bb0a711fa
commit 43de276c19
No known key found for this signature in database
GPG Key ID: D3A4405BE6CC17F4
12 changed files with 645 additions and 735 deletions

View File

@ -35,6 +35,9 @@
* Setting `--shadow-exclude-reg` is now a hard error. It was deprecated almost since the start of `picom`. `--clip-shadow-above` is the better alternative. (#1254)
* Remove command line options `-n`, `-a`, and `-s`. They were removed more than 10 years ago, it's time to finally get rid of them entirely. (#1254)
* Remove error message for `--glx-swap-method`, it was deprecated in v6.
* Remove error message for passing argument to `--vsync` arguments, it was deprecated in v5.
* Option `--opengl` is now deprecated, use `--backend=glx` instead.
## Bug fixes

View File

@ -58,7 +58,8 @@ if get_option('warning_level') != '0'
'nonnull', 'shadow', 'no-type-limits', 'old-style-declaration', 'override-init',
'sign-compare', 'type-limits', 'uninitialized', 'shift-negative-value',
'unused-but-set-parameter', 'unused-parameter', 'implicit-fallthrough=2',
'no-unknown-warning-option', 'no-missing-braces', 'conversion', 'empty-body' ]
'no-unknown-warning-option', 'no-missing-braces', 'conversion', 'empty-body',
'no-c2x-extensions' ]
bad_warns_ubsan = [
'no-format-overflow' # see gcc bug 87884, enabling UBSAN makes gcc spit out spurious warnings
# (if you saw this comment, went and checked gcc bugzilla, and found out

View File

@ -183,7 +183,7 @@ const char *parse_readnum(const char *src, double *dest) {
return pc;
}
enum blur_method parse_blur_method(const char *src) {
int parse_blur_method(const char *src) {
if (strcmp(src, "box") == 0) {
return BLUR_METHOD_BOX;
}
@ -209,9 +209,8 @@ enum blur_method parse_blur_method(const char *src) {
* @param[out] endptr return where the end of kernel is in the string
* @param[out] hasneg whether the kernel has negative values
*/
conv *parse_blur_kern(const char *src, const char **endptr, bool *hasneg) {
static conv *parse_blur_kern(const char *src, const char **endptr) {
int width = 0, height = 0;
*hasneg = false;
const char *pc = NULL;
@ -257,9 +256,6 @@ conv *parse_blur_kern(const char *src, const char **endptr, bool *hasneg) {
goto err2;
}
src = pc;
if (val < 0) {
*hasneg = true;
}
matrix->data[i] = val;
}
@ -307,7 +303,7 @@ err1:
* @param[out] hasneg whether any of the kernels have negative values
* @return the kernels
*/
struct conv **parse_blur_kern_lst(const char *src, bool *hasneg, int *count) {
struct conv **parse_blur_kern_lst(const char *src, int *count) {
// TODO(yshui) just return a predefined kernels, not parse predefined strings...
static const struct {
const char *name;
@ -363,11 +359,10 @@ struct conv **parse_blur_kern_lst(const char *src, bool *hasneg, int *count) {
};
*count = 0;
*hasneg = false;
for (unsigned int i = 0;
i < sizeof(CONV_KERN_PREDEF) / sizeof(CONV_KERN_PREDEF[0]); ++i) {
if (!strcmp(CONV_KERN_PREDEF[i].name, src)) {
return parse_blur_kern_lst(CONV_KERN_PREDEF[i].kern_str, hasneg, count);
return parse_blur_kern_lst(CONV_KERN_PREDEF[i].kern_str, count);
}
}
@ -386,9 +381,8 @@ struct conv **parse_blur_kern_lst(const char *src, bool *hasneg, int *count) {
// Continue parsing until the end of source string
i = 0;
while (pc && *pc) {
bool tmp_hasneg;
assert(i < nkernels);
ret[i] = parse_blur_kern(pc, &pc, &tmp_hasneg);
ret[i] = parse_blur_kern(pc, &pc);
if (!ret[i]) {
for (int j = 0; j < i; j++) {
free(ret[j]);
@ -397,7 +391,6 @@ struct conv **parse_blur_kern_lst(const char *src, bool *hasneg, int *count) {
return NULL;
}
i++;
*hasneg |= tmp_hasneg;
}
if (i > 1) {
@ -633,80 +626,12 @@ void *parse_window_shader_prefix(const char *src, const char **end, void *user_d
*end = endptr + 1;
return shader_source;
}
/**
* Add a pattern to a condition linked list.
*/
bool condlst_add(c2_lptr_t **pcondlst, const char *pattern) {
if (!pattern) {
return false;
}
if (!c2_parse(pcondlst, pattern, NULL)) {
exit(1);
}
return true;
void *parse_window_shader_prefix_with_cwd(const char *src, const char **end, void *) {
scoped_charp cwd = getcwd(NULL, 0);
return parse_window_shader_prefix(src, end, cwd);
}
void set_default_winopts(options_t *opt, win_option_mask_t *mask, bool shadow_enable,
bool fading_enable, bool blur_enable) {
// Apply default wintype options.
if (!mask[WINTYPE_DESKTOP].shadow) {
// Desktop windows are always drawn without shadow by default.
mask[WINTYPE_DESKTOP].shadow = true;
opt->wintype_option[WINTYPE_DESKTOP].shadow = false;
}
// Focused/unfocused state only apply to a few window types, all other windows
// are always considered focused.
const wintype_t nofocus_type[] = {WINTYPE_UNKNOWN, WINTYPE_NORMAL, WINTYPE_UTILITY};
for (unsigned long i = 0; i < ARR_SIZE(nofocus_type); i++) {
if (!mask[nofocus_type[i]].focus) {
mask[nofocus_type[i]].focus = true;
opt->wintype_option[nofocus_type[i]].focus = false;
}
}
for (unsigned long i = 0; i < NUM_WINTYPES; i++) {
if (!mask[i].shadow) {
mask[i].shadow = true;
opt->wintype_option[i].shadow = shadow_enable;
}
if (!mask[i].fade) {
mask[i].fade = true;
opt->wintype_option[i].fade = fading_enable;
}
if (!mask[i].focus) {
mask[i].focus = true;
opt->wintype_option[i].focus = true;
}
if (!mask[i].blur_background) {
mask[i].blur_background = true;
opt->wintype_option[i].blur_background = blur_enable;
}
if (!mask[i].full_shadow) {
mask[i].full_shadow = true;
opt->wintype_option[i].full_shadow = false;
}
if (!mask[i].redir_ignore) {
mask[i].redir_ignore = true;
opt->wintype_option[i].redir_ignore = false;
}
if (!mask[i].opacity) {
mask[i].opacity = true;
// Opacity is not set to a concrete number here because the
// opacity logic is complicated, and needs an "unset" state
opt->wintype_option[i].opacity = NAN;
}
if (!mask[i].clip_shadow_above) {
mask[i].clip_shadow_above = true;
opt->wintype_option[i].clip_shadow_above = false;
}
}
}
char *parse_config(options_t *opt, const char *config_file, bool *shadow_enable,
bool *fading_enable, bool *hasneg, win_option_mask_t *winopt_mask) {
char *parse_config(options_t *opt, const char *config_file) {
// clang-format off
*opt = (struct options){
.backend = BKEND_XRENDER,
@ -727,7 +652,7 @@ char *parse_config(options_t *opt, const char *config_file, bool *shadow_enable,
.logpath = NULL,
.use_damage = true,
.no_frame_pacing = false,
.frame_pacing = true,
.shadow_red = 0.0,
.shadow_green = 0.0,
@ -786,7 +711,6 @@ char *parse_config(options_t *opt, const char *config_file, bool *shadow_enable,
// clang-format on
char *ret = NULL;
ret = parse_config_libconfig(opt, config_file, shadow_enable, fading_enable,
hasneg, winopt_mask);
ret = parse_config_libconfig(opt, config_file);
return ret;
}

View File

@ -111,7 +111,9 @@ typedef struct options {
/// Path to write PID to.
char *write_pid_path;
/// The backend in use.
enum backend backend;
int backend;
/// Log level.
int log_level;
/// Whether to sync X drawing with X Sync fence to avoid certain delay
/// issues with GLX backend.
bool xrender_sync_fence;
@ -135,7 +137,7 @@ typedef struct options {
/// when determining if a window could be unredirected.
c2_lptr_t *unredir_if_possible_blacklist;
/// Delay before unredirecting screen, in milliseconds.
long unredir_if_possible_delay;
int unredir_if_possible_delay;
/// Forced redirection setting through D-Bus.
switch_t redirected_force;
/// Whether to stop painting. Controlled through D-Bus.
@ -156,6 +158,7 @@ typedef struct options {
bool no_x_selection;
/// Window type option override.
win_option_t wintype_option[NUM_WINTYPES];
struct win_option_mask wintype_option_mask[NUM_WINTYPES];
/// Whether to set realtime scheduling policy for the compositor process.
bool use_realtime_scheduling;
@ -168,7 +171,7 @@ typedef struct options {
/// Whether use damage information to help limit the area to paint
bool use_damage;
/// Disable frame pacing
bool no_frame_pacing;
bool frame_pacing;
// === Shadow ===
/// Red, green and blue tone of the shadow.
@ -184,6 +187,7 @@ typedef struct options {
bool crop_shadow_to_monitor;
/// Don't draw shadow over these windows. A linked list of conditions.
c2_lptr_t *shadow_clip_list;
bool shadow_enable;
// === Fading ===
/// How much to fade in in a single fading step.
@ -198,6 +202,7 @@ typedef struct options {
bool no_fading_destroyed_argb;
/// Fading blacklist. A linked list of conditions.
c2_lptr_t *fade_blacklist;
bool fading_enable;
// === Opacity ===
/// Default opacity for inactive windows.
@ -293,19 +298,19 @@ extern const char *const BACKEND_STRS[NUM_BKEND + 1];
bool must_use parse_long(const char *, long *);
bool must_use parse_int(const char *, int *);
struct conv **must_use parse_blur_kern_lst(const char *, bool *hasneg, int *count);
struct conv **must_use parse_blur_kern_lst(const char *, int *count);
/// Parse the path prefix of a c2 rule. Then look for the specified file in the
/// given include directories. The include directories are passed via `user_data`.
void *parse_window_shader_prefix(const char *src, const char **end, void *user_data);
/// Same as `parse_window_shader_prefix`, but the path is relative to the current
/// working directory. `user_data` is ignored.
void *parse_window_shader_prefix_with_cwd(const char *src, const char **end, void *);
void *parse_numeric_prefix(const char *src, const char **end, void *user_data);
char *must_use locate_auxiliary_file(const char *scope, const char *path,
const char *include_dir);
enum blur_method must_use parse_blur_method(const char *src);
int must_use parse_blur_method(const char *src);
void parse_debug_options(struct debug_options *);
/**
* Add a pattern to a condition linked list.
*/
bool condlst_add(c2_lptr_t **, const char *);
const char *xdg_config_home(void);
char **xdg_config_dirs(void);
@ -317,24 +322,19 @@ char **xdg_config_dirs(void);
/// win_option_mask = whether option overrides for specific window type is set for given
/// options
/// hasneg = whether the convolution kernel has negative values
char *
parse_config_libconfig(options_t *, const char *config_file, bool *shadow_enable,
bool *fading_enable, bool *hasneg, win_option_mask_t *winopt_mask);
char *parse_config_libconfig(options_t *, const char *config_file);
void set_default_winopts(options_t *, win_option_mask_t *, bool shadow_enable,
bool fading_enable, bool blur_enable);
/// Parse a configuration file is that is enabled, also initialize the winopt_mask with
/// default values
/// Outputs and returns:
/// same as parse_config_libconfig
char *parse_config(options_t *, const char *config_file, bool *shadow_enable,
bool *fading_enable, bool *hasneg, win_option_mask_t *winopt_mask);
char *parse_config(options_t *, const char *config_file);
/**
* Parse a backend option argument.
*/
static inline attr_pure enum backend parse_backend(const char *str) {
for (enum backend i = 0; BACKEND_STRS[i]; ++i) {
static inline attr_pure int parse_backend(const char *str) {
for (int i = 0; BACKEND_STRS[i]; ++i) {
if (!strcasecmp(str, BACKEND_STRS[i])) {
return i;
}

View File

@ -119,34 +119,40 @@ FILE *open_config_file(const char *cpath, char **ppath) {
/**
* Parse a condition list in configuration file.
*/
void parse_cfg_condlst(const config_t *pcfg, c2_lptr_t **pcondlst, const char *name) {
bool must_use parse_cfg_condlst(const config_t *pcfg, c2_lptr_t **pcondlst, 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--) {
condlst_add(pcondlst,
config_setting_get_string_elem(setting, i));
if (setting == NULL) {
return true;
}
// Parse an array of options
if (config_setting_is_array(setting)) {
int i = config_setting_length(setting);
while (i--) {
if (!c2_parse(pcondlst,
config_setting_get_string_elem(setting, i), NULL)) {
return false;
}
}
// Treat it as a single pattern if it's a string
else if (CONFIG_TYPE_STRING == config_setting_type(setting)) {
condlst_add(pcondlst, config_setting_get_string(setting));
}
// Treat it as a single pattern if it's a string
else if (CONFIG_TYPE_STRING == config_setting_type(setting)) {
if (!c2_parse(pcondlst, config_setting_get_string(setting), NULL)) {
return false;
}
}
return true;
}
/**
* Parse a window corner radius rule list in configuration file.
*/
static inline void
static inline bool
parse_cfg_condlst_with_prefix(c2_lptr_t **condlst, const config_t *pcfg, const char *name,
void *(*parse_prefix)(const char *, const char **, void *),
void (*free_value)(void *), void *user_data) {
config_setting_t *setting = config_lookup(pcfg, name);
if (setting == NULL) {
return;
return true;
}
// Parse an array of options
if (config_setting_is_array(setting)) {
@ -155,7 +161,7 @@ parse_cfg_condlst_with_prefix(c2_lptr_t **condlst, const config_t *pcfg, const c
if (!c2_parse_with_prefix(
condlst, config_setting_get_string_elem(setting, i),
parse_prefix, free_value, user_data)) {
exit(1);
return false;
}
}
}
@ -163,9 +169,10 @@ parse_cfg_condlst_with_prefix(c2_lptr_t **condlst, const config_t *pcfg, const c
else if (config_setting_type(setting) == CONFIG_TYPE_STRING) {
if (!c2_parse_with_prefix(condlst, config_setting_get_string(setting),
parse_prefix, free_value, user_data)) {
exit(1);
return false;
}
}
return true;
}
static inline void parse_wintype_config(const config_t *cfg, const char *member_name,
@ -218,9 +225,7 @@ static inline void parse_wintype_config(const config_t *cfg, const char *member_
*
* Returns the actually config_file name
*/
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) {
char *parse_config_libconfig(options_t *opt, const char *config_file) {
const char *deprecation_message =
"option has been deprecated. Please remove it from your configuration file. "
@ -310,19 +315,15 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
}
// --corner-radius
config_lookup_int(&cfg, "corner-radius", &opt->corner_radius);
// --rounded-corners-exclude
parse_cfg_condlst(&cfg, &opt->rounded_corners_blacklist, "rounded-corners-exclude");
// --corner-radius-rules
parse_cfg_condlst_with_prefix(&opt->corner_radius_rules, &cfg, "corner-radius-rules",
parse_numeric_prefix, NULL, (int[]){0, INT_MAX});
// --no-frame-pacing
lcfg_lookup_bool(&cfg, "no-frame-pacing", &opt->no_frame_pacing);
if (lcfg_lookup_bool(&cfg, "no-frame-pacing", &bval)) {
opt->frame_pacing = !bval;
}
// -e (frame_opacity)
config_lookup_float(&cfg, "frame-opacity", &opt->frame_opacity);
// -c (shadow_enable)
lcfg_lookup_bool(&cfg, "shadow", shadow_enable);
lcfg_lookup_bool(&cfg, "shadow", &opt->shadow_enable);
// -m (menu_opacity)
if (config_lookup_float(&cfg, "menu-opacity", &dval)) {
log_warn("Option `menu-opacity` is deprecated, and will be removed."
@ -330,12 +331,12 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
"and `dropdown_menu` instead.");
opt->wintype_option[WINTYPE_DROPDOWN_MENU].opacity = dval;
opt->wintype_option[WINTYPE_POPUP_MENU].opacity = dval;
winopt_mask[WINTYPE_DROPDOWN_MENU].opacity = true;
winopt_mask[WINTYPE_POPUP_MENU].opacity = true;
opt->wintype_option_mask[WINTYPE_DROPDOWN_MENU].opacity = true;
opt->wintype_option_mask[WINTYPE_POPUP_MENU].opacity = true;
}
// -f (fading_enable)
if (config_lookup_bool(&cfg, "fading", &ival)) {
*fading_enable = ival;
opt->fading_enable = ival;
}
// --no-fading-open-close
lcfg_lookup_bool(&cfg, "no-fading-openclose", &opt->no_fading_openclose);
@ -404,11 +405,11 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
}
// --log-level
if (config_lookup_string(&cfg, "log-level", &sval)) {
auto level = string_to_log_level(sval);
if (level == LOG_LEVEL_INVALID) {
opt->log_level = string_to_log_level(sval);
if (opt->log_level == LOG_LEVEL_INVALID) {
log_warn("Invalid log level, defaults to WARN");
} else {
log_set_level_tls(level);
log_set_level_tls(opt->log_level);
}
}
// --log-file
@ -448,35 +449,36 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
lcfg_lookup_bool(&cfg, "transparent-clipping", &opt->transparent_clipping);
// --dithered_present
lcfg_lookup_bool(&cfg, "dithered-present", &opt->dithered_present);
// --transparent-clipping-exclude
parse_cfg_condlst(&cfg, &opt->transparent_clipping_blacklist,
"transparent-clipping-exclude");
// --shadow-exclude
parse_cfg_condlst(&cfg, &opt->shadow_blacklist, "shadow-exclude");
// --clip-shadow-above
parse_cfg_condlst(&cfg, &opt->shadow_clip_list, "clip-shadow-above");
// --fade-exclude
parse_cfg_condlst(&cfg, &opt->fade_blacklist, "fade-exclude");
// --focus-exclude
parse_cfg_condlst(&cfg, &opt->focus_blacklist, "focus-exclude");
// --invert-color-include
parse_cfg_condlst(&cfg, &opt->invert_color_list, "invert-color-include");
// --blur-background-exclude
parse_cfg_condlst(&cfg, &opt->blur_background_blacklist, "blur-background-exclude");
// --opacity-rule
parse_cfg_condlst_with_prefix(&opt->opacity_rules, &cfg, "opacity-rule",
parse_numeric_prefix, NULL, (int[]){0, 100});
// --unredir-if-possible-exclude
parse_cfg_condlst(&cfg, &opt->unredir_if_possible_blacklist,
"unredir-if-possible-exclude");
if (!parse_cfg_condlst(&cfg, &opt->transparent_clipping_blacklist,
"transparent-clipping-exclude") ||
!parse_cfg_condlst(&cfg, &opt->shadow_blacklist, "shadow-exclude") ||
!parse_cfg_condlst(&cfg, &opt->shadow_clip_list, "clip-shadow-above") ||
!parse_cfg_condlst(&cfg, &opt->fade_blacklist, "fade-exclude") ||
!parse_cfg_condlst(&cfg, &opt->focus_blacklist, "focus-exclude") ||
!parse_cfg_condlst(&cfg, &opt->invert_color_list, "invert-color-include") ||
!parse_cfg_condlst(&cfg, &opt->blur_background_blacklist, "blur-background-exclude") ||
!parse_cfg_condlst(&cfg, &opt->unredir_if_possible_blacklist,
"unredir-if-possible-exclude") ||
!parse_cfg_condlst(&cfg, &opt->rounded_corners_blacklist, "rounded-corners-exclude") ||
!parse_cfg_condlst_with_prefix(&opt->corner_radius_rules, &cfg, "corner-radius-rules",
parse_numeric_prefix, NULL, (int[]){0, INT_MAX}) ||
!parse_cfg_condlst_with_prefix(&opt->opacity_rules, &cfg, "opacity-rule",
parse_numeric_prefix, NULL, (int[]){0, 100}) ||
!parse_cfg_condlst_with_prefix(
&opt->window_shader_fg_rules, &cfg, "window-shader-fg-rule",
parse_window_shader_prefix, free, (void *)config_get_include_dir(&cfg))) {
goto err;
}
// --blur-method
if (config_lookup_string(&cfg, "blur-method", &sval)) {
enum blur_method method = parse_blur_method(sval);
int method = parse_blur_method(sval);
if (method >= BLUR_METHOD_INVALID) {
log_fatal("Invalid blur method %s", sval);
goto err;
}
opt->blur_method = method;
opt->blur_method = (enum blur_method)method;
}
// --blur-size
config_lookup_int(&cfg, "blur-size", &opt->blur_radius);
@ -496,8 +498,7 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
lcfg_lookup_bool(&cfg, "blur-background-fixed", &opt->blur_background_fixed);
// --blur-kern
if (config_lookup_string(&cfg, "blur-kern", &sval)) {
opt->blur_kerns =
parse_blur_kern_lst(sval, conv_kern_hasneg, &opt->blur_kernel_count);
opt->blur_kerns = parse_blur_kern_lst(sval, &opt->blur_kernel_count);
if (!opt->blur_kerns) {
log_fatal("Cannot parse \"blur-kern\"");
goto err;
@ -547,11 +548,6 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
locate_auxiliary_file("shaders", sval, config_get_include_dir(&cfg));
}
// --window-shader-fg-rule
parse_cfg_condlst_with_prefix(&opt->window_shader_fg_rules, &cfg,
"window-shader-fg-rule", parse_window_shader_prefix,
free, (void *)config_get_include_dir(&cfg));
// --glx-use-gpushader4
if (config_lookup_bool(&cfg, "glx-use-gpushader4", &ival)) {
log_error("glx-use-gpushader4 has been removed, please remove it "
@ -569,19 +565,18 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
config_setting_t *blur_cfg = config_lookup(&cfg, "blur");
if (blur_cfg) {
if (config_setting_lookup_string(blur_cfg, "method", &sval)) {
enum blur_method method = parse_blur_method(sval);
int method = parse_blur_method(sval);
if (method >= BLUR_METHOD_INVALID) {
log_warn("Invalid blur method %s, ignoring.", sval);
} else {
opt->blur_method = method;
opt->blur_method = (enum blur_method)method;
}
}
config_setting_lookup_int(blur_cfg, "size", &opt->blur_radius);
if (config_setting_lookup_string(blur_cfg, "kernel", &sval)) {
opt->blur_kerns = parse_blur_kern_lst(sval, conv_kern_hasneg,
&opt->blur_kernel_count);
opt->blur_kerns = parse_blur_kern_lst(sval, &opt->blur_kernel_count);
if (!opt->blur_kerns) {
log_warn("Failed to parse blur kernel: %s", sval);
}
@ -605,12 +600,12 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
// XXX ! Refactor all the wintype_* arrays into a struct
for (wintype_t i = 0; i < NUM_WINTYPES; ++i) {
parse_wintype_config(&cfg, WINTYPES[i].name, &opt->wintype_option[i],
&winopt_mask[i]);
&opt->wintype_option_mask[i]);
}
// Compatibility with the old name for notification windows.
parse_wintype_config(&cfg, "notify", &opt->wintype_option[WINTYPE_NOTIFICATION],
&winopt_mask[WINTYPE_NOTIFICATION]);
&opt->wintype_option_mask[WINTYPE_NOTIFICATION]);
config_destroy(&cfg);
return path;

View File

@ -853,7 +853,7 @@ cdbus_process_opts_get(session_t *ps, DBusMessage *msg, DBusMessage *reply, DBus
dbus_set_error_const(err, DBUS_ERROR_INVALID_ARGS, NULL);
return DBUS_HANDLER_RESULT_HANDLED;
}
assert(ps->o.backend < sizeof(BACKEND_STRS) / sizeof(BACKEND_STRS[0]));
assert((size_t)ps->o.backend < sizeof(BACKEND_STRS) / sizeof(BACKEND_STRS[0]));
#define append(tgt, type, ret) \
if (!strcmp(#tgt, target)) { \

View File

@ -173,17 +173,14 @@ int inspect_main(int argc, char **argv, const char *config_file) {
char *config_file_to_free = NULL;
struct options options;
bool shadow_enabled, fading_enable, hasneg;
win_option_mask_t winopt_mask[NUM_WINTYPES] = {0};
config_file = config_file_to_free = parse_config(
&options, config_file, &shadow_enabled, &fading_enable, &hasneg, winopt_mask);
config_file = config_file_to_free = parse_config(&options, config_file);
if (IS_ERR(config_file_to_free)) {
return 1;
}
// Parse all of the rest command line options
if (!get_cfg(&options, argc, argv, shadow_enabled, fading_enable, hasneg, winopt_mask)) {
if (!get_cfg(&options, argc, argv)) {
log_fatal("Failed to get configuration, usually mean you have specified "
"invalid options.");
return 1;

View File

@ -78,7 +78,7 @@ static attr_const const char *log_level_to_string(enum log_level level) {
}
}
enum log_level string_to_log_level(const char *str) {
int string_to_log_level(const char *str) {
if (strcasecmp(str, "TRACE") == 0) {
return LOG_LEVEL_TRACE;
}

View File

@ -60,7 +60,7 @@ attr_nonnull_all void log_destroy(struct log *);
attr_nonnull(1) void log_set_level(struct log *l, int level);
attr_pure enum log_level log_get_level(const struct log *l);
attr_nonnull_all void log_add_target(struct log *, struct log_target *);
attr_pure enum log_level string_to_log_level(const char *);
attr_pure int string_to_log_level(const char *);
/// Remove a previously added log target for a log struct, and destroy it. If the log
/// target was never added, nothing happens.
void log_remove_target(struct log *l, struct log_target *tgt);

File diff suppressed because it is too large Load Diff

View File

@ -30,9 +30,7 @@ bool get_early_config(int argc, char *const *argv, char **config_file, bool *all
* Returns:
* Whether configuration are processed successfully.
*/
bool must_use get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
bool fading_enable, bool conv_kern_hasneg,
win_option_mask_t *winopt_mask);
bool must_use get_cfg(options_t *opt, int argc, char *const *argv);
void options_postprocess_c2_lists(struct c2_state *state, struct x_connection *c,
struct options *option);
void options_destroy(struct options *options);

View File

@ -1492,7 +1492,7 @@ static bool redirect_start(session_t *ps) {
pixman_region32_init(&ps->damage_ring.damages[i]);
}
ps->frame_pacing = !ps->o.no_frame_pacing && ps->o.vsync;
ps->frame_pacing = ps->o.frame_pacing && ps->o.vsync;
if ((ps->o.legacy_backends || ps->o.benchmark || !ps->backend_data->ops->last_render_time) &&
ps->frame_pacing) {
// Disable frame pacing if we are using a legacy backend or if we are in
@ -2208,18 +2208,15 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
}
// Parse configuration file
win_option_mask_t winopt_mask[NUM_WINTYPES] = {{0}};
bool shadow_enabled = false, fading_enable = false, hasneg = false;
char *config_file_to_free = NULL;
config_file = config_file_to_free = parse_config(
&ps->o, config_file, &shadow_enabled, &fading_enable, &hasneg, winopt_mask);
config_file = config_file_to_free = parse_config(&ps->o, config_file);
if (IS_ERR(config_file_to_free)) {
return NULL;
}
// Parse all of the rest command line options
if (!get_cfg(&ps->o, argc, argv, shadow_enabled, fading_enable, hasneg, winopt_mask)) {
if (!get_cfg(&ps->o, argc, argv)) {
log_fatal("Failed to get configuration, usually mean you have specified "
"invalid options.");
return NULL;