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:
11
libi3/font.c
11
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);
|
||||
|
Reference in New Issue
Block a user