Merge branch 'yshui:next' into next

This commit is contained in:
Arda Atci
2023-08-16 05:24:15 +03:00
committed by GitHub
21 changed files with 177 additions and 121 deletions

View File

@@ -27,7 +27,7 @@ jobs:
languages: ${{ matrix.language }}
# Install dependencies
- run: sudo apt update && sudo apt install libxext-dev libxcb1-dev libxcb-dpms0-dev libxcb-damage0-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-randr0-dev libxcb-composite0-dev libxcb-image0-dev libxcb-present-dev libxcb-glx0-dev libxcb-util-dev libpixman-1-dev libdbus-1-dev libconfig-dev libgl1-mesa-dev libpcre2-dev libevdev-dev uthash-dev libev-dev libx11-xcb-dev meson ninja-build
- run: sudo apt update && sudo apt install libconfig-dev libdbus-1-dev libegl-dev libev-dev libgl-dev libpcre2-dev libpixman-1-dev libx11-xcb-dev libxcb1-dev libxcb-composite0-dev libxcb-damage0-dev libxcb-dpms0-dev libxcb-glx0-dev libxcb-image0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-shape0-dev libxcb-util-dev libxcb-xfixes0-dev libxext-dev meson ninja-build uthash-dev
if: ${{ matrix.language == 'cpp' }}
# Autobuild

View File

@@ -49,7 +49,7 @@ Assuming you already have all the usual building tools installed (e.g. gcc, pyth
On Debian based distributions (e.g. Ubuntu), the needed packages are
```
libxext-dev libxcb1-dev libxcb-damage0-dev libxcb-dpms0-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-randr0-dev libxcb-composite0-dev libxcb-image0-dev libxcb-present-dev libxcb-glx0-dev libpixman-1-dev libdbus-1-dev libconfig-dev libgl-dev libegl-dev libpcre2-dev libevdev-dev uthash-dev libev-dev libx11-xcb-dev meson
libconfig-dev libdbus-1-dev libegl-dev libev-dev libgl-dev libpcre2-dev libpixman-1-dev libx11-xcb-dev libxcb1-dev libxcb-composite0-dev libxcb-damage0-dev libxcb-dpms0-dev libxcb-glx0-dev libxcb-image0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-shape0-dev libxcb-util-dev libxcb-xfixes0-dev libxext-dev meson ninja-build uthash-dev
```
On Fedora, the needed packages are

View File

@@ -405,31 +405,31 @@ struct dual_kawase_params *generate_dual_kawase_params(void *args) {
int min_radius; /// Approximate gauss-blur with at least this
/// radius and std-deviation
} strength_levels[20] = {
{.iterations = 1, .offset = 1.25f, .min_radius = 1}, // LVL 1
{.iterations = 1, .offset = 2.25f, .min_radius = 6}, // LVL 2
{.iterations = 2, .offset = 2.00f, .min_radius = 11}, // LVL 3
{.iterations = 2, .offset = 3.00f, .min_radius = 17}, // LVL 4
{.iterations = 2, .offset = 4.25f, .min_radius = 24}, // LVL 5
{.iterations = 3, .offset = 2.50f, .min_radius = 32}, // LVL 6
{.iterations = 3, .offset = 3.25f, .min_radius = 40}, // LVL 7
{.iterations = 3, .offset = 4.25f, .min_radius = 51}, // LVL 8
{.iterations = 3, .offset = 5.50f, .min_radius = 67}, // LVL 9
{.iterations = 4, .offset = 3.25f, .min_radius = 83}, // LVL 10
{.iterations = 4, .offset = 4.00f, .min_radius = 101}, // LVL 11
{.iterations = 4, .offset = 5.00f, .min_radius = 123}, // LVL 12
{.iterations = 4, .offset = 6.00f, .min_radius = 148}, // LVL 13
{.iterations = 4, .offset = 7.25f, .min_radius = 178}, // LVL 14
{.iterations = 4, .offset = 8.25f, .min_radius = 208}, // LVL 15
{.iterations = 5, .offset = 4.50f, .min_radius = 236}, // LVL 16
{.iterations = 5, .offset = 5.25f, .min_radius = 269}, // LVL 17
{.iterations = 5, .offset = 6.25f, .min_radius = 309}, // LVL 18
{.iterations = 5, .offset = 7.25f, .min_radius = 357}, // LVL 19
{.iterations = 5, .offset = 8.50f, .min_radius = 417}, // LVL 20
{.iterations = 1, .offset = 1.25F, .min_radius = 1}, // LVL 1
{.iterations = 1, .offset = 2.25F, .min_radius = 6}, // LVL 2
{.iterations = 2, .offset = 2.00F, .min_radius = 11}, // LVL 3
{.iterations = 2, .offset = 3.00F, .min_radius = 17}, // LVL 4
{.iterations = 2, .offset = 4.25F, .min_radius = 24}, // LVL 5
{.iterations = 3, .offset = 2.50F, .min_radius = 32}, // LVL 6
{.iterations = 3, .offset = 3.25F, .min_radius = 40}, // LVL 7
{.iterations = 3, .offset = 4.25F, .min_radius = 51}, // LVL 8
{.iterations = 3, .offset = 5.50F, .min_radius = 67}, // LVL 9
{.iterations = 4, .offset = 3.25F, .min_radius = 83}, // LVL 10
{.iterations = 4, .offset = 4.00F, .min_radius = 101}, // LVL 11
{.iterations = 4, .offset = 5.00F, .min_radius = 123}, // LVL 12
{.iterations = 4, .offset = 6.00F, .min_radius = 148}, // LVL 13
{.iterations = 4, .offset = 7.25F, .min_radius = 178}, // LVL 14
{.iterations = 4, .offset = 8.25F, .min_radius = 208}, // LVL 15
{.iterations = 5, .offset = 4.50F, .min_radius = 236}, // LVL 16
{.iterations = 5, .offset = 5.25F, .min_radius = 269}, // LVL 17
{.iterations = 5, .offset = 6.25F, .min_radius = 309}, // LVL 18
{.iterations = 5, .offset = 7.25F, .min_radius = 357}, // LVL 19
{.iterations = 5, .offset = 8.50F, .min_radius = 417}, // LVL 20
};
auto params = ccalloc(1, struct dual_kawase_params);
params->iterations = 0;
params->offset = 1.0f;
params->offset = 1.0F;
if (blur_args->strength <= 0 && blur_args->size) {
// find highest level that approximates blur-strength with the selected
@@ -453,7 +453,7 @@ struct dual_kawase_params *generate_dual_kawase_params(void *args) {
// - Smallest texture dimensions are halved `iterations`-times
// - Upsample needs pixels two-times `offset` away from the border
// - Plus one for interpolation differences
params->expand = (1 << params->iterations) * 2 * (int)ceil(params->offset) + 1;
params->expand = (1 << params->iterations) * 2 * (int)ceilf(params->offset) + 1;
return params;
}

View File

@@ -47,7 +47,7 @@ static inline void print_drivers(enum driver drivers) {
const char *seen_drivers[ARR_SIZE(driver_names)];
int driver_count = 0;
for (size_t i = 0; i < ARR_SIZE(driver_names); i++) {
if (drivers & (1ul << i)) {
if (drivers & (1UL << i)) {
seen_drivers[driver_count++] = driver_names[i];
}
}

View File

@@ -150,6 +150,9 @@ bool gl_dual_kawase_blur(double opacity, struct gl_blur_context *bctx, const rec
glUniform2f(down_pass->texorig_loc, (GLfloat)extent->x1, (GLfloat)dst_y_fb_coord);
glBindVertexArray(vao[1]);
int nelems = vao_nelems[1];
for (int i = 0; i < iterations; ++i) {
// Scale output width / height by half in each iteration
scale_factor <<= 1;
@@ -174,8 +177,6 @@ bool gl_dual_kawase_blur(double opacity, struct gl_blur_context *bctx, const rec
assert(bctx->blur_fbos[i]);
glBindTexture(GL_TEXTURE_2D, src_texture);
glBindVertexArray(vao[1]);
auto nelems = vao_nelems[1];
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, bctx->blur_fbos[i]);
glDrawBuffer(GL_COLOR_ATTACHMENT0);
@@ -194,6 +195,15 @@ bool gl_dual_kawase_blur(double opacity, struct gl_blur_context *bctx, const rec
glUniform2f(up_pass->texorig_loc, (GLfloat)extent->x1, (GLfloat)dst_y_fb_coord);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, default_mask);
glUniform1i(up_pass->uniform_mask_tex, 1);
glUniform2f(up_pass->uniform_mask_offset, 0.0F, 0.0F);
glUniform1i(up_pass->uniform_mask_inverted, 0);
glUniform1f(up_pass->uniform_mask_corner_radius, 0.0F);
glUniform1f(up_pass->uniform_opacity, 1.0F);
for (int i = iterations - 1; i >= 0; --i) {
// Scale output width / height back by two in each iteration
scale_factor >>= 1;
@@ -206,28 +216,15 @@ bool gl_dual_kawase_blur(double opacity, struct gl_blur_context *bctx, const rec
int tex_width = src_size.width;
int tex_height = src_size.height;
// The number of indices in the selected vertex array
GLsizei nelems;
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, src_texture);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, default_mask);
glUniform1i(up_pass->uniform_mask_tex, 1);
glUniform2f(up_pass->uniform_mask_offset, 0.0F, 0.0F);
glUniform1i(up_pass->uniform_mask_inverted, 0);
glUniform1f(up_pass->uniform_mask_corner_radius, 0.0F);
if (i > 0) {
assert(bctx->blur_fbos[i - 1]);
// not last pass, draw into next framebuffer
glBindVertexArray(vao[1]);
nelems = vao_nelems[1];
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, bctx->blur_fbos[i - 1]);
glDrawBuffer(GL_COLOR_ATTACHMENT0);
glUniform1f(up_pass->uniform_opacity, (GLfloat)1);
} else {
// last pass, draw directly into the back buffer
if (mask) {

View File

@@ -482,8 +482,6 @@ static void _gl_compose(backend_t *base, struct backend_image *img, GLuint targe
glUseProgram(0);
gl_check_err();
return;
}
/// Convert rectangles in X coordinates to OpenGL vertex and texture coordinates

View File

@@ -615,7 +615,7 @@ void glxext_init(Display *dpy, int screen) {
#endif
#undef check_ext
#define lookup(name) (name = (__typeof__(name))glXGetProcAddress((GLubyte *)#name))
#define lookup(name) ((name) = (__typeof__(name))glXGetProcAddress((GLubyte *)#name))
// Checking if the returned function pointer is NULL is not really necessary,
// or maybe not even useful, since glXGetProcAddress might always return
// something. We are doing it just for completeness' sake.

View File

@@ -12,11 +12,11 @@
#undef glXBindTexImageEXT
#undef glXReleaseTexImageEXT
#include <X11/Xlib.h>
#include <xcb/xcb.h>
#include <xcb/render.h>
#include <xcb/xcb.h>
#include "log.h"
#include "compiler.h"
#include "log.h"
#include "utils.h"
#include "x.h"

View File

@@ -133,8 +133,9 @@ bool parse_long(const char *s, long *dest) {
log_error("Invalid number: %s", s);
return false;
}
while (isspace((unsigned char)*endptr))
while (isspace((unsigned char)*endptr)) {
++endptr;
}
if (*endptr) {
log_error("Trailing characters: %s", s);
return false;
@@ -216,12 +217,14 @@ conv *parse_blur_kern(const char *src, const char **endptr, bool *hasneg) {
// Get matrix width and height
double val = 0.0;
if (src == (pc = parse_readnum(src, &val)))
if (src == (pc = parse_readnum(src, &val))) {
goto err1;
}
src = pc;
width = (int)val;
if (src == (pc = parse_readnum(src, &val)))
if (src == (pc = parse_readnum(src, &val))) {
goto err1;
}
src = pc;
height = (int)val;
@@ -234,9 +237,10 @@ conv *parse_blur_kern(const char *src, const char **endptr, bool *hasneg) {
log_error("Blur kernel width/height must be odd.");
goto err1;
}
if (width > 16 || height > 16)
if (width > 16 || height > 16) {
log_warn("Blur kernel width/height too large, may slow down"
"rendering, and/or consume lots of memory");
}
// Allocate memory
conv *matrix = cvalloc(sizeof(conv) + (size_t)(width * height) * sizeof(double));
@@ -362,8 +366,9 @@ struct conv **parse_blur_kern_lst(const char *src, bool *hasneg, int *count) {
*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))
if (!strcmp(CONV_KERN_PREDEF[i].name, src)) {
return parse_blur_kern_lst(CONV_KERN_PREDEF[i].kern_str, hasneg, count);
}
}
int nkernels = 1;
@@ -655,11 +660,13 @@ bool parse_rule_window_shader(c2_lptr_t **res, const char *src, const char *incl
* Add a pattern to a condition linked list.
*/
bool condlst_add(c2_lptr_t **pcondlst, const char *pattern) {
if (!pattern)
if (!pattern) {
return false;
}
if (!c2_parse(pcondlst, pattern, NULL))
if (!c2_parse(pcondlst, pattern, NULL)) {
exit(1);
}
return true;
}

View File

@@ -73,8 +73,9 @@ FILE *open_config_file(const char *cpath, char **ppath) {
if (cpath) {
FILE *ret = fopen(cpath, "r");
if (ret && ppath)
if (ret && ppath) {
*ppath = strdup(cpath);
}
return ret;
}
@@ -124,9 +125,10 @@ void parse_cfg_condlst(const config_t *pcfg, c2_lptr_t **pcondlst, const char *n
// Parse an array of options
if (config_setting_is_array(setting)) {
int i = config_setting_length(setting);
while (i--)
while (i--) {
condlst_add(pcondlst,
config_setting_get_string_elem(setting, i));
}
}
// Treat it as a single pattern if it's a string
else if (CONFIG_TYPE_STRING == config_setting_type(setting)) {
@@ -145,18 +147,22 @@ parse_cfg_condlst_corner(options_t *opt, const config_t *pcfg, const char *name)
// Parse an array of options
if (config_setting_is_array(setting)) {
int i = config_setting_length(setting);
while (i--)
while (i--) {
if (!parse_numeric_window_rule(
&opt->corner_radius_rules,
config_setting_get_string_elem(setting, i), 0, INT_MAX))
config_setting_get_string_elem(setting, i), 0,
INT_MAX)) {
exit(1);
}
}
}
// Treat it as a single pattern if it's a string
else if (config_setting_type(setting) == CONFIG_TYPE_STRING) {
if (!parse_numeric_window_rule(&opt->corner_radius_rules,
config_setting_get_string(setting),
0, INT_MAX))
0, INT_MAX)) {
exit(1);
}
}
}
}
@@ -171,17 +177,21 @@ parse_cfg_condlst_opct(options_t *opt, const config_t *pcfg, const char *name) {
// Parse an array of options
if (config_setting_is_array(setting)) {
int i = config_setting_length(setting);
while (i--)
while (i--) {
if (!parse_numeric_window_rule(
&opt->opacity_rules,
config_setting_get_string_elem(setting, i), 0, 100))
config_setting_get_string_elem(setting, i), 0, 100)) {
exit(1);
}
}
}
// Treat it as a single pattern if it's a string
else if (config_setting_type(setting) == CONFIG_TYPE_STRING) {
if (!parse_numeric_window_rule(
&opt->opacity_rules, config_setting_get_string(setting), 0, 100))
if (!parse_numeric_window_rule(&opt->opacity_rules,
config_setting_get_string(setting),
0, 100)) {
exit(1);
}
}
}
}
@@ -390,8 +400,9 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
winopt_mask[WINTYPE_POPUP_MENU].opacity = true;
}
// -f (fading_enable)
if (config_lookup_bool(&cfg, "fading", &ival))
if (config_lookup_bool(&cfg, "fading", &ival)) {
*fading_enable = ival;
}
// --no-fading-open-close
lcfg_lookup_bool(&cfg, "no-fading-openclose", &opt->no_fading_openclose);
// --no-fading-destroyed-argb
@@ -411,8 +422,9 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
opt->shadow_blue = rgb.blue;
}
// --shadow-exclude-reg
if (config_lookup_string(&cfg, "shadow-exclude-reg", &sval))
if (config_lookup_string(&cfg, "shadow-exclude-reg", &sval)) {
opt->shadow_exclude_reg_str = strdup(sval);
}
// --inactive-opacity-override
lcfg_lookup_bool(&cfg, "inactive-opacity-override", &opt->inactive_opacity_override);
// --inactive-dim
@@ -674,9 +686,10 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
// --xrender-sync-fence
lcfg_lookup_bool(&cfg, "xrender-sync-fence", &opt->xrender_sync_fence);
if (lcfg_lookup_bool(&cfg, "clear-shadow", &bval))
if (lcfg_lookup_bool(&cfg, "clear-shadow", &bval)) {
log_warn("\"clear-shadow\" is removed as an option, and is always"
" enabled now. Consider removing it from your config file");
}
config_setting_t *blur_cfg = config_lookup(&cfg, "blur");
if (blur_cfg) {

View File

@@ -253,8 +253,9 @@ static dbus_bool_t cdbus_callback_add_timeout(DBusTimeout *timeout, void *data)
t->t = timeout;
dbus_timeout_set_data(timeout, t, NULL);
if (dbus_timeout_get_enabled(timeout))
if (dbus_timeout_get_enabled(timeout)) {
ev_timer_start(ps->loop, &t->w);
}
return true;
}
@@ -302,10 +303,12 @@ typedef struct ev_dbus_io {
void cdbus_io_callback(EV_P attr_unused, ev_io *w, int revents) {
ev_dbus_io *dw = (void *)w;
DBusWatchFlags flags = 0;
if (revents & EV_READ)
if (revents & EV_READ) {
flags |= DBUS_WATCH_READABLE;
if (revents & EV_WRITE)
}
if (revents & EV_WRITE) {
flags |= DBUS_WATCH_WRITABLE;
}
dbus_watch_handle(dw->dw, flags);
while (dbus_connection_dispatch(dw->cd->dbus_conn) != DBUS_DISPATCH_COMPLETE)
;
@@ -317,10 +320,12 @@ void cdbus_io_callback(EV_P attr_unused, ev_io *w, int revents) {
static inline int cdbus_get_watch_cond(DBusWatch *watch) {
const unsigned flags = dbus_watch_get_flags(watch);
int condition = 0;
if (flags & DBUS_WATCH_READABLE)
if (flags & DBUS_WATCH_READABLE) {
condition |= EV_READ;
if (flags & DBUS_WATCH_WRITABLE)
}
if (flags & DBUS_WATCH_WRITABLE) {
condition |= EV_WRITE;
}
return condition;
}
@@ -338,8 +343,9 @@ static dbus_bool_t cdbus_callback_add_watch(DBusWatch *watch, void *data) {
cdbus_get_watch_cond(watch));
// Leave disabled watches alone
if (dbus_watch_get_enabled(watch))
if (dbus_watch_get_enabled(watch)) {
ev_io_start(ps->loop, &w->w);
}
dbus_watch_set_data(watch, w, NULL);
@@ -363,10 +369,11 @@ static void cdbus_callback_remove_watch(DBusWatch *watch, void *data) {
static void cdbus_callback_watch_toggled(DBusWatch *watch, void *data) {
session_t *ps = data;
ev_io *w = dbus_watch_get_data(watch);
if (dbus_watch_get_enabled(watch))
if (dbus_watch_get_enabled(watch)) {
ev_io_start(ps->loop, w);
else
} else {
ev_io_stop(ps->loop, w);
}
}
///@}
@@ -513,8 +520,9 @@ static bool cdbus_apdarg_enum(session_t *ps attr_unused, DBusMessage *msg, const
static bool
cdbus_apdarg_string(session_t *ps attr_unused, DBusMessage *msg, const void *data) {
const char *str = data;
if (!str)
if (!str) {
str = "";
}
if (!dbus_message_append_args(msg, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID)) {
log_error("Failed to append argument.");
@@ -1050,32 +1058,36 @@ static bool cdbus_process_win_set(session_t *ps, DBusMessage *msg) {
if (!strcmp("shadow_force", target)) {
cdbus_enum_t val = UNSET;
if (!cdbus_msg_get_arg(msg, 2, CDBUS_TYPE_ENUM, &val))
if (!cdbus_msg_get_arg(msg, 2, CDBUS_TYPE_ENUM, &val)) {
return false;
}
win_set_shadow_force(ps, w, val);
goto cdbus_process_win_set_success;
}
if (!strcmp("fade_force", target)) {
cdbus_enum_t val = UNSET;
if (!cdbus_msg_get_arg(msg, 2, CDBUS_TYPE_ENUM, &val))
if (!cdbus_msg_get_arg(msg, 2, CDBUS_TYPE_ENUM, &val)) {
return false;
}
win_set_fade_force(w, val);
goto cdbus_process_win_set_success;
}
if (!strcmp("focused_force", target)) {
cdbus_enum_t val = UNSET;
if (!cdbus_msg_get_arg(msg, 2, CDBUS_TYPE_ENUM, &val))
if (!cdbus_msg_get_arg(msg, 2, CDBUS_TYPE_ENUM, &val)) {
return false;
}
win_set_focused_force(ps, w, val);
goto cdbus_process_win_set_success;
}
if (!strcmp("invert_color_force", target)) {
cdbus_enum_t val = UNSET;
if (!cdbus_msg_get_arg(msg, 2, CDBUS_TYPE_ENUM, &val))
if (!cdbus_msg_get_arg(msg, 2, CDBUS_TYPE_ENUM, &val)) {
return false;
}
win_set_invert_color_force(ps, w, val);
goto cdbus_process_win_set_success;
}
@@ -1087,8 +1099,9 @@ static bool cdbus_process_win_set(session_t *ps, DBusMessage *msg) {
return true;
cdbus_process_win_set_success:
if (!dbus_message_get_no_reply(msg))
if (!dbus_message_get_no_reply(msg)) {
cdbus_reply_bool(ps, msg, true);
}
return true;
}
@@ -1098,16 +1111,18 @@ cdbus_process_win_set_success:
static bool cdbus_process_find_win(session_t *ps, DBusMessage *msg) {
const char *target = NULL;
if (!cdbus_msg_get_arg(msg, 0, DBUS_TYPE_STRING, &target))
if (!cdbus_msg_get_arg(msg, 0, DBUS_TYPE_STRING, &target)) {
return false;
}
xcb_window_t wid = XCB_NONE;
// Find window by client window
if (!strcmp("client", target)) {
cdbus_window_t client = XCB_NONE;
if (!cdbus_msg_get_arg(msg, 1, CDBUS_TYPE_WINDOW, &client))
if (!cdbus_msg_get_arg(msg, 1, CDBUS_TYPE_WINDOW, &client)) {
return false;
}
auto w = find_toplevel(ps, client);
if (w) {
wid = w->base.id;
@@ -1136,8 +1151,9 @@ static bool cdbus_process_find_win(session_t *ps, DBusMessage *msg) {
static bool cdbus_process_opts_get(session_t *ps, DBusMessage *msg) {
const char *target = NULL;
if (!cdbus_msg_get_arg(msg, 0, DBUS_TYPE_STRING, &target))
if (!cdbus_msg_get_arg(msg, 0, DBUS_TYPE_STRING, &target)) {
return false;
}
#define cdbus_m_opts_get_do(tgt, apdarg_func) \
if (!strcmp(#tgt, target)) { \
@@ -1246,8 +1262,9 @@ void queue_redraw(session_t *ps);
static bool cdbus_process_opts_set(session_t *ps, DBusMessage *msg) {
const char *target = NULL;
if (!cdbus_msg_get_arg(msg, 0, DBUS_TYPE_STRING, &target))
if (!cdbus_msg_get_arg(msg, 0, DBUS_TYPE_STRING, &target)) {
return false;
}
#define cdbus_m_opts_set_do(tgt, type, real_type) \
if (!strcmp(#tgt, target)) { \
@@ -1274,8 +1291,9 @@ static bool cdbus_process_opts_set(session_t *ps, DBusMessage *msg) {
// fade_in_step
if (!strcmp("fade_in_step", target)) {
double val = 0.0;
if (!cdbus_msg_get_arg(msg, 1, DBUS_TYPE_DOUBLE, &val))
if (!cdbus_msg_get_arg(msg, 1, DBUS_TYPE_DOUBLE, &val)) {
return false;
}
ps->o.fade_in_step = normalize_d(val);
goto cdbus_process_opts_set_success;
}
@@ -1283,8 +1301,9 @@ static bool cdbus_process_opts_set(session_t *ps, DBusMessage *msg) {
// fade_out_step
if (!strcmp("fade_out_step", target)) {
double val = 0.0;
if (!cdbus_msg_get_arg(msg, 1, DBUS_TYPE_DOUBLE, &val))
if (!cdbus_msg_get_arg(msg, 1, DBUS_TYPE_DOUBLE, &val)) {
return false;
}
ps->o.fade_out_step = normalize_d(val);
goto cdbus_process_opts_set_success;
}
@@ -1292,8 +1311,9 @@ static bool cdbus_process_opts_set(session_t *ps, DBusMessage *msg) {
// no_fading_openclose
if (!strcmp("no_fading_openclose", target)) {
dbus_bool_t val = FALSE;
if (!cdbus_msg_get_arg(msg, 1, DBUS_TYPE_BOOLEAN, &val))
if (!cdbus_msg_get_arg(msg, 1, DBUS_TYPE_BOOLEAN, &val)) {
return false;
}
opts_set_no_fading_openclose(ps, val);
goto cdbus_process_opts_set_success;
}
@@ -1301,8 +1321,9 @@ static bool cdbus_process_opts_set(session_t *ps, DBusMessage *msg) {
// unredir_if_possible
if (!strcmp("unredir_if_possible", target)) {
dbus_bool_t val = FALSE;
if (!cdbus_msg_get_arg(msg, 1, DBUS_TYPE_BOOLEAN, &val))
if (!cdbus_msg_get_arg(msg, 1, DBUS_TYPE_BOOLEAN, &val)) {
return false;
}
if (ps->o.unredir_if_possible != val) {
ps->o.unredir_if_possible = val;
queue_redraw(ps);
@@ -1323,8 +1344,9 @@ static bool cdbus_process_opts_set(session_t *ps, DBusMessage *msg) {
// redirected_force
if (!strcmp("redirected_force", target)) {
cdbus_enum_t val = UNSET;
if (!cdbus_msg_get_arg(msg, 1, CDBUS_TYPE_ENUM, &val))
if (!cdbus_msg_get_arg(msg, 1, CDBUS_TYPE_ENUM, &val)) {
return false;
}
ps->o.redirected_force = val;
force_repaint(ps);
goto cdbus_process_opts_set_success;
@@ -1341,8 +1363,9 @@ static bool cdbus_process_opts_set(session_t *ps, DBusMessage *msg) {
return true;
cdbus_process_opts_set_success:
if (!dbus_message_get_no_reply(msg))
if (!dbus_message_get_no_reply(msg)) {
cdbus_reply_bool(ps, msg, true);
}
return true;
}
@@ -1512,13 +1535,15 @@ cdbus_process(DBusConnection *c attr_unused, DBusMessage *msg, void *ud) {
if (cdbus_m_ismethod("reset")) {
log_info("picom is resetting...");
ev_break(ps->loop, EVBREAK_ALL);
if (!dbus_message_get_no_reply(msg))
if (!dbus_message_get_no_reply(msg)) {
cdbus_reply_bool(ps, msg, true);
}
handled = true;
} else if (cdbus_m_ismethod("repaint")) {
force_repaint(ps);
if (!dbus_message_get_no_reply(msg))
if (!dbus_message_get_no_reply(msg)) {
cdbus_reply_bool(ps, msg, true);
}
handled = true;
} else if (cdbus_m_ismethod("list_win")) {
handled = cdbus_process_list_win(ps, msg);
@@ -1566,8 +1591,9 @@ cdbus_process(DBusConnection *c attr_unused, DBusMessage *msg, void *ud) {
dbus_message_get_member(msg));
}
if (DBUS_MESSAGE_TYPE_METHOD_CALL == dbus_message_get_type(msg) &&
!dbus_message_get_no_reply(msg))
!dbus_message_get_no_reply(msg)) {
cdbus_reply_err(ps, msg, CDBUS_ERROR_BADMSG, CDBUS_ERROR_BADMSG_S);
}
handled = true;
}
@@ -1593,8 +1619,9 @@ cdbus_process_windows(DBusConnection *c attr_unused, DBusMessage *msg, void *ud)
const char *last_segment = strrchr(path, '/');
if (last_segment == NULL) {
if (DBUS_MESSAGE_TYPE_METHOD_CALL == dbus_message_get_type(msg) &&
!dbus_message_get_no_reply(msg))
!dbus_message_get_no_reply(msg)) {
cdbus_reply_err(ps, msg, CDBUS_ERROR_BADMSG, CDBUS_ERROR_BADMSG_S);
}
return DBUS_HANDLER_RESULT_HANDLED;
}
bool is_root = strncmp(last_segment, "/windows", 8) == 0;

View File

@@ -54,8 +54,9 @@ static inline double attr_const gaussian(double r, double x, double y) {
// Formula can be found here:
// https://en.wikipedia.org/wiki/Gaussian_blur#Mathematics
// Except a special case for r == 0 to produce sharp shadows
if (r == 0)
if (r == 0) {
return 1;
}
return exp(-0.5 * (x * x + y * y) / (r * r)) / (2 * M_PI * r * r);
}

View File

@@ -15,12 +15,14 @@ picom_inc = include_directories('.')
cflags = []
required_xcb_packages = [
'xcb-render', 'xcb-damage', 'xcb-randr', 'xcb-sync', 'xcb-composite',
'xcb-shape', 'xcb-xfixes', 'xcb-present', 'xcb-glx', 'xcb-dpms', 'xcb'
'xcb', 'xcb-composite', 'xcb-damage', 'xcb-dpms', 'xcb-glx', 'xcb-present',
'xcb-randr', 'xcb-render', 'xcb-shape', 'xcb-sync', 'xcb-xfixes'
]
# Some XCB packages are here because their versioning differs (see check below).
required_packages = [
'x11', 'x11-xcb', 'xcb-renderutil', 'xcb-image', 'xext', 'pixman-1', 'xcb-util'
'pixman-1', 'x11', 'x11-xcb', 'xcb-image', 'xcb-renderutil', 'xcb-util',
'xext'
]
foreach i : required_packages

View File

@@ -570,8 +570,9 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
case 290:
// --backend
opt->backend = parse_backend(optarg);
if (opt->backend >= NUM_BKEND)
if (opt->backend >= NUM_BKEND) {
exit(1);
}
break;
P_CASEBOOL(291, glx_no_stencil);
P_CASEINT(293, benchmark);
@@ -631,8 +632,9 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
break;
case 304:
// --opacity-rule
if (!parse_numeric_window_rule(&opt->opacity_rules, optarg, 0, 100))
if (!parse_numeric_window_rule(&opt->opacity_rules, optarg, 0, 100)) {
exit(1);
}
break;
case 305:
// --shadow-exclude-reg
@@ -737,8 +739,9 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
break;
case 340:
// --corner-radius-rules
if (!parse_numeric_window_rule(&opt->corner_radius_rules, optarg, 0, INT_MAX))
if (!parse_numeric_window_rule(&opt->corner_radius_rules, optarg, 0, INT_MAX)) {
exit(1);
}
break;
case 335:
// --clip-shadow-above

View File

@@ -501,8 +501,9 @@ static void rebuild_screen_reg(session_t *ps) {
*/
static void rebuild_shadow_exclude_reg(session_t *ps) {
bool ret = parse_geometry(ps, ps->o.shadow_exclude_reg_str, &ps->shadow_exclude_reg);
if (!ret)
if (!ret) {
exit(1);
}
}
/// Free up all the images and deinit the backend

View File

@@ -60,9 +60,11 @@ uint8_t session_redirection_mode(session_t *ps);
static inline void wintype_arr_enable_unset(switch_t arr[]) {
wintype_t i;
for (i = 0; i < NUM_WINTYPES; ++i)
if (UNSET == arr[i])
for (i = 0; i < NUM_WINTYPES; ++i) {
if (UNSET == arr[i]) {
arr[i] = ON;
}
}
}
/**

View File

@@ -23,9 +23,10 @@ static inline void dump_region(const region_t *x) {
int nrects;
const rect_t *rects = pixman_region32_rectangles((region_t *)x, &nrects);
log_trace("nrects: %d", nrects);
for (int i = 0; i < nrects; i++)
for (int i = 0; i < nrects; i++) {
log_trace("(%d, %d) - (%d, %d)", rects[i].x1, rects[i].y1, rects[i].x2,
rects[i].y2);
}
}
/// Convert one xcb rectangle to our rectangle type
@@ -51,8 +52,7 @@ static inline rect_t *from_x_rects(int nrects, const xcb_rectangle_t *rects) {
/**
* Resize a region.
*/
static inline void _resize_region(const region_t *region, region_t *output, int dx,
int dy) {
static inline void _resize_region(const region_t *region, region_t *output, int dx, int dy) {
if (!region || !output) {
return;
}
@@ -77,8 +77,7 @@ static inline void _resize_region(const region_t *region, region_t *output, int
if (wid <= 0 || hei <= 0) {
continue;
}
newrects[nnewrects] =
(rect_t){.x1 = x1, .x2 = x2, .y1 = y1, .y2 = y2};
newrects[nnewrects] = (rect_t){.x1 = x1, .x2 = x2, .y1 = y1, .y2 = y2};
++nnewrects;
}

View File

@@ -973,7 +973,7 @@ win_blur_background(session_t *ps, struct managed_win *w, xcb_render_picture_t t
#ifdef CONFIG_OPENGL
case BKEND_GLX:
// TODO(compton) Handle frame opacity
glx_blur_dst(ps, x, y, wid, hei, (float)ps->psglx->z - 0.5f,
glx_blur_dst(ps, x, y, wid, hei, (float)ps->psglx->z - 0.5F,
(float)factor_center, reg_paint, &w->glx_blur_cache);
break;
#endif

View File

@@ -24,8 +24,9 @@ static inline int uitostr(unsigned int n, char *buf) {
ret++;
}
if (ret == 0)
if (ret == 0) {
ret = 1;
}
int pos = ret;
while (pos--) {
@@ -36,18 +37,22 @@ static inline int uitostr(unsigned int n, char *buf) {
}
static inline const char *skip_space_const(const char *src) {
if (!src)
if (!src) {
return NULL;
while (*src && isspace((unsigned char)*src))
}
while (*src && isspace((unsigned char)*src)) {
src++;
}
return src;
}
static inline char *skip_space_mut(char *src) {
if (!src)
if (!src) {
return NULL;
while (*src && isspace((unsigned char)*src))
}
while (*src && isspace((unsigned char)*src)) {
src++;
}
return src;
}

View File

@@ -376,7 +376,8 @@ bool win_bind_shadow(struct backend_base *b, struct managed_win *w, struct color
w->shadow_image = b->ops->render_shadow(b, w->widthb, w->heightb, sctx, c);
} else {
if (!w->mask_image) {
// It's possible we already allocated a mask because of background blur
// It's possible we already allocated a mask because of background
// blur
win_bind_mask(b, w);
}
w->shadow_image = b->ops->shadow_from_mask(b, w->mask_image, sctx, c);
@@ -1778,12 +1779,11 @@ struct win *add_win_above(session_t *ps, xcb_window_t id, xcb_window_t below) {
return NULL;
}
return add_win_top(ps, id);
} else {
// we found something from the hash table, so if the stack is
// empty, we are in an inconsistent state.
assert(!list_is_empty(&ps->window_stack));
return add_win(ps, id, w->stack_neighbour.prev);
}
// we found something from the hash table, so if the stack is
// empty, we are in an inconsistent state.
assert(!list_is_empty(&ps->window_stack));
return add_win(ps, id, w->stack_neighbour.prev);
}
/// Query the Xorg for information about window `win`

View File

@@ -26,11 +26,12 @@ typedef struct session session_t;
typedef struct _glx_texture glx_texture_t;
#define win_stack_foreach_managed(w, win_stack) \
list_foreach(struct managed_win, w, win_stack, base.stack_neighbour) if (w->base.managed)
list_foreach(struct managed_win, w, win_stack, \
base.stack_neighbour) if ((w)->base.managed)
#define win_stack_foreach_managed_safe(w, win_stack) \
list_foreach_safe(struct managed_win, w, win_stack, \
base.stack_neighbour) if (w->base.managed)
base.stack_neighbour) if ((w)->base.managed)
#ifdef CONFIG_OPENGL
// FIXME this type should be in opengl.h