Merge pull request #68 from yshui/better-log

Convert print_errf in win.c and compton.c
This commit is contained in:
yshui 2018-12-20 17:43:59 +00:00 committed by GitHub
commit 729cffbf69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 566 additions and 678 deletions

111
src/c2.c
View File

@ -338,18 +338,8 @@ c2h_dump_str_tgt(const c2_l_t *pleaf);
static const char *
c2h_dump_str_type(const c2_l_t *pleaf);
static void
c2_dump_raw(c2_ptr_t p);
/**
* Wrapper of c2_dump_raw().
*/
static inline void attr_unused
c2_dump(c2_ptr_t p) {
c2_dump_raw(p);
printf("\n");
fflush(stdout);
}
static void attr_unused
c2_dump(c2_ptr_t p);
static Atom
c2_get_atom_type(const c2_l_t *pleaf);
@ -384,9 +374,6 @@ c2_parse(session_t *ps, c2_lptr_t **pcondlst, const char *pattern,
{
static const c2_lptr_t lptr_def = C2_LPTR_INIT;
auto plptr = cmalloc(c2_lptr_t);
if (!plptr)
printf_errfq(1, "(): Failed to allocate memory for new condition linked"
" list element.");
memcpy(plptr, &lptr_def, sizeof(c2_lptr_t));
plptr->ptr = result;
plptr->data = data;
@ -396,7 +383,7 @@ c2_parse(session_t *ps, c2_lptr_t **pcondlst, const char *pattern,
}
#ifdef DEBUG_C2
printf_dbgf("(\"%s\"): ", pattern);
log_trace("(\"%s\"): ", pattern);
c2_dump(plptr->ptr);
#endif
@ -404,13 +391,12 @@ c2_parse(session_t *ps, c2_lptr_t **pcondlst, const char *pattern,
}
}
#undef c2_error
#define c2_error(format, ...) do { \
printf_err("Pattern \"%s\" pos %d: " format, pattern, offset, \
## __VA_ARGS__); \
return -1; \
log_error("Pattern \"%s\" pos %d: " format, pattern, offset, ##__VA_ARGS__); \
goto fail; \
} while(0)
// TODO Not a very good macro
#define C2H_SKIP_SPACES() { while (isspace(pattern[offset])) ++offset; }
/**
@ -430,13 +416,6 @@ c2_parse_grp(session_t *ps, const char *pattern, int offset, c2_ptr_t *presult,
// Expected end character
const char endchar = (offset ? ')': '\0');
#undef c2_error
#define c2_error(format, ...) do { \
printf_err("Pattern \"%s\" pos %d: " format, pattern, offset, \
## __VA_ARGS__); \
goto c2_parse_grp_fail; \
} while(0)
// We use a system that a maximum of 2 elements are kept. When we find
// the third element, we combine the elements according to operator
// precedence. This design limits operators to have at most two-levels
@ -527,23 +506,23 @@ c2_parse_grp(session_t *ps, const char *pattern, int offset, c2_ptr_t *presult,
// It's a subgroup if it starts with '('
if ('(' == pattern[offset]) {
if ((offset = c2_parse_grp(ps, pattern, offset + 1, pele, level + 1)) < 0)
goto c2_parse_grp_fail;
goto fail;
}
// Otherwise it's a leaf
else {
if ((offset = c2_parse_target(ps, pattern, offset, pele)) < 0)
goto c2_parse_grp_fail;
goto fail;
assert(!pele->isbranch && !c2_ptr_isempty(*pele));
if ((offset = c2_parse_op(pattern, offset, pele)) < 0)
goto c2_parse_grp_fail;
goto fail;
if ((offset = c2_parse_pattern(ps, pattern, offset, pele)) < 0)
goto c2_parse_grp_fail;
goto fail;
if (!c2_l_postprocess(ps, pele->l))
goto c2_parse_grp_fail;
goto fail;
}
// Decrement offset -- we will increment it in loop update
--offset;
@ -589,20 +568,13 @@ c2_parse_grp(session_t *ps, const char *pattern, int offset, c2_ptr_t *presult,
return offset;
c2_parse_grp_fail:
fail:
c2_freep(&eles[0]);
c2_freep(&eles[1]);
return -1;
}
#undef c2_error
#define c2_error(format, ...) do { \
printf_err("Pattern \"%s\" pos %d: " format, pattern, offset, \
## __VA_ARGS__); \
return -1; \
} while(0)
/**
* Parse the target part of a rule.
*/
@ -611,8 +583,6 @@ c2_parse_target(session_t *ps, const char *pattern, int offset, c2_ptr_t *presul
// Initialize leaf
presult->isbranch = false;
presult->l = cmalloc(c2_l_t);
if (!presult->l)
c2_error("Failed to allocate memory for new leaf.");
c2_l_t * const pleaf = presult->l;
memcpy(pleaf, &leaf_def, sizeof(c2_l_t));
@ -739,11 +709,11 @@ c2_parse_target(session_t *ps, const char *pattern, int offset, c2_ptr_t *presul
if (type) {
if (pleaf->predef) {
printf_errf("(): Warning: Type specified for a default target will be ignored.");
log_warn("Type specified for a default target will be ignored.");
}
else {
if (pleaf->type && type != pleaf->type)
printf_errf("(): Warning: Default type overridden on target.");
log_warn("Default type overridden on target.");
pleaf->type = type;
}
}
@ -769,13 +739,12 @@ c2_parse_target(session_t *ps, const char *pattern, int offset, c2_ptr_t *presul
// Write format
if (hasformat) {
if (pleaf->predef)
printf_errf("(): Warning: Format \"%d\" specified on a default target will be ignored.", format);
log_warn("Format \"%d\" specified on a default target will be ignored.", format);
else if (C2_L_TSTRING == pleaf->type)
printf_errf("(): Warning: Format \"%d\" specified on a string target will be ignored.", format);
log_warn("Format \"%d\" specified on a string target will be ignored.", format);
else {
if (pleaf->format && pleaf->format != format)
printf_err("Warning: Default format %d overridden on target.",
pleaf->format);
log_warn("Default format %d overridden on target.", pleaf->format);
pleaf->format = format;
}
}
@ -792,6 +761,9 @@ c2_parse_target(session_t *ps, const char *pattern, int offset, c2_ptr_t *presul
c2_error("Invalid format.");
return offset;
fail:
return -1;
}
/**
@ -857,6 +829,9 @@ c2_parse_op(const char *pattern, int offset, c2_ptr_t *presult) {
c2_error("Exists/greater-than/less-than operators cannot have a qualifier.");
return offset;
fail:
return -1;
}
/**
@ -993,6 +968,9 @@ c2_parse_pattern(session_t *ps, const char *pattern, int offset, c2_ptr_t *presu
c2_error("String pattern cannot have an arithmetic operator.");
return offset;
fail:
return -1;
}
/**
@ -1008,8 +986,6 @@ c2_parse_legacy(session_t *ps, const char *pattern, int offset, c2_ptr_t *presul
// Allocate memory for new leaf
auto pleaf = cmalloc(c2_l_t);
if (!pleaf)
printf_errfq(1, "(): Failed to allocate memory for new leaf.");
presult->isbranch = false;
presult->l = pleaf;
memcpy(pleaf, &leaf_def, sizeof(c2_l_t));
@ -1061,12 +1037,12 @@ c2_parse_legacy(session_t *ps, const char *pattern, int offset, c2_ptr_t *presul
return -1;
return offset;
fail:
return -1;
}
#undef c2_error
#define c2_error(format, ...) { \
printf_err(format, ## __VA_ARGS__); \
return false; }
/**
* Do postprocessing on a condition leaf.
@ -1082,8 +1058,10 @@ c2_l_postprocess(session_t *ps, c2_l_t *pleaf) {
// Get target atom if it's not a predefined one
if (!pleaf->predef) {
pleaf->tgtatom = get_atom(ps, pleaf->tgt);
if (!pleaf->tgtatom)
c2_error("Failed to get atom for target \"%s\".", pleaf->tgt);
if (!pleaf->tgtatom) {
log_error("Failed to get atom for target \"%s\".", pleaf->tgt);
return false;
}
}
// Insert target Atom into atom track list
@ -1098,8 +1076,6 @@ c2_l_postprocess(session_t *ps, c2_l_t *pleaf) {
}
if (!found) {
auto pnew = cmalloc(latom_t);
if (!pnew)
printf_errfq(1, "(): Failed to allocate memory for new track atom.");
pnew->next = ps->track_atom_lst;
pnew->atom = pleaf->tgtatom;
ps->track_atom_lst = pnew;
@ -1124,7 +1100,7 @@ c2_l_postprocess(session_t *ps, c2_l_t *pleaf) {
if (!pleaf->predef) {
for (const char *pc = pleaf->tgt; *pc; ++pc) {
if (islower(*pc)) {
printf_errf("(): Warning: Lowercase character in target name \"%s\".", pleaf->tgt);
log_warn("Lowercase character in target name \"%s\".", pleaf->tgt);
break;
}
}
@ -1144,9 +1120,11 @@ c2_l_postprocess(session_t *ps, c2_l_t *pleaf) {
// Compile PCRE expression
pleaf->regex_pcre = pcre_compile(pleaf->ptnstr, options,
&error, &erroffset, NULL);
if (!pleaf->regex_pcre)
c2_error("Pattern \"%s\": PCRE regular expression parsing failed on "
if (!pleaf->regex_pcre) {
log_error("Pattern \"%s\": PCRE regular expression parsing failed on "
"offset %d: %s", pleaf->ptnstr, erroffset, error);
return false;
}
#ifdef CONFIG_REGEX_PCRE_JIT
pleaf->regex_pcre_extra = pcre_study(pleaf->regex_pcre,
PCRE_STUDY_JIT_COMPILE, &error);
@ -1160,7 +1138,8 @@ c2_l_postprocess(session_t *ps, c2_l_t *pleaf) {
// free(pleaf->tgt);
// pleaf->tgt = NULL;
#else
c2_error("PCRE regular expression support not compiled in.");
log_error("PCRE regular expression support not compiled in.");
return false;
#endif
}
@ -1246,7 +1225,7 @@ c2h_dump_str_type(const c2_l_t *pleaf) {
* Dump a condition tree.
*/
static void
c2_dump_raw(c2_ptr_t p) {
c2_dump(c2_ptr_t p) {
// For a branch
if (p.isbranch) {
const c2_b_t * const pbranch = p.b;
@ -1258,7 +1237,7 @@ c2_dump_raw(c2_ptr_t p) {
putchar('!');
printf("(");
c2_dump_raw(pbranch->opr1);
c2_dump(pbranch->opr1);
switch (pbranch->op) {
case C2_B_OAND: printf(" && "); break;
@ -1267,7 +1246,7 @@ c2_dump_raw(c2_ptr_t p) {
default: assert(0); break;
}
c2_dump_raw(pbranch->opr2);
c2_dump(pbranch->opr2);
printf(")");
}
// For a leaf
@ -1601,7 +1580,7 @@ c2_match_once(session_t *ps, win *w, const c2_ptr_t cond) {
}
#ifdef DEBUG_WINMATCH
printf_dbgf("(%#010lx): branch: result = %d, pattern = ", w->id, result);
log_trace("(%#010lx): branch: result = %d, pattern = ", w->id, result);
c2_dump(cond);
#endif
}
@ -1621,7 +1600,7 @@ c2_match_once(session_t *ps, win *w, const c2_ptr_t cond) {
}
#ifdef DEBUG_WINMATCH
printf_dbgf("(%#010lx): leaf: result = %d, error = %d, "
log_trace("(%#010lx): leaf: result = %d, error = %d, "
"client = %#010lx, pattern = ",
w->id, result, error, w->client_win);
c2_dump(cond);

View File

@ -16,18 +16,10 @@
// === Options ===
// Debug options, enable them using -D in CFLAGS
// #define DEBUG_BACKTRACE 1
// #define DEBUG_REPAINT 1
// #define DEBUG_EVENTS 1
// #define DEBUG_RESTACK 1
// #define DEBUG_WINTYPE 1
// #define DEBUG_CLIENTWIN 1
// #define DEBUG_WINDATA 1
// #define DEBUG_WINMATCH 1
// #define DEBUG_REDIR 1
// #define DEBUG_ALLOC_REG 1
// #define DEBUG_FRAME 1
// #define DEBUG_LEADER 1
// #define DEBUG_C2 1
// #define DEBUG_GLX 1
// #define DEBUG_GLX_GLSL 1
@ -58,10 +50,6 @@
#define COMPTON_VERSION "unknown"
#endif
#if defined(DEBUG_ALLOC_REG)
#define DEBUG_BACKTRACE 1
#endif
#define MAX_ALPHA (255)
// === Includes ===
@ -934,33 +922,6 @@ print_timestamp(session_t *ps);
void
ev_xcb_error(session_t *ps, xcb_generic_error_t *err);
#ifdef DEBUG_BACKTRACE
#include <execinfo.h>
#define BACKTRACE_SIZE 25
/**
* Print current backtrace.
*
* Stolen from glibc manual.
*/
static inline void
print_backtrace(void) {
void *array[BACKTRACE_SIZE];
size_t size;
char **strings;
size = backtrace(array, BACKTRACE_SIZE);
strings = backtrace_symbols(array, size);
for (size_t i = 0; i < size; i++)
printf ("%s\n", strings[i]);
free(strings);
}
#endif
// === Functions ===
/**
@ -1134,7 +1095,7 @@ parse_vsync(session_t *ps, const char *str) {
return true;
}
printf_errf("(\"%s\"): Invalid vsync argument.", str);
log_error("Invalid vsync argument: %s", str);
return false;
}
@ -1158,7 +1119,7 @@ parse_backend(session_t *ps, const char *str) {
ps->o.backend = BKEND_XR_GLX_HYBRID;
return true;
}
printf_errf("(\"%s\"): Invalid backend argument.", str);
log_error("Invalid backend argument: %s", str);
return false;
}
@ -1193,18 +1154,18 @@ parse_glx_swap_method(session_t *ps, const char *str) {
char *pc = NULL;
int age = strtol(str, &pc, 0);
if (!pc || str == pc) {
printf_errf("(\"%s\"): Invalid number.", str);
log_error("glx-swap-method is an invalid number: %s", str);
return false;
}
for (; *pc; ++pc)
if (!isspace(*pc)) {
printf_errf("(\"%s\"): Trailing characters.", str);
log_error("Trailing characters in glx-swap-method option: %s", str);
return false;
}
if (age > CGLX_MAX_BUFFER_AGE + 1 || age < -1) {
printf_errf("(\"%s\"): Number too large / too small.", str);
log_error("Number for glx-swap-method is too large / too small: %s", str);
return false;
}
@ -1534,7 +1495,7 @@ xr_sync(session_t *ps, Drawable d, XSyncFence *pfence) {
assert(!XSyncQueryFence(ps->dpy, *pfence, &triggered) || triggered);
}
else {
printf_errf("(%#010lx): Failed to create X Sync fence.", d);
log_error("Failed to create X Sync fence for %#010lx", d);
}
free_fence(ps, &tmp_fence);
if (*pfence)
@ -1600,63 +1561,6 @@ opts_set_no_fading_openclose(session_t *ps, bool newval);
//!@}
#endif
/**
* @brief Dump the given data to a file.
*/
static inline bool
write_binary_data(const char *path, const unsigned char *data, int length) {
if (!data)
return false;
FILE *f = fopen(path, "wb");
if (!f) {
printf_errf("(\"%s\"): Failed to open file for writing.", path);
return false;
}
int wrote_len = fwrite(data, sizeof(unsigned char), length, f);
fclose(f);
if (wrote_len != length) {
printf_errf("(\"%s\"): Failed to write all blocks: %d / %d", path,
wrote_len, length);
return false;
}
return true;
}
/**
* @brief Dump raw bytes in HEX format.
*
* @param data pointer to raw data
* @param len length of data
*/
static inline void
hexdump(const char *data, int len) {
static const int BYTE_PER_LN = 16;
if (len <= 0)
return;
// Print header
printf("%10s:", "Offset");
for (int i = 0; i < BYTE_PER_LN; ++i)
printf(" %2d", i);
putchar('\n');
// Dump content
for (int offset = 0; offset < len; ++offset) {
if (!(offset % BYTE_PER_LN))
printf("0x%08x:", offset);
printf(" %02hhx", data[offset]);
if ((BYTE_PER_LN - 1) == offset % BYTE_PER_LN)
putchar('\n');
}
if (len % BYTE_PER_LN)
putchar('\n');
fflush(stdout);
}
/**
* Set a <code>bool</code> array of all wintypes to true.
*/

View File

@ -500,11 +500,8 @@ recheck_focus(session_t *ps) {
win *w = find_win_all(ps, wid);
#ifdef DEBUG_EVENTS
print_timestamp(ps);
printf_dbgf("(): %#010" PRIx32 " (%#010lx \"%s\") focused.\n", wid,
log_trace("%#010" PRIx32 " (%#010lx \"%s\") focused.", wid,
(w ? w->id: None), (w ? w->name: NULL));
#endif
// And we set the focus state here
if (w) {
@ -624,7 +621,7 @@ paint_preprocess(session_t *ps, win *list) {
if (!reg_ignore_valid)
rc_region_unref(&w->reg_ignore);
//printf_errf("(): %d %d %s", w->a.map_state, w->ever_damaged, w->name);
//log_trace("%d %d %s", w->a.map_state, w->ever_damaged, w->name);
// Give up if it's not damaged or invisible, or it's unmapped and its
// pixmap is gone (for example due to a ConfigureNotify), or when it's
@ -636,7 +633,7 @@ paint_preprocess(session_t *ps, win *list) {
|| (double) w->opacity / OPAQUE * MAX_ALPHA < 1
|| w->paint_excluded)
to_paint = false;
//printf_errf("(): %s %d %d %d", w->name, to_paint, w->opacity, w->paint_excluded);
//log_trace("%s %d %d %d", w->name, to_paint, w->opacity, w->paint_excluded);
// Add window to damaged area if its painting status changes
// or opacity changes
@ -753,7 +750,7 @@ xr_take_screenshot(session_t *ps) {
XImage *img = XGetImage(ps->dpy, get_tgt_window(ps), 0, 0,
ps->root_width, ps->root_height, AllPlanes, XYPixmap);
if (!img) {
printf_errf("(): Failed to get XImage.");
log_error("Failed to get XImage.");
return NULL;
}
assert(0 == img->xoffset);
@ -841,9 +838,7 @@ map_win(session_t *ps, Window id) {
win *w = find_win(ps, id);
#ifdef DEBUG_EVENTS
printf_dbgf("(%#010lx \"%s\"): %p\n", id, (w ? w->name: NULL), w);
#endif
log_trace("(%#010lx \"%s\"): %p", id, (w ? w->name: NULL), w);
// Don't care about window mapping if it's an InputOnly window
// Try avoiding mapping a window twice
@ -885,9 +880,7 @@ map_win(session_t *ps, Window id) {
assert(w->client_win);
#ifdef DEBUG_WINTYPE
printf_dbgf("(%#010lx): type %s\n", w->id, WINTYPES[w->window_type]);
#endif
log_trace("(%#010lx): type %s", w->id, WINTYPES[w->window_type]);
// FocusIn/Out may be ignored when the window is unmapped, so we must
// recheck focus here
@ -1027,8 +1020,7 @@ restack_win(session_t *ps, win *w, Window new_above) {
}
if (new_above && !found) {
printf_errf("(%#010lx, %#010lx): "
"Failed to found new above window.", w->id, new_above);
log_error("(%#010lx, %#010lx): Failed to found new above window.", w->id, new_above);
return;
}
@ -1047,8 +1039,8 @@ restack_win(session_t *ps, win *w, Window new_above) {
bool to_free;
win* c = ps->list;
printf_dbgf("(%#010lx, %#010lx): "
"Window stack modified. Current stack:\n", w->id, new_above);
log_trace("(%#010lx, %#010lx): "
"Window stack modified. Current stack:", w->id, new_above);
for (; c; c = c->next) {
window_name = "(Failed to get title)";
@ -1099,9 +1091,9 @@ configure_win(session_t *ps, xcb_configure_notify_event_t *ce) {
// Reinitialize GLX on root change
if (ps->o.glx_reinit_on_root_change && ps->psglx) {
if (!glx_reinit(ps, bkend_use_glx(ps)))
printf_errf("(): Failed to reinitialize GLX, troubles ahead.");
log_error("Failed to reinitialize GLX, troubles ahead.");
if (BKEND_GLX == ps->o.backend && !glx_init_blur(ps))
printf_errf("(): Failed to initialize filters.");
log_error("Failed to initialize filters.");
}
// GLX root change callback
@ -1196,15 +1188,11 @@ finish_destroy_win(session_t *ps, win **_w) {
assert(w->destroyed);
win **prev = NULL, *i = NULL;
#ifdef DEBUG_EVENTS
printf_dbgf("(%#010lx): Starting...\n", w->id);
#endif
log_trace("(%#010lx): Starting...", w->id);
for (prev = &ps->list; (i = *prev); prev = &i->next) {
if (w == i) {
#ifdef DEBUG_EVENTS
printf_dbgf("(%#010lx \"%s\"): %p\n", w->id, w->name, w);
#endif
log_trace("(%#010lx \"%s\"): %p", w->id, w->name, w);
finish_unmap_win(ps, _w);
*prev = w->next;
@ -1232,9 +1220,7 @@ static void
destroy_win(session_t *ps, Window id) {
win *w = find_win(ps, id);
#ifdef DEBUG_EVENTS
printf_dbgf("(%#010lx \"%s\"): %p\n", id, (w ? w->name: NULL), w);
#endif
log_trace("(%#010lx \"%s\"): %p", id, (w ? w->name: NULL), w);
if (w) {
unmap_win(ps, &w);
@ -1506,7 +1492,7 @@ ev_focus_detail_name(xcb_focus_in_event_t* ev) {
static inline void attr_unused
ev_focus_report(xcb_focus_in_event_t *ev) {
printf(" { mode: %s, detail: %s }\n", ev_focus_mode_name(ev),
log_trace("{ mode: %s, detail: %s }\n", ev_focus_mode_name(ev),
ev_focus_detail_name(ev));
}
@ -1549,12 +1535,8 @@ ev_create_notify(session_t *ps, xcb_create_notify_event_t *ev) {
inline static void
ev_configure_notify(session_t *ps, xcb_configure_notify_event_t *ev) {
#ifdef DEBUG_EVENTS
printf(" { send_event: %d, "
" above: %#010x, "
" override_redirect: %d }\n",
log_trace("{ send_event: %d, above: %#010x, override_redirect: %d }",
ev->event, ev->above_sibling, ev->override_redirect);
#endif
configure_win(ps, ev);
}
@ -1578,10 +1560,8 @@ ev_unmap_notify(session_t *ps, xcb_unmap_notify_event_t *ev) {
inline static void
ev_reparent_notify(session_t *ps, xcb_reparent_notify_event_t *ev) {
#ifdef DEBUG_EVENTS
printf_dbg(" { new_parent: %#010x, override_redirect: %d }\n",
log_trace("{ new_parent: %#010x, override_redirect: %d }",
ev->parent, ev->override_redirect);
#endif
if (ev->parent == ps->root) {
add_win(ps, ev->window, 0);
@ -1679,7 +1659,7 @@ ev_property_notify(session_t *ps, xcb_property_notify_event_t *ev) {
name_len = xcb_get_atom_name_name_length(reply);
}
printf_dbg(" { atom = %.*s }\n", name_len, name);
log_trace("{ atom = %.*s }", name_len, name);
free(reply);
}
#endif
@ -1857,8 +1837,7 @@ ev_screen_change_notify(session_t *ps,
if (ps->o.sw_opti && !ps->o.refresh_rate) {
update_refresh_rate(ps);
if (!ps->refresh_rate) {
fprintf(stderr, "ev_screen_change_notify(): Refresh rate detection failed."
"swopti will be temporarily disabled");
log_warn("Refresh rate detection failed. swopti will be temporarily disabled");
}
}
}
@ -1868,8 +1847,7 @@ ev_selection_clear(session_t *ps,
xcb_selection_clear_event_t attr_unused *ev) {
// The only selection we own is the _NET_WM_CM_Sn selection.
// If we lose that one, we should exit.
fprintf(stderr, "Another composite manager started and "
"took the _NET_WM_CM_Sn selection.\n");
log_fatal("Another composite manager started and took the _NET_WM_CM_Sn selection.");
exit(1);
}
@ -1912,8 +1890,7 @@ ev_handle(session_t *ps, xcb_generic_event_t *ev) {
char *window_name = NULL;
ev_window_name(ps, wid, &window_name);
print_timestamp(ps);
printf_errf(" event %10.10s serial %#010x window %#010lx \"%s\"\n",
log_trace("event %10.10s serial %#010x window %#010lx \"%s\"",
ev_name(ps, ev), ev_serial(ev), wid, window_name);
}
#endif
@ -2371,7 +2348,7 @@ register_cm(session_t *ps) {
None, None);
if (!ps->reg_win) {
printf_errf("(): Failed to create window.");
log_fatal("Failed to create window.");
return false;
}
@ -2398,8 +2375,9 @@ register_cm(session_t *ps) {
}
// Set COMPTON_VERSION
if (!wid_set_text_prop(ps, ps->reg_win, get_atom(ps, "COMPTON_VERSION"), COMPTON_VERSION)) {
printf_errf("(): Failed to set COMPTON_VERSION.");
if (!wid_set_text_prop(ps, ps->reg_win, get_atom(ps, "COMPTON_VERSION"),
COMPTON_VERSION)) {
log_error("Failed to set COMPTON_VERSION.");
}
// Acquire X Selection _NET_WM_CM_S?
@ -2425,7 +2403,7 @@ register_cm(session_t *ps) {
if (reply && reply->owner != XCB_NONE) {
free(reply);
fprintf(stderr, "Another composite manager is already running\n");
log_fatal("Another composite manager is already running");
return false;
}
free(reply);
@ -2439,7 +2417,7 @@ register_cm(session_t *ps) {
* Reopen streams for logging.
*/
static bool
ostream_reopen(session_t *ps, const char *path) {
stdout_reopen(session_t *ps, const char *path) {
if (!path)
path = ps->o.logpath;
if (!path)
@ -2447,8 +2425,10 @@ ostream_reopen(session_t *ps, const char *path) {
bool success = freopen(path, "a", stdout);
success = freopen(path, "a", stderr) && success;
if (!success)
printf_errfq(1, "(%s): freopen() failed.", path);
if (!success) {
log_fatal("(%s): freopen() failed.", path);
exit(1);
}
return success;
}
@ -2464,7 +2444,7 @@ fork_after(session_t *ps) {
#ifdef CONFIG_OPENGL
// GLX context must be released and reattached on fork
if (glx_has_context(ps) && !glXMakeCurrent(ps->dpy, None, NULL)) {
printf_errf("(): Failed to detach GLx context.");
log_fatal("Failed to detach GLX context.");
return false;
}
#endif
@ -2472,7 +2452,7 @@ fork_after(session_t *ps) {
int pid = fork();
if (-1 == pid) {
printf_errf("(): fork() failed.");
log_fatal("fork() failed.");
return false;
}
@ -2483,19 +2463,17 @@ fork_after(session_t *ps) {
#ifdef CONFIG_OPENGL
if (glx_has_context(ps)
&& !glXMakeCurrent(ps->dpy, get_tgt_window(ps), ps->psglx->context)) {
printf_errf("(): Failed to make GLX context current.");
log_fatal("Failed to make GLX context current.");
return false;
}
#endif
// Mainly to suppress the _FORTIFY_SOURCE warning
bool success = freopen("/dev/null", "r", stdin);
if (!success) {
printf_errf("(): freopen() failed.");
if (!freopen("/dev/null", "r", stdin)) {
log_fatal("freopen() failed.");
return false;
}
return success;
return true;
}
/**
@ -2508,7 +2486,7 @@ write_pid(session_t *ps) {
FILE *f = fopen(ps->o.write_pid_path, "w");
if (unlikely(!f)) {
printf_errf("(): Failed to write PID to \"%s\".", ps->o.write_pid_path);
log_error("Failed to write PID to \"%s\".", ps->o.write_pid_path);
return false;
}
@ -2646,7 +2624,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
// Check for abundant positional arguments
if (optind < argc)
printf_errfq(1, "(): compton doesn't accept positional arguments.");
log_fatal("compton doesn't accept positional arguments.");
return;
}
@ -2731,14 +2709,14 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
ps->o.frame_opacity = atof(optarg);
break;
case 'z':
printf_errf("(): clear-shadow is removed, shadows are automatically cleared now.\n"
"If you want to prevent shadow from been cleared under certain types of windows,\n"
log_warn("clear-shadow is removed, shadows are automatically cleared now. "
"If you want to prevent shadow from been cleared under certain types of windows, "
"you can use the \"full-shadow\" per window type option.");
break;
case 'n':
case 'a':
case 's':
printf_errfq(1, "(): -n, -a, and -s have been removed.");
log_error("-n, -a, and -s have been removed.");
break;
P_CASEBOOL('b', fork_after_register);
// Long options
@ -2780,14 +2758,14 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
break;
case 271:
// --alpha-step
printf_errf("(): --alpha-step has been removed, compton now tries to make use"
log_warn("--alpha-step has been removed, compton now tries to make use"
" of all alpha values");
break;
case 272:
printf_errf("(): use of --dbe is deprecated");
log_warn("use of --dbe is deprecated");
break;
case 273:
printf_errf("(): --paint-on-overlay has been removed, and is enabled when "
log_warn("--paint-on-overlay has been removed, and is enabled when "
"possible");
break;
P_CASEBOOL(274, sw_opti);
@ -2825,7 +2803,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
break;
P_CASEBOOL(291, glx_no_stencil);
case 292:
printf_errf("(): --glx-copy-from-front %s", deprecation_message);
log_warn("--glx-copy-from-front %s", deprecation_message);
break;
P_CASELONG(293, benchmark);
case 294:
@ -2833,7 +2811,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
ps->o.benchmark_wid = strtol(optarg, NULL, 0);
break;
case 295:
printf_errf("(): --glx-use-copysubbuffermesa %s", deprecation_message);
log_warn("--glx-use-copysubbuffermesa %s", deprecation_message);
break;
case 296:
// --blur-background-exclude
@ -2868,7 +2846,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
case 305:
// --shadow-exclude-reg
ps->o.shadow_exclude_reg_str = strdup(optarg);
printf_err("--shadow-exclude-reg is deprecated.\n"
log_warn("--shadow-exclude-reg is deprecated. "
"You are likely better off using --shadow-exclude anyway");
break;
case 306:
@ -2892,9 +2870,9 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
P_CASEBOOL(316, force_win_blend);
case 317:
ps->o.glx_fshader_win_str = strdup(optarg);
printf_errf("(): --glx-fshader-win is being deprecated, and might be\n"
" removed in the future. If you really need this feature, please report\n"
"an issue to let us know\n");
log_warn("--glx-fshader-win is being deprecated, and might be"
" removed in the future. If you really need this feature, please report"
" an issue to let us know");
break;
case 321: {
enum log_level tmp_level = string_to_log_level(optarg);
@ -2923,8 +2901,9 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
setlocale(LC_NUMERIC, lc_numeric_old);
free(lc_numeric_old);
if (ps->o.monitor_repaint && ps->o.backend != BKEND_XRENDER)
printf_errf("(): --monitor-repaint has no effect when backend is not xrender");
if (ps->o.monitor_repaint && ps->o.backend != BKEND_XRENDER) {
log_warn("--monitor-repaint has no effect when backend is not xrender");
}
// Range checking and option assignments
ps->o.fade_delta = max_i(ps->o.fade_delta, 1);
@ -2992,7 +2971,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
rebuild_shadow_exclude_reg(ps);
if (ps->o.resize_damage < 0)
printf_errf("(): Negative --resize-damage does not work correctly.");
log_warn("Negative --resize-damage will not work correctly.");
}
/**
@ -3137,13 +3116,13 @@ init_overlay(session_t *ps) {
e = XCB_SYNCED_VOID(xcb_shape_mask, ps->c, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING,
ps->overlay, 0, 0, 0);
if (e) {
printf_errf("(): failed to set the bounding shape of overlay, giving up.");
log_fatal("Failed to set the bounding shape of overlay, giving up.");
exit(1);
}
e = XCB_SYNCED_VOID(xcb_shape_rectangles, ps->c, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT,
XCB_CLIP_ORDERING_UNSORTED, ps->overlay, 0, 0, 0, NULL);
if (e) {
printf_errf("(): failed to set the input shape of overlay, giving up.");
log_fatal("Failed to set the input shape of overlay, giving up.");
exit(1);
}
@ -3159,13 +3138,11 @@ init_overlay(session_t *ps) {
// the window isn't created yet.
// xcb_unmap_window(c, ps->overlay);
// XFlush(ps->dpy);
} else {
log_error("Cannot get X Composite overlay window. Falling "
"back to painting on root window.");
}
else
fprintf(stderr, "Cannot get X Composite overlay window. Falling "
"back to painting on root window.\n");
#ifdef DEBUG_REDIR
printf_dbgf("(): overlay = %#010lx\n", ps->overlay);
#endif
log_debug("overlay = %#010lx", ps->overlay);
return ps->overlay;
}
@ -3176,10 +3153,7 @@ init_overlay(session_t *ps) {
static void
redir_start(session_t *ps) {
if (!ps->redirected) {
#ifdef DEBUG_REDIR
print_timestamp(ps);
printf_dbgf("(): Screen redirected.\n");
#endif
log_trace("Screen redirected.");
// Map overlay window. Done firstly according to this:
// https://bugzilla.gnome.org/show_bug.cgi?id=597014
@ -3213,10 +3187,7 @@ redir_start(session_t *ps) {
static void
redir_stop(session_t *ps) {
if (ps->redirected) {
#ifdef DEBUG_REDIR
print_timestamp(ps);
printf_dbgf("(): Screen unredirected.\n");
#endif
log_trace("Screen unredirected.");
// Destroy all Pictures as they expire once windows are unredirected
// If we don't destroy them here, looks like the resources are just
// kept inaccessible somehow
@ -3251,7 +3222,8 @@ handle_queued_x_events(EV_P_ ev_prepare *w, int revents) {
int err = xcb_connection_has_error(ps->c);
if (err) {
printf_errfq(1, "(): X11 server connection broke (error %d)", err);
log_fatal("X11 server connection broke (error %d)", err);
exit(1);
}
}
@ -3277,7 +3249,7 @@ _draw_callback(EV_P_ session_t *ps, int revents) {
if (ps->o.benchmark_wid) {
win *wi = find_win(ps, ps->o.benchmark_wid);
if (!wi) {
printf_errf("(): Couldn't find specified benchmark window.");
log_fatal("Couldn't find specified benchmark window.");
exit(1);
}
add_damage_from_win(ps, wi);
@ -3605,7 +3577,8 @@ session_init(session_t *ps_old, int argc, char **argv) {
if (!ps->dpy) {
ps->dpy = XOpenDisplay(ps->o.display);
if (!ps->dpy) {
printf_errfq(1, "(): Can't open display.");
log_fatal("Can't open display.");
exit(1);
}
XSetEventQueueOwner(ps->dpy, XCBOwnsEventQueue);
}
@ -3646,7 +3619,7 @@ session_init(session_t *ps_old, int argc, char **argv) {
ext_info = xcb_get_extension_data(ps->c, &xcb_render_id);
if (!ext_info || !ext_info->present) {
fprintf(stderr, "No render extension\n");
log_fatal("No render extension");
exit(1);
}
ps->render_event = ext_info->first_event;
@ -3654,7 +3627,7 @@ session_init(session_t *ps_old, int argc, char **argv) {
ext_info = xcb_get_extension_data(ps->c, &xcb_composite_id);
if (!ext_info || !ext_info->present) {
fprintf(stderr, "No composite extension\n");
log_fatal("No composite extension");
exit(1);
}
ps->composite_opcode = ext_info->major_opcode;
@ -3676,7 +3649,7 @@ session_init(session_t *ps_old, int argc, char **argv) {
ext_info = xcb_get_extension_data(ps->c, &xcb_damage_id);
if (!ext_info || !ext_info->present) {
fprintf(stderr, "No damage extension\n");
log_fatal("No damage extension");
exit(1);
}
ps->damage_event = ext_info->first_event;
@ -3686,7 +3659,7 @@ session_init(session_t *ps_old, int argc, char **argv) {
ext_info = xcb_get_extension_data(ps->c, &xcb_xfixes_id);
if (!ext_info || !ext_info->present) {
fprintf(stderr, "No XFixes extension\n");
log_fatal("No XFixes extension");
exit(1);
}
ps->xfixes_event = ext_info->first_event;
@ -3747,16 +3720,17 @@ session_init(session_t *ps_old, int argc, char **argv) {
}
if (!ps->xsync_exists && ps->o.xrender_sync_fence) {
printf_errf("(): X Sync extension not found. No X Sync fence sync is "
"possible.");
log_fatal("X Sync extension not found. No X Sync fence sync is "
"possible. (xrender-sync-fence can't be enabled)");
exit(1);
}
// Query X RandR
if ((ps->o.sw_opti && !ps->o.refresh_rate) || ps->o.xinerama_shadow_crop) {
if (!ps->randr_exists) {
printf_errf("(): No XRandR extension, automatic screen change "
"detection impossible.");
log_fatal("No XRandR extension. sw-opti, refresh-rate or xinerama-shadow-crop "
"cannot be enabled.");
exit(1);
}
}
@ -3766,7 +3740,8 @@ session_init(session_t *ps_old, int argc, char **argv) {
ext_info = xcb_get_extension_data(ps->c, &xcb_xinerama_id);
ps->xinerama_exists = ext_info && ext_info->present;
#else
printf_errf("(): Xinerama support not compiled in.");
log_fatal("Xinerama support not compiled in. xinerama-shadow-crop cannot be enabled");
exit(1);
#endif
}
@ -3777,8 +3752,10 @@ session_init(session_t *ps_old, int argc, char **argv) {
init_overlay(ps);
// Initialize filters, must be preceded by OpenGL context creation
if (!init_render(ps))
if (!init_render(ps)) {
log_fatal("Failed to initialize the backend");
exit(1);
}
if (ps->o.print_diagnostics) {
print_diagnostics(ps);
@ -3893,7 +3870,8 @@ session_init(session_t *ps_old, int argc, char **argv) {
ps->o.dbus = false;
}
#else
printf_errfq(1, "(): DBus support not compiled in!");
log_fatal("DBus support not compiled in!");
exit(1);
#endif
}
@ -3907,7 +3885,7 @@ session_init(session_t *ps_old, int argc, char **argv) {
// Redirect output stream
if (ps->o.fork_after_register || ps->o.logpath)
ostream_reopen(ps, NULL);
stdout_reopen(ps, NULL);
write_pid(ps);
@ -4070,7 +4048,28 @@ session_destroy(session_t *ps) {
log_deinit_tls();
}
/*
#if 0
/**
* @brief Dump the given data to a file.
*/
static inline bool
write_binary_data(const char *path, const unsigned char *data, int length) {
if (!data)
return false;
FILE *f = fopen(path, "wb");
if (!f) {
log_error("Failed to open \"%s\" for writing.", path);
return false;
}
int wrote_len = fwrite(data, sizeof(unsigned char), length, f);
fclose(f);
if (wrote_len != length) {
log_error("Failed to write all blocks: %d / %d to %s",
wrote_len, length, path);
return false;
}
return true;
}
static inline void
dump_img(session_t *ps) {
int len = 0;
@ -4078,7 +4077,7 @@ dump_img(session_t *ps) {
write_binary_data("/tmp/dump.raw", d, len);
free(d);
}
*/
#endif
/**
* Do the actual work.
@ -4133,7 +4132,7 @@ main(int argc, char **argv) {
while (!quit) {
ps_g = session_init(ps_old, argc, argv);
if (!ps_g) {
printf_errf("(): Failed to create new session.");
log_fatal("Failed to create new compton session.");
return 1;
}
session_run(ps_g);

View File

@ -134,7 +134,7 @@ static inline bool
wid_set_text_prop(session_t *ps, Window wid, Atom prop_atom, char *str) {
XTextProperty *pprop = make_text_prop(ps, str);
if (!pprop) {
printf_errf("(\"%s\"): Failed to make text property.", str);
log_error("Failed to make text property: %s.", str);
return false;
}
@ -155,10 +155,11 @@ dump_drawable(session_t *ps, Drawable drawable) {
unsigned width = 0, height = 0, border = 0, depth = 0;
if (XGetGeometry(ps->dpy, drawable, &rroot, &x, &y, &width, &height,
&border, &depth)) {
printf_dbgf("(%#010lx): x = %u, y = %u, wid = %u, hei = %d, b = %u, d = %u\n", drawable, x, y, width, height, border, depth);
log_trace("Drawable %#010lx: x = %u, y = %u, wid = %u, hei = %d, b = %u, d = %u",
drawable, x, y, width, height, border, depth);
}
else {
printf_dbgf("(%#010lx): Failed\n", drawable);
log_trace("Drawable %#010lx: Failed", drawable);
}
}

View File

@ -22,13 +22,13 @@ parse_long(const char *s, long *dest) {
const char *endptr = NULL;
long val = strtol(s, (char **) &endptr, 0);
if (!endptr || endptr == s) {
printf_errf("(\"%s\"): Invalid number.", s);
log_error("Invalid number: %s", s);
return false;
}
while (isspace(*endptr))
++endptr;
if (*endptr) {
printf_errf("(\"%s\"): Trailing characters.", s);
log_error("Trailing characters: %s", s);
return false;
}
*dest = val;
@ -43,7 +43,7 @@ parse_matrix_readnum(const char *src, double *dest) {
char *pc = NULL;
double val = strtod(src, &pc);
if (!pc || pc == src) {
printf_errf("(\"%s\"): No number found.", src);
log_error("No number found: %s", src);
return src;
}
@ -78,23 +78,19 @@ parse_matrix(session_t *ps, const char *src, const char **endptr) {
// Validate matrix width and height
if (wid <= 0 || hei <= 0) {
printf_errf("(): Invalid matrix width/height.");
log_error("Invalid matrix width/height.");
goto err1;
}
if (!(wid % 2 && hei % 2)) {
printf_errf("(): Width/height not odd.");
log_error("Width/height not odd.");
goto err1;
}
if (wid > 16 || hei > 16)
printf_errf("(): Matrix width/height too large, may slow down"
log_warn("Matrix width/height too large, may slow down"
"rendering, and/or consume lots of memory");
// Allocate memory
auto matrix = ccalloc(wid * hei + 2, xcb_render_fixed_t);
if (!matrix) {
printf_errf("(): Failed to allocate memory for matrix.");
goto err1;
}
// Read elements
{
@ -114,14 +110,14 @@ parse_matrix(session_t *ps, const char *src, const char **endptr) {
matrix[2 + i] = DOUBLE_TO_XFIXED(val);
}
if (BKEND_XRENDER == ps->o.backend && hasneg)
printf_errf("(): A convolution kernel with negative values "
"may not work properly under X Render backend.");
log_warn("A convolution kernel with negative values may not work properly under X "
"Render backend.");
}
// Detect trailing characters
for ( ;*pc && ';' != *pc; ++pc)
if (!isspace(*pc) && ',' != *pc) {
printf_errf("(): Trailing characters in matrix string.");
log_error("Trailing characters in matrix string.");
goto err2;
}
@ -137,7 +133,7 @@ parse_matrix(session_t *ps, const char *src, const char **endptr) {
if (endptr)
*endptr = pc;
else if (*pc) {
printf_errf("(): Only one matrix expected.");
log_error("Only one matrix expected.");
goto err2;
}
@ -201,13 +197,13 @@ parse_conv_kern_lst(session_t *ps, const char *src, xcb_render_fixed_t **dest, i
}
if (i > 1) {
printf_errf("(): You are seeing this message because your are using multipass\n"
"blur. Please report an issue to us so we know multipass blur is actually been used.\n"
log_warn("You are seeing this message because your are using multipassblur. Please "
"report an issue to us so we know multipass blur is actually been used. "
"Otherwise it might be removed in future releases");
}
if (*pc) {
printf_errf("(): Too many blur kernels!");
log_error("Too many blur kernels!");
return false;
}
@ -243,7 +239,7 @@ parse_geometry(session_t *ps, const char *src, region_t *dest) {
if (src != endptr) {
geom.wid = val;
if (geom.wid < 0) {
printf_errf("(\"%s\"): Invalid width.", src);
log_error("Invalid width: %s", src);
return false;
}
src = endptr;
@ -259,7 +255,7 @@ parse_geometry(session_t *ps, const char *src, region_t *dest) {
if (src != endptr) {
geom.hei = val;
if (geom.hei < 0) {
printf_errf("(\"%s\"): Invalid height.", src);
log_error("Invalid height: %s", src);
return false;
}
src = endptr;
@ -292,7 +288,7 @@ parse_geometry(session_t *ps, const char *src, region_t *dest) {
}
if (*src) {
printf_errf("(\"%s\"): Trailing characters.", src);
log_error("Trailing characters: %s", src);
return false;
}
@ -309,11 +305,11 @@ bool parse_rule_opacity(session_t *ps, const char *src) {
char *endptr = NULL;
long val = strtol(src, &endptr, 0);
if (!endptr || endptr == src) {
printf_errf("(\"%s\"): No opacity specified?", src);
log_error("No opacity specified: %s", src);
return false;
}
if (val > 100 || val < 0) {
printf_errf("(\"%s\"): Opacity %ld invalid.", src, val);
log_error("Opacity %ld invalid: %s", val, src);
return false;
}
@ -321,7 +317,7 @@ bool parse_rule_opacity(session_t *ps, const char *src) {
while (*endptr && isspace(*endptr))
++endptr;
if (':' != *endptr) {
printf_errf("(\"%s\"): Opacity terminator not found.", src);
log_error("Opacity terminator not found: %s", src);
return false;
}
++endptr;

View File

@ -140,10 +140,11 @@ void parse_config_libconfig(session_t *ps, bool *shadow_enable,
f = open_config_file(ps->o.config_file, &path);
if (!f) {
if (ps->o.config_file) {
printf_errfq(1, "(): Failed to read configuration file \"%s\".",
ps->o.config_file);
free(ps->o.config_file);
ps->o.config_file = NULL;
log_fatal("Failed to read configuration file \"%s\".", ps->o.config_file);
abort();
}
return;
}
@ -166,7 +167,7 @@ void parse_config_libconfig(session_t *ps, bool *shadow_enable,
fclose(f);
f = NULL;
if (read_result == CONFIG_FALSE) {
printf("Error when reading configuration file \"%s\", line %d: %s\n",
log_error("Error when reading configuration file \"%s\", line %d: %s",
path, config_error_line(&cfg), config_error_text(&cfg));
config_destroy(&cfg);
free(path);
@ -213,22 +214,22 @@ void parse_config_libconfig(session_t *ps, bool *shadow_enable,
*shadow_enable = ival;
// -C (no_dock_shadow)
if (config_lookup_bool(&cfg, "no-dock-shadow", &ival)) {
printf_errf("(): option `no-dock-shadow` is deprecated, and will be removed.\n"
log_warn("Option `no-dock-shadow` is deprecated, and will be removed."
" Please use the wintype option `shadow` of `dock` instead.");
ps->o.wintype_option[WINTYPE_DOCK].shadow = false;
winopt_mask[WINTYPE_DOCK].shadow = true;
}
// -G (no_dnd_shadow)
if (config_lookup_bool(&cfg, "no-dnd-shadow", &ival)) {
printf_errf("(): option `no-dnd-shadow` is deprecated, and will be removed.\n"
log_warn("Option `no-dnd-shadow` is deprecated, and will be removed."
" Please use the wintype option `shadow` of `dnd` instead.");
ps->o.wintype_option[WINTYPE_DND].shadow = false;
winopt_mask[WINTYPE_DND].shadow = true;
};
// -m (menu_opacity)
if (config_lookup_float(&cfg, "menu-opacity", &dval)) {
printf_errf("(): option `menu-opacity` is deprecated, and will be removed.\n"
"Please use the wintype option `opacity` of `popup_menu` and `dropdown_menu` instead.");
log_warn("Option `menu-opacity` is deprecated, and will be removed.Please use the "
"wintype option `opacity` of `popup_menu` and `dropdown_menu` instead.");
ps->o.wintype_option[WINTYPE_DROPDOWN_MENU].opacity = dval;
ps->o.wintype_option[WINTYPE_POPUP_MENU].opacity = dval;
winopt_mask[WINTYPE_DROPDOWN_MENU].opacity = true;
@ -276,11 +277,15 @@ void parse_config_libconfig(session_t *ps, bool *shadow_enable,
// --refresh-rate
config_lookup_int(&cfg, "refresh-rate", &ps->o.refresh_rate);
// --vsync
if (config_lookup_string(&cfg, "vsync", &sval) && !parse_vsync(ps, sval))
if (config_lookup_string(&cfg, "vsync", &sval) && !parse_vsync(ps, sval)) {
log_fatal("Cannot parse vsync");
exit(1);
}
// --backend
if (config_lookup_string(&cfg, "backend", &sval) && !parse_backend(ps, sval))
if (config_lookup_string(&cfg, "backend", &sval) && !parse_backend(ps, sval)) {
log_fatal("Cannot parse backend");
exit(1);
}
// --log-level
if (config_lookup_string(&cfg, "log-level", &sval)) {
auto level = string_to_log_level(sval);
@ -332,8 +337,10 @@ void parse_config_libconfig(session_t *ps, bool *shadow_enable,
&ps->o.blur_background_fixed);
// --blur-kern
if (config_lookup_string(&cfg, "blur-kern", &sval)
&& !parse_conv_kern_lst(ps, sval, ps->o.blur_kerns, MAX_BLUR_PASS))
&& !parse_conv_kern_lst(ps, sval, ps->o.blur_kerns, MAX_BLUR_PASS)) {
log_fatal("Cannot parse \"blur-kern\"");
exit(1);
}
// --resize-damage
config_lookup_int(&cfg, "resize-damage", &ps->o.resize_damage);
// --glx-no-stencil
@ -341,9 +348,11 @@ void parse_config_libconfig(session_t *ps, bool *shadow_enable,
// --glx-no-rebind-pixmap
lcfg_lookup_bool(&cfg, "glx-no-rebind-pixmap", &ps->o.glx_no_rebind_pixmap);
// --glx-swap-method
if (config_lookup_string(&cfg, "glx-swap-method", &sval)
&& !parse_glx_swap_method(ps, sval))
if (config_lookup_string(&cfg, "glx-swap-method", &sval) &&
!parse_glx_swap_method(ps, sval)) {
log_fatal("Cannot parse \"glx-swap-method\"");
exit(1);
}
// --glx-use-gpushader4
lcfg_lookup_bool(&cfg, "glx-use-gpushader4", &ps->o.glx_use_gpushader4);
// --xrender-sync
@ -352,22 +361,22 @@ void parse_config_libconfig(session_t *ps, bool *shadow_enable,
lcfg_lookup_bool(&cfg, "xrender-sync-fence", &ps->o.xrender_sync_fence);
if (lcfg_lookup_bool(&cfg, "clear-shadow", &bval))
printf_errf("(): \"clear-shadow\" is removed as an option, and is always"
log_warn("\"clear-shadow\" is removed as an option, and is always"
" enabled now. Consider removing it from your config file");
if (lcfg_lookup_bool(&cfg, "paint-on-overlay", &bval))
printf_errf("(): \"paint-on-overlay\" has been removed as an option, and "
log_warn("\"paint-on-overlay\" has been removed as an option, and "
"is enabled whenever possible");
if (config_lookup_float(&cfg, "alpha-step", &dval))
printf_errf("(): \"alpha-step\" has been removed, compton now tries to make use"
log_warn("\"alpha-step\" has been removed, compton now tries to make use"
" of all alpha values");
const char *deprecation_message = "has been removed. If you encounter problems "
"without this feature, please feel free to open a bug report";
if (lcfg_lookup_bool(&cfg, "glx-use-copysubbuffermesa", &bval) && bval)
printf_errf("(): \"glx-use-copysubbuffermesa\" %s", deprecation_message);
log_warn("\"glx-use-copysubbuffermesa\" %s", deprecation_message);
if (lcfg_lookup_bool(&cfg, "glx-copy-from-front", &bval) && bval)
printf_errf("(): \"glx-copy-from-front\" %s", deprecation_message);
log_warn("\"glx-copy-from-front\" %s", deprecation_message);
// Wintype settings

View File

@ -51,13 +51,13 @@ cdbus_init(session_t *ps) {
// Use dbus_bus_get_private() so we can fully recycle it ourselves
ps->dbus_conn = dbus_bus_get_private(DBUS_BUS_SESSION, &err);
if (dbus_error_is_set(&err)) {
printf_errf("(): D-Bus connection failed (%s).", err.message);
log_error("D-Bus connection failed (%s).", err.message);
dbus_error_free(&err);
return false;
}
if (!ps->dbus_conn) {
printf_errf("(): D-Bus connection failed for unknown reason.");
log_error("D-Bus connection failed for unknown reason.");
return false;
}
@ -75,14 +75,13 @@ cdbus_init(session_t *ps) {
DBUS_NAME_FLAG_DO_NOT_QUEUE, &err);
if (dbus_error_is_set(&err)) {
printf_errf("(): Failed to obtain D-Bus name (%s).", err.message);
log_error("Failed to obtain D-Bus name (%s).", err.message);
dbus_error_free(&err);
}
if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret
&& DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER != ret) {
printf_errf("(): Failed to become the primary owner of requested "
"D-Bus name (%d).", ret);
log_error("Failed to become the primary owner of requested D-Bus name (%d).", ret);
}
}
@ -91,7 +90,7 @@ cdbus_init(session_t *ps) {
if (!dbus_connection_set_watch_functions(ps->dbus_conn,
cdbus_callback_add_watch, cdbus_callback_remove_watch,
cdbus_callback_watch_toggled, ps, NULL)) {
printf_errf("(): Failed to add D-Bus watch functions.");
log_error("Failed to add D-Bus watch functions.");
return false;
}
@ -99,7 +98,7 @@ cdbus_init(session_t *ps) {
if (!dbus_connection_set_timeout_functions(ps->dbus_conn,
cdbus_callback_add_timeout, cdbus_callback_remove_timeout,
cdbus_callback_timeout_toggled, ps, NULL)) {
printf_errf("(): Failed to add D-Bus timeout functions.");
log_error("Failed to add D-Bus timeout functions.");
return false;
}
@ -107,7 +106,7 @@ cdbus_init(session_t *ps) {
dbus_bus_add_match(ps->dbus_conn,
"type='method_call',interface='" CDBUS_INTERFACE_NAME "'", &err);
if (dbus_error_is_set(&err)) {
printf_errf("(): Failed to add D-Bus match.");
log_error("Failed to add D-Bus match.");
dbus_error_free(&err);
return false;
}
@ -128,8 +127,7 @@ cdbus_destroy(session_t *ps) {
dbus_bus_release_name(ps->dbus_conn, ps->dbus_service, &err);
if (dbus_error_is_set(&err)) {
printf_errf("(): Failed to release DBus name (%s).",
err.message);
log_error("Failed to release DBus name (%s).", err.message);
dbus_error_free(&err);
}
}
@ -309,7 +307,7 @@ cdbus_apdarg_bool(session_t *ps, DBusMessage *msg, const void *data) {
if (!dbus_message_append_args(msg, DBUS_TYPE_BOOLEAN, &val,
DBUS_TYPE_INVALID)) {
printf_errf("(): Failed to append argument.");
log_error("Failed to append argument.");
return false;
}
@ -323,7 +321,7 @@ static bool
cdbus_apdarg_int32(session_t *ps, DBusMessage *msg, const void *data) {
if (!dbus_message_append_args(msg, DBUS_TYPE_INT32, data,
DBUS_TYPE_INVALID)) {
printf_errf("(): Failed to append argument.");
log_error("Failed to append argument.");
return false;
}
@ -337,7 +335,7 @@ static bool
cdbus_apdarg_uint32(session_t *ps, DBusMessage *msg, const void *data) {
if (!dbus_message_append_args(msg, DBUS_TYPE_UINT32, data,
DBUS_TYPE_INVALID)) {
printf_errf("(): Failed to append argument.");
log_error("Failed to append argument.");
return false;
}
@ -351,7 +349,7 @@ static bool
cdbus_apdarg_double(session_t *ps, DBusMessage *msg, const void *data) {
if (!dbus_message_append_args(msg, DBUS_TYPE_DOUBLE, data,
DBUS_TYPE_INVALID)) {
printf_errf("(): Failed to append argument.");
log_error("Failed to append argument.");
return false;
}
@ -368,7 +366,7 @@ cdbus_apdarg_wid(session_t *ps, DBusMessage *msg, const void *data) {
if (!dbus_message_append_args(msg, CDBUS_TYPE_WINDOW, &val,
DBUS_TYPE_INVALID)) {
printf_errf("(): Failed to append argument.");
log_error("Failed to append argument.");
return false;
}
@ -383,7 +381,7 @@ cdbus_apdarg_enum(session_t *ps, DBusMessage *msg, const void *data) {
assert(data);
if (!dbus_message_append_args(msg, CDBUS_TYPE_ENUM, data,
DBUS_TYPE_INVALID)) {
printf_errf("(): Failed to append argument.");
log_error("Failed to append argument.");
return false;
}
@ -401,7 +399,7 @@ cdbus_apdarg_string(session_t *ps, DBusMessage *msg, const void *data) {
if (!dbus_message_append_args(msg, DBUS_TYPE_STRING, &str,
DBUS_TYPE_INVALID)) {
printf_errf("(): Failed to append argument.");
log_error("Failed to append argument.");
return false;
}
@ -422,10 +420,6 @@ cdbus_apdarg_wids(session_t *ps, DBusMessage *msg, const void *data) {
// Allocate memory for an array of window IDs
auto arr = ccalloc(count, cdbus_window_t);
if (!arr) {
printf_errf("(): Failed to allocate memory for window ID array.");
return false;
}
// Build the array
{
@ -443,7 +437,7 @@ cdbus_apdarg_wids(session_t *ps, DBusMessage *msg, const void *data) {
// Append arguments
if (!dbus_message_append_args(msg, DBUS_TYPE_ARRAY, CDBUS_TYPE_WINDOW,
&arr, count, DBUS_TYPE_INVALID)) {
printf_errf("(): Failed to append argument.");
log_error("Failed to append argument.");
free(arr);
return false;
}
@ -472,7 +466,7 @@ cdbus_signal(session_t *ps, const char *name,
msg = dbus_message_new_signal(CDBUS_OBJECT_NAME, CDBUS_INTERFACE_NAME,
name);
if (!msg) {
printf_errf("(): Failed to create D-Bus signal.");
log_error("Failed to create D-Bus signal.");
return false;
}
@ -484,7 +478,7 @@ cdbus_signal(session_t *ps, const char *name,
// Send the message and flush the connection
if (!dbus_connection_send(ps->dbus_conn, msg, NULL)) {
printf_errf("(): Failed to send D-Bus signal.");
log_error("Failed to send D-Bus signal.");
dbus_message_unref(msg);
return false;
}
@ -514,7 +508,7 @@ cdbus_reply(session_t *ps, DBusMessage *srcmsg,
// Create a reply
msg = dbus_message_new_method_return(srcmsg);
if (!msg) {
printf_errf("(): Failed to create D-Bus reply.");
log_error("Failed to create D-Bus reply.");
return false;
}
@ -526,7 +520,7 @@ cdbus_reply(session_t *ps, DBusMessage *srcmsg,
// Send the message and flush the connection
if (!dbus_connection_send(ps->dbus_conn, msg, NULL)) {
printf_errf("(): Failed to send D-Bus reply.");
log_error("Failed to send D-Bus reply.");
dbus_message_unref(msg);
return false;
}
@ -547,13 +541,13 @@ cdbus_reply(session_t *ps, DBusMessage *srcmsg,
static bool
cdbus_reply_errm(session_t *ps, DBusMessage *msg) {
if (!msg) {
printf_errf("(): Failed to create D-Bus reply.");
log_error("Failed to create D-Bus reply.");
return false;
}
// Send the message and flush the connection
if (!dbus_connection_send(ps->dbus_conn, msg, NULL)) {
printf_errf("(): Failed to send D-Bus reply.");
log_error("Failed to send D-Bus reply.");
dbus_message_unref(msg);
return false;
}
@ -579,7 +573,7 @@ cdbus_msg_get_arg(DBusMessage *msg, int count, const int type, void *pdest) {
DBusMessageIter iter = { };
if (!dbus_message_iter_init(msg, &iter)) {
printf_errf("(): Message has no argument.");
log_error("Message has no argument.");
return false;
}
@ -587,7 +581,7 @@ cdbus_msg_get_arg(DBusMessage *msg, int count, const int type, void *pdest) {
const int oldcount = count;
while (count) {
if (!dbus_message_iter_next(&iter)) {
printf_errf("(): Failed to find argument %d.", oldcount);
log_error("Failed to find argument %d.", oldcount);
return false;
}
--count;
@ -595,7 +589,7 @@ cdbus_msg_get_arg(DBusMessage *msg, int count, const int type, void *pdest) {
}
if (type != dbus_message_iter_get_arg_type(&iter)) {
printf_errf("(): Argument has incorrect type.");
log_error("Argument has incorrect type.");
return false;
}
@ -631,8 +625,7 @@ cdbus_process_win_get(session_t *ps, DBusMessage *msg) {
CDBUS_TYPE_WINDOW, &wid,
DBUS_TYPE_STRING, &target,
DBUS_TYPE_INVALID)) {
printf_errf("(): Failed to parse argument of \"win_get\" (%s).",
err.message);
log_error("Failed to parse argument of \"win_get\" (%s).", err.message);
dbus_error_free(&err);
return false;
}
@ -640,7 +633,7 @@ cdbus_process_win_get(session_t *ps, DBusMessage *msg) {
win *w = find_win(ps, wid);
if (!w) {
printf_errf("(): Window %#010x not found.", wid);
log_error("Window %#010x not found.", wid);
cdbus_reply_err(ps, msg, CDBUS_ERROR_BADWIN, CDBUS_ERROR_BADWIN_S, wid);
return true;
}
@ -717,7 +710,7 @@ cdbus_process_win_get(session_t *ps, DBusMessage *msg) {
cdbus_m_win_get_do(blur_background, cdbus_reply_bool);
#undef cdbus_m_win_get_do
printf_errf("(): " CDBUS_ERROR_BADTGT_S, target);
log_error(CDBUS_ERROR_BADTGT_S, target);
cdbus_reply_err(ps, msg, CDBUS_ERROR_BADTGT, CDBUS_ERROR_BADTGT_S, target);
return true;
@ -736,8 +729,7 @@ cdbus_process_win_set(session_t *ps, DBusMessage *msg) {
CDBUS_TYPE_WINDOW, &wid,
DBUS_TYPE_STRING, &target,
DBUS_TYPE_INVALID)) {
printf_errf("(): Failed to parse argument of \"win_set\" (%s).",
err.message);
log_error("(): Failed to parse argument of \"win_set\" (%s).", err.message);
dbus_error_free(&err);
return false;
}
@ -745,7 +737,7 @@ cdbus_process_win_set(session_t *ps, DBusMessage *msg) {
win *w = find_win(ps, wid);
if (!w) {
printf_errf("(): Window %#010x not found.", wid);
log_error("Window %#010x not found.", wid);
cdbus_reply_err(ps, msg, CDBUS_ERROR_BADWIN, CDBUS_ERROR_BADWIN_S, wid);
return true;
}
@ -792,7 +784,7 @@ cdbus_process_win_set(session_t *ps, DBusMessage *msg) {
}
#undef cdbus_m_win_set_do
printf_errf("(): " CDBUS_ERROR_BADTGT_S, target);
log_error(CDBUS_ERROR_BADTGT_S, target);
cdbus_reply_err(ps, msg, CDBUS_ERROR_BADTGT, CDBUS_ERROR_BADTGT_S, target);
return true;
@ -831,7 +823,7 @@ cdbus_process_find_win(session_t *ps, DBusMessage *msg) {
wid = w->id;
}
else {
printf_errf("(): " CDBUS_ERROR_BADTGT_S, target);
log_error(CDBUS_ERROR_BADTGT_S, target);
cdbus_reply_err(ps, msg, CDBUS_ERROR_BADTGT, CDBUS_ERROR_BADTGT_S, target);
return true;
@ -957,7 +949,7 @@ cdbus_process_opts_get(session_t *ps, DBusMessage *msg) {
#undef cdbus_m_opts_get_do
#undef cdbus_m_opts_get_stub
printf_errf("(): " CDBUS_ERROR_BADTGT_S, target);
log_error(CDBUS_ERROR_BADTGT_S, target);
cdbus_reply_err(ps, msg, CDBUS_ERROR_BADTGT, CDBUS_ERROR_BADTGT_S, target);
return true;
@ -1056,11 +1048,11 @@ cdbus_process_opts_set(session_t *ps, DBusMessage *msg) {
return false;
vsync_deinit(ps);
if (!parse_vsync(ps, val)) {
printf_errf("(): " CDBUS_ERROR_BADARG_S, 1, "Value invalid.");
log_error(CDBUS_ERROR_BADARG_S, 1, "Value invalid.");
cdbus_reply_err(ps, msg, CDBUS_ERROR_BADARG, CDBUS_ERROR_BADARG_S, 1, "Value invalid.");
}
else if (!vsync_init(ps)) {
printf_errf("(): " CDBUS_ERROR_CUSTOM_S, "Failed to initialize specified VSync method.");
log_error(CDBUS_ERROR_CUSTOM_S, "Failed to initialize specified VSync method.");
cdbus_reply_err(ps, msg, CDBUS_ERROR_CUSTOM, CDBUS_ERROR_CUSTOM_S, "Failed to initialize specified VSync method.");
}
else
@ -1083,7 +1075,7 @@ cdbus_process_opts_set(session_t *ps, DBusMessage *msg) {
#undef cdbus_m_opts_set_do
printf_errf("(): " CDBUS_ERROR_BADTGT_S, target);
log_error(CDBUS_ERROR_BADTGT_S, target);
cdbus_reply_err(ps, msg, CDBUS_ERROR_BADTGT, CDBUS_ERROR_BADTGT_S, target);
return true;
@ -1210,13 +1202,13 @@ cdbus_process(DBusConnection *c, DBusMessage *msg, void *ud) {
}
else {
if (DBUS_MESSAGE_TYPE_ERROR == dbus_message_get_type(msg)) {
printf_errf("(): Error message of path \"%s\" "
log_error("Error message of path \"%s\" "
"interface \"%s\", member \"%s\", error \"%s\"",
dbus_message_get_path(msg), dbus_message_get_interface(msg),
dbus_message_get_member(msg), dbus_message_get_error_name(msg));
}
else {
printf_errf("(): Illegal message of type \"%s\", path \"%s\" "
log_error("Illegal message of type \"%s\", path \"%s\" "
"interface \"%s\", member \"%s\"",
cdbus_repr_msgtype(msg), dbus_message_get_path(msg),
dbus_message_get_interface(msg), dbus_message_get_member(msg));

View File

@ -96,23 +96,18 @@ conv *gaussian_kernel(double r) {
c->size = size;
t = 0.0;
/*printf_errf("(): %f", r);*/
for (int y = 0; y < size; y++) {
for (int x = 0; x < size; x++) {
double g = gaussian(r, x - center, y - center);
t += g;
c->data[y * size + x] = g;
/*printf("%f ", c->data[y*size+x]);*/
}
/*printf("\n");*/
}
for (int y = 0; y < size; y++) {
for (int x = 0; x < size; x++) {
c->data[y * size + x] /= t;
/*printf("%f ", c->data[y*size+x]);*/
}
/*printf("\n");*/
}
return c;

102
src/log.c
View File

@ -3,6 +3,7 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <sys/uio.h>
#include <time.h>
#include <unistd.h>
@ -31,6 +32,7 @@ struct log_target {
struct log_ops {
void (*write)(struct log_target *, const char *, size_t);
void (*writev)(struct log_target *, const struct iovec *, int vcnt);
void (*destroy)(struct log_target *);
/// Additional strings to print around the log_level string
@ -38,9 +40,22 @@ struct log_ops {
const char *(*colorize_end)(enum log_level);
};
/// Helper function for writing null terminated strings
static void log_strwrite(struct log_target *tgt, const char *str) {
return tgt->ops->write(tgt, str, strlen(str));
/// Fallback writev for targets don't implement it
static attr_unused void
log_default_writev(struct log_target *tgt, const struct iovec *vec, int vcnt) {
size_t total = 0;
for (int i = 0; i < vcnt; i++) {
total += vec[i].iov_len;
}
char *buf = ccalloc(total, char);
total = 0;
for (int i = 0; i < vcnt; i++) {
memcpy(buf + total, vec[i].iov_base, vec[i].iov_len);
total += vec[i].iov_len;
}
tgt->ops->write(tgt, buf, total);
free(buf);
}
static attr_const const char *log_level_to_string(enum log_level level) {
@ -77,6 +92,7 @@ struct log *log_new(void) {
}
void log_add_target(struct log *l, struct log_target *tgt) {
assert(tgt->ops->writev);
tgt->next = l->head;
l->head = tgt;
}
@ -112,56 +128,61 @@ attr_printf(4, 5) void log_printf(struct log *l, int level, const char *func,
va_list args;
va_start(args, fmt);
size_t len = vasprintf(&buf, fmt, args);
size_t blen = vasprintf(&buf, fmt, args);
va_end(args);
if (!buf)
return;
struct timespec ts;
timespec_get(&ts, TIME_UTC);
auto tm = localtime(&ts.tv_sec);
char time_buf[100];
strftime(time_buf, sizeof time_buf, "%x %T", tm);
if (!buf)
char *time = NULL;
size_t tlen = asprintf(&time, "%s.%03ld", time_buf, ts.tv_nsec / 1000000);
if (!time) {
free(buf);
return;
}
const char *log_level_str = log_level_to_string(level);
char *common = NULL;
size_t plen = asprintf(&common, "[ %s.%03ld %s %s ] ", time_buf,
ts.tv_nsec / 1000000, func, log_level_str);
if (!common)
return;
common = crealloc(common, plen + len + 2);
strcpy(common + plen, buf);
strcpy(common + plen + len, "\n");
size_t llen = strlen(log_level_str);
size_t flen = strlen(func);
struct log_target *head = l->head;
while (head) {
const char *p = "", *s = "";
size_t plen = 0, slen = 0;
if (head->ops->colorize_begin) {
// construct target specific prefix
const char *p = head->ops->colorize_begin(level);
const char *s = "";
if (head->ops->colorize_end)
p = head->ops->colorize_begin(level);
plen = strlen(p);
if (head->ops->colorize_end) {
s = head->ops->colorize_end(level);
char *str = NULL;
size_t plen2 =
asprintf(&str, "[ %s.%03ld %s %s%s%s ] ", time_buf,
ts.tv_nsec / 1000000, func, p, log_level_str, s);
if (!str) {
log_strwrite(head, common);
continue;
slen = strlen(s);
}
str = crealloc(str, plen2 + len + 2);
strcpy(str + plen2, buf);
strcpy(str + plen2 + len, "\n");
log_strwrite(head, str);
free(str);
} else {
log_strwrite(head, common);
}
head->ops->writev(
head,
(struct iovec[]){{.iov_base = "[ ", .iov_len = 2},
{.iov_base = time, .iov_len = tlen},
{.iov_base = " ", .iov_len = 1},
{.iov_base = (void *)func, .iov_len = flen},
{.iov_base = " ", .iov_len = 1},
{.iov_base = (void *)p, .iov_len = plen},
{.iov_base = (void *)log_level_str, .iov_len = llen},
{.iov_base = (void *)s, .iov_len = slen},
{.iov_base = " ] ", .iov_len = 3},
{.iov_base = buf, .iov_len = blen},
{.iov_base = "\n", .iov_len = 1}},
11);
head = head->next;
}
free(common);
free(time);
free(buf);
}
/// A trivial deinitializer that simply frees the memory
@ -179,12 +200,19 @@ struct log_target *null_logger_new(void) {
return &null_logger_target;
}
static void null_logger_write(struct log_target *tgt, const char *str, size_t len) {
static void null_logger_write(struct log_target *attr_unused tgt,
const char *attr_unused str, size_t attr_unused len) {
return;
}
static void null_logger_writev(struct log_target *attr_unused tgt,
const struct iovec *attr_unused vec, int attr_unused vcnt) {
return;
}
static const struct log_ops null_logger_ops = {
.write = null_logger_write,
.writev = null_logger_writev,
};
/// A file based logger that writes to file (or stdout/stderr)
@ -199,6 +227,12 @@ void file_logger_write(struct log_target *tgt, const char *str, size_t len) {
fwrite(str, 1, len, f->f);
}
void file_logger_writev(struct log_target *tgt, const struct iovec *vec, int vcnt) {
auto f = (struct file_logger *)tgt;
fflush(f->f);
writev(fileno(f->f), vec, vcnt);
}
void file_logger_destroy(struct log_target *tgt) {
auto f = (struct file_logger *)tgt;
fclose(f->f);
@ -225,6 +259,7 @@ const char *terminal_colorize_end(enum log_level level) {
static const struct log_ops file_logger_ops = {
.write = file_logger_write,
.writev = file_logger_writev,
.destroy = file_logger_destroy,
};
@ -282,6 +317,7 @@ void glx_string_marker_logger_write(struct log_target *tgt, const char *str, siz
static const struct log_ops glx_string_marker_logger_ops = {
.write = glx_string_marker_logger_write,
.writev = log_default_writev,
.destroy = logger_trivial_destroy,
};

View File

@ -31,26 +31,6 @@ enum log_level {
#define log_error(x, ...) LOG(ERROR, x, ##__VA_ARGS__)
#define log_fatal(x, ...) LOG(FATAL, x, ##__VA_ARGS__)
/// Print out an error message.
#define printf_err(format, ...) log_error(format, ##__VA_ARGS__)
/// Print out an error message with function name.
#define printf_errf(format, ...) log_error(format, ##__VA_ARGS__)
/// Print out an error message with function name, and quit with a
/// specific exit code.
#define printf_errfq(code, format, ...) \
{ \
log_error(format, ##__VA_ARGS__); \
exit(code); \
}
/// Print out a debug message.
#define printf_dbg(format, ...) log_debug(format, ##__VA_ARGS__)
/// Print out a debug message with function name.
#define printf_dbgf(format, ...) log_debug(format, ##__VA_ARGS__)
struct log;
struct log_target;

View File

@ -4,7 +4,7 @@ deps = [
dependency('xcb', version: '>=1.9.2'),
]
srcs = [ files('compton.c', 'win.c', 'c2.c', 'x.c', 'config.c', 'vsync.c',
srcs = [ files('compton.c', 'win.c', 'c2.c', 'x.c', 'config.c', 'vsync.c', 'utils.c',
'diagnostic.c', 'string_utils.c', 'render.c', 'kernel.c', 'log.c')]
cflags = []

View File

@ -74,9 +74,11 @@ glx_update_fbconfig_bydepth(session_t *ps, int depth, glx_fbconfig_t *pfbcfg) {
// Compare new FBConfig with current one
if (glx_cmp_fbconfig(ps, ps->psglx->fbconfigs[depth], pfbcfg) < 0) {
#ifdef DEBUG_GLX
printf_dbgf("(%d): %#x overrides %#x, target %#x.\n", depth, (unsigned) pfbcfg->cfg, (ps->psglx->fbconfigs[depth] ? (unsigned) ps->psglx->fbconfigs[depth]->cfg: 0), pfbcfg->texture_tgts);
#endif
log_trace("(depth %d): %p overrides %p, target %#x.", depth,
pfbcfg->cfg,
ps->psglx->fbconfigs[depth] ? ps->psglx->fbconfigs[depth]->cfg:
0,
pfbcfg->texture_tgts);
if (!ps->psglx->fbconfigs[depth]) {
ps->psglx->fbconfigs[depth] = cmalloc(glx_fbconfig_t);
}
@ -113,11 +115,11 @@ glx_update_fbconfig(session_t *ps) {
if (Success != glXGetFBConfigAttrib(ps->dpy, *pcur, GLX_BUFFER_SIZE, &depth)
|| Success != glXGetFBConfigAttrib(ps->dpy, *pcur, GLX_ALPHA_SIZE, &depth_alpha)) {
printf_errf("(): Failed to retrieve buffer size and alpha size of FBConfig %d.", id);
log_error("Failed to retrieve buffer size and alpha size of FBConfig %d.", id);
continue;
}
if (Success != glXGetFBConfigAttrib(ps->dpy, *pcur, GLX_BIND_TO_TEXTURE_TARGETS_EXT, &fbinfo.texture_tgts)) {
printf_errf("(): Failed to retrieve BIND_TO_TEXTURE_TARGETS_EXT of FBConfig %d.", id);
log_error("Failed to retrieve BIND_TO_TEXTURE_TARGETS_EXT of FBConfig %d.", id);
continue;
}
@ -126,7 +128,7 @@ glx_update_fbconfig(session_t *ps) {
XVisualInfo *pvi = glXGetVisualFromFBConfig(ps->dpy, *pcur);
if (!pvi) {
// On nvidia-drivers-325.08 this happens slightly too often...
// printf_errf("(): Failed to retrieve X Visual of FBConfig %d.", id);
// log_error("Failed to retrieve X Visual of FBConfig %d.", id);
continue;
}
visualdepth = pvi->depth;
@ -163,19 +165,16 @@ glx_update_fbconfig(session_t *ps) {
// Sanity checks
if (!ps->psglx->fbconfigs[ps->depth]) {
printf_errf("(): No FBConfig found for default depth %d.", ps->depth);
log_error("No FBConfig found for default depth %d.", ps->depth);
return false;
}
if (!ps->psglx->fbconfigs[32]) {
printf_errf("(): No FBConfig found for depth 32. Expect crazy things.");
log_error("No FBConfig found for depth 32. Expect crazy things.");
}
#ifdef DEBUG_GLX
printf_dbgf("(): %d-bit: %#3x, 32-bit: %#3x\n",
ps->depth, (int) ps->psglx->fbconfigs[ps->depth]->cfg,
(int) ps->psglx->fbconfigs[32]->cfg);
#endif
log_trace("%d-bit: %p, 32-bit: %p", ps->depth, ps->psglx->fbconfigs[ps->depth]->cfg,
ps->psglx->fbconfigs[32]->cfg);
return true;
}
@ -208,7 +207,7 @@ static void
glx_debug_msg_callback(GLenum source, GLenum type,
GLuint id, GLenum severity, GLsizei length, const GLchar *message,
GLvoid *userParam) {
printf_dbgf("(): source 0x%04X, type 0x%04X, id %u, severity 0x%0X, \"%s\"\n",
log_trace("source 0x%04X, type 0x%04X, id %u, severity 0x%0X, \"%s\"",
source, type, id, severity, message);
}
#endif
@ -226,7 +225,7 @@ glx_init(session_t *ps, bool need_render) {
if (glXQueryExtension(ps->dpy, &ps->glx_event, &ps->glx_error))
ps->glx_exists = true;
else {
printf_errf("(): No GLX extension.");
log_error("No GLX extension.");
goto glx_init_end;
}
}
@ -234,7 +233,7 @@ glx_init(session_t *ps, bool need_render) {
// Get XVisualInfo
pvis = get_visualinfo_from_visual(ps, ps->vis);
if (!pvis) {
printf_errf("(): Failed to acquire XVisualInfo for current visual.");
log_error("Failed to acquire XVisualInfo for current visual.");
goto glx_init_end;
}
@ -242,13 +241,13 @@ glx_init(session_t *ps, bool need_render) {
if (need_render) {
int value = 0;
if (Success != glXGetConfig(ps->dpy, pvis, GLX_USE_GL, &value) || !value) {
printf_errf("(): Root visual is not a GL visual.");
log_error("Root visual is not a GL visual.");
goto glx_init_end;
}
if (Success != glXGetConfig(ps->dpy, pvis, GLX_DOUBLEBUFFER, &value)
|| !value) {
printf_errf("(): Root visual is not a double buffered GL visual.");
log_error("Root visual is not a double buffered GL visual.");
goto glx_init_end;
}
}
@ -281,8 +280,7 @@ glx_init(session_t *ps, bool need_render) {
{
GLXFBConfig fbconfig = get_fbconfig_from_visualinfo(ps, pvis);
if (!fbconfig) {
printf_errf("(): Failed to get GLXFBConfig for root visual %#lx.",
pvis->visualid);
log_error("Failed to get GLXFBConfig for root visual %#lx.", pvis->visualid);
goto glx_init_end;
}
@ -290,7 +288,7 @@ glx_init(session_t *ps, bool need_render) {
(f_glXCreateContextAttribsARB)
glXGetProcAddress((const GLubyte *) "glXCreateContextAttribsARB");
if (!p_glXCreateContextAttribsARB) {
printf_errf("(): Failed to get glXCreateContextAttribsARB().");
log_error("Failed to get glXCreateContextAttribsARB().");
goto glx_init_end;
}
@ -304,13 +302,13 @@ glx_init(session_t *ps, bool need_render) {
#endif
if (!psglx->context) {
printf_errf("(): Failed to get GLX context.");
log_error("Failed to get GLX context.");
goto glx_init_end;
}
// Attach GLX context
if (!glXMakeCurrent(ps->dpy, get_tgt_window(ps), psglx->context)) {
printf_errf("(): Failed to attach GLX context.");
log_error("Failed to attach GLX context.");
goto glx_init_end;
}
@ -320,7 +318,7 @@ glx_init(session_t *ps, bool need_render) {
(f_DebugMessageCallback)
glXGetProcAddress((const GLubyte *) "glDebugMessageCallback");
if (!p_DebugMessageCallback) {
printf_errf("(): Failed to get glDebugMessageCallback(0.");
log_error("Failed to get glDebugMessageCallback(0.");
goto glx_init_end;
}
p_DebugMessageCallback(glx_debug_msg_callback, ps);
@ -336,7 +334,7 @@ glx_init(session_t *ps, bool need_render) {
GLint val = 0;
glGetIntegerv(GL_STENCIL_BITS, &val);
if (!val) {
printf_errf("(): Target window doesn't have stencil buffer.");
log_error("Target window doesn't have stencil buffer.");
goto glx_init_end;
}
}
@ -361,7 +359,7 @@ glx_init(session_t *ps, bool need_render) {
psglx->glXReleaseTexImageProc = (f_ReleaseTexImageEXT)
glXGetProcAddress((const GLubyte *) "glXReleaseTexImageEXT");
if (!psglx->glXBindTexImageProc || !psglx->glXReleaseTexImageProc) {
printf_errf("(): Failed to acquire glXBindTexImageEXT() / glXReleaseTexImageEXT().");
log_error("Failed to acquire glXBindTexImageEXT() / glXReleaseTexImageEXT().");
goto glx_init_end;
}
}
@ -468,12 +466,12 @@ glx_reinit(session_t *ps, bool need_render) {
glx_destroy(ps);
if (!glx_init(ps, need_render)) {
printf_errf("(): Failed to initialize GLX.");
log_error("Failed to initialize GLX.");
return false;
}
if (!vsync_init(ps)) {
printf_errf("(): Failed to initialize VSync.");
log_error("Failed to initialize VSync.");
return false;
}
@ -508,8 +506,8 @@ glx_init_blur(session_t *ps) {
GLuint fbo = 0;
glGenFramebuffers(1, &fbo);
if (!fbo) {
printf_errf("(): Failed to generate Framebuffer. Cannot do "
"multi-pass blur with GLX backend.");
log_error("Failed to generate Framebuffer. Cannot do multi-pass blur with GLX"
" backend.");
return false;
}
glDeleteFramebuffers(1, &fbo);
@ -572,11 +570,6 @@ glx_init_blur(session_t *ps) {
strlen(FRAG_SHADER_BLUR_SUFFIX) +
strlen(texture_func) + 12 + 1;
char *shader_str = ccalloc(len, char);
if (!shader_str) {
printf_errf("(): Failed to allocate %d bytes for shader string.", len);
return false;
}
{
char *pc = shader_str;
sprintf(pc, FRAG_SHADER_BLUR_PREFIX, extension, sampler_type);
pc += strlen(pc);
@ -599,20 +592,19 @@ glx_init_blur(session_t *ps) {
sprintf(pc, FRAG_SHADER_BLUR_SUFFIX, texture_func, sum);
assert(strlen(shader_str) < len);
}
ppass->frag_shader = glx_create_shader(GL_FRAGMENT_SHADER, shader_str);
free(shader_str);
}
if (!ppass->frag_shader) {
printf_errf("(): Failed to create fragment shader %d.", i);
log_error("Failed to create fragment shader %d.", i);
return false;
}
// Build program
ppass->prog = glx_create_program(&ppass->frag_shader, 1);
if (!ppass->prog) {
printf_errf("(): Failed to create GLSL program.");
log_error("Failed to create GLSL program.");
return false;
}
@ -620,7 +612,7 @@ glx_init_blur(session_t *ps) {
#define P_GET_UNIFM_LOC(name, target) { \
ppass->target = glGetUniformLocation(ppass->prog, name); \
if (ppass->target < 0) { \
printf_errf("(): Failed to get location of %d-th uniform '" name "'. Might be troublesome.", i); \
log_error("Failed to get location of %d-th uniform '" name "'. Might be troublesome.", i); \
} \
}
@ -657,7 +649,7 @@ glx_load_prog_main(session_t *ps,
// Build program
pprogram->prog = glx_create_program_from_str(vshader_str, fshader_str);
if (!pprogram->prog) {
printf_errf("(): Failed to create GLSL program.");
log_error("Failed to create GLSL program.");
return false;
}
@ -665,7 +657,7 @@ glx_load_prog_main(session_t *ps,
#define P_GET_UNIFM_LOC(name, target) { \
pprogram->target = glGetUniformLocation(pprogram->prog, name); \
if (pprogram->target < 0) { \
printf_errf("(): Failed to get location of uniform '" name "'. Might be troublesome."); \
log_error("Failed to get location of uniform '" name "'. Might be troublesome."); \
} \
}
P_GET_UNIFM_LOC("opacity", unifm_opacity);
@ -688,7 +680,7 @@ glx_bind_pixmap(session_t *ps, glx_texture_t **pptex, xcb_pixmap_t pixmap,
return true;
if (!pixmap) {
printf_errf("(%#010x): Binding to an empty pixmap. This can't work.", pixmap);
log_error("Binding to an empty pixmap %#010x. This can't work.", pixmap);
return false;
}
@ -730,11 +722,11 @@ glx_bind_pixmap(session_t *ps, glx_texture_t **pptex, xcb_pixmap_t pixmap,
unsigned rbdwid = 0;
if (!XGetGeometry(ps->dpy, pixmap, &rroot, &rx, &ry,
&width, &height, &rbdwid, &depth)) {
printf_errf("(%#010x): Failed to query Pixmap info.", pixmap);
log_error("Failed to query info of pixmap %#010x.", pixmap);
return false;
}
if (depth > OPENGL_MAX_DEPTH) {
printf_errf("(%d): Requested depth higher than %d.", depth,
log_error("Requested depth %d higher than %d.", depth,
OPENGL_MAX_DEPTH);
return false;
}
@ -742,7 +734,7 @@ glx_bind_pixmap(session_t *ps, glx_texture_t **pptex, xcb_pixmap_t pixmap,
const glx_fbconfig_t *pcfg = ps->psglx->fbconfigs[depth];
if (!pcfg) {
printf_errf("(%d): Couldn't find FBConfig with requested depth.", depth);
log_error("Couldn't find FBConfig with requested depth %d.", depth);
return false;
}
@ -760,10 +752,8 @@ glx_bind_pixmap(session_t *ps, glx_texture_t **pptex, xcb_pixmap_t pixmap,
else
tex_tgt = GLX_TEXTURE_2D_EXT;
#ifdef DEBUG_GLX
printf_dbgf("(): depth %d, tgt %#x, rgba %d\n", depth, tex_tgt,
log_debug("depth %d, tgt %#x, rgba %d", depth, tex_tgt,
(GLX_TEXTURE_FORMAT_RGBA_EXT == pcfg->texture_fmt));
#endif
GLint attrs[] = {
GLX_TEXTURE_FORMAT_EXT,
@ -783,7 +773,7 @@ glx_bind_pixmap(session_t *ps, glx_texture_t **pptex, xcb_pixmap_t pixmap,
ptex->y_inverted = pcfg->y_inverted;
}
if (!ptex->glpixmap) {
printf_errf("(): Failed to allocate GLX pixmap.");
log_error("Failed to allocate GLX pixmap.");
return false;
}
@ -807,7 +797,7 @@ glx_bind_pixmap(session_t *ps, glx_texture_t **pptex, xcb_pixmap_t pixmap,
ptex->texture = texture;
}
if (!ptex->texture) {
printf_errf("(): Failed to allocate texture.");
log_error("Failed to allocate texture.");
return false;
}
@ -1003,9 +993,7 @@ glx_blur_dst(session_t *ps, int dx, int dy, int width, int height, float z,
pbc = &ibc;
int mdx = dx, mdy = dy, mwidth = width, mheight = height;
#ifdef DEBUG_GLX
printf_dbgf("(): %d, %d, %d, %d\n", mdx, mdy, mwidth, mheight);
#endif
//log_trace("%d, %d, %d, %d", mdx, mdy, mwidth, mheight);
/*
if (ps->o.resize_damage > 0) {
@ -1050,11 +1038,11 @@ glx_blur_dst(session_t *ps, int dx, int dy, int width, int height, float z,
const GLuint fbo = pbc->fbo;
if (!tex_scr || (more_passes && !tex_scr2)) {
printf_errf("(): Failed to allocate texture.");
log_error("Failed to allocate texture.");
goto glx_blur_dst_end;
}
if (more_passes && !fbo) {
printf_errf("(): Failed to allocate framebuffer.");
log_error("Failed to allocate framebuffer.");
goto glx_blur_dst_end;
}
@ -1104,7 +1092,7 @@ glx_blur_dst(session_t *ps, int dx, int dy, int width, int height, float z,
glDrawBuffers(1, DRAWBUFS);
if (glCheckFramebufferStatus(GL_FRAMEBUFFER)
!= GL_FRAMEBUFFER_COMPLETE) {
printf_errf("(): Framebuffer attachment failed.");
log_error("Framebuffer attachment failed.");
goto glx_blur_dst_end;
}
}
@ -1147,9 +1135,8 @@ glx_blur_dst(session_t *ps, int dx, int dy, int width, int height, float z,
GLfloat rdxe = rdx + (crect.x2 - crect.x1);
GLfloat rdye = rdy - (crect.y2 - crect.y1);
#ifdef DEBUG_GLX
printf_dbgf("(): %f, %f, %f, %f -> %f, %f, %f, %f\n", rx, ry, rxe, rye, rdx, rdy, rdxe, rdye);
#endif
//log_trace("%f, %f, %f, %f -> %f, %f, %f, %f", rx, ry, rxe, rye, rdx,
// rdy, rdxe, rdye);
glTexCoord2f(rx, ry);
glVertex3f(rdx, rdy, z);
@ -1240,7 +1227,7 @@ glx_render(session_t *ps, const glx_texture_t *ptex,
const region_t *reg_tgt, const glx_prog_main_t *pprogram
) {
if (!ptex || !ptex->texture) {
printf_errf("(): Missing texture.");
log_error("Missing texture.");
return false;
}
@ -1354,9 +1341,8 @@ glx_render(session_t *ps, const glx_texture_t *ptex,
glUniform1i(pprogram->unifm_tex, 0);
}
#ifdef DEBUG_GLX
printf_dbgf("(): Draw: %d, %d, %d, %d -> %d, %d (%d, %d) z %d\n", x, y, width, height, dx, dy, ptex->width, ptex->height, z);
#endif
//log_trace("Draw: %d, %d, %d, %d -> %d, %d (%d, %d) z %d", x, y, width, height,
// dx, dy, ptex->width, ptex->height, z);
// Bind texture
glBindTexture(ptex->target, ptex->texture);
@ -1394,9 +1380,8 @@ glx_render(session_t *ps, const glx_texture_t *ptex,
rye = 1.0 - rye;
}
#ifdef DEBUG_GLX
printf_dbgf("(): Rect %d: %f, %f, %f, %f -> %d, %d, %d, %d\n", ri, rx, ry, rxe, rye, rdx, rdy, rdxe, rdye);
#endif
//log_trace("Rect %d: %f, %f, %f, %f -> %d, %d, %d, %d", ri, rx, ry, rxe, rye,
// rdx, rdy, rdxe, rdye);
#define P_TEXCOORD(cx, cy) { \
if (dual_texture) { \
@ -1470,15 +1455,12 @@ glx_take_screenshot(session_t *ps, int *out_length) {
GLuint
glx_create_shader(GLenum shader_type, const char *shader_str) {
#ifdef DEBUG_GLX_GLSL
printf("glx_create_shader(): ===\n%s\n===\n", shader_str);
fflush(stdout);
#endif
log_trace("glx_create_shader(): ===\n%s\n===", shader_str);
bool success = false;
GLuint shader = glCreateShader(shader_type);
if (!shader) {
printf_errf("(): Failed to create shader with type %#x.", shader_type);
log_error("Failed to create shader with type %#x.", shader_type);
goto glx_create_shader_end;
}
glShaderSource(shader, 1, &shader_str, NULL);
@ -1494,8 +1476,7 @@ glx_create_shader(GLenum shader_type, const char *shader_str) {
if (log_len) {
char log[log_len + 1];
glGetShaderInfoLog(shader, log_len, NULL, log);
printf_errf("(): Failed to compile shader with type %d: %s",
shader_type, log);
log_error("Failed to compile shader with type %d: %s", shader_type, log);
}
goto glx_create_shader_end;
}
@ -1517,7 +1498,7 @@ glx_create_program(const GLuint * const shaders, int nshaders) {
bool success = false;
GLuint program = glCreateProgram();
if (!program) {
printf_errf("(): Failed to create program.");
log_error("Failed to create program.");
goto glx_create_program_end;
}
@ -1535,7 +1516,7 @@ glx_create_program(const GLuint * const shaders, int nshaders) {
if (log_len) {
char log[log_len + 1];
glGetProgramInfoLog(program, log_len, NULL, log);
printf_errf("(): Failed to link program: %s", log);
log_error("Failed to link program: %s", log);
}
goto glx_create_program_end;
}
@ -1570,7 +1551,6 @@ glx_create_program_from_str(const char *vert_shader_str,
if (frag_shader_str)
frag_shader = glx_create_shader(GL_FRAGMENT_SHADER, frag_shader_str);
{
GLuint shaders[2];
unsigned int count = 0;
if (vert_shader)
@ -1580,7 +1560,6 @@ glx_create_program_from_str(const char *vert_shader_str,
assert(count <= sizeof(shaders) / sizeof(shaders[0]));
if (count)
prog = glx_create_program(shaders, count);
}
if (vert_shader)
glDeleteShader(vert_shader);

View File

@ -50,14 +50,14 @@ glx_check_err_(session_t *ps, const char *func, int line) {
GLenum err = GL_NO_ERROR;
while (GL_NO_ERROR != (err = glGetError())) {
print_timestamp(ps);
printf("%s():%d: GLX error ", func, line);
const char *errtext = glx_dump_err_str(err);
if (errtext) {
printf_dbg("%s\n", errtext);
log_printf(tls_logger, LOG_LEVEL_ERROR, func, "GLX error at line %d: %s", line,
errtext);
}
else {
printf_dbg("%d\n", err);
log_printf(tls_logger, LOG_LEVEL_ERROR, func, "GLX error at line %d: %d", line,
err);
}
}
}
@ -96,13 +96,13 @@ static inline bool
glx_hasglxext(session_t *ps, const char *ext) {
const char *glx_exts = glXQueryExtensionsString(ps->dpy, ps->scr);
if (!glx_exts) {
printf_errf("(): Failed get GLX extension list.");
log_error("Failed get GLX extension list.");
return false;
}
bool found = wd_is_in_str(glx_exts, ext);
if (!found)
printf_errf("(): Missing GLX extension %s.", ext);
log_info("Missing GLX extension %s.", ext);
return found;
}
@ -114,13 +114,13 @@ static inline bool
glx_hasglext(session_t *ps, const char *ext) {
const char *gl_exts = (const char *) glGetString(GL_EXTENSIONS);
if (!gl_exts) {
printf_errf("(): Failed get GL extension list.");
log_error("Failed get GL extension list.");
return false;
}
bool found = wd_is_in_str(gl_exts, ext);
if (!found)
printf_errf("(): Missing GL extension %s.", ext);
log_info("Missing GL extension %s.", ext);
return found;
}

View File

@ -4,7 +4,9 @@
#include <xcb/xcb.h>
#include <pixman.h>
#include <stdio.h>
#include "utils.h"
#include "log.h"
typedef struct pixman_region32 pixman_region32_t;
typedef struct pixman_box32 pixman_box32_t;
@ -23,9 +25,9 @@ static inline void
dump_region(const region_t *x) {
int nrects;
const rect_t *rects = pixman_region32_rectangles((region_t *)x, &nrects);
fprintf(stderr, "nrects: %d\n", nrects);
log_trace("nrects: %d", nrects);
for (int i = 0; i < nrects; i++)
fprintf(stderr, "(%d, %d) - (%d, %d)\n", rects[i].x1, rects[i].y1, rects[i].x2, rects[i].y2);
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

View File

@ -51,8 +51,7 @@ static inline void xrfilter_reset(session_t *ps, xcb_render_picture_t p) {
#undef FILTER
}
static inline void attr_nonnull(1, 2)
set_tgt_clip(session_t *ps, region_t *reg) {
static inline void attr_nonnull(1, 2) set_tgt_clip(session_t *ps, region_t *reg) {
switch (ps->o.backend) {
case BKEND_XRENDER:
case BKEND_XR_GLX_HYBRID:
@ -187,12 +186,12 @@ void paint_one(session_t *ps, win *w, const region_t *reg_paint) {
// causing the jittering issue M4he reported in #7.
if (!paint_bind_tex(ps, &w->paint, 0, 0, 0,
(!ps->o.glx_no_rebind_pixmap && w->pixmap_damaged))) {
printf_errf("(%#010lx): Failed to bind texture. Expect troubles.", w->id);
log_error("Failed to bind texture for window %#010lx.", w->id);
}
w->pixmap_damaged = false;
if (!paint_isvalid(ps, &w->paint)) {
printf_errf("(%#010lx): Missing painting data. This is a bad sign.", w->id);
log_error("Window %#010lx is missing painting data.", w->id);
return;
}
@ -380,14 +379,14 @@ static bool get_root_tile(session_t *ps) {
// Make sure the pixmap we got is valid
if (pixmap && !x_validate_pixmap(ps, pixmap))
pixmap = None;
pixmap = XCB_NONE;
// Create a pixmap if there isn't any
if (!pixmap) {
pixmap = x_create_pixmap(ps, ps->depth, ps->root, 1, 1);
if (pixmap == XCB_NONE) {
fprintf(stderr, "Failed to create some pixmap\n");
exit(1);
log_error("Failed to create pixmaps for root tile.");
return false;
}
fill = true;
}
@ -429,8 +428,10 @@ static bool get_root_tile(session_t *ps) {
* Paint root window content.
*/
static void paint_root(session_t *ps, const region_t *reg_paint) {
if (!ps->root_tile_paint.pixmap)
get_root_tile(ps);
// If there is no root tile pixmap, try getting one.
// If that fails, give up.
if (!ps->root_tile_paint.pixmap && !get_root_tile(ps))
return;
paint_region(ps, NULL, 0, 0, ps->root_width, ps->root_height, 1.0, reg_paint,
ps->root_tile_paint.pict);
@ -451,7 +452,7 @@ static xcb_image_t *make_shadow(session_t *ps, double opacity, int width, int he
XCB_IMAGE_FORMAT_Z_PIXMAP, 8, 0, 0, NULL);
if (!ximage) {
printf_errf("(): failed to create an X image");
log_error("failed to create an X image");
return 0;
}
@ -556,7 +557,7 @@ static xcb_image_t *make_shadow(session_t *ps, double opacity, int width, int he
static bool win_build_shadow(session_t *ps, win *w, double opacity) {
const int width = w->widthb;
const int height = w->heightb;
// printf_errf("(): building shadow for %s %d %d", w->name, width, height);
// log_trace("(): building shadow for %s %d %d", w->name, width, height);
xcb_image_t *shadow_image = NULL;
xcb_pixmap_t shadow_pixmap = None, shadow_pixmap_argb = None;
@ -565,7 +566,7 @@ static bool win_build_shadow(session_t *ps, win *w, double opacity) {
shadow_image = make_shadow(ps, opacity, width, height);
if (!shadow_image) {
printf_errf("(): failed to make shadow");
log_error("failed to make shadow");
return None;
}
@ -575,7 +576,7 @@ static bool win_build_shadow(session_t *ps, win *w, double opacity) {
x_create_pixmap(ps, 32, ps->root, shadow_image->width, shadow_image->height);
if (!shadow_pixmap || !shadow_pixmap_argb) {
printf_errf("(): failed to create shadow pixmaps");
log_error("failed to create shadow pixmaps");
goto shadow_picture_err;
}
@ -634,7 +635,7 @@ static inline void win_paint_shadow(session_t *ps, win *w, region_t *reg_paint)
paint_bind_tex(ps, &w->shadow_paint, 0, 0, 32, false);
if (!paint_isvalid(ps, &w->shadow_paint)) {
printf_errf("(%#010lx): Missing shadow data.", w->id);
log_error("Window %#010lx is missing shadow data.", w->id);
return;
}
@ -680,7 +681,7 @@ xr_blur_dst(session_t *ps, xcb_render_picture_t tgt_buffer, int x, int y, int wi
xcb_render_picture_t tmp_picture = x_create_picture(ps, wid, hei, NULL, 0, NULL);
if (!tmp_picture) {
printf_errf("(): Failed to build intermediate Picture.");
log_error("Failed to build intermediate Picture.");
return false;
}
@ -768,11 +769,6 @@ win_blur_background(session_t *ps, win *w, xcb_render_picture_t tgt_buffer,
// Allocate cache space if needed
if (!kern_dst) {
kern_dst = ccalloc(kwid * khei + 2, xcb_render_fixed_t);
if (!kern_dst) {
printf_errf("(): Failed to allocate memory "
"for blur kernel.");
return;
}
ps->blur_kerns_cache[i] = kern_dst;
}
@ -842,8 +838,8 @@ void paint_all(session_t *ps, region_t *region, const region_t *region_real, win
ps->tgt_buffer.pixmap = x_create_pixmap(
ps, ps->depth, ps->root, ps->root_width, ps->root_height);
if (ps->tgt_buffer.pixmap == XCB_NONE) {
fprintf(stderr, "Failed to allocate a screen-sized "
"pixmap\n");
log_fatal("Failed to allocate a screen-sized pixmap for"
"painting");
exit(1);
}
}
@ -883,7 +879,7 @@ void paint_all(session_t *ps, region_t *region, const region_t *region_real, win
// Lazy shadow building
if (!w->shadow_paint.pixmap)
if (!win_build_shadow(ps, w, 1))
printf_errf("(): build shadow failed");
log_error("build shadow failed");
// Shadow doesn't need to be painted underneath the body of
// the window Because no one can see it
@ -1055,17 +1051,14 @@ void paint_all(session_t *ps, region_t *region, const region_t *region_real, win
#endif
#ifdef DEBUG_REPAINT
print_timestamp(ps);
struct timespec now = get_time_timespec();
struct timespec diff = {0};
timespec_subtract(&diff, &now, &last_paint);
printf("[ %5ld:%09ld ] ", diff.tv_sec, diff.tv_nsec);
log_trace("[ %5ld:%09ld ] ", diff.tv_sec, diff.tv_nsec);
last_paint = now;
printf("paint:");
log_trace("paint:");
for (win *w = t; w; w = w->prev_trans)
printf(" %#010lx", w->id);
putchar('\n');
fflush(stdout);
log_trace(" %#010lx", w->id);
#endif
// Check if fading is finished on all painted windows
@ -1101,7 +1094,7 @@ static bool xr_init_blur(session_t *ps) {
// Turn features off if any required filter is not present
if (!ps->xrfilter_convolution_exists) {
printf_errf("(): Xrender convolution filter "
log_error("Xrender convolution filter "
"unsupported by your X server. "
"Background blur is not possible.");
return false;
@ -1174,7 +1167,6 @@ static void presum_gaussian(session_t *ps, conv *map) {
const int r = ps->cgsize + 1; // radius of the kernel
const int width = ps->cgsize * 2, height = ps->cgsize * 2;
if (ps->shadow_corner)
free(ps->shadow_corner);
if (ps->shadow_top)
@ -1215,9 +1207,10 @@ bool init_render(session_t *ps) {
if (bkend_use_glx(ps)) {
#ifdef CONFIG_OPENGL
if (!glx_init(ps, true))
exit(1);
return false;
#else
printf_errfq(1, "(): GLX backend support not compiled in.");
log_error("GLX backend support not compiled in.");
return false;
#endif
}
@ -1233,14 +1226,14 @@ bool init_render(session_t *ps) {
&ps->o.glx_prog_win))
return false;
#else
printf_errf("(): GLSL supported not compiled in, can't load "
log_error("GLSL supported not compiled in, can't load "
"shader.");
return false;
#endif
}
if (!init_alpha_picts(ps)) {
printf_errf("(): Failed to init alpha pictures.");
log_error("Failed to init alpha pictures.");
return false;
}
@ -1266,7 +1259,7 @@ bool init_render(session_t *ps) {
ps->white_picture = solid_picture(ps, true, 1, 1, 1, 1);
if (ps->black_picture == XCB_NONE || ps->white_picture == XCB_NONE) {
printf_errf("(): Failed to create solid xrender pictures.");
log_error("Failed to create solid xrender pictures.");
return false;
}
@ -1278,7 +1271,7 @@ bool init_render(session_t *ps) {
ps->cshadow_picture = solid_picture(
ps, true, 1, ps->o.shadow_red, ps->o.shadow_green, ps->o.shadow_blue);
if (ps->cshadow_picture == XCB_NONE) {
printf_errf("(): Failed to create shadow picture.");
log_error("Failed to create shadow picture.");
return false;
}
}

View File

@ -11,6 +11,25 @@ char *
mstrjoin3(const char *src1, const char *src2, const char *src3);
void mstrextend(char **psrc1, const char *src2);
static inline int uitostr(unsigned int n, char *buf) {
int ret = 0;
unsigned int tmp = n;
while (tmp > 0) {
tmp /= 10;
ret++;
}
if (ret == 0)
ret = 1;
int pos = ret;
while (pos--) {
buf[pos] = n%10 + '0';
n /= 10;
}
return ret;
}
static inline const char *
skip_space_const(const char *src) {
if (!src)

34
src/utils.c Normal file
View File

@ -0,0 +1,34 @@
#include <stdio.h>
#include <sys/uio.h>
#include "compiler.h"
#include "string_utils.h"
#include "utils.h"
/// Report allocation failure without allocating memory
void report_allocation_failure(const char *func, const char *file, unsigned int line) {
// Since memory allocation failed, we try to print this error message without any
// memory allocation. Since logging framework allocates memory (and might even
// have not been initialized yet), so we can't use it.
char buf[11];
int llen = uitostr(line, buf);
const char msg1[] = " has failed to allocate memory, ";
const char msg2[] = ". Aborting...\n";
const struct iovec v[] = {
{.iov_base = (void *)func, .iov_len = strlen(func)},
{.iov_base = "()", .iov_len = 2},
{.iov_base = (void *)msg1, .iov_len = sizeof(msg1) - 1},
{.iov_base = "at ", .iov_len = 3},
{.iov_base = (void *)file, .iov_len = strlen(file)},
{.iov_base = ":", .iov_len = 1},
{.iov_base = buf, .iov_len = llen},
{.iov_base = (void *)msg2, .iov_len = sizeof(msg2) - 1},
};
writev(STDERR_FILENO, v, ARR_SIZE(v));
abort();
unreachable;
}
// vim: set noet sw=8 ts=8 :

View File

@ -101,24 +101,21 @@ normalize_d(double d) {
return normalize_d_range(d, 0.0, 1.0);
}
void report_allocation_failure(const char *func, const char *file, unsigned int line);
/**
* @brief Quit if the passed-in pointer is empty.
*/
static inline void *
allocchk_(const char *func_name, void *ptr) {
allocchk_(const char *func_name, const char *file, unsigned int line, void *ptr) {
if (unlikely(!ptr)) {
// Since memory allocation failed, we try to print
// this error message without any memory allocation.
const char msg[] = "(): Failed to allocate memory\n";
write(STDERR_FILENO, func_name, strlen(func_name));
write(STDERR_FILENO, msg, ARR_SIZE(msg));
abort();
report_allocation_failure(func_name, file, line);
}
return ptr;
}
/// @brief Wrapper of allocchk_().
#define allocchk(ptr) allocchk_(__func__, ptr)
#define allocchk(ptr) allocchk_(__func__, __FILE__, __LINE__, ptr)
/// @brief Wrapper of malloc().
#define cmalloc(type) ((type *) allocchk(malloc(sizeof(type))))

View File

@ -22,7 +22,7 @@ vsync_drm_init(session_t *ps) {
#ifdef CONFIG_VSYNC_DRM
// Should we always open card0?
if (ps->drm_fd < 0 && (ps->drm_fd = open("/dev/dri/card0", O_RDWR)) < 0) {
printf_errf("(): Failed to open device.");
log_error("Failed to open device.");
return false;
}
@ -31,7 +31,7 @@ vsync_drm_init(session_t *ps) {
return true;
#else
printf_errf("(): Program not compiled with DRM VSync support.");
log_error("compton is not compiled with DRM VSync support.");
return false;
#endif
}
@ -51,7 +51,7 @@ vsync_opengl_init(session_t *ps) {
return false;
if (!glx_hasglxext(ps, "GLX_SGI_video_sync")) {
printf_errf("(): Your driver doesn't support SGI_video_sync, giving up.");
log_error("Your driver doesn't support SGI_video_sync, giving up.");
return false;
}
@ -63,13 +63,13 @@ vsync_opengl_init(session_t *ps) {
ps->psglx->glXWaitVideoSyncSGI = (f_WaitVideoSync)
glXGetProcAddress((const GLubyte *) "glXWaitVideoSyncSGI");
if (!ps->psglx->glXWaitVideoSyncSGI || !ps->psglx->glXGetVideoSyncSGI) {
printf_errf("(): Failed to get glXWait/GetVideoSyncSGI function.");
log_error("Failed to get glXWait/GetVideoSyncSGI function.");
return false;
}
return true;
#else
printf_errf("(): Program not compiled with OpenGL VSync support.");
log_error("compton is not compiled with OpenGL VSync support.");
return false;
#endif
}
@ -81,7 +81,7 @@ vsync_opengl_oml_init(session_t *ps) {
return false;
if (!glx_hasglxext(ps, "GLX_OML_sync_control")) {
printf_errf("(): Your driver doesn't support OML_sync_control, giving up.");
log_error("Your driver doesn't support OML_sync_control, giving up.");
return false;
}
@ -93,13 +93,13 @@ vsync_opengl_oml_init(session_t *ps) {
ps->psglx->glXWaitForMscOML = (f_WaitForMscOML)
glXGetProcAddress ((const GLubyte *) "glXWaitForMscOML");
if (!ps->psglx->glXGetSyncValuesOML || !ps->psglx->glXWaitForMscOML) {
printf_errf("(): Failed to get OML_sync_control functions.");
log_error("Failed to get OML_sync_control functions.");
return false;
}
return true;
#else
printf_errf("(): Program not compiled with OpenGL VSync support.");
log_error("compton is not compiled with OpenGL VSync support.");
return false;
#endif
}
@ -118,7 +118,7 @@ vsync_opengl_swc_swap_interval(session_t *ps, unsigned int interval) {
ps->psglx->glXSwapIntervalProc = (f_SwapIntervalSGI)
glXGetProcAddress ((const GLubyte *) "glXSwapIntervalSGI");
} else {
printf_errf("(): Your driver doesn't support SGI_swap_control nor MESA_swap_control, giving up.");
log_error("Your driver doesn't support SGI_swap_control nor MESA_swap_control, giving up.");
return false;
}
}
@ -138,25 +138,25 @@ static bool
vsync_opengl_swc_init(session_t *ps) {
#ifdef CONFIG_OPENGL
if (!bkend_use_glx(ps)) {
printf_errf("(): OpenGL swap control requires the GLX backend.");
log_warn("OpenGL swap control requires the GLX backend.");
return false;
}
if (!vsync_opengl_swc_swap_interval(ps, 1)) {
printf_errf("(): Failed to load a swap control extension.");
log_error("Failed to load a swap control extension.");
return false;
}
return true;
#else
printf_errf("(): Program not compiled with OpenGL VSync support.");
log_error("compton is not compiled with OpenGL VSync support.");
return false;
#endif
}
static bool
vsync_opengl_mswc_init(session_t *ps) {
printf_errf("(): opengl-mswc is deprecated, please use opengl-swc instead.");
log_warn("opengl-mswc is deprecated, please use opengl-swc instead.");
return vsync_opengl_swc_init(ps);
}
@ -188,8 +188,7 @@ vsync_drm_wait(session_t *ps) {
} while (ret && errno == EINTR);
if (ret)
fprintf(stderr, "vsync_drm_wait(): VBlank ioctl did not work, "
"unimplemented in this drmver?\n");
log_error("VBlank ioctl did not work, unimplemented in this drmver?");
return ret;

View File

@ -172,9 +172,7 @@ int win_get_name(session_t *ps, win *w) {
return 0;
if (!(wid_get_text_prop(ps, w->client_win, ps->atom_name_ewmh, &strlst, &nstr))) {
#ifdef DEBUG_WINDATA
printf_dbgf("(%#010lx): _NET_WM_NAME unset, falling back to WM_NAME.\n", wid);
#endif
log_trace("(%#010lx): _NET_WM_NAME unset, falling back to WM_NAME.", w->client_win);
if (!(XGetWMName(ps->dpy, w->client_win, &text_prop) && text_prop.value)) {
return -1;
@ -199,10 +197,8 @@ int win_get_name(session_t *ps, win *w) {
XFreeStringList(strlst);
#ifdef DEBUG_WINDATA
printf_dbgf("(%#010lx): client = %#010lx, name = \"%s\", "
"ret = %d\n", w->id, w->client_win, w->name, ret);
#endif
log_trace("(%#010lx): client = %#010lx, name = \"%s\", "
"ret = %d", w->id, w->client_win, w->name, ret);
return ret;
}
@ -222,10 +218,8 @@ int win_get_role(session_t *ps, win *w) {
XFreeStringList(strlst);
#ifdef DEBUG_WINDATA
printf_dbgf("(%#010lx): client = %#010lx, role = \"%s\", "
"ret = %d\n", w->id, w->client_win, w->role, ret);
#endif
log_trace("(%#010lx): client = %#010lx, role = \"%s\", "
"ret = %d", w->id, w->client_win, w->role, ret);
return ret;
}
@ -703,19 +697,15 @@ void win_recheck_client(session_t *ps, win *w) {
// Always recursively look for a window with WM_STATE, as Fluxbox
// sets override-redirect flags on all frame windows.
Window cw = find_client_win(ps, w->id);
#ifdef DEBUG_CLIENTWIN
if (cw)
printf_dbgf("(%#010lx): client %#010lx\n", w->id, cw);
#endif
log_trace("(%#010lx): client %#010lx", w->id, cw);
// Set a window's client window to itself if we couldn't find a
// client window
if (!cw) {
cw = w->id;
w->wmwin = !w->a.override_redirect;
#ifdef DEBUG_CLIENTWIN
printf_dbgf("(%#010lx): client self (%s)\n", w->id,
log_trace("(%#010lx): client self (%s)", w->id,
(w->wmwin ? "wmwin" : "override-redirected"));
#endif
}
// Unmark the old one
@ -817,14 +807,7 @@ bool add_win(session_t *ps, Window id, Window prev) {
// Allocate and initialize the new win structure
auto new = cmalloc(win);
#ifdef DEBUG_EVENTS
printf_dbgf("(%#010lx): %p\n", id, new);
#endif
if (!new) {
printf_errf("(%#010lx): Failed to allocate memory for the new window.", id);
return false;
}
log_trace("(%#010lx): %p", id, new);
*new = win_def;
pixman_region32_init(&new->bounding_shape);
@ -988,9 +971,8 @@ void win_update_leader(session_t *ps, win *w) {
win_set_leader(ps, w, leader);
#ifdef DEBUG_LEADER
printf_dbgf("(%#010lx): client %#010lx, leader %#010lx, cache %#010lx\n", w->id, w->client_win, w->leader, win_get_leader(ps, w));
#endif
log_trace("(%#010lx): client %#010lx, leader %#010lx, cache %#010lx",
w->id, w->client_win, w->leader, win_get_leader(ps, w));
}
/**
@ -1049,11 +1031,9 @@ bool win_get_class(session_t *ps, win *w) {
XFreeStringList(strlst);
#ifdef DEBUG_WINDATA
printf_dbgf("(%#010lx): client = %#010lx, "
"instance = \"%s\", general = \"%s\"\n",
log_trace("(%#010lx): client = %#010lx, "
"instance = \"%s\", general = \"%s\"",
w->id, w->client_win, w->class_instance, w->class_general);
#endif
return true;
}
@ -1201,7 +1181,7 @@ void win_update_bounding_shape(session_t *ps, win *w) {
// Window shape changed, we should free old wpaint and shadow pict
free_paint(ps, &w->paint);
free_paint(ps, &w->shadow_paint);
//printf_errf("(): free out dated pict");
//log_trace("free out dated pict");
win_on_factor_change(ps, w);
}
@ -1252,11 +1232,9 @@ win_update_frame_extents(session_t *ps, win *w, Window client) {
w->reg_ignore_valid = false;
}
#ifdef DEBUG_FRAME
printf_dbgf("(%#010lx): %d, %d, %d, %d\n", w->id,
log_trace("(%#010lx): %d, %d, %d, %d", w->id,
w->frame_extents.left, w->frame_extents.right,
w->frame_extents.top, w->frame_extents.bottom);
#endif
free_winprop(&prop);
}

30
src/x.c
View File

@ -112,7 +112,7 @@ static inline void x_get_server_pictfmts(session_t *ps) {
xcb_render_query_pict_formats_reply(ps->c,
xcb_render_query_pict_formats(ps->c), &e);
if (e || !ps->pictfmts) {
printf_errf("(): failed to get pict formats\n");
log_fatal("failed to get pict formats\n");
abort();
}
}
@ -142,8 +142,8 @@ x_create_picture_with_pictfmt_and_pixmap(
if (attr) {
xcb_render_create_picture_value_list_serialize(&buf, valuemask, attr);
if (!buf) {
printf_errf("(): failed to serialize picture attributes");
return None;
log_error("failed to serialize picture attributes");
return XCB_NONE;
}
}
@ -153,8 +153,8 @@ x_create_picture_with_pictfmt_and_pixmap(
pixmap, pictfmt->id, valuemask, buf));
free(buf);
if (e) {
printf_errf("(): failed to create picture");
return None;
log_error("failed to create picture");
return XCB_NONE;
}
return tmp_picture;
}
@ -196,7 +196,7 @@ x_create_picture(session_t *ps, int wid, int hei,
pictfmt = x_get_pictform_for_visual(ps, ps->vis);
if (!pictfmt) {
printf_errf("(): default visual is invalid");
log_fatal("Default visual is invalid");
abort();
}
@ -219,7 +219,7 @@ bool x_fetch_region(session_t *ps, xcb_xfixes_region_t r, pixman_region32_t *res
xcb_xfixes_fetch_region_reply_t *xr = xcb_xfixes_fetch_region_reply(ps->c,
xcb_xfixes_fetch_region(ps->c, r), &e);
if (!xr) {
printf_errf("(): failed to fetch rectangles");
log_error("Failed to fetch rectangles");
return false;
}
@ -257,7 +257,7 @@ void x_set_picture_clip_region(session_t *ps, xcb_render_picture_t pict,
xcb_request_check(ps->c, xcb_render_set_picture_clip_rectangles_checked(ps->c, pict,
clip_x_origin, clip_y_origin, nrects, xrects));
if (e)
printf_errf("(): failed to set clip region");
log_error("Failed to set clip region");
free(e);
free(xrects);
return;
@ -277,8 +277,8 @@ x_print_error(unsigned long serial, uint8_t major, uint8_t minor, uint8_t error_
if (major == ps->composite_opcode
&& minor == XCB_COMPOSITE_REDIRECT_SUBWINDOWS) {
fprintf(stderr, "Another composite manager is already running "
"(and does not handle _NET_WM_CM_Sn correctly)\n");
log_fatal("Another composite manager is already running "
"(and does not handle _NET_WM_CM_Sn correctly)");
exit(1);
}
@ -349,16 +349,12 @@ x_print_error(unsigned long serial, uint8_t major, uint8_t minor, uint8_t error_
#undef CASESTRRET2
print_timestamp(ps);
{
char buf[BUF_LEN] = "";
XGetErrorText(ps->dpy, error_code, buf, BUF_LEN);
printf("error %4d %-12s request %4d minor %4d serial %6lu: \"%s\"\n",
error_code, name, major,
minor, serial, buf);
log_warn("X error %d %s request %d minor %d serial %lu: \"%s\"",
error_code, name, major, minor, serial, buf);
}
// print_backtrace();
}
/**
@ -372,7 +368,7 @@ x_create_pixmap(session_t *ps, uint8_t depth, xcb_drawable_t drawable, uint16_t
if (err == NULL)
return pix;
printf_err("Failed to create pixmap:");
log_error("Failed to create pixmap:");
ev_xcb_error(ps, err);
free(err);
return XCB_NONE;

View File

@ -40,7 +40,7 @@ xrc_delete_xid_(XID xid, M_POS_DATA_PARAMS) {
xrc_xid_record_t *prec = NULL;
HASH_FIND_XID(gs_xid_records, &xid, prec);
if (!prec) {
printf_err("XRC: %s:%d %s(): Can't find XID %#010lx we want to delete.",
log_error("XRC: %s:%d %s(): Can't find XID %#010lx we want to delete.",
file, line, func, xid);
return;
}
@ -54,7 +54,7 @@ xrc_delete_xid_(XID xid, M_POS_DATA_PARAMS) {
void
xrc_report_xid(void) {
for (xrc_xid_record_t *prec = gs_xid_records; prec; prec = prec->hh.next)
printf_dbg("XRC: %s:%d %s(): %#010lx (%s) not freed.\n",
log_trace("XRC: %s:%d %s(): %#010lx (%s) not freed.\n",
prec->file, prec->line, prec->func, prec->xid, prec->type);
}