diff --git a/i3-config-wizard/main.c b/i3-config-wizard/main.c index 880b80ed..09b94841 100644 --- a/i3-config-wizard/main.c +++ b/i3-config-wizard/main.c @@ -420,7 +420,7 @@ static char *rewrite_binding(const char *input) { /* - * Having verboselog() and errorlog() is necessary when using libi3. + * Having verboselog(), errorlog() and debuglog() is necessary when using libi3. * */ void verboselog(char *fmt, ...) { @@ -439,6 +439,9 @@ void errorlog(char *fmt, ...) { va_end(args); } +void debuglog(char *fmt, ...) { +} + /* * This function resolves ~ in pathnames. * It may resolve wildcards in the first part of the path, but if no match diff --git a/i3-input/main.c b/i3-input/main.c index da95c903..1c0d6856 100644 --- a/i3-input/main.c +++ b/i3-input/main.c @@ -57,7 +57,7 @@ xcb_screen_t *root_screen; static xcb_get_input_focus_cookie_t focus_cookie; /* - * Having verboselog() and errorlog() is necessary when using libi3. + * Having verboselog(), errorlog() and debuglog() is necessary when using libi3. * */ void verboselog(char *fmt, ...) { @@ -76,6 +76,9 @@ void errorlog(char *fmt, ...) { va_end(args); } +void debuglog(char *fmt, ...) { +} + /* * Restores the X11 input focus to whereever it was before. * This is necessary because i3-input’s window has override_redirect=1 diff --git a/i3-nagbar/main.c b/i3-nagbar/main.c index 952270e7..791da97b 100644 --- a/i3-nagbar/main.c +++ b/i3-nagbar/main.c @@ -61,7 +61,7 @@ xcb_connection_t *conn; xcb_screen_t *root_screen; /* - * Having verboselog() and errorlog() is necessary when using libi3. + * Having verboselog(), errorlog() and debuglog() is necessary when using libi3. * */ void verboselog(char *fmt, ...) { @@ -80,6 +80,9 @@ void errorlog(char *fmt, ...) { va_end(args); } +void debuglog(char *fmt, ...) { +} + /* * Starts the given application by passing it through a shell. We use double fork * to avoid zombie processes. As the started application’s parent exits (immediately), diff --git a/i3bar/include/util.h b/i3bar/include/util.h index 6ae97815..468eff3e 100644 --- a/i3bar/include/util.h +++ b/i3bar/include/util.h @@ -48,6 +48,9 @@ } \ } while (0) +#if defined(DLOG) +#undef DLOG +#endif /* Use cool logging-macros */ #define DLOG(fmt, ...) do { \ if (config.verbose) { \ diff --git a/i3bar/src/main.c b/i3bar/src/main.c index c62f7b3c..9ae69e3c 100644 --- a/i3bar/src/main.c +++ b/i3bar/src/main.c @@ -18,7 +18,7 @@ #include "common.h" /* - * Having verboselog() and errorlog() is necessary when using libi3. + * Having verboselog(), errorlog() and debuglog() is necessary when using libi3. * */ void verboselog(char *fmt, ...) { @@ -37,6 +37,9 @@ void errorlog(char *fmt, ...) { va_end(args); } +void debuglog(char *fmt, ...) { +} + /* * Glob path, i.e. expand ~ * diff --git a/include/libi3.h b/include/libi3.h index 18c64690..8c580da8 100644 --- a/include/libi3.h +++ b/include/libi3.h @@ -72,13 +72,20 @@ struct Font { /* Since this file also gets included by utilities which don’t use the i3 log * infrastructure, we define a fallback. */ #if !defined(LOG) -void verboselog(char *fmt, ...); +void verboselog(char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); #define LOG(fmt, ...) verboselog("[libi3] " __FILE__ " " fmt, ##__VA_ARGS__) #endif #if !defined(ELOG) -void errorlog(char *fmt, ...); +void errorlog(char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); #define ELOG(fmt, ...) errorlog("[libi3] ERROR: " fmt, ##__VA_ARGS__) #endif +#if !defined(DLOG) +void debuglog(char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); +#define DLOG(fmt, ...) debuglog("%s:%s:%d - " fmt, I3__FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__) +#endif /** * Try to get the contents of the given atom (for example I3_SOCKET_PATH) from diff --git a/include/log.h b/include/log.h index c8e3c8ef..ef4dbd3c 100644 --- a/include/log.h +++ b/include/log.h @@ -21,6 +21,9 @@ #if defined(ELOG) #undef ELOG #endif +#if defined(DLOG) +#undef DLOG +#endif /** ##__VA_ARGS__ means: leave out __VA_ARGS__ completely if it is empty, that is, delete the preceding comma */ #define LOG(fmt, ...) verboselog(fmt, ##__VA_ARGS__) diff --git a/libi3/font.c b/libi3/font.c index 4c064f2b..e1e5b826 100644 --- a/libi3/font.c +++ b/libi3/font.c @@ -30,6 +30,10 @@ static double pango_font_red; static double pango_font_green; static double pango_font_blue; +/* Necessary to track whether the dpi changes and trigger a LOG() message, + * which is more easily visible to users. */ +static double logged_dpi = 0.0; + static PangoLayout *create_layout_with_dpi(cairo_t *cr) { PangoLayout *layout; PangoContext *context; @@ -37,7 +41,12 @@ static PangoLayout *create_layout_with_dpi(cairo_t *cr) { context = pango_cairo_create_context(cr); const double dpi = (double)root_screen->height_in_pixels * 25.4 / (double)root_screen->height_in_millimeters; - LOG("X11 root window dictates %f DPI\n", dpi); + if (logged_dpi != dpi) { + logged_dpi = dpi; + LOG("X11 root window dictates %f DPI\n", dpi); + } else { + DLOG("X11 root window dictates %f DPI\n", dpi); + } pango_cairo_context_set_resolution(context, dpi); layout = pango_layout_new(context); g_object_unref(context);