options: reject invalid backend earlier
Unsupported backends were rejected when we try to initialize them, now we reject them in the option parsing phase. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
6efd88b82f
commit
2848b24a57
|
@ -10,6 +10,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <xcb/render.h> // for xcb_render_fixed_t, XXX
|
#include <xcb/render.h> // for xcb_render_fixed_t, XXX
|
||||||
|
|
||||||
|
#include "backend/backend.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
@ -480,7 +481,7 @@ bool get_early_config(int argc, char *const *argv, char **config_file, bool *all
|
||||||
/**
|
/**
|
||||||
* Process arguments and configuration files.
|
* Process arguments and configuration files.
|
||||||
*/
|
*/
|
||||||
void get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
|
bool 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 fading_enable, bool conv_kern_hasneg, win_option_mask_t *winopt_mask) {
|
||||||
|
|
||||||
int o = 0, longopt_idx = -1;
|
int o = 0, longopt_idx = -1;
|
||||||
|
@ -822,6 +823,13 @@ void get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
|
||||||
log_warn("--monitor-repaint has no effect when backend is not xrender");
|
log_warn("--monitor-repaint has no effect when backend is not xrender");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opt->experimental_backends && !backend_list[opt->backend]) {
|
||||||
|
log_error("Backend \"%s\" is not available as part of the experimental "
|
||||||
|
"backends.",
|
||||||
|
BACKEND_STRS[opt->backend]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Range checking and option assignments
|
// Range checking and option assignments
|
||||||
opt->fade_delta = max2(opt->fade_delta, 1);
|
opt->fade_delta = max2(opt->fade_delta, 1);
|
||||||
opt->shadow_radius = max2(opt->shadow_radius, 0);
|
opt->shadow_radius = max2(opt->shadow_radius, 0);
|
||||||
|
@ -880,6 +888,8 @@ void get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
|
||||||
log_warn("A convolution kernel with negative values may not work "
|
log_warn("A convolution kernel with negative values may not work "
|
||||||
"properly under X Render backend.");
|
"properly under X Render backend.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: set noet sw=8 ts=8 :
|
// vim: set noet sw=8 ts=8 :
|
||||||
|
|
|
@ -27,8 +27,11 @@ bool get_early_config(int argc, char *const *argv, char **config_file, bool *all
|
||||||
* fading_enable
|
* fading_enable
|
||||||
* conv_kern_hasneg
|
* conv_kern_hasneg
|
||||||
* winopt_mask
|
* winopt_mask
|
||||||
|
* Returns:
|
||||||
|
* Whether configuration are processed successfully.
|
||||||
*/
|
*/
|
||||||
void get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
|
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 fading_enable, bool conv_kern_hasneg,
|
||||||
|
win_option_mask_t *winopt_mask);
|
||||||
|
|
||||||
// vim: set noet sw=8 ts=8:
|
// vim: set noet sw=8 ts=8:
|
||||||
|
|
13
src/picom.c
13
src/picom.c
|
@ -724,13 +724,8 @@ static bool initialize_backend(session_t *ps) {
|
||||||
if (ps->o.experimental_backends) {
|
if (ps->o.experimental_backends) {
|
||||||
assert(!ps->backend_data);
|
assert(!ps->backend_data);
|
||||||
// Reinitialize win_data
|
// Reinitialize win_data
|
||||||
if (backend_list[ps->o.backend]) {
|
assert(backend_list[ps->o.backend]);
|
||||||
ps->backend_data = backend_list[ps->o.backend]->init(ps);
|
ps->backend_data = backend_list[ps->o.backend]->init(ps);
|
||||||
} else {
|
|
||||||
log_error("Backend \"%s\" is not available as part of the "
|
|
||||||
"experimental backends.",
|
|
||||||
BACKEND_STRS[ps->o.backend]);
|
|
||||||
}
|
|
||||||
if (!ps->backend_data) {
|
if (!ps->backend_data) {
|
||||||
log_fatal("Failed to initialize backend, aborting...");
|
log_fatal("Failed to initialize backend, aborting...");
|
||||||
quit(ps);
|
quit(ps);
|
||||||
|
@ -1751,7 +1746,11 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse all of the rest command line options
|
// Parse all of the rest command line options
|
||||||
get_cfg(&ps->o, argc, argv, shadow_enabled, fading_enable, hasneg, winopt_mask);
|
if (!get_cfg(&ps->o, argc, argv, shadow_enabled, fading_enable, hasneg, winopt_mask)) {
|
||||||
|
log_fatal("Failed to get configuration, usually mean you have specified "
|
||||||
|
"invalid options.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (ps->o.logpath) {
|
if (ps->o.logpath) {
|
||||||
auto l = file_logger_new(ps->o.logpath);
|
auto l = file_logger_new(ps->o.logpath);
|
||||||
|
|
Loading…
Reference in New Issue