1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2024-11-25 14:06:08 -05:00

Fix compiler warning about unused parameters

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-07-25 02:27:02 +01:00
parent c3c0578d14
commit bb756b2238
No known key found for this signature in database
GPG key ID: 37C999F617EA1A47
15 changed files with 122 additions and 90 deletions

View file

@ -280,9 +280,9 @@ static void _gl_compose(backend_t *base, struct gl_image *img, GLuint target,
/// @param[in] root_height height of the back buffer /// @param[in] root_height height of the back buffer
/// @param[in] y_inverted whether the texture is y inverted /// @param[in] y_inverted whether the texture is y inverted
/// @param[out] coord, indices output /// @param[out] coord, indices output
static void x_rect_to_coords(int nrects, const rect_t *rects, int dst_x, int dst_y, static void
int width, int height, int root_height, bool y_inverted, x_rect_to_coords(int nrects, const rect_t *rects, int dst_x, int dst_y, int height,
GLint *coord, GLuint *indices) { int root_height, bool y_inverted, GLint *coord, GLuint *indices) {
dst_y = root_height - dst_y; dst_y = root_height - dst_y;
if (y_inverted) { if (y_inverted) {
dst_y -= height; dst_y -= height;
@ -334,8 +334,9 @@ static void x_rect_to_coords(int nrects, const rect_t *rects, int dst_x, int dst
} }
} }
// TODO: make use of reg_visible
void gl_compose(backend_t *base, void *image_data, int dst_x, int dst_y, void gl_compose(backend_t *base, void *image_data, int dst_x, int dst_y,
const region_t *reg_tgt, const region_t *reg_visible) { const region_t *reg_tgt, const region_t *reg_visible attr_unused) {
struct gl_data *gd = (void *)base; struct gl_data *gd = (void *)base;
struct gl_image *img = image_data; struct gl_image *img = image_data;
@ -357,8 +358,8 @@ void gl_compose(backend_t *base, void *image_data, int dst_x, int dst_y,
auto coord = ccalloc(nrects * 16, GLint); auto coord = ccalloc(nrects * 16, GLint);
auto indices = ccalloc(nrects * 6, GLuint); auto indices = ccalloc(nrects * 6, GLuint);
x_rect_to_coords(nrects, rects, dst_x, dst_y, img->inner->width, img->inner->height, x_rect_to_coords(nrects, rects, dst_x, dst_y, img->inner->height, gd->height,
gd->height, img->inner->y_inverted, coord, indices); img->inner->y_inverted, coord, indices);
_gl_compose(base, img, 0, coord, indices, nrects); _gl_compose(base, img, 0, coord, indices, nrects);
free(indices); free(indices);
@ -369,7 +370,7 @@ void gl_compose(backend_t *base, void *image_data, int dst_x, int dst_y,
* Blur contents in a particular region. * Blur contents in a particular region.
*/ */
bool gl_blur(backend_t *base, double opacity, void *ctx, const region_t *reg_blur, bool gl_blur(backend_t *base, double opacity, void *ctx, const region_t *reg_blur,
const region_t *reg_visible) { const region_t *reg_visible attr_unused) {
struct gl_blur_context *bctx = ctx; struct gl_blur_context *bctx = ctx;
struct gl_data *gd = (void *)base; struct gl_data *gd = (void *)base;
@ -441,14 +442,13 @@ bool gl_blur(backend_t *base, double opacity, void *ctx, const region_t *reg_blu
auto coord = ccalloc(nrects * 16, GLint); auto coord = ccalloc(nrects * 16, GLint);
auto indices = ccalloc(nrects * 6, GLuint); auto indices = ccalloc(nrects * 6, GLuint);
x_rect_to_coords(nrects, rects, extent_resized->x1, extent_resized->y2, x_rect_to_coords(nrects, rects, extent_resized->x1, extent_resized->y2,
bctx->texture_width, bctx->texture_height, gd->height, false, bctx->texture_height, gd->height, false, coord, indices);
coord, indices);
auto coord_resized = ccalloc(nrects_resized * 16, GLint); auto coord_resized = ccalloc(nrects_resized * 16, GLint);
auto indices_resized = ccalloc(nrects_resized * 6, GLuint); auto indices_resized = ccalloc(nrects_resized * 6, GLuint);
x_rect_to_coords(nrects_resized, rects_resized, extent_resized->x1, x_rect_to_coords(nrects_resized, rects_resized, extent_resized->x1,
extent_resized->y2, bctx->texture_width, bctx->texture_height, extent_resized->y2, bctx->texture_height, bctx->texture_height,
bctx->texture_height, false, coord_resized, indices_resized); false, coord_resized, indices_resized);
pixman_region32_fini(&reg_blur_resized); pixman_region32_fini(&reg_blur_resized);
GLuint vao[2]; GLuint vao[2];
@ -729,7 +729,8 @@ void gl_release_image(backend_t *base, void *image_data) {
gl_check_err(); gl_check_err();
} }
void *gl_copy(backend_t *base, const void *image_data, const region_t *reg_visible) { void *gl_copy(backend_t *base attr_unused, const void *image_data,
const region_t *reg_visible attr_unused) {
const struct gl_image *img = image_data; const struct gl_image *img = image_data;
auto new_img = ccalloc(1, struct gl_image); auto new_img = ccalloc(1, struct gl_image);
*new_img = *img; *new_img = *img;
@ -745,7 +746,7 @@ static inline void gl_free_blur_shader(gl_blur_shader_t *shader) {
shader->prog = 0; shader->prog = 0;
} }
void gl_destroy_blur_context(backend_t *base, void *ctx) { void gl_destroy_blur_context(backend_t *base attr_unused, void *ctx) {
struct gl_blur_context *bctx = ctx; struct gl_blur_context *bctx = ctx;
// Free GLSL shaders/programs // Free GLSL shaders/programs
for (int i = 0; i < bctx->npasses; ++i) { for (int i = 0; i < bctx->npasses; ++i) {
@ -1105,7 +1106,7 @@ static void gl_image_apply_alpha(backend_t *base, struct gl_image *img,
/// stub for backend_operations::image_op /// stub for backend_operations::image_op
bool gl_image_op(backend_t *base, enum image_operations op, void *image_data, bool gl_image_op(backend_t *base, enum image_operations op, void *image_data,
const region_t *reg_op, const region_t *reg_visible, void *arg) { const region_t *reg_op, const region_t *reg_visible attr_unused, void *arg) {
struct gl_image *tex = image_data; struct gl_image *tex = image_data;
int *iargs = arg; int *iargs = arg;
switch (op) { switch (op) {
@ -1129,7 +1130,7 @@ bool gl_image_op(backend_t *base, enum image_operations op, void *image_data,
return true; return true;
} }
bool gl_is_image_transparent(backend_t *base, void *image_data) { bool gl_is_image_transparent(backend_t *base attr_unused, void *image_data) {
struct gl_image *img = image_data; struct gl_image *img = image_data;
return img->has_alpha; return img->has_alpha;
} }

View file

@ -25,8 +25,8 @@
#include "backend/gl/gl_common.h" #include "backend/gl/gl_common.h"
#include "backend/gl/glx.h" #include "backend/gl/glx.h"
#include "common.h" #include "common.h"
#include "compton.h"
#include "compiler.h" #include "compiler.h"
#include "compton.h"
#include "config.h" #include "config.h"
#include "log.h" #include "log.h"
#include "region.h" #include "region.h"
@ -203,7 +203,7 @@ void glx_deinit(backend_t *base) {
free(gd); free(gd);
} }
static void *glx_decouple_user_data(backend_t * attr_unused base, void * attr_unused ud) { static void *glx_decouple_user_data(backend_t *base attr_unused, void *ud attr_unused) {
auto ret = cmalloc(struct _glx_pixmap); auto ret = cmalloc(struct _glx_pixmap);
ret->owned = false; ret->owned = false;
ret->glpixmap = 0; ret->glpixmap = 0;

View file

@ -361,7 +361,7 @@ static int buffer_age(backend_t *backend_data) {
return xd->buffer_age[xd->curr_back]; return xd->buffer_age[xd->curr_back];
} }
static bool is_image_transparent(backend_t *bd, void *image) { static bool is_image_transparent(backend_t *bd attr_unused, void *image) {
struct _xrender_image_data *img = image; struct _xrender_image_data *img = image;
return img->has_alpha; return img->has_alpha;
} }
@ -484,7 +484,7 @@ static void *copy(backend_t *base, const void *image, const region_t *reg) {
return new_img; return new_img;
} }
void *create_blur_context(backend_t *base, enum blur_method method, void *args) { void *create_blur_context(backend_t *base attr_unused, enum blur_method method, void *args) {
auto ret = ccalloc(1, struct _xrender_blur_context); auto ret = ccalloc(1, struct _xrender_blur_context);
if (!method || method >= BLUR_METHOD_INVALID) { if (!method || method >= BLUR_METHOD_INVALID) {
ret->method = BLUR_METHOD_NONE; ret->method = BLUR_METHOD_NONE;
@ -521,7 +521,7 @@ void *create_blur_context(backend_t *base, enum blur_method method, void *args)
return ret; return ret;
} }
void destroy_blur_context(backend_t *base, void *ctx_) { void destroy_blur_context(backend_t *base attr_unused, void *ctx_) {
struct _xrender_blur_context *ctx = ctx_; struct _xrender_blur_context *ctx = ctx_;
for (int i = 0; i < ctx->x_blur_kernel_count; i++) { for (int i = 0; i < ctx->x_blur_kernel_count; i++) {
free(ctx->x_blur_kernel[i]); free(ctx->x_blur_kernel[i]);

View file

@ -96,7 +96,7 @@ void set_root_flags(session_t *ps, uint64_t flags) {
ps->root_flags |= flags; ps->root_flags |= flags;
} }
static inline void quit_compton(session_t *ps) { void quit_compton(session_t *ps) {
ps->quit = true; ps->quit = true;
ev_break(ps->loop, EVBREAK_ALL); ev_break(ps->loop, EVBREAK_ALL);
} }
@ -178,8 +178,9 @@ static inline struct managed_win *find_win_all(session_t *ps, const xcb_window_t
void queue_redraw(session_t *ps) { void queue_redraw(session_t *ps) {
// If --benchmark is used, redraw is always queued // If --benchmark is used, redraw is always queued
if (!ps->redraw_needed && !ps->o.benchmark) if (!ps->redraw_needed && !ps->o.benchmark) {
ev_idle_start(ps->loop, &ps->draw_idle); ev_idle_start(ps->loop, &ps->draw_idle);
}
ps->redraw_needed = true; ps->redraw_needed = true;
} }
@ -1225,7 +1226,7 @@ static void redir_stop(session_t *ps) {
} }
// Handle queued events before we go to sleep // Handle queued events before we go to sleep
static void handle_queued_x_events(EV_P_ ev_prepare *w, int revents) { static void handle_queued_x_events(EV_P attr_unused, ev_prepare *w, int revents attr_unused) {
session_t *ps = session_ptr(w, event_check); session_t *ps = session_ptr(w, event_check);
xcb_generic_event_t *ev; xcb_generic_event_t *ev;
while ((ev = xcb_poll_for_queued_event(ps->c))) { while ((ev = xcb_poll_for_queued_event(ps->c))) {
@ -1288,18 +1289,18 @@ static void refresh_stale_images(session_t *ps) {
/** /**
* Unredirection timeout callback. * Unredirection timeout callback.
*/ */
static void tmout_unredir_callback(EV_P_ ev_timer *w, int revents) { static void tmout_unredir_callback(EV_P attr_unused, ev_timer *w, int revents attr_unused) {
session_t *ps = session_ptr(w, unredir_timer); session_t *ps = session_ptr(w, unredir_timer);
ps->tmout_unredir_hit = true; ps->tmout_unredir_hit = true;
queue_redraw(ps); queue_redraw(ps);
} }
static void fade_timer_callback(EV_P_ ev_timer *w, int revents) { static void fade_timer_callback(EV_P attr_unused, ev_timer *w, int revents attr_unused) {
session_t *ps = session_ptr(w, fade_timer); session_t *ps = session_ptr(w, fade_timer);
queue_redraw(ps); queue_redraw(ps);
} }
static void _draw_callback(EV_P_ session_t *ps, int revents) { static void _draw_callback(EV_P_ session_t *ps, int revents attr_unused) {
if (ps->pending_updates) { if (ps->pending_updates) {
log_debug("Delayed handling of events, entering critical section"); log_debug("Delayed handling of events, entering critical section");
auto e = xcb_request_check(ps->c, xcb_grab_server_checked(ps->c)); auto e = xcb_request_check(ps->c, xcb_grab_server_checked(ps->c));
@ -1311,7 +1312,7 @@ static void _draw_callback(EV_P_ session_t *ps, int revents) {
} }
// Catching up with X server // Catching up with X server
handle_queued_x_events(ps->loop, &ps->event_check, 0); handle_queued_x_events(EV_A_ & ps->event_check, 0);
// Call fill_win on new windows // Call fill_win on new windows
handle_new_windows(ps); handle_new_windows(ps);
@ -1373,10 +1374,10 @@ static void _draw_callback(EV_P_ session_t *ps, int revents) {
// Start/stop fade timer depends on whether window are fading // Start/stop fade timer depends on whether window are fading
if (!fade_running && ev_is_active(&ps->fade_timer)) { if (!fade_running && ev_is_active(&ps->fade_timer)) {
ev_timer_stop(ps->loop, &ps->fade_timer); ev_timer_stop(EV_A_ & ps->fade_timer);
} else if (fade_running && !ev_is_active(&ps->fade_timer)) { } else if (fade_running && !ev_is_active(&ps->fade_timer)) {
ev_timer_set(&ps->fade_timer, fade_timeout(ps), 0); ev_timer_set(&ps->fade_timer, fade_timeout(ps), 0);
ev_timer_start(ps->loop, &ps->fade_timer); ev_timer_start(EV_A_ & ps->fade_timer);
} }
// If the screen is unredirected, free all_damage to stop painting // If the screen is unredirected, free all_damage to stop painting
@ -1408,8 +1409,9 @@ static void draw_callback(EV_P_ ev_idle *w, int revents) {
_draw_callback(EV_A_ ps, revents); _draw_callback(EV_A_ ps, revents);
// Don't do painting non-stop unless we are in benchmark mode // Don't do painting non-stop unless we are in benchmark mode
if (!ps->o.benchmark) if (!ps->o.benchmark) {
ev_idle_stop(ps->loop, &ps->draw_idle); ev_idle_stop(EV_A_ & ps->draw_idle);
}
} }
static void delayed_draw_timer_callback(EV_P_ ev_timer *w, int revents) { static void delayed_draw_timer_callback(EV_P_ ev_timer *w, int revents) {
@ -1431,7 +1433,7 @@ static void delayed_draw_callback(EV_P_ ev_idle *w, int revents) {
double delay = swopti_handle_timeout(ps); double delay = swopti_handle_timeout(ps);
if (delay < 1e-6) { if (delay < 1e-6) {
if (!ps->o.benchmark) { if (!ps->o.benchmark) {
ev_idle_stop(ps->loop, &ps->draw_idle); ev_idle_stop(EV_A_ & ps->draw_idle);
} }
return _draw_callback(EV_A_ ps, revents); return _draw_callback(EV_A_ ps, revents);
} }
@ -1446,13 +1448,13 @@ static void delayed_draw_callback(EV_P_ ev_idle *w, int revents) {
// We do this anyway even if we are in benchmark mode. That means we will // We do this anyway even if we are in benchmark mode. That means we will
// have to restart draw_idle after the draw actually happened when we are in // have to restart draw_idle after the draw actually happened when we are in
// benchmark mode. // benchmark mode.
ev_idle_stop(ps->loop, &ps->draw_idle); ev_idle_stop(EV_A_ & ps->draw_idle);
ev_timer_set(&ps->delayed_draw_timer, delay, 0); ev_timer_set(&ps->delayed_draw_timer, delay, 0);
ev_timer_start(ps->loop, &ps->delayed_draw_timer); ev_timer_start(EV_A_ & ps->delayed_draw_timer);
} }
static void x_event_callback(EV_P_ ev_io *w, int revents) { static void x_event_callback(EV_P attr_unused, ev_io *w, int revents attr_unused) {
session_t *ps = (session_t *)w; session_t *ps = (session_t *)w;
xcb_generic_event_t *ev = xcb_poll_for_event(ps->c); xcb_generic_event_t *ev = xcb_poll_for_event(ps->c);
if (ev) { if (ev) {
@ -1466,13 +1468,12 @@ static void x_event_callback(EV_P_ ev_io *w, int revents) {
* *
* This will result in compton resetting itself after next paint. * This will result in compton resetting itself after next paint.
*/ */
static void reset_enable(EV_P_ ev_signal *w, int revents) { static void reset_enable(EV_P_ ev_signal *w attr_unused, int revents attr_unused) {
session_t *ps = session_ptr(w, usr1_signal);
log_info("compton is resetting..."); log_info("compton is resetting...");
ev_break(ps->loop, EVBREAK_ALL); ev_break(EV_A_ EVBREAK_ALL);
} }
static void exit_enable(EV_P_ ev_signal *w, int revents) { static void exit_enable(EV_P attr_unused, ev_signal *w, int revents attr_unused) {
session_t *ps = session_ptr(w, int_signal); session_t *ps = session_ptr(w, int_signal);
log_info("compton is quitting..."); log_info("compton is quitting...");
quit_compton(ps); quit_compton(ps);

View file

@ -59,6 +59,8 @@ void discard_ignore(session_t *ps, unsigned long sequence);
void set_root_flags(session_t *ps, uint64_t flags); void set_root_flags(session_t *ps, uint64_t flags);
void quit_compton(session_t *ps);
xcb_window_t session_get_target_window(session_t *); xcb_window_t session_get_target_window(session_t *);
/** /**

View file

@ -226,7 +226,7 @@ typedef struct ev_dbus_timer {
/** /**
* Callback for handling a D-Bus timeout. * Callback for handling a D-Bus timeout.
*/ */
static void cdbus_callback_handle_timeout(EV_P_ ev_timer *w, int revents) { static void cdbus_callback_handle_timeout(EV_P attr_unused, ev_timer *w, int revents attr_unused) {
ev_dbus_timer *t = (void *)w; ev_dbus_timer *t = (void *)w;
dbus_timeout_handle(t->t); dbus_timeout_handle(t->t);
} }
@ -289,7 +289,7 @@ typedef struct ev_dbus_io {
DBusWatch *dw; DBusWatch *dw;
} ev_dbus_io; } ev_dbus_io;
void cdbus_io_callback(EV_P_ ev_io *w, int revents) { void cdbus_io_callback(EV_P attr_unused, ev_io *w, int revents) {
ev_dbus_io *dw = (void *)w; ev_dbus_io *dw = (void *)w;
DBusWatchFlags flags = 0; DBusWatchFlags flags = 0;
if (revents & EV_READ) if (revents & EV_READ)
@ -368,7 +368,7 @@ static void cdbus_callback_watch_toggled(DBusWatch *watch, void *data) {
/** /**
* Callback to append a bool argument to a message. * Callback to append a bool argument to a message.
*/ */
static bool cdbus_apdarg_bool(session_t *ps, DBusMessage *msg, const void *data) { static bool cdbus_apdarg_bool(session_t *ps attr_unused, DBusMessage *msg, const void *data) {
assert(data); assert(data);
dbus_bool_t val = *(const bool *)data; dbus_bool_t val = *(const bool *)data;
@ -384,7 +384,7 @@ static bool cdbus_apdarg_bool(session_t *ps, DBusMessage *msg, const void *data)
/** /**
* Callback to append an int32 argument to a message. * Callback to append an int32 argument to a message.
*/ */
static bool cdbus_apdarg_int32(session_t *ps, DBusMessage *msg, const void *data) { static bool cdbus_apdarg_int32(session_t *ps attr_unused, DBusMessage *msg, const void *data) {
if (!dbus_message_append_args(msg, DBUS_TYPE_INT32, data, DBUS_TYPE_INVALID)) { if (!dbus_message_append_args(msg, DBUS_TYPE_INT32, data, DBUS_TYPE_INVALID)) {
log_error("Failed to append argument."); log_error("Failed to append argument.");
return false; return false;
@ -396,7 +396,8 @@ static bool cdbus_apdarg_int32(session_t *ps, DBusMessage *msg, const void *data
/** /**
* Callback to append an uint32 argument to a message. * Callback to append an uint32 argument to a message.
*/ */
static bool cdbus_apdarg_uint32(session_t *ps, DBusMessage *msg, const void *data) { static bool
cdbus_apdarg_uint32(session_t *ps attr_unused, DBusMessage *msg, const void *data) {
if (!dbus_message_append_args(msg, DBUS_TYPE_UINT32, data, DBUS_TYPE_INVALID)) { if (!dbus_message_append_args(msg, DBUS_TYPE_UINT32, data, DBUS_TYPE_INVALID)) {
log_error("Failed to append argument."); log_error("Failed to append argument.");
return false; return false;
@ -408,7 +409,8 @@ static bool cdbus_apdarg_uint32(session_t *ps, DBusMessage *msg, const void *dat
/** /**
* Callback to append a double argument to a message. * Callback to append a double argument to a message.
*/ */
static bool cdbus_apdarg_double(session_t *ps, DBusMessage *msg, const void *data) { static bool
cdbus_apdarg_double(session_t *ps attr_unused, DBusMessage *msg, const void *data) {
if (!dbus_message_append_args(msg, DBUS_TYPE_DOUBLE, data, DBUS_TYPE_INVALID)) { if (!dbus_message_append_args(msg, DBUS_TYPE_DOUBLE, data, DBUS_TYPE_INVALID)) {
log_error("Failed to append argument."); log_error("Failed to append argument.");
return false; return false;
@ -420,7 +422,7 @@ static bool cdbus_apdarg_double(session_t *ps, DBusMessage *msg, const void *dat
/** /**
* Callback to append a Window argument to a message. * Callback to append a Window argument to a message.
*/ */
static bool cdbus_apdarg_wid(session_t *ps, DBusMessage *msg, const void *data) { static bool cdbus_apdarg_wid(session_t *ps attr_unused, DBusMessage *msg, const void *data) {
assert(data); assert(data);
cdbus_window_t val = *(const xcb_window_t *)data; cdbus_window_t val = *(const xcb_window_t *)data;
@ -435,7 +437,7 @@ static bool cdbus_apdarg_wid(session_t *ps, DBusMessage *msg, const void *data)
/** /**
* Callback to append an cdbus_enum_t argument to a message. * Callback to append an cdbus_enum_t argument to a message.
*/ */
static bool cdbus_apdarg_enum(session_t *ps, DBusMessage *msg, const void *data) { static bool cdbus_apdarg_enum(session_t *ps attr_unused, DBusMessage *msg, const void *data) {
assert(data); assert(data);
if (!dbus_message_append_args(msg, CDBUS_TYPE_ENUM, data, DBUS_TYPE_INVALID)) { if (!dbus_message_append_args(msg, CDBUS_TYPE_ENUM, data, DBUS_TYPE_INVALID)) {
log_error("Failed to append argument."); log_error("Failed to append argument.");
@ -448,7 +450,8 @@ static bool cdbus_apdarg_enum(session_t *ps, DBusMessage *msg, const void *data)
/** /**
* Callback to append a string argument to a message. * Callback to append a string argument to a message.
*/ */
static bool cdbus_apdarg_string(session_t *ps, DBusMessage *msg, const void *data) { static bool
cdbus_apdarg_string(session_t *ps attr_unused, DBusMessage *msg, const void *data) {
const char *str = data; const char *str = data;
if (!str) if (!str)
str = ""; str = "";
@ -464,7 +467,7 @@ static bool cdbus_apdarg_string(session_t *ps, DBusMessage *msg, const void *dat
/** /**
* Callback to append all window IDs to a message. * Callback to append all window IDs to a message.
*/ */
static bool cdbus_apdarg_wids(session_t *ps, DBusMessage *msg, const void *data) { static bool cdbus_apdarg_wids(session_t *ps, DBusMessage *msg, const void *data attr_unused) {
// Get the number of wids we are to include // Get the number of wids we are to include
unsigned count = 0; unsigned count = 0;
HASH_ITER2(ps->windows, w) { HASH_ITER2(ps->windows, w) {
@ -876,7 +879,7 @@ static bool cdbus_process_win_set(session_t *ps, DBusMessage *msg) {
cdbus_enum_t val = UNSET; 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; return false;
win_set_fade_force(ps, w, val); win_set_fade_force(w, val);
goto cdbus_process_win_set_success; goto cdbus_process_win_set_success;
} }
@ -1216,7 +1219,8 @@ static bool cdbus_process_introspect(session_t *ps, DBusMessage *msg) {
/** /**
* Process a message from D-Bus. * Process a message from D-Bus.
*/ */
static DBusHandlerResult cdbus_process(DBusConnection *c, DBusMessage *msg, void *ud) { static DBusHandlerResult
cdbus_process(DBusConnection *c attr_unused, DBusMessage *msg, void *ud) {
session_t *ps = ud; session_t *ps = ud;
bool handled = false; bool handled = false;

View file

@ -613,7 +613,7 @@ ev_selection_clear(session_t *ps, xcb_selection_clear_event_t attr_unused *ev) {
// If we lose that one, we should exit. // If we lose that one, we should exit.
log_fatal("Another composite manager started and took the _NET_WM_CM_Sn " log_fatal("Another composite manager started and took the _NET_WM_CM_Sn "
"selection."); "selection.");
exit(1); quit_compton(ps);
} }
void ev_handle(session_t *ps, xcb_generic_event_t *ev) { void ev_handle(session_t *ps, xcb_generic_event_t *ev) {

View file

@ -225,13 +225,13 @@ struct log_target *null_logger_new(void) {
return &null_logger_target; return &null_logger_target;
} }
static void null_logger_write(struct log_target *attr_unused tgt, static void null_logger_write(struct log_target *tgt attr_unused,
const char *attr_unused str, size_t attr_unused len) { const char *str attr_unused, size_t len attr_unused) {
return; return;
} }
static void null_logger_writev(struct log_target *attr_unused tgt, static void null_logger_writev(struct log_target *tgt attr_unused,
const struct iovec *attr_unused vec, int attr_unused vcnt) { const struct iovec *vec attr_unused, int vcnt attr_unused) {
return; return;
} }
@ -247,25 +247,25 @@ struct file_logger {
struct log_ops ops; struct log_ops ops;
}; };
void file_logger_write(struct log_target *tgt, const char *str, size_t len) { static void file_logger_write(struct log_target *tgt, const char *str, size_t len) {
auto f = (struct file_logger *)tgt; auto f = (struct file_logger *)tgt;
fwrite(str, 1, len, f->f); fwrite(str, 1, len, f->f);
} }
void file_logger_writev(struct log_target *tgt, const struct iovec *vec, int vcnt) { static void file_logger_writev(struct log_target *tgt, const struct iovec *vec, int vcnt) {
auto f = (struct file_logger *)tgt; auto f = (struct file_logger *)tgt;
fflush(f->f); fflush(f->f);
writev(fileno(f->f), vec, vcnt); writev(fileno(f->f), vec, vcnt);
} }
void file_logger_destroy(struct log_target *tgt) { static void file_logger_destroy(struct log_target *tgt) {
auto f = (struct file_logger *)tgt; auto f = (struct file_logger *)tgt;
fclose(f->f); fclose(f->f);
free(tgt); free(tgt);
} }
#define ANSI(x) "\033[" x "m" #define ANSI(x) "\033[" x "m"
const char *terminal_colorize_begin(enum log_level level) { static const char *terminal_colorize_begin(enum log_level level) {
switch (level) { switch (level) {
case LOG_LEVEL_TRACE: return ANSI("30;2"); case LOG_LEVEL_TRACE: return ANSI("30;2");
case LOG_LEVEL_DEBUG: return ANSI("37;2"); case LOG_LEVEL_DEBUG: return ANSI("37;2");
@ -277,7 +277,7 @@ const char *terminal_colorize_begin(enum log_level level) {
} }
} }
const char *terminal_colorize_end(enum log_level level) { static const char *terminal_colorize_end(enum log_level level attr_unused) {
return ANSI("0"); return ANSI("0");
} }
#undef PREFIX #undef PREFIX
@ -335,7 +335,7 @@ struct gl_string_marker_logger {
PFNGLSTRINGMARKERGREMEDYPROC gl_string_marker; PFNGLSTRINGMARKERGREMEDYPROC gl_string_marker;
}; };
void gl_string_marker_logger_write(struct log_target *tgt, const char *str, size_t len) { static void gl_string_marker_logger_write(struct log_target *tgt, const char *str, size_t len) {
auto g = (struct gl_string_marker_logger *)tgt; auto g = (struct gl_string_marker_logger *)tgt;
g->gl_string_marker((GLsizei)len, str); g->gl_string_marker((GLsizei)len, str);
} }

View file

@ -208,7 +208,7 @@ glx_init_end:
return success; return success;
} }
static void glx_free_prog_main(session_t *ps, glx_prog_main_t *pprogram) { static void glx_free_prog_main(glx_prog_main_t *pprogram) {
if (!pprogram) if (!pprogram)
return; return;
if (pprogram->prog) { if (pprogram->prog) {
@ -242,7 +242,7 @@ void glx_destroy(session_t *ps) {
} }
free(ps->psglx->blur_passes); free(ps->psglx->blur_passes);
glx_free_prog_main(ps, &ps->glx_prog_win); glx_free_prog_main(&ps->glx_prog_win);
gl_check_err(); gl_check_err();
@ -419,7 +419,7 @@ bool glx_init_blur(session_t *ps) {
/** /**
* Load a GLSL main program from shader strings. * Load a GLSL main program from shader strings.
*/ */
bool glx_load_prog_main(session_t *ps, const char *vshader_str, const char *fshader_str, bool glx_load_prog_main(const char *vshader_str, const char *fshader_str,
glx_prog_main_t *pprogram) { glx_prog_main_t *pprogram) {
assert(pprogram); assert(pprogram);
@ -662,7 +662,7 @@ void glx_set_clip(session_t *ps, const region_t *reg) {
\ \
pixman_region32_fini(&reg_new); pixman_region32_fini(&reg_new);
static inline GLuint glx_gen_texture(session_t *ps, GLenum tex_tgt, int width, int height) { static inline GLuint glx_gen_texture(GLenum tex_tgt, int width, int height) {
GLuint tex = 0; GLuint tex = 0;
glGenTextures(1, &tex); glGenTextures(1, &tex);
if (!tex) if (!tex)
@ -738,10 +738,10 @@ bool glx_blur_dst(session_t *ps, int dx, int dy, int width, int height, float z,
// Generate FBO and textures if needed // Generate FBO and textures if needed
if (!pbc->textures[0]) if (!pbc->textures[0])
pbc->textures[0] = glx_gen_texture(ps, tex_tgt, mwidth, mheight); pbc->textures[0] = glx_gen_texture(tex_tgt, mwidth, mheight);
GLuint tex_scr = pbc->textures[0]; GLuint tex_scr = pbc->textures[0];
if (more_passes && !pbc->textures[1]) if (more_passes && !pbc->textures[1])
pbc->textures[1] = glx_gen_texture(ps, tex_tgt, mwidth, mheight); pbc->textures[1] = glx_gen_texture(tex_tgt, mwidth, mheight);
pbc->width = mwidth; pbc->width = mwidth;
pbc->height = mheight; pbc->height = mheight;
GLuint tex_scr2 = pbc->textures[1]; GLuint tex_scr2 = pbc->textures[1];

View file

@ -81,7 +81,7 @@ void glx_on_root_change(session_t *ps);
bool glx_init_blur(session_t *ps); bool glx_init_blur(session_t *ps);
#ifdef CONFIG_OPENGL #ifdef CONFIG_OPENGL
bool glx_load_prog_main(session_t *ps, const char *vshader_str, const char *fshader_str, bool glx_load_prog_main(const char *vshader_str, const char *fshader_str,
glx_prog_main_t *pprogram); glx_prog_main_t *pprogram);
#endif #endif
@ -144,7 +144,7 @@ static inline void free_texture_r(session_t *ps, GLuint *ptexture) {
/** /**
* Free a GLX Framebuffer object. * Free a GLX Framebuffer object.
*/ */
static inline void free_glx_fbo(session_t *ps, GLuint *pfbo) { static inline void free_glx_fbo(GLuint *pfbo) {
if (*pfbo) { if (*pfbo) {
glDeleteFramebuffers(1, pfbo); glDeleteFramebuffers(1, pfbo);
*pfbo = 0; *pfbo = 0;
@ -166,7 +166,7 @@ static inline void free_glx_bc_resize(session_t *ps, glx_blur_cache_t *pbc) {
* Free a glx_blur_cache_t * Free a glx_blur_cache_t
*/ */
static inline void free_glx_bc(session_t *ps, glx_blur_cache_t *pbc) { static inline void free_glx_bc(session_t *ps, glx_blur_cache_t *pbc) {
free_glx_fbo(ps, &pbc->fbo); free_glx_fbo(&pbc->fbo);
free_glx_bc_resize(ps, pbc); free_glx_bc_resize(ps, pbc);
} }

View file

@ -1091,7 +1091,7 @@ bool init_render(session_t *ps) {
// Initialize window GL shader // Initialize window GL shader
if (BKEND_GLX == ps->o.backend && ps->o.glx_fshader_win_str) { if (BKEND_GLX == ps->o.backend && ps->o.glx_fshader_win_str) {
#ifdef CONFIG_OPENGL #ifdef CONFIG_OPENGL
if (!glx_load_prog_main(ps, NULL, ps->o.glx_fshader_win_str, &ps->glx_prog_win)) if (!glx_load_prog_main(NULL, ps->o.glx_fshader_win_str, &ps->glx_prog_win))
return false; return false;
#else #else
log_error("GLSL supported not compiled in, can't load " log_error("GLSL supported not compiled in, can't load "

View file

@ -36,7 +36,7 @@ safe_isnan(double a) {
#define CASESTRRET(s) \ #define CASESTRRET(s) \
case s: return #s case s: return #s
/// Same as assert false, but make sure we abort _even in release builds_. /// Same as assert(false), but make sure we abort _even in release builds_.
/// Silence compiler warning caused by release builds making some code paths reachable. /// Silence compiler warning caused by release builds making some code paths reachable.
#define BUG() \ #define BUG() \
do { \ do { \
@ -47,11 +47,35 @@ safe_isnan(double a) {
/// Same as assert, but evaluates the expression even in release builds /// Same as assert, but evaluates the expression even in release builds
#define CHECK(expr) \ #define CHECK(expr) \
do { \ do { \
__auto_type _ = (expr); \ auto _ = (expr); \
/* make sure the original expression appears in the assertion message */ \
assert((CHECK_EXPR(expr), _)); \ assert((CHECK_EXPR(expr), _)); \
(void)_; \ (void)_; \
} while (0) } while (0)
/// Asserts that var is within [lower, upper]. Silence compiler warning about expressions
/// being always true or false.
#define ASSERT_IN_RANGE(var, lower, upper) \
do { \
auto __tmp = (var); \
_Pragma("GCC diagnostic push"); \
_Pragma("GCC diagnostic ignored \"-Wtype-limits\""); \
assert(__tmp >= lower); \
assert(__tmp <= upper); \
_Pragma("GCC diagnostic pop"); \
} while (0)
/// Asserts that var >= lower. Silence compiler warning about expressions
/// being always true or false.
#define ASSERT_GEQ(var, lower) \
do { \
auto __tmp = (var); \
_Pragma("GCC diagnostic push"); \
_Pragma("GCC diagnostic ignored \"-Wtype-limits\""); \
assert(__tmp >= lower); \
_Pragma("GCC diagnostic pop"); \
} while (0)
// Some macros for checked cast // Some macros for checked cast
// Note these macros are not complete, as in, they won't work for every integer types. But // Note these macros are not complete, as in, they won't work for every integer types. But
// they are good enough for compton. // they are good enough for compton.
@ -59,28 +83,28 @@ safe_isnan(double a) {
#define to_int_checked(val) \ #define to_int_checked(val) \
({ \ ({ \
int64_t tmp = (val); \ int64_t tmp = (val); \
assert(tmp >= INT_MIN && tmp <= INT_MAX); \ ASSERT_IN_RANGE(tmp, INT_MIN, INT_MAX); \
(int)tmp; \ (int)tmp; \
}) })
#define to_char_checked(val) \ #define to_char_checked(val) \
({ \ ({ \
int64_t tmp = (val); \ int64_t tmp = (val); \
assert(tmp >= CHAR_MIN && tmp <= CHAR_MAX); \ ASSERT_IN_RANGE(tmp, CHAR_MIN, CHAR_MAX); \
(char)tmp; \ (char)tmp; \
}) })
#define to_u16_checked(val) \ #define to_u16_checked(val) \
({ \ ({ \
auto tmp = (val); \ auto tmp = (val); \
assert(tmp >= 0 && tmp <= UINT16_MAX); \ ASSERT_IN_RANGE(tmp, 0, UINT16_MAX); \
(uint16_t) tmp; \ (uint16_t) tmp; \
}) })
#define to_i16_checked(val) \ #define to_i16_checked(val) \
({ \ ({ \
int64_t tmp = (val); \ int64_t tmp = (val); \
assert(tmp >= INT16_MIN && tmp <= INT16_MAX); \ ASSERT_IN_RANGE(tmp, INT16_MIN, INT16_MAX); \
(int16_t) tmp; \ (int16_t) tmp; \
}) })
@ -89,7 +113,7 @@ safe_isnan(double a) {
auto tmp = (val); \ auto tmp = (val); \
int64_t max = UINT32_MAX; /* silence clang tautological \ int64_t max = UINT32_MAX; /* silence clang tautological \
comparison warning*/ \ comparison warning*/ \
CHECK(tmp >= 0 && tmp <= max); \ ASSERT_IN_RANGE(tmp, 0, max); \
(uint32_t) tmp; \ (uint32_t) tmp; \
}) })
/** /**
@ -171,7 +195,7 @@ allocchk_(const char *func_name, const char *file, unsigned int line, void *ptr)
#define ccalloc(nmemb, type) \ #define ccalloc(nmemb, type) \
({ \ ({ \
auto tmp = (nmemb); \ auto tmp = (nmemb); \
assert(tmp >= 0); \ ASSERT_GEQ(tmp, 0); \
((type *)allocchk(calloc((size_t)tmp, sizeof(type)))); \ ((type *)allocchk(calloc((size_t)tmp, sizeof(type)))); \
}) })
@ -179,7 +203,7 @@ allocchk_(const char *func_name, const char *file, unsigned int line, void *ptr)
#define crealloc(ptr, nmemb) \ #define crealloc(ptr, nmemb) \
({ \ ({ \
auto tmp = (nmemb); \ auto tmp = (nmemb); \
assert(tmp >= 0); \ ASSERT_GEQ(tmp, 0); \
((__typeof__(ptr))allocchk(realloc((ptr), (size_t)tmp * sizeof(*(ptr))))); \ ((__typeof__(ptr))allocchk(realloc((ptr), (size_t)tmp * sizeof(*(ptr))))); \
}) })

View file

@ -124,7 +124,7 @@ static bool vsync_opengl_swc_init(session_t *ps) {
/** /**
* Wait for next VSync, OpenGL method. * Wait for next VSync, OpenGL method.
*/ */
static int vsync_opengl_wait(session_t *ps) { static int vsync_opengl_wait(session_t *ps attr_unused) {
unsigned vblank_count = 0; unsigned vblank_count = 0;
glXGetVideoSyncSGI(&vblank_count); glXGetVideoSyncSGI(&vblank_count);

View file

@ -673,7 +673,7 @@ void win_set_invert_color_force(session_t *ps, struct managed_win *w, switch_t v
* *
* Doesn't affect fading already in progress * Doesn't affect fading already in progress
*/ */
void win_set_fade_force(session_t *ps, struct managed_win *w, switch_t val) { void win_set_fade_force(struct managed_win *w, switch_t val) {
w->fade_force = val; w->fade_force = val;
} }
@ -1659,7 +1659,7 @@ static void finish_destroy_win(session_t *ps, struct managed_win **_w) {
assert(false); assert(false);
} }
static void finish_map_win(session_t *ps, struct managed_win **_w) { static void finish_map_win(struct managed_win **_w) {
auto w = *_w; auto w = *_w;
w->in_openclose = false; w->in_openclose = false;
w->state = WSTATE_MAPPED; w->state = WSTATE_MAPPED;
@ -1853,7 +1853,7 @@ void win_check_fade_finished(session_t *ps, struct managed_win **_w) {
switch (w->state) { switch (w->state) {
case WSTATE_UNMAPPING: return finish_unmap_win(ps, _w); case WSTATE_UNMAPPING: return finish_unmap_win(ps, _w);
case WSTATE_DESTROYING: return finish_destroy_win(ps, _w); case WSTATE_DESTROYING: return finish_destroy_win(ps, _w);
case WSTATE_MAPPING: return finish_map_win(ps, _w); case WSTATE_MAPPING: return finish_map_win(_w);
case WSTATE_FADING: w->state = WSTATE_MAPPED; break; case WSTATE_FADING: w->state = WSTATE_MAPPED; break;
default: unreachable; default: unreachable;
} }

View file

@ -331,7 +331,7 @@ int win_get_name(session_t *ps, struct managed_win *w);
int win_get_role(session_t *ps, struct managed_win *w); int win_get_role(session_t *ps, struct managed_win *w);
winmode_t attr_pure win_calc_mode(const struct managed_win *w); winmode_t attr_pure win_calc_mode(const struct managed_win *w);
void win_set_shadow_force(session_t *ps, struct managed_win *w, switch_t val); void win_set_shadow_force(session_t *ps, struct managed_win *w, switch_t val);
void win_set_fade_force(session_t *ps, struct managed_win *w, switch_t val); void win_set_fade_force(struct managed_win *w, switch_t val);
void win_set_focused_force(session_t *ps, struct managed_win *w, switch_t val); void win_set_focused_force(session_t *ps, struct managed_win *w, switch_t val);
void win_set_invert_color_force(session_t *ps, struct managed_win *w, switch_t val); void win_set_invert_color_force(session_t *ps, struct managed_win *w, switch_t val);
/** /**