/* Functions for handling font and other changes dynamically.
-Copyright (C) 2009-2014 Free Software Foundation, Inc.
+Copyright (C) 2009-2016 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
static char *current_mono_font;
static char *current_font;
static struct x_display_info *first_dpyinfo;
-static Lisp_Object Qmonospace_font_name, Qfont_name, Qfont_render,
- Qtool_bar_style;
static Lisp_Object current_tool_bar_style;
/* Store an config changed event in to the event queue. */
/* First 4 bytes is a serial number, skip that. */
- if (bytes < 12) return BadLength;
+ if (bytes < 12) return settings_seen;
memcpy (&n_settings, prop+8, 4);
if (my_bo != that_bo) n_settings = bswap_32 (n_settings);
bytes_parsed = 12;
memcpy (&nlen, prop+bytes_parsed, 2);
bytes_parsed += 2;
if (my_bo != that_bo) nlen = bswap_16 (nlen);
- if (bytes_parsed+nlen > bytes) return BadLength;
- to_cpy = nlen > 127 ? 127 : nlen;
+ if (bytes_parsed + nlen > bytes) return settings_seen;
+ to_cpy = min (nlen, sizeof name - 1);
memcpy (name, prop+bytes_parsed, to_cpy);
name[to_cpy] = '\0';
bytes_parsed = PAD (bytes_parsed);
bytes_parsed += 4; /* Skip serial for this value */
- if (bytes_parsed > bytes) return BadLength;
+ if (bytes_parsed > bytes) return settings_seen;
- want_this =
+ want_this = strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0;
#ifdef HAVE_XFT
- (nlen > 6 && strncmp (name, "Xft/", 4) == 0)
- || strcmp (XSETTINGS_FONT_NAME, name) == 0
- ||
+ if ((nlen > 6 && memcmp (name, "Xft/", 4) == 0)
+ || strcmp (XSETTINGS_FONT_NAME, name) == 0)
+ want_this = true;
#endif
- strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0;
switch (type)
{
case 0: /* Integer */
- if (bytes_parsed+4 > bytes) return BadLength;
+ if (bytes_parsed + 4 > bytes) return settings_seen;
if (want_this)
{
memcpy (&ival, prop+bytes_parsed, 4);
break;
case 1: /* String */
- if (bytes_parsed+4 > bytes) return BadLength;
+ if (bytes_parsed + 4 > bytes) return settings_seen;
memcpy (&vlen, prop+bytes_parsed, 4);
bytes_parsed += 4;
if (my_bo != that_bo) vlen = bswap_32 (vlen);
if (want_this)
{
- to_cpy = vlen > 127 ? 127 : vlen;
+ to_cpy = min (vlen, sizeof sval - 1);
memcpy (sval, prop+bytes_parsed, to_cpy);
sval[to_cpy] = '\0';
}
case 2: /* RGB value */
/* No need to parse this */
- if (bytes_parsed+8 > bytes) return BadLength;
+ if (bytes_parsed + 8 > bytes) return settings_seen;
bytes_parsed += 8; /* 4 values (r, b, g, alpha), 2 bytes each. */
break;
default: /* Parse Error */
- return BadValue;
+ return settings_seen;
}
if (want_this)
{
- ++settings_seen;
if (strcmp (name, XSETTINGS_TOOL_BAR_STYLE) == 0)
{
dupstring (&settings->tb_style, sval);
else
settings->seen &= ~SEEN_RGBA;
}
- else if (strcmp (name, "Xft/DPI") == 0)
+ else if (strcmp (name, "Xft/DPI") == 0 && ival != (CARD32) -1)
{
settings->seen |= SEEN_DPI;
- settings->dpi = (double)ival/1024.0;
+ settings->dpi = ival / 1024.0;
}
else if (strcmp (name, "Xft/lcdfilter") == 0)
{
settings->seen &= ~SEEN_LCDFILTER;
}
#endif /* HAVE_XFT */
+ else
+ want_this = false;
+ settings_seen += want_this;
}
}
unsigned char *prop = NULL;
Display *dpy = dpyinfo->display;
int rc;
+ bool got_settings = false;
x_catch_errors (dpy);
rc = XGetWindowProperty (dpy,
if (rc == Success && prop != NULL && act_form == 8 && nitems > 0
&& act_type == dpyinfo->Xatom_xsettings_prop)
- rc = parse_settings (prop, nitems, settings);
+ got_settings = parse_settings (prop, nitems, settings) != 0;
XFree (prop);
x_uncatch_errors ();
- return rc != 0;
+ return got_settings;
}
/* Apply Xft settings in SETTINGS to the Xft library.
GSettingsSchema *sc = g_settings_schema_source_lookup
(g_settings_schema_source_get_default (),
GSETTINGS_SCHEMA,
- TRUE);
+ true);
schema_found = sc != NULL;
if (sc) g_settings_schema_unref (sc);
}