* xsettings.c (apply_xft_settings): Fix potential buffer overrun.
[emacs.git] / src / xsettings.c
blobc8cb95296472d97e76e76001ab18458eb0d74a8b
1 /* Functions for handling font and other changes dynamically.
3 Copyright (C) 2009-2011 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
20 #include <config.h>
22 #include <float.h>
23 #include <limits.h>
24 #include <setjmp.h>
25 #include <fcntl.h>
26 #include "lisp.h"
27 #include "xterm.h"
28 #include "xsettings.h"
29 #include "frame.h"
30 #include "keyboard.h"
31 #include "blockinput.h"
32 #include "termhooks.h"
33 #include "termopts.h"
35 #include <X11/Xproto.h>
37 #ifdef HAVE_GCONF
38 #include <gconf/gconf-client.h>
39 #endif
40 #ifdef HAVE_XFT
41 #include <X11/Xft/Xft.h>
42 #endif
44 static char *current_mono_font;
45 static char *current_font;
46 static struct x_display_info *first_dpyinfo;
47 static Lisp_Object Qmonospace_font_name, Qfont_name, Qfont_render,
48 Qtool_bar_style;
49 static Lisp_Object current_tool_bar_style;
51 #ifdef HAVE_GCONF
52 static GConfClient *gconf_client;
53 #endif
56 static void
57 store_config_changed_event (Lisp_Object arg, Lisp_Object display_name)
59 struct input_event event;
60 EVENT_INIT (event);
61 event.kind = CONFIG_CHANGED_EVENT;
62 event.frame_or_window = display_name;
63 event.arg = arg;
64 kbd_buffer_store_event (&event);
67 #define XSETTINGS_FONT_NAME "Gtk/FontName"
68 #define XSETTINGS_TOOL_BAR_STYLE "Gtk/ToolbarStyle"
70 enum {
71 SEEN_AA = 0x01,
72 SEEN_HINTING = 0x02,
73 SEEN_RGBA = 0x04,
74 SEEN_LCDFILTER = 0x08,
75 SEEN_HINTSTYLE = 0x10,
76 SEEN_DPI = 0x20,
77 SEEN_FONT = 0x40,
78 SEEN_TB_STYLE = 0x80,
80 struct xsettings
82 #ifdef HAVE_XFT
83 FcBool aa, hinting;
84 int rgba, lcdfilter, hintstyle;
85 double dpi;
86 #endif
88 char *font;
89 char *tb_style;
91 unsigned seen;
94 #ifdef HAVE_GCONF
96 #define SYSTEM_MONO_FONT "/desktop/gnome/interface/monospace_font_name"
97 #define SYSTEM_FONT "/desktop/gnome/interface/font_name"
99 /* Callback called when something changed in GConf that we care about,
100 that is SYSTEM_MONO_FONT. */
102 static void
103 something_changedCB (GConfClient *client,
104 guint cnxn_id,
105 GConfEntry *entry,
106 gpointer user_data)
108 GConfValue *v = gconf_entry_get_value (entry);
110 if (!v) return;
111 if (v->type == GCONF_VALUE_STRING)
113 const char *value = gconf_value_get_string (v);
114 if (current_mono_font != NULL && strcmp (value, current_mono_font) == 0)
115 return; /* No change. */
117 xfree (current_mono_font);
118 current_mono_font = xstrdup (value);
122 if (first_dpyinfo != NULL)
124 /* Check if display still open */
125 struct x_display_info *dpyinfo;
126 int found = 0;
127 for (dpyinfo = x_display_list; !found && dpyinfo; dpyinfo = dpyinfo->next)
128 found = dpyinfo == first_dpyinfo;
130 if (found && use_system_font)
131 store_config_changed_event (Qmonospace_font_name,
132 XCAR (first_dpyinfo->name_list_element));
135 #endif /* HAVE_GCONF */
137 #ifdef HAVE_XFT
139 /* Older fontconfig versions don't have FC_LCD_*. */
140 #ifndef FC_LCD_NONE
141 #define FC_LCD_NONE 0
142 #endif
143 #ifndef FC_LCD_DEFAULT
144 #define FC_LCD_DEFAULT 1
145 #endif
146 #ifndef FC_LCD_FILTER
147 #define FC_LCD_FILTER "lcdfilter"
148 #endif
150 #endif /* HAVE_XFT */
152 /* Find the window that contains the XSETTINGS property values. */
154 static void
155 get_prop_window (struct x_display_info *dpyinfo)
157 Display *dpy = dpyinfo->display;
159 XGrabServer (dpy);
160 dpyinfo->xsettings_window = XGetSelectionOwner (dpy,
161 dpyinfo->Xatom_xsettings_sel);
162 if (dpyinfo->xsettings_window != None)
163 /* Select events so we can detect if window is deleted or if settings
164 are changed. */
165 XSelectInput (dpy, dpyinfo->xsettings_window,
166 PropertyChangeMask|StructureNotifyMask);
168 XUngrabServer (dpy);
171 #define SWAP32(nr) (((nr) << 24) | (((nr) << 8) & 0xff0000) \
172 | (((nr) >> 8) & 0xff00) | ((nr) >> 24))
173 #define SWAP16(nr) (((nr) << 8) | ((nr) >> 8))
174 #define PAD(nr) (((nr) + 3) & ~3)
176 /* Parse xsettings and extract those that deal with Xft.
177 See http://freedesktop.org/wiki/Specifications/XSettingsRegistry
178 and http://standards.freedesktop.org/xsettings-spec/xsettings-spec-0.5.html.
180 Layout of prop. First is a header:
182 bytes type what
183 ------------------------------------
184 1 CARD8 byte-order
185 3 unused
186 4 CARD32 SERIAL
187 4 CARD32 N_SETTINGS
189 Then N_SETTINGS records, with header:
191 bytes type what
192 ------------------------------------
193 1 SETTING_TYPE type (0 = integer, 1 = string, 2 RGB color).
194 1 unused
195 2 CARD16 n == name-length
196 n STRING8 name
197 p unused, p=pad_to_even_4(n)
198 4 CARD32 last-change-serial
200 and then the value, For string:
202 bytes type what
203 ------------------------------------
204 4 CARD32 n = value-length
205 n STRING8 value
206 p unused, p=pad_to_even_4(n)
208 For integer:
210 bytes type what
211 ------------------------------------
212 4 INT32 value
214 For RGB color:
216 bytes type what
217 ------------------------------------
218 2 CARD16 red
219 2 CARD16 blue
220 2 CARD16 green
221 2 CARD16 alpha
223 Returns non-zero if some Xft settings was seen, zero otherwise.
226 static int
227 parse_settings (unsigned char *prop,
228 long unsigned int bytes,
229 struct xsettings *settings)
231 Lisp_Object byteorder = Fbyteorder ();
232 int my_bo = XFASTINT (byteorder) == 'B' ? MSBFirst : LSBFirst;
233 int that_bo = prop[0];
234 CARD32 n_settings;
235 int bytes_parsed = 0;
236 int settings_seen = 0;
237 int i = 0;
239 /* First 4 bytes is a serial number, skip that. */
241 if (bytes < 12) return BadLength;
242 memcpy (&n_settings, prop+8, 4);
243 if (my_bo != that_bo) n_settings = SWAP32 (n_settings);
244 bytes_parsed = 12;
246 memset (settings, 0, sizeof (*settings));
248 while (bytes_parsed+4 < bytes && settings_seen < 7
249 && i < n_settings)
251 int type = prop[bytes_parsed++];
252 CARD16 nlen;
253 CARD32 vlen, ival = 0;
254 char name[128]; /* The names we are looking for are not this long. */
255 char sval[128]; /* The values we are looking for are not this long. */
256 int want_this;
257 int to_cpy;
259 sval[0] = '\0';
260 ++i;
261 ++bytes_parsed; /* Padding */
263 memcpy (&nlen, prop+bytes_parsed, 2);
264 bytes_parsed += 2;
265 if (my_bo != that_bo) nlen = SWAP16 (nlen);
266 if (bytes_parsed+nlen > bytes) return BadLength;
267 to_cpy = nlen > 127 ? 127 : nlen;
268 memcpy (name, prop+bytes_parsed, to_cpy);
269 name[to_cpy] = '\0';
271 bytes_parsed += nlen;
272 bytes_parsed = PAD (bytes_parsed);
274 bytes_parsed += 4; /* Skip serial for this value */
275 if (bytes_parsed > bytes) return BadLength;
277 want_this =
278 #ifdef HAVE_XFT
279 (nlen > 6 && strncmp (name, "Xft/", 4) == 0)
281 #endif
282 (strcmp (XSETTINGS_FONT_NAME, name) == 0)
283 || (strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0);
285 switch (type)
287 case 0: /* Integer */
288 if (bytes_parsed+4 > bytes) return BadLength;
289 if (want_this)
291 memcpy (&ival, prop+bytes_parsed, 4);
292 if (my_bo != that_bo) ival = SWAP32 (ival);
294 bytes_parsed += 4;
295 break;
297 case 1: /* String */
298 if (bytes_parsed+4 > bytes) return BadLength;
299 memcpy (&vlen, prop+bytes_parsed, 4);
300 bytes_parsed += 4;
301 if (my_bo != that_bo) vlen = SWAP32 (vlen);
302 if (want_this)
304 to_cpy = vlen > 127 ? 127 : vlen;
305 memcpy (sval, prop+bytes_parsed, to_cpy);
306 sval[to_cpy] = '\0';
308 bytes_parsed += vlen;
309 bytes_parsed = PAD (bytes_parsed);
310 break;
312 case 2: /* RGB value */
313 /* No need to parse this */
314 if (bytes_parsed+8 > bytes) return BadLength;
315 bytes_parsed += 8; /* 4 values (r, b, g, alpha), 2 bytes each. */
316 break;
318 default: /* Parse Error */
319 return BadValue;
322 if (want_this)
324 ++settings_seen;
325 if (strcmp (name, XSETTINGS_FONT_NAME) == 0)
327 settings->font = xstrdup (sval);
328 settings->seen |= SEEN_FONT;
330 else if (strcmp (name, XSETTINGS_TOOL_BAR_STYLE) == 0)
332 settings->tb_style = xstrdup (sval);
333 settings->seen |= SEEN_TB_STYLE;
335 #ifdef HAVE_XFT
336 else if (strcmp (name, "Xft/Antialias") == 0)
338 settings->seen |= SEEN_AA;
339 settings->aa = ival != 0;
341 else if (strcmp (name, "Xft/Hinting") == 0)
343 settings->seen |= SEEN_HINTING;
344 settings->hinting = ival != 0;
346 # ifdef FC_HINT_STYLE
347 else if (strcmp (name, "Xft/HintStyle") == 0)
349 settings->seen |= SEEN_HINTSTYLE;
350 if (strcmp (sval, "hintnone") == 0)
351 settings->hintstyle = FC_HINT_NONE;
352 else if (strcmp (sval, "hintslight") == 0)
353 settings->hintstyle = FC_HINT_SLIGHT;
354 else if (strcmp (sval, "hintmedium") == 0)
355 settings->hintstyle = FC_HINT_MEDIUM;
356 else if (strcmp (sval, "hintfull") == 0)
357 settings->hintstyle = FC_HINT_FULL;
358 else
359 settings->seen &= ~SEEN_HINTSTYLE;
361 # endif
362 else if (strcmp (name, "Xft/RGBA") == 0)
364 settings->seen |= SEEN_RGBA;
365 if (strcmp (sval, "none") == 0)
366 settings->rgba = FC_RGBA_NONE;
367 else if (strcmp (sval, "rgb") == 0)
368 settings->rgba = FC_RGBA_RGB;
369 else if (strcmp (sval, "bgr") == 0)
370 settings->rgba = FC_RGBA_BGR;
371 else if (strcmp (sval, "vrgb") == 0)
372 settings->rgba = FC_RGBA_VRGB;
373 else if (strcmp (sval, "vbgr") == 0)
374 settings->rgba = FC_RGBA_VBGR;
375 else
376 settings->seen &= ~SEEN_RGBA;
378 else if (strcmp (name, "Xft/DPI") == 0)
380 settings->seen |= SEEN_DPI;
381 settings->dpi = (double)ival/1024.0;
383 else if (strcmp (name, "Xft/lcdfilter") == 0)
385 settings->seen |= SEEN_LCDFILTER;
386 if (strcmp (sval, "none") == 0)
387 settings->lcdfilter = FC_LCD_NONE;
388 else if (strcmp (sval, "lcddefault") == 0)
389 settings->lcdfilter = FC_LCD_DEFAULT;
390 else
391 settings->seen &= ~SEEN_LCDFILTER;
393 #endif /* HAVE_XFT */
397 return settings_seen;
400 static int
401 read_settings (struct x_display_info *dpyinfo, struct xsettings *settings)
403 Atom act_type;
404 int act_form;
405 unsigned long nitems, bytes_after;
406 unsigned char *prop = NULL;
407 Display *dpy = dpyinfo->display;
408 int rc;
410 x_catch_errors (dpy);
411 rc = XGetWindowProperty (dpy,
412 dpyinfo->xsettings_window,
413 dpyinfo->Xatom_xsettings_prop,
414 0, LONG_MAX, False, AnyPropertyType,
415 &act_type, &act_form, &nitems, &bytes_after,
416 &prop);
418 if (rc == Success && prop != NULL && act_form == 8 && nitems > 0
419 && act_type == dpyinfo->Xatom_xsettings_prop)
420 rc = parse_settings (prop, nitems, settings);
422 XFree (prop);
424 x_uncatch_errors ();
426 return rc != 0;
430 static void
431 apply_xft_settings (struct x_display_info *dpyinfo,
432 int send_event_p,
433 struct xsettings *settings)
435 #ifdef HAVE_XFT
436 FcPattern *pat;
437 struct xsettings oldsettings;
438 int changed = 0;
440 memset (&oldsettings, 0, sizeof (oldsettings));
441 pat = FcPatternCreate ();
442 XftDefaultSubstitute (dpyinfo->display,
443 XScreenNumberOfScreen (dpyinfo->screen),
444 pat);
445 FcPatternGetBool (pat, FC_ANTIALIAS, 0, &oldsettings.aa);
446 FcPatternGetBool (pat, FC_HINTING, 0, &oldsettings.hinting);
447 # ifdef FC_HINT_STYLE
448 FcPatternGetInteger (pat, FC_HINT_STYLE, 0, &oldsettings.hintstyle);
449 # endif
450 FcPatternGetInteger (pat, FC_LCD_FILTER, 0, &oldsettings.lcdfilter);
451 FcPatternGetInteger (pat, FC_RGBA, 0, &oldsettings.rgba);
452 FcPatternGetDouble (pat, FC_DPI, 0, &oldsettings.dpi);
454 if ((settings->seen & SEEN_AA) != 0 && oldsettings.aa != settings->aa)
456 FcPatternDel (pat, FC_ANTIALIAS);
457 FcPatternAddBool (pat, FC_ANTIALIAS, settings->aa);
458 ++changed;
459 oldsettings.aa = settings->aa;
462 if ((settings->seen & SEEN_HINTING) != 0
463 && oldsettings.hinting != settings->hinting)
465 FcPatternDel (pat, FC_HINTING);
466 FcPatternAddBool (pat, FC_HINTING, settings->hinting);
467 ++changed;
468 oldsettings.hinting = settings->hinting;
470 if ((settings->seen & SEEN_RGBA) != 0 && oldsettings.rgba != settings->rgba)
472 FcPatternDel (pat, FC_RGBA);
473 FcPatternAddInteger (pat, FC_RGBA, settings->rgba);
474 oldsettings.rgba = settings->rgba;
475 ++changed;
478 /* Older fontconfig versions don't have FC_LCD_FILTER. */
479 if ((settings->seen & SEEN_LCDFILTER) != 0
480 && oldsettings.lcdfilter != settings->lcdfilter)
482 FcPatternDel (pat, FC_LCD_FILTER);
483 FcPatternAddInteger (pat, FC_LCD_FILTER, settings->lcdfilter);
484 ++changed;
485 oldsettings.lcdfilter = settings->lcdfilter;
488 # ifdef FC_HINT_STYLE
489 if ((settings->seen & SEEN_HINTSTYLE) != 0
490 && oldsettings.hintstyle != settings->hintstyle)
492 FcPatternDel (pat, FC_HINT_STYLE);
493 FcPatternAddInteger (pat, FC_HINT_STYLE, settings->hintstyle);
494 ++changed;
495 oldsettings.hintstyle = settings->hintstyle;
497 # endif
499 if ((settings->seen & SEEN_DPI) != 0 && oldsettings.dpi != settings->dpi
500 && settings->dpi > 0)
502 Lisp_Object frame, tail;
504 FcPatternDel (pat, FC_DPI);
505 FcPatternAddDouble (pat, FC_DPI, settings->dpi);
506 ++changed;
507 oldsettings.dpi = settings->dpi;
509 /* Change the DPI on this display and all frames on the display. */
510 dpyinfo->resy = dpyinfo->resx = settings->dpi;
511 FOR_EACH_FRAME (tail, frame)
512 if (FRAME_X_P (XFRAME (frame))
513 && FRAME_X_DISPLAY_INFO (XFRAME (frame)) == dpyinfo)
514 XFRAME (frame)->resy = XFRAME (frame)->resx = settings->dpi;
517 if (changed)
519 static char const format[] =
520 "Antialias: %d, Hinting: %d, RGBA: %d, LCDFilter: %d, "
521 "Hintstyle: %d, DPI: %lf";
522 enum
524 d_formats = 5,
525 d_growth = INT_BUFSIZE_BOUND (int) - sizeof "%d",
526 lf_formats = 1,
527 max_f_integer_digits = DBL_MAX_10_EXP + 1,
528 f_precision = 6,
529 lf_growth = (sizeof "-." + max_f_integer_digits + f_precision
530 - sizeof "%lf")
532 char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth];
534 XftDefaultSet (dpyinfo->display, pat);
535 if (send_event_p)
536 store_config_changed_event (Qfont_render,
537 XCAR (dpyinfo->name_list_element));
538 sprintf (buf, format, oldsettings.aa, oldsettings.hinting,
539 oldsettings.rgba, oldsettings.lcdfilter,
540 oldsettings.hintstyle, oldsettings.dpi);
541 Vxft_settings = build_string (buf);
543 else
544 FcPatternDestroy (pat);
545 #endif /* HAVE_XFT */
548 static void
549 read_and_apply_settings (struct x_display_info *dpyinfo, int send_event_p)
551 struct xsettings settings;
552 Lisp_Object dpyname = XCAR (dpyinfo->name_list_element);
554 if (!read_settings (dpyinfo, &settings))
555 return;
557 apply_xft_settings (dpyinfo, True, &settings);
558 if (settings.seen & SEEN_TB_STYLE)
560 Lisp_Object style = Qnil;
561 if (strcmp (settings.tb_style, "both") == 0)
562 style = Qboth;
563 else if (strcmp (settings.tb_style, "both-horiz") == 0)
564 style = Qboth_horiz;
565 else if (strcmp (settings.tb_style, "icons") == 0)
566 style = Qimage;
567 else if (strcmp (settings.tb_style, "text") == 0)
568 style = Qtext;
569 if (!NILP (style) && !EQ (style, current_tool_bar_style))
571 current_tool_bar_style = style;
572 if (send_event_p)
573 store_config_changed_event (Qtool_bar_style, dpyname);
575 xfree (settings.tb_style);
578 if (settings.seen & SEEN_FONT)
580 if (!current_font || strcmp (current_font, settings.font) != 0)
582 xfree (current_font);
583 current_font = settings.font;
584 if (send_event_p)
585 store_config_changed_event (Qfont_name, dpyname);
587 else
588 xfree (settings.font);
592 void
593 xft_settings_event (struct x_display_info *dpyinfo, XEvent *event)
595 int check_window_p = 0;
596 int apply_settings = 0;
598 switch (event->type)
600 case DestroyNotify:
601 if (dpyinfo->xsettings_window == event->xany.window)
602 check_window_p = 1;
603 break;
605 case ClientMessage:
606 if (event->xclient.message_type == dpyinfo->Xatom_xsettings_mgr
607 && event->xclient.data.l[1] == dpyinfo->Xatom_xsettings_sel
608 && event->xclient.window == dpyinfo->root_window)
609 check_window_p = 1;
610 break;
612 case PropertyNotify:
613 if (event->xproperty.window == dpyinfo->xsettings_window
614 && event->xproperty.state == PropertyNewValue
615 && event->xproperty.atom == dpyinfo->Xatom_xsettings_prop)
616 apply_settings = 1;
617 break;
621 if (check_window_p)
623 dpyinfo->xsettings_window = None;
624 get_prop_window (dpyinfo);
625 if (dpyinfo->xsettings_window != None)
626 apply_settings = 1;
629 if (apply_settings)
630 read_and_apply_settings (dpyinfo, True);
634 static void
635 init_gconf (void)
637 #if defined (HAVE_GCONF) && defined (HAVE_XFT)
638 char *s;
640 #ifdef HAVE_G_TYPE_INIT
641 g_type_init ();
642 #endif
643 gconf_client = gconf_client_get_default ();
644 s = gconf_client_get_string (gconf_client, SYSTEM_MONO_FONT, NULL);
645 if (s)
647 current_mono_font = xstrdup (s);
648 g_free (s);
650 s = gconf_client_get_string (gconf_client, SYSTEM_FONT, NULL);
651 if (s)
653 current_font = xstrdup (s);
654 g_free (s);
656 gconf_client_set_error_handling (gconf_client, GCONF_CLIENT_HANDLE_NONE);
657 gconf_client_add_dir (gconf_client,
658 SYSTEM_MONO_FONT,
659 GCONF_CLIENT_PRELOAD_ONELEVEL,
660 NULL);
661 gconf_client_notify_add (gconf_client,
662 SYSTEM_MONO_FONT,
663 something_changedCB,
664 NULL, NULL, NULL);
665 #endif /* HAVE_GCONF && HAVE_XFT */
668 static void
669 init_xsettings (struct x_display_info *dpyinfo)
671 Display *dpy = dpyinfo->display;
673 BLOCK_INPUT;
675 /* Select events so we can detect client messages sent when selection
676 owner changes. */
677 XSelectInput (dpy, dpyinfo->root_window, StructureNotifyMask);
679 get_prop_window (dpyinfo);
680 if (dpyinfo->xsettings_window != None)
681 read_and_apply_settings (dpyinfo, False);
683 UNBLOCK_INPUT;
686 void
687 xsettings_initialize (struct x_display_info *dpyinfo)
689 if (first_dpyinfo == NULL) first_dpyinfo = dpyinfo;
690 init_gconf ();
691 init_xsettings (dpyinfo);
694 const char *
695 xsettings_get_system_font (void)
697 return current_mono_font;
700 #ifdef USE_LUCID
701 const char *
702 xsettings_get_system_normal_font (void)
704 return current_font;
706 #endif
708 DEFUN ("font-get-system-normal-font", Ffont_get_system_normal_font,
709 Sfont_get_system_normal_font,
710 0, 0, 0,
711 doc: /* Get the system default application font. */)
712 (void)
714 return current_font
715 ? make_string (current_font, strlen (current_font))
716 : Qnil;
719 DEFUN ("font-get-system-font", Ffont_get_system_font, Sfont_get_system_font,
720 0, 0, 0,
721 doc: /* Get the system default fixed width font. */)
722 (void)
724 return current_mono_font
725 ? make_string (current_mono_font, strlen (current_mono_font))
726 : Qnil;
729 DEFUN ("tool-bar-get-system-style", Ftool_bar_get_system_style,
730 Stool_bar_get_system_style, 0, 0, 0,
731 doc: /* Get the system tool bar style.
732 If no system tool bar style is known, return `tool-bar-style' if set to a
733 known style. Otherwise return image. */)
734 (void)
736 if (EQ (Vtool_bar_style, Qimage)
737 || EQ (Vtool_bar_style, Qtext)
738 || EQ (Vtool_bar_style, Qboth)
739 || EQ (Vtool_bar_style, Qboth_horiz)
740 || EQ (Vtool_bar_style, Qtext_image_horiz))
741 return Vtool_bar_style;
742 if (!NILP (current_tool_bar_style))
743 return current_tool_bar_style;
744 return Qimage;
747 void
748 syms_of_xsettings (void)
750 current_mono_font = NULL;
751 current_font = NULL;
752 first_dpyinfo = NULL;
753 #ifdef HAVE_GCONF
754 gconf_client = NULL;
755 #endif
757 Qmonospace_font_name = intern_c_string ("monospace-font-name");
758 staticpro (&Qmonospace_font_name);
759 Qfont_name = intern_c_string ("font-name");
760 staticpro (&Qfont_name);
761 Qfont_render = intern_c_string ("font-render");
762 staticpro (&Qfont_render);
763 defsubr (&Sfont_get_system_font);
764 defsubr (&Sfont_get_system_normal_font);
766 DEFVAR_BOOL ("font-use-system-font", use_system_font,
767 doc: /* *Non-nil means to apply the system defined font dynamically.
768 When this is non-nil and the system defined fixed width font changes, we
769 update frames dynamically.
770 If this variable is nil, Emacs ignores system font changes. */);
771 use_system_font = 0;
773 DEFVAR_LISP ("xft-settings", Vxft_settings,
774 doc: /* Font settings applied to Xft. */);
775 Vxft_settings = make_string ("", 0);
777 #ifdef HAVE_XFT
778 Fprovide (intern_c_string ("font-render-setting"), Qnil);
779 #ifdef HAVE_GCONF
780 Fprovide (intern_c_string ("system-font-setting"), Qnil);
781 #endif
782 #endif
784 current_tool_bar_style = Qnil;
785 Qtool_bar_style = intern_c_string ("tool-bar-style");
786 staticpro (&Qtool_bar_style);
787 defsubr (&Stool_bar_get_system_style);
789 Fprovide (intern_c_string ("dynamic-setting"), Qnil);