only LOG() the DPI when it changes, DLOG() it otherwise (Thanks lkraav)

This avoids flooding stdout every time some text (e.g. a window
decoration) is drawn, yet leaves the message in place when it’s actually
relevant (upon DPI changes).

fixes #1115
This commit is contained in:
Michael Stapelberg
2013-12-24 10:35:56 +01:00
parent 28939365cb
commit 0883dfbe14
8 changed files with 41 additions and 7 deletions

View File

@ -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);