Commit | Line | Data |
---|---|---|
4ff155dd GM |
1 | /* Functions for handling font and other changes dynamically. |
2 | ||
ba318903 | 3 | Copyright (C) 2009-2014 Free Software Foundation, Inc. |
637fa988 JD |
4 | |
5 | This file is part of GNU Emacs. | |
6 | ||
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. | |
11 | ||
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. | |
16 | ||
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/>. */ | |
19 | ||
08a494a3 | 20 | #include <config.h> |
aaafe47a PE |
21 | |
22 | #include <float.h> | |
210af043 | 23 | #include <limits.h> |
637fa988 | 24 | #include <fcntl.h> |
4eed3157 PE |
25 | |
26 | #include <byteswap.h> | |
27 | ||
637fa988 JD |
28 | #include "lisp.h" |
29 | #include "xterm.h" | |
30 | #include "xsettings.h" | |
31 | #include "frame.h" | |
b87dd913 | 32 | #include "keyboard.h" |
637fa988 JD |
33 | #include "blockinput.h" |
34 | #include "termhooks.h" | |
637fa988 JD |
35 | |
36 | #include <X11/Xproto.h> | |
37 | ||
9851bfc5 | 38 | #ifdef HAVE_GSETTINGS |
51bb811f JD |
39 | #include <glib-object.h> |
40 | #include <gio/gio.h> | |
869795d6 JD |
41 | #endif |
42 | ||
637fa988 JD |
43 | #ifdef HAVE_GCONF |
44 | #include <gconf/gconf-client.h> | |
45 | #endif | |
9851bfc5 | 46 | |
637fa988 JD |
47 | #ifdef HAVE_XFT |
48 | #include <X11/Xft/Xft.h> | |
49 | #endif | |
50 | ||
51 | static char *current_mono_font; | |
99852628 | 52 | static char *current_font; |
637fa988 | 53 | static struct x_display_info *first_dpyinfo; |
f904c0f9 JD |
54 | static Lisp_Object Qmonospace_font_name, Qfont_name, Qfont_render, |
55 | Qtool_bar_style; | |
f904c0f9 | 56 | static Lisp_Object current_tool_bar_style; |
637fa988 | 57 | |
869795d6 JD |
58 | /* Store an config changed event in to the event queue. */ |
59 | ||
637fa988 | 60 | static void |
971de7fb | 61 | store_config_changed_event (Lisp_Object arg, Lisp_Object display_name) |
637fa988 JD |
62 | { |
63 | struct input_event event; | |
64 | EVENT_INIT (event); | |
65 | event.kind = CONFIG_CHANGED_EVENT; | |
66 | event.frame_or_window = display_name; | |
67 | event.arg = arg; | |
68 | kbd_buffer_store_event (&event); | |
69 | } | |
70 | ||
869795d6 JD |
71 | /* Return non-zero if DPYINFO is still valid. */ |
72 | static int | |
73 | dpyinfo_valid (struct x_display_info *dpyinfo) | |
74 | { | |
75 | int found = 0; | |
76 | if (dpyinfo != NULL) | |
77 | { | |
78 | struct x_display_info *d; | |
79 | for (d = x_display_list; !found && d; d = d->next) | |
80 | found = d == dpyinfo && d->display == dpyinfo->display; | |
81 | } | |
82 | return found; | |
83 | } | |
84 | ||
85 | /* Store a monospace font change event if the monospaced font changed. */ | |
86 | ||
490011a6 | 87 | #if defined HAVE_XFT && (defined HAVE_GSETTINGS || defined HAVE_GCONF) |
9851bfc5 | 88 | static void |
0949d2b6 | 89 | store_monospaced_changed (const char *newfont) |
9851bfc5 | 90 | { |
0949d2b6 JD |
91 | if (current_mono_font != NULL && strcmp (newfont, current_mono_font) == 0) |
92 | return; /* No change. */ | |
93 | ||
8268febf | 94 | dupstring (¤t_mono_font, newfont); |
0949d2b6 | 95 | |
869795d6 | 96 | if (dpyinfo_valid (first_dpyinfo) && use_system_font) |
9851bfc5 | 97 | { |
869795d6 JD |
98 | store_config_changed_event (Qmonospace_font_name, |
99 | XCAR (first_dpyinfo->name_list_element)); | |
9851bfc5 JD |
100 | } |
101 | } | |
490011a6 | 102 | #endif |
9851bfc5 | 103 | |
869795d6 | 104 | /* Store a font name change event if the font name changed. */ |
9851bfc5 | 105 | |
490011a6 | 106 | #ifdef HAVE_XFT |
869795d6 JD |
107 | static void |
108 | store_font_name_changed (const char *newfont) | |
109 | { | |
110 | if (current_font != NULL && strcmp (newfont, current_font) == 0) | |
111 | return; /* No change. */ | |
112 | ||
8268febf | 113 | dupstring (¤t_font, newfont); |
869795d6 JD |
114 | |
115 | if (dpyinfo_valid (first_dpyinfo)) | |
116 | { | |
117 | store_config_changed_event (Qfont_name, | |
118 | XCAR (first_dpyinfo->name_list_element)); | |
119 | } | |
120 | } | |
121 | #endif /* HAVE_XFT */ | |
122 | ||
da6062e6 | 123 | /* Map TOOL_BAR_STYLE from a string to its corresponding Lisp value. |
869795d6 JD |
124 | Return Qnil if TOOL_BAR_STYLE is not known. */ |
125 | ||
126 | static Lisp_Object | |
127 | map_tool_bar_style (const char *tool_bar_style) | |
128 | { | |
129 | Lisp_Object style = Qnil; | |
130 | if (tool_bar_style) | |
131 | { | |
132 | if (strcmp (tool_bar_style, "both") == 0) | |
133 | style = Qboth; | |
134 | else if (strcmp (tool_bar_style, "both-horiz") == 0) | |
135 | style = Qboth_horiz; | |
136 | else if (strcmp (tool_bar_style, "icons") == 0) | |
137 | style = Qimage; | |
138 | else if (strcmp (tool_bar_style, "text") == 0) | |
139 | style = Qtext; | |
140 | } | |
141 | ||
142 | return style; | |
143 | } | |
144 | ||
145 | /* Store a tool bar style change event if the tool bar style changed. */ | |
146 | ||
147 | static void | |
148 | store_tool_bar_style_changed (const char *newstyle, | |
149 | struct x_display_info *dpyinfo) | |
150 | { | |
151 | Lisp_Object style = map_tool_bar_style (newstyle); | |
152 | if (EQ (current_tool_bar_style, style)) | |
153 | return; /* No change. */ | |
154 | ||
155 | current_tool_bar_style = style; | |
156 | if (dpyinfo_valid (dpyinfo)) | |
157 | store_config_changed_event (Qtool_bar_style, | |
158 | XCAR (dpyinfo->name_list_element)); | |
159 | } | |
9851bfc5 | 160 | |
2014308a | 161 | #ifdef HAVE_XFT |
f904c0f9 | 162 | #define XSETTINGS_FONT_NAME "Gtk/FontName" |
2014308a | 163 | #endif |
f904c0f9 | 164 | #define XSETTINGS_TOOL_BAR_STYLE "Gtk/ToolbarStyle" |
0269ef77 | 165 | |
f904c0f9 JD |
166 | enum { |
167 | SEEN_AA = 0x01, | |
168 | SEEN_HINTING = 0x02, | |
169 | SEEN_RGBA = 0x04, | |
170 | SEEN_LCDFILTER = 0x08, | |
171 | SEEN_HINTSTYLE = 0x10, | |
172 | SEEN_DPI = 0x20, | |
173 | SEEN_FONT = 0x40, | |
29abe551 | 174 | SEEN_TB_STYLE = 0x80 |
f904c0f9 | 175 | }; |
af59aa6e | 176 | struct xsettings |
f904c0f9 JD |
177 | { |
178 | #ifdef HAVE_XFT | |
179 | FcBool aa, hinting; | |
180 | int rgba, lcdfilter, hintstyle; | |
181 | double dpi; | |
f904c0f9 JD |
182 | |
183 | char *font; | |
869795d6 JD |
184 | #endif |
185 | ||
f904c0f9 JD |
186 | char *tb_style; |
187 | ||
188 | unsigned seen; | |
189 | }; | |
190 | ||
9851bfc5 | 191 | #ifdef HAVE_GSETTINGS |
869795d6 JD |
192 | #define GSETTINGS_SCHEMA "org.gnome.desktop.interface" |
193 | #define GSETTINGS_TOOL_BAR_STYLE "toolbar-style" | |
194 | ||
195 | #ifdef HAVE_XFT | |
196 | #define GSETTINGS_MONO_FONT "monospace-font-name" | |
197 | #define GSETTINGS_FONT_NAME "font-name" | |
198 | #endif | |
199 | ||
200 | ||
201 | /* The single GSettings instance, or NULL if not connected to GSettings. */ | |
202 | ||
203 | static GSettings *gsettings_client; | |
204 | ||
205 | /* Callback called when something changed in GSettings. */ | |
31a01b90 | 206 | |
0949d2b6 | 207 | static void |
869795d6 JD |
208 | something_changed_gsettingsCB (GSettings *settings, |
209 | gchar *key, | |
210 | gpointer user_data) | |
0949d2b6 JD |
211 | { |
212 | GVariant *val; | |
869795d6 JD |
213 | |
214 | if (strcmp (key, GSETTINGS_TOOL_BAR_STYLE) == 0) | |
0949d2b6 | 215 | { |
869795d6 JD |
216 | val = g_settings_get_value (settings, GSETTINGS_TOOL_BAR_STYLE); |
217 | if (val) | |
0949d2b6 | 218 | { |
869795d6 JD |
219 | g_variant_ref_sink (val); |
220 | if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING)) | |
221 | { | |
222 | const gchar *newstyle = g_variant_get_string (val, NULL); | |
223 | store_tool_bar_style_changed (newstyle, first_dpyinfo); | |
224 | } | |
225 | g_variant_unref (val); | |
226 | } | |
227 | } | |
228 | #ifdef HAVE_XFT | |
229 | else if (strcmp (key, GSETTINGS_MONO_FONT) == 0) | |
230 | { | |
231 | val = g_settings_get_value (settings, GSETTINGS_MONO_FONT); | |
232 | if (val) | |
233 | { | |
234 | g_variant_ref_sink (val); | |
235 | if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING)) | |
236 | { | |
237 | const gchar *newfont = g_variant_get_string (val, NULL); | |
238 | store_monospaced_changed (newfont); | |
239 | } | |
240 | g_variant_unref (val); | |
0949d2b6 | 241 | } |
0949d2b6 | 242 | } |
869795d6 JD |
243 | else if (strcmp (key, GSETTINGS_FONT_NAME) == 0) |
244 | { | |
245 | val = g_settings_get_value (settings, GSETTINGS_FONT_NAME); | |
246 | if (val) | |
247 | { | |
248 | g_variant_ref_sink (val); | |
249 | if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING)) | |
250 | { | |
251 | const gchar *newfont = g_variant_get_string (val, NULL); | |
252 | store_font_name_changed (newfont); | |
253 | } | |
254 | g_variant_unref (val); | |
255 | } | |
256 | } | |
490011a6 | 257 | #endif /* HAVE_XFT */ |
0949d2b6 JD |
258 | } |
259 | ||
869795d6 | 260 | #endif /* HAVE_GSETTINGS */ |
2e13213d | 261 | |
869795d6 JD |
262 | #ifdef HAVE_GCONF |
263 | #define GCONF_TOOL_BAR_STYLE "/desktop/gnome/interface/toolbar_style" | |
2e13213d | 264 | #ifdef HAVE_XFT |
869795d6 JD |
265 | #define GCONF_MONO_FONT "/desktop/gnome/interface/monospace_font_name" |
266 | #define GCONF_FONT_NAME "/desktop/gnome/interface/font_name" | |
2e13213d | 267 | #endif |
31a01b90 | 268 | |
869795d6 JD |
269 | /* The single GConf instance, or NULL if not connected to GConf. */ |
270 | ||
271 | static GConfClient *gconf_client; | |
272 | ||
273 | /* Callback called when something changed in GConf that we care about. */ | |
637fa988 JD |
274 | |
275 | static void | |
869795d6 JD |
276 | something_changed_gconfCB (GConfClient *client, |
277 | guint cnxn_id, | |
278 | GConfEntry *entry, | |
279 | gpointer user_data) | |
637fa988 JD |
280 | { |
281 | GConfValue *v = gconf_entry_get_value (entry); | |
869795d6 | 282 | const char *key = gconf_entry_get_key (entry); |
af59aa6e | 283 | |
869795d6 JD |
284 | if (!v || v->type != GCONF_VALUE_STRING || ! key) return; |
285 | if (strcmp (key, GCONF_TOOL_BAR_STYLE) == 0) | |
286 | { | |
287 | const char *value = gconf_value_get_string (v); | |
288 | store_tool_bar_style_changed (value, first_dpyinfo); | |
289 | } | |
290 | #ifdef HAVE_XFT | |
291 | else if (strcmp (key, GCONF_MONO_FONT) == 0) | |
637fa988 JD |
292 | { |
293 | const char *value = gconf_value_get_string (v); | |
0949d2b6 | 294 | store_monospaced_changed (value); |
637fa988 | 295 | } |
869795d6 JD |
296 | else if (strcmp (key, GCONF_FONT_NAME) == 0) |
297 | { | |
298 | const char *value = gconf_value_get_string (v); | |
299 | store_font_name_changed (value); | |
300 | } | |
301 | #endif /* HAVE_XFT */ | |
637fa988 | 302 | } |
9851bfc5 | 303 | |
637fa988 JD |
304 | #endif /* HAVE_GCONF */ |
305 | ||
306 | #ifdef HAVE_XFT | |
307 | ||
21050de1 JD |
308 | /* Older fontconfig versions don't have FC_LCD_*. */ |
309 | #ifndef FC_LCD_NONE | |
310 | #define FC_LCD_NONE 0 | |
311 | #endif | |
312 | #ifndef FC_LCD_DEFAULT | |
313 | #define FC_LCD_DEFAULT 1 | |
314 | #endif | |
315 | #ifndef FC_LCD_FILTER | |
316 | #define FC_LCD_FILTER "lcdfilter" | |
317 | #endif | |
318 | ||
f904c0f9 JD |
319 | #endif /* HAVE_XFT */ |
320 | ||
637fa988 JD |
321 | /* Find the window that contains the XSETTINGS property values. */ |
322 | ||
323 | static void | |
971de7fb | 324 | get_prop_window (struct x_display_info *dpyinfo) |
637fa988 JD |
325 | { |
326 | Display *dpy = dpyinfo->display; | |
327 | ||
328 | XGrabServer (dpy); | |
329 | dpyinfo->xsettings_window = XGetSelectionOwner (dpy, | |
330 | dpyinfo->Xatom_xsettings_sel); | |
331 | if (dpyinfo->xsettings_window != None) | |
332 | /* Select events so we can detect if window is deleted or if settings | |
333 | are changed. */ | |
334 | XSelectInput (dpy, dpyinfo->xsettings_window, | |
335 | PropertyChangeMask|StructureNotifyMask); | |
336 | ||
337 | XUngrabServer (dpy); | |
338 | } | |
339 | ||
637fa988 JD |
340 | #define PAD(nr) (((nr) + 3) & ~3) |
341 | ||
342 | /* Parse xsettings and extract those that deal with Xft. | |
343 | See http://freedesktop.org/wiki/Specifications/XSettingsRegistry | |
344 | and http://standards.freedesktop.org/xsettings-spec/xsettings-spec-0.5.html. | |
345 | ||
346 | Layout of prop. First is a header: | |
347 | ||
348 | bytes type what | |
349 | ------------------------------------ | |
350 | 1 CARD8 byte-order | |
351 | 3 unused | |
352 | 4 CARD32 SERIAL | |
353 | 4 CARD32 N_SETTINGS | |
354 | ||
355 | Then N_SETTINGS records, with header: | |
356 | ||
357 | bytes type what | |
358 | ------------------------------------ | |
359 | 1 SETTING_TYPE type (0 = integer, 1 = string, 2 RGB color). | |
360 | 1 unused | |
361 | 2 CARD16 n == name-length | |
362 | n STRING8 name | |
363 | p unused, p=pad_to_even_4(n) | |
364 | 4 CARD32 last-change-serial | |
365 | ||
366 | and then the value, For string: | |
af59aa6e | 367 | |
637fa988 JD |
368 | bytes type what |
369 | ------------------------------------ | |
370 | 4 CARD32 n = value-length | |
371 | n STRING8 value | |
372 | p unused, p=pad_to_even_4(n) | |
373 | ||
374 | For integer: | |
375 | ||
376 | bytes type what | |
377 | ------------------------------------ | |
378 | 4 INT32 value | |
379 | ||
380 | For RGB color: | |
381 | ||
382 | bytes type what | |
383 | ------------------------------------ | |
384 | 2 CARD16 red | |
385 | 2 CARD16 blue | |
386 | 2 CARD16 green | |
387 | 2 CARD16 alpha | |
388 | ||
3c055b77 | 389 | Returns non-zero if some Xft settings was seen, zero otherwise. |
637fa988 JD |
390 | */ |
391 | ||
392 | static int | |
e4c8d29a | 393 | parse_settings (unsigned char *prop, |
2d9783e0 | 394 | unsigned long bytes, |
e4c8d29a | 395 | struct xsettings *settings) |
637fa988 JD |
396 | { |
397 | Lisp_Object byteorder = Fbyteorder (); | |
398 | int my_bo = XFASTINT (byteorder) == 'B' ? MSBFirst : LSBFirst; | |
399 | int that_bo = prop[0]; | |
400 | CARD32 n_settings; | |
401 | int bytes_parsed = 0; | |
402 | int settings_seen = 0; | |
403 | int i = 0; | |
404 | ||
405 | /* First 4 bytes is a serial number, skip that. */ | |
406 | ||
407 | if (bytes < 12) return BadLength; | |
408 | memcpy (&n_settings, prop+8, 4); | |
4eed3157 | 409 | if (my_bo != that_bo) n_settings = bswap_32 (n_settings); |
637fa988 JD |
410 | bytes_parsed = 12; |
411 | ||
412 | memset (settings, 0, sizeof (*settings)); | |
413 | ||
99852628 | 414 | while (bytes_parsed+4 < bytes && settings_seen < 7 |
637fa988 JD |
415 | && i < n_settings) |
416 | { | |
417 | int type = prop[bytes_parsed++]; | |
418 | CARD16 nlen; | |
419 | CARD32 vlen, ival = 0; | |
420 | char name[128]; /* The names we are looking for are not this long. */ | |
421 | char sval[128]; /* The values we are looking for are not this long. */ | |
99852628 | 422 | int want_this; |
637fa988 JD |
423 | int to_cpy; |
424 | ||
425 | sval[0] = '\0'; | |
426 | ++i; | |
427 | ++bytes_parsed; /* Padding */ | |
428 | ||
429 | memcpy (&nlen, prop+bytes_parsed, 2); | |
430 | bytes_parsed += 2; | |
4eed3157 | 431 | if (my_bo != that_bo) nlen = bswap_16 (nlen); |
637fa988 JD |
432 | if (bytes_parsed+nlen > bytes) return BadLength; |
433 | to_cpy = nlen > 127 ? 127 : nlen; | |
434 | memcpy (name, prop+bytes_parsed, to_cpy); | |
435 | name[to_cpy] = '\0'; | |
436 | ||
437 | bytes_parsed += nlen; | |
438 | bytes_parsed = PAD (bytes_parsed); | |
439 | ||
440 | bytes_parsed += 4; /* Skip serial for this value */ | |
441 | if (bytes_parsed > bytes) return BadLength; | |
442 | ||
490011a6 | 443 | want_this = |
f904c0f9 JD |
444 | #ifdef HAVE_XFT |
445 | (nlen > 6 && strncmp (name, "Xft/", 4) == 0) | |
869795d6 | 446 | || strcmp (XSETTINGS_FONT_NAME, name) == 0 |
f904c0f9 JD |
447 | || |
448 | #endif | |
869795d6 | 449 | strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0; |
490011a6 | 450 | |
af59aa6e | 451 | switch (type) |
637fa988 JD |
452 | { |
453 | case 0: /* Integer */ | |
454 | if (bytes_parsed+4 > bytes) return BadLength; | |
99852628 | 455 | if (want_this) |
637fa988 JD |
456 | { |
457 | memcpy (&ival, prop+bytes_parsed, 4); | |
4eed3157 | 458 | if (my_bo != that_bo) ival = bswap_32 (ival); |
637fa988 JD |
459 | } |
460 | bytes_parsed += 4; | |
461 | break; | |
462 | ||
463 | case 1: /* String */ | |
464 | if (bytes_parsed+4 > bytes) return BadLength; | |
465 | memcpy (&vlen, prop+bytes_parsed, 4); | |
466 | bytes_parsed += 4; | |
4eed3157 | 467 | if (my_bo != that_bo) vlen = bswap_32 (vlen); |
99852628 | 468 | if (want_this) |
637fa988 JD |
469 | { |
470 | to_cpy = vlen > 127 ? 127 : vlen; | |
471 | memcpy (sval, prop+bytes_parsed, to_cpy); | |
472 | sval[to_cpy] = '\0'; | |
473 | } | |
474 | bytes_parsed += vlen; | |
475 | bytes_parsed = PAD (bytes_parsed); | |
476 | break; | |
477 | ||
478 | case 2: /* RGB value */ | |
479 | /* No need to parse this */ | |
480 | if (bytes_parsed+8 > bytes) return BadLength; | |
af59aa6e | 481 | bytes_parsed += 8; /* 4 values (r, b, g, alpha), 2 bytes each. */ |
637fa988 JD |
482 | break; |
483 | ||
484 | default: /* Parse Error */ | |
485 | return BadValue; | |
486 | } | |
487 | ||
af59aa6e | 488 | if (want_this) |
637fa988 JD |
489 | { |
490 | ++settings_seen; | |
869795d6 | 491 | if (strcmp (name, XSETTINGS_TOOL_BAR_STYLE) == 0) |
f904c0f9 | 492 | { |
8268febf | 493 | dupstring (&settings->tb_style, sval); |
f904c0f9 JD |
494 | settings->seen |= SEEN_TB_STYLE; |
495 | } | |
496 | #ifdef HAVE_XFT | |
869795d6 JD |
497 | else if (strcmp (name, XSETTINGS_FONT_NAME) == 0) |
498 | { | |
8268febf | 499 | dupstring (&settings->font, sval); |
869795d6 JD |
500 | settings->seen |= SEEN_FONT; |
501 | } | |
f904c0f9 | 502 | else if (strcmp (name, "Xft/Antialias") == 0) |
3c055b77 JD |
503 | { |
504 | settings->seen |= SEEN_AA; | |
505 | settings->aa = ival != 0; | |
506 | } | |
637fa988 | 507 | else if (strcmp (name, "Xft/Hinting") == 0) |
3c055b77 JD |
508 | { |
509 | settings->seen |= SEEN_HINTING; | |
510 | settings->hinting = ival != 0; | |
511 | } | |
af59aa6e | 512 | # ifdef FC_HINT_STYLE |
637fa988 JD |
513 | else if (strcmp (name, "Xft/HintStyle") == 0) |
514 | { | |
3c055b77 | 515 | settings->seen |= SEEN_HINTSTYLE; |
637fa988 JD |
516 | if (strcmp (sval, "hintnone") == 0) |
517 | settings->hintstyle = FC_HINT_NONE; | |
518 | else if (strcmp (sval, "hintslight") == 0) | |
519 | settings->hintstyle = FC_HINT_SLIGHT; | |
520 | else if (strcmp (sval, "hintmedium") == 0) | |
521 | settings->hintstyle = FC_HINT_MEDIUM; | |
522 | else if (strcmp (sval, "hintfull") == 0) | |
523 | settings->hintstyle = FC_HINT_FULL; | |
3c055b77 JD |
524 | else |
525 | settings->seen &= ~SEEN_HINTSTYLE; | |
637fa988 | 526 | } |
af59aa6e | 527 | # endif |
637fa988 JD |
528 | else if (strcmp (name, "Xft/RGBA") == 0) |
529 | { | |
3c055b77 | 530 | settings->seen |= SEEN_RGBA; |
637fa988 JD |
531 | if (strcmp (sval, "none") == 0) |
532 | settings->rgba = FC_RGBA_NONE; | |
533 | else if (strcmp (sval, "rgb") == 0) | |
534 | settings->rgba = FC_RGBA_RGB; | |
535 | else if (strcmp (sval, "bgr") == 0) | |
536 | settings->rgba = FC_RGBA_BGR; | |
537 | else if (strcmp (sval, "vrgb") == 0) | |
538 | settings->rgba = FC_RGBA_VRGB; | |
539 | else if (strcmp (sval, "vbgr") == 0) | |
540 | settings->rgba = FC_RGBA_VBGR; | |
3c055b77 JD |
541 | else |
542 | settings->seen &= ~SEEN_RGBA; | |
637fa988 JD |
543 | } |
544 | else if (strcmp (name, "Xft/DPI") == 0) | |
3c055b77 JD |
545 | { |
546 | settings->seen |= SEEN_DPI; | |
547 | settings->dpi = (double)ival/1024.0; | |
548 | } | |
637fa988 JD |
549 | else if (strcmp (name, "Xft/lcdfilter") == 0) |
550 | { | |
3c055b77 | 551 | settings->seen |= SEEN_LCDFILTER; |
637fa988 JD |
552 | if (strcmp (sval, "none") == 0) |
553 | settings->lcdfilter = FC_LCD_NONE; | |
554 | else if (strcmp (sval, "lcddefault") == 0) | |
555 | settings->lcdfilter = FC_LCD_DEFAULT; | |
3c055b77 JD |
556 | else |
557 | settings->seen &= ~SEEN_LCDFILTER; | |
637fa988 | 558 | } |
f904c0f9 | 559 | #endif /* HAVE_XFT */ |
637fa988 JD |
560 | } |
561 | } | |
562 | ||
3c055b77 | 563 | return settings_seen; |
637fa988 JD |
564 | } |
565 | ||
869795d6 JD |
566 | /* Read settings from the XSettings property window on display for DPYINFO. |
567 | Store settings read in SETTINGS. | |
568 | Return non-zero if successful, zero if not. */ | |
569 | ||
637fa988 | 570 | static int |
971de7fb | 571 | read_settings (struct x_display_info *dpyinfo, struct xsettings *settings) |
637fa988 | 572 | { |
637fa988 JD |
573 | Atom act_type; |
574 | int act_form; | |
575 | unsigned long nitems, bytes_after; | |
576 | unsigned char *prop = NULL; | |
577 | Display *dpy = dpyinfo->display; | |
578 | int rc; | |
579 | ||
580 | x_catch_errors (dpy); | |
581 | rc = XGetWindowProperty (dpy, | |
582 | dpyinfo->xsettings_window, | |
583 | dpyinfo->Xatom_xsettings_prop, | |
584 | 0, LONG_MAX, False, AnyPropertyType, | |
585 | &act_type, &act_form, &nitems, &bytes_after, | |
586 | &prop); | |
587 | ||
588 | if (rc == Success && prop != NULL && act_form == 8 && nitems > 0 | |
589 | && act_type == dpyinfo->Xatom_xsettings_prop) | |
f904c0f9 | 590 | rc = parse_settings (prop, nitems, settings); |
637fa988 JD |
591 | |
592 | XFree (prop); | |
593 | ||
594 | x_uncatch_errors (); | |
595 | ||
3c055b77 | 596 | return rc != 0; |
637fa988 JD |
597 | } |
598 | ||
869795d6 JD |
599 | /* Apply Xft settings in SETTINGS to the Xft library. |
600 | If SEND_EVENT_P is non-zero store a Lisp event that Xft settings changed. */ | |
581e51e8 | 601 | |
637fa988 | 602 | static void |
e4c8d29a J |
603 | apply_xft_settings (struct x_display_info *dpyinfo, |
604 | int send_event_p, | |
605 | struct xsettings *settings) | |
637fa988 | 606 | { |
f904c0f9 | 607 | #ifdef HAVE_XFT |
637fa988 | 608 | FcPattern *pat; |
f904c0f9 | 609 | struct xsettings oldsettings; |
637fa988 JD |
610 | int changed = 0; |
611 | ||
637fa988 | 612 | memset (&oldsettings, 0, sizeof (oldsettings)); |
637fa988 JD |
613 | pat = FcPatternCreate (); |
614 | XftDefaultSubstitute (dpyinfo->display, | |
615 | XScreenNumberOfScreen (dpyinfo->screen), | |
616 | pat); | |
617 | FcPatternGetBool (pat, FC_ANTIALIAS, 0, &oldsettings.aa); | |
618 | FcPatternGetBool (pat, FC_HINTING, 0, &oldsettings.hinting); | |
869795d6 | 619 | #ifdef FC_HINT_STYLE |
637fa988 | 620 | FcPatternGetInteger (pat, FC_HINT_STYLE, 0, &oldsettings.hintstyle); |
869795d6 | 621 | #endif |
637fa988 JD |
622 | FcPatternGetInteger (pat, FC_LCD_FILTER, 0, &oldsettings.lcdfilter); |
623 | FcPatternGetInteger (pat, FC_RGBA, 0, &oldsettings.rgba); | |
624 | FcPatternGetDouble (pat, FC_DPI, 0, &oldsettings.dpi); | |
625 | ||
f904c0f9 | 626 | if ((settings->seen & SEEN_AA) != 0 && oldsettings.aa != settings->aa) |
637fa988 JD |
627 | { |
628 | FcPatternDel (pat, FC_ANTIALIAS); | |
f904c0f9 | 629 | FcPatternAddBool (pat, FC_ANTIALIAS, settings->aa); |
637fa988 | 630 | ++changed; |
f904c0f9 | 631 | oldsettings.aa = settings->aa; |
637fa988 | 632 | } |
67477f30 | 633 | |
f904c0f9 JD |
634 | if ((settings->seen & SEEN_HINTING) != 0 |
635 | && oldsettings.hinting != settings->hinting) | |
637fa988 JD |
636 | { |
637 | FcPatternDel (pat, FC_HINTING); | |
f904c0f9 | 638 | FcPatternAddBool (pat, FC_HINTING, settings->hinting); |
637fa988 | 639 | ++changed; |
f904c0f9 | 640 | oldsettings.hinting = settings->hinting; |
637fa988 | 641 | } |
f904c0f9 | 642 | if ((settings->seen & SEEN_RGBA) != 0 && oldsettings.rgba != settings->rgba) |
637fa988 JD |
643 | { |
644 | FcPatternDel (pat, FC_RGBA); | |
f904c0f9 JD |
645 | FcPatternAddInteger (pat, FC_RGBA, settings->rgba); |
646 | oldsettings.rgba = settings->rgba; | |
637fa988 JD |
647 | ++changed; |
648 | } | |
67477f30 | 649 | |
a6eb20d8 | 650 | /* Older fontconfig versions don't have FC_LCD_FILTER. */ |
f904c0f9 JD |
651 | if ((settings->seen & SEEN_LCDFILTER) != 0 |
652 | && oldsettings.lcdfilter != settings->lcdfilter) | |
637fa988 JD |
653 | { |
654 | FcPatternDel (pat, FC_LCD_FILTER); | |
f904c0f9 | 655 | FcPatternAddInteger (pat, FC_LCD_FILTER, settings->lcdfilter); |
637fa988 | 656 | ++changed; |
f904c0f9 | 657 | oldsettings.lcdfilter = settings->lcdfilter; |
637fa988 | 658 | } |
67477f30 | 659 | |
869795d6 | 660 | #ifdef FC_HINT_STYLE |
f904c0f9 JD |
661 | if ((settings->seen & SEEN_HINTSTYLE) != 0 |
662 | && oldsettings.hintstyle != settings->hintstyle) | |
637fa988 JD |
663 | { |
664 | FcPatternDel (pat, FC_HINT_STYLE); | |
f904c0f9 | 665 | FcPatternAddInteger (pat, FC_HINT_STYLE, settings->hintstyle); |
637fa988 | 666 | ++changed; |
f904c0f9 | 667 | oldsettings.hintstyle = settings->hintstyle; |
637fa988 | 668 | } |
869795d6 | 669 | #endif |
67477f30 | 670 | |
f904c0f9 JD |
671 | if ((settings->seen & SEEN_DPI) != 0 && oldsettings.dpi != settings->dpi |
672 | && settings->dpi > 0) | |
637fa988 | 673 | { |
637fa988 | 674 | FcPatternDel (pat, FC_DPI); |
f904c0f9 | 675 | FcPatternAddDouble (pat, FC_DPI, settings->dpi); |
637fa988 | 676 | ++changed; |
f904c0f9 | 677 | oldsettings.dpi = settings->dpi; |
af59aa6e | 678 | |
42143acd DA |
679 | /* Changing the DPI on this display affects all frames on it. |
680 | Check FRAME_RES_X and FRAME_RES_Y in frame.h to see how. */ | |
f904c0f9 | 681 | dpyinfo->resy = dpyinfo->resx = settings->dpi; |
637fa988 JD |
682 | } |
683 | ||
684 | if (changed) | |
685 | { | |
aaafe47a PE |
686 | static char const format[] = |
687 | "Antialias: %d, Hinting: %d, RGBA: %d, LCDFilter: %d, " | |
29abe551 | 688 | "Hintstyle: %d, DPI: %f"; |
aaafe47a PE |
689 | enum |
690 | { | |
691 | d_formats = 5, | |
692 | d_growth = INT_BUFSIZE_BOUND (int) - sizeof "%d", | |
693 | lf_formats = 1, | |
694 | max_f_integer_digits = DBL_MAX_10_EXP + 1, | |
695 | f_precision = 6, | |
696 | lf_growth = (sizeof "-." + max_f_integer_digits + f_precision | |
29abe551 | 697 | - sizeof "%f") |
aaafe47a PE |
698 | }; |
699 | char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth]; | |
700 | ||
637fa988 JD |
701 | XftDefaultSet (dpyinfo->display, pat); |
702 | if (send_event_p) | |
f904c0f9 JD |
703 | store_config_changed_event (Qfont_render, |
704 | XCAR (dpyinfo->name_list_element)); | |
0328b6de | 705 | Vxft_settings |
a8290ec3 DA |
706 | = make_formatted_string (buf, format, |
707 | oldsettings.aa, oldsettings.hinting, | |
708 | oldsettings.rgba, oldsettings.lcdfilter, | |
709 | oldsettings.hintstyle, oldsettings.dpi); | |
0328b6de | 710 | |
637fa988 JD |
711 | } |
712 | else | |
713 | FcPatternDestroy (pat); | |
f904c0f9 | 714 | #endif /* HAVE_XFT */ |
637fa988 JD |
715 | } |
716 | ||
869795d6 JD |
717 | /* Read XSettings from the display for DPYINFO. |
718 | If SEND_EVENT_P is non-zero store a Lisp event settings that changed. */ | |
719 | ||
f904c0f9 | 720 | static void |
971de7fb | 721 | read_and_apply_settings (struct x_display_info *dpyinfo, int send_event_p) |
f904c0f9 JD |
722 | { |
723 | struct xsettings settings; | |
f904c0f9 JD |
724 | |
725 | if (!read_settings (dpyinfo, &settings)) | |
726 | return; | |
727 | ||
728 | apply_xft_settings (dpyinfo, True, &settings); | |
729 | if (settings.seen & SEEN_TB_STYLE) | |
730 | { | |
869795d6 JD |
731 | if (send_event_p) |
732 | store_tool_bar_style_changed (settings.tb_style, dpyinfo); | |
733 | else | |
734 | current_tool_bar_style = map_tool_bar_style (settings.tb_style); | |
baad03f0 | 735 | xfree (settings.tb_style); |
f904c0f9 | 736 | } |
869795d6 | 737 | #ifdef HAVE_XFT |
f904c0f9 JD |
738 | if (settings.seen & SEEN_FONT) |
739 | { | |
869795d6 JD |
740 | if (send_event_p) |
741 | store_font_name_changed (settings.font); | |
742 | else | |
8268febf | 743 | dupstring (¤t_font, settings.font); |
869795d6 | 744 | xfree (settings.font); |
f904c0f9 | 745 | } |
869795d6 | 746 | #endif |
f904c0f9 | 747 | } |
637fa988 | 748 | |
869795d6 JD |
749 | /* Check if EVENT for the display in DPYINFO is XSettings related. */ |
750 | ||
637fa988 | 751 | void |
b7ad2f74 | 752 | xft_settings_event (struct x_display_info *dpyinfo, const XEvent *event) |
637fa988 | 753 | { |
d7e6881a | 754 | bool check_window_p = 0, apply_settings_p = 0; |
637fa988 JD |
755 | |
756 | switch (event->type) | |
757 | { | |
758 | case DestroyNotify: | |
759 | if (dpyinfo->xsettings_window == event->xany.window) | |
760 | check_window_p = 1; | |
761 | break; | |
762 | ||
763 | case ClientMessage: | |
764 | if (event->xclient.message_type == dpyinfo->Xatom_xsettings_mgr | |
765 | && event->xclient.data.l[1] == dpyinfo->Xatom_xsettings_sel | |
766 | && event->xclient.window == dpyinfo->root_window) | |
767 | check_window_p = 1; | |
768 | break; | |
769 | ||
770 | case PropertyNotify: | |
771 | if (event->xproperty.window == dpyinfo->xsettings_window | |
772 | && event->xproperty.state == PropertyNewValue | |
773 | && event->xproperty.atom == dpyinfo->Xatom_xsettings_prop) | |
d7e6881a | 774 | apply_settings_p = 1; |
637fa988 JD |
775 | break; |
776 | } | |
777 | ||
f904c0f9 | 778 | |
637fa988 JD |
779 | if (check_window_p) |
780 | { | |
781 | dpyinfo->xsettings_window = None; | |
782 | get_prop_window (dpyinfo); | |
783 | if (dpyinfo->xsettings_window != None) | |
d7e6881a | 784 | apply_settings_p = 1; |
637fa988 | 785 | } |
f904c0f9 | 786 | |
d7e6881a | 787 | if (apply_settings_p) |
f904c0f9 | 788 | read_and_apply_settings (dpyinfo, True); |
637fa988 JD |
789 | } |
790 | ||
869795d6 | 791 | /* Initialize GSettings and read startup values. */ |
637fa988 | 792 | |
9851bfc5 JD |
793 | static void |
794 | init_gsettings (void) | |
795 | { | |
796 | #ifdef HAVE_GSETTINGS | |
797 | GVariant *val; | |
0949d2b6 JD |
798 | const gchar *const *schemas; |
799 | int schema_found = 0; | |
800 | ||
3f386383 | 801 | #if ! GLIB_CHECK_VERSION (2, 36, 0) |
9851bfc5 JD |
802 | g_type_init (); |
803 | #endif | |
804 | ||
5e617bc2 | 805 | schemas = g_settings_list_schemas (); |
0949d2b6 JD |
806 | if (schemas == NULL) return; |
807 | while (! schema_found && *schemas != NULL) | |
808 | schema_found = strcmp (*schemas++, GSETTINGS_SCHEMA) == 0; | |
809 | if (!schema_found) return; | |
810 | ||
9851bfc5 JD |
811 | gsettings_client = g_settings_new (GSETTINGS_SCHEMA); |
812 | if (!gsettings_client) return; | |
813 | g_object_ref_sink (G_OBJECT (gsettings_client)); | |
869795d6 JD |
814 | g_signal_connect (G_OBJECT (gsettings_client), "changed", |
815 | G_CALLBACK (something_changed_gsettingsCB), NULL); | |
816 | ||
817 | val = g_settings_get_value (gsettings_client, GSETTINGS_TOOL_BAR_STYLE); | |
818 | if (val) | |
819 | { | |
820 | g_variant_ref_sink (val); | |
821 | if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING)) | |
822 | current_tool_bar_style | |
823 | = map_tool_bar_style (g_variant_get_string (val, NULL)); | |
824 | g_variant_unref (val); | |
825 | } | |
9851bfc5 | 826 | |
869795d6 JD |
827 | #ifdef HAVE_XFT |
828 | val = g_settings_get_value (gsettings_client, GSETTINGS_MONO_FONT); | |
2e13213d | 829 | if (val) |
9851bfc5 JD |
830 | { |
831 | g_variant_ref_sink (val); | |
832 | if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING)) | |
8268febf | 833 | dupstring (¤t_mono_font, g_variant_get_string (val, NULL)); |
9851bfc5 JD |
834 | g_variant_unref (val); |
835 | } | |
836 | ||
869795d6 JD |
837 | val = g_settings_get_value (gsettings_client, GSETTINGS_FONT_NAME); |
838 | if (val) | |
839 | { | |
840 | g_variant_ref_sink (val); | |
841 | if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING)) | |
8268febf | 842 | dupstring (¤t_font, g_variant_get_string (val, NULL)); |
869795d6 JD |
843 | g_variant_unref (val); |
844 | } | |
845 | #endif /* HAVE_XFT */ | |
846 | ||
9851bfc5 JD |
847 | #endif /* HAVE_GSETTINGS */ |
848 | } | |
849 | ||
869795d6 | 850 | /* Init GConf and read startup values. */ |
9851bfc5 | 851 | |
637fa988 | 852 | static void |
971de7fb | 853 | init_gconf (void) |
637fa988 | 854 | { |
869795d6 | 855 | #if defined (HAVE_GCONF) |
637fa988 | 856 | char *s; |
637fa988 | 857 | |
3f386383 | 858 | #if ! GLIB_CHECK_VERSION (2, 36, 0) |
637fa988 | 859 | g_type_init (); |
1e600395 | 860 | #endif |
869795d6 | 861 | |
637fa988 | 862 | gconf_client = gconf_client_get_default (); |
869795d6 JD |
863 | gconf_client_set_error_handling (gconf_client, GCONF_CLIENT_HANDLE_NONE); |
864 | gconf_client_add_dir (gconf_client, | |
865 | GCONF_TOOL_BAR_STYLE, | |
866 | GCONF_CLIENT_PRELOAD_ONELEVEL, | |
867 | NULL); | |
868 | gconf_client_notify_add (gconf_client, | |
869 | GCONF_TOOL_BAR_STYLE, | |
870 | something_changed_gconfCB, | |
871 | NULL, NULL, NULL); | |
872 | ||
873 | s = gconf_client_get_string (gconf_client, GCONF_TOOL_BAR_STYLE, NULL); | |
874 | if (s) | |
875 | { | |
876 | current_tool_bar_style = map_tool_bar_style (s); | |
877 | g_free (s); | |
878 | } | |
879 | ||
880 | #ifdef HAVE_XFT | |
881 | s = gconf_client_get_string (gconf_client, GCONF_MONO_FONT, NULL); | |
637fa988 JD |
882 | if (s) |
883 | { | |
8268febf | 884 | dupstring (¤t_mono_font, s); |
637fa988 JD |
885 | g_free (s); |
886 | } | |
869795d6 | 887 | s = gconf_client_get_string (gconf_client, GCONF_FONT_NAME, NULL); |
99852628 JD |
888 | if (s) |
889 | { | |
8268febf | 890 | dupstring (¤t_font, s); |
99852628 JD |
891 | g_free (s); |
892 | } | |
637fa988 | 893 | gconf_client_add_dir (gconf_client, |
869795d6 | 894 | GCONF_MONO_FONT, |
637fa988 JD |
895 | GCONF_CLIENT_PRELOAD_ONELEVEL, |
896 | NULL); | |
897 | gconf_client_notify_add (gconf_client, | |
869795d6 JD |
898 | GCONF_MONO_FONT, |
899 | something_changed_gconfCB, | |
637fa988 | 900 | NULL, NULL, NULL); |
869795d6 JD |
901 | gconf_client_add_dir (gconf_client, |
902 | GCONF_FONT_NAME, | |
903 | GCONF_CLIENT_PRELOAD_ONELEVEL, | |
904 | NULL); | |
905 | gconf_client_notify_add (gconf_client, | |
906 | GCONF_FONT_NAME, | |
907 | something_changed_gconfCB, | |
908 | NULL, NULL, NULL); | |
909 | #endif /* HAVE_XFT */ | |
910 | #endif /* HAVE_GCONF */ | |
637fa988 JD |
911 | } |
912 | ||
869795d6 JD |
913 | /* Init Xsettings and read startup values. */ |
914 | ||
637fa988 | 915 | static void |
971de7fb | 916 | init_xsettings (struct x_display_info *dpyinfo) |
637fa988 | 917 | { |
637fa988 JD |
918 | Display *dpy = dpyinfo->display; |
919 | ||
4d7e6e51 | 920 | block_input (); |
637fa988 | 921 | |
637fa988 JD |
922 | /* Select events so we can detect client messages sent when selection |
923 | owner changes. */ | |
924 | XSelectInput (dpy, dpyinfo->root_window, StructureNotifyMask); | |
925 | ||
926 | get_prop_window (dpyinfo); | |
927 | if (dpyinfo->xsettings_window != None) | |
f904c0f9 | 928 | read_and_apply_settings (dpyinfo, False); |
637fa988 | 929 | |
4d7e6e51 | 930 | unblock_input (); |
637fa988 JD |
931 | } |
932 | ||
933 | void | |
971de7fb | 934 | xsettings_initialize (struct x_display_info *dpyinfo) |
637fa988 JD |
935 | { |
936 | if (first_dpyinfo == NULL) first_dpyinfo = dpyinfo; | |
937 | init_gconf (); | |
f904c0f9 | 938 | init_xsettings (dpyinfo); |
869795d6 | 939 | init_gsettings (); |
637fa988 JD |
940 | } |
941 | ||
869795d6 JD |
942 | /* Return the system monospaced font. |
943 | May be NULL if not known. */ | |
944 | ||
0d1d0d26 | 945 | const char * |
971de7fb | 946 | xsettings_get_system_font (void) |
0d1d0d26 JD |
947 | { |
948 | return current_mono_font; | |
949 | } | |
637fa988 | 950 | |
e87b6180 | 951 | #ifdef USE_LUCID |
869795d6 JD |
952 | /* Return the system font. |
953 | May be NULL if not known. */ | |
954 | ||
99852628 | 955 | const char * |
971de7fb | 956 | xsettings_get_system_normal_font (void) |
99852628 JD |
957 | { |
958 | return current_font; | |
959 | } | |
e87b6180 | 960 | #endif |
99852628 JD |
961 | |
962 | DEFUN ("font-get-system-normal-font", Ffont_get_system_normal_font, | |
963 | Sfont_get_system_normal_font, | |
964 | 0, 0, 0, | |
bf935339 | 965 | doc: /* Get the system default application font. */) |
5842a27b | 966 | (void) |
99852628 | 967 | { |
2674ddc8 | 968 | return current_font ? build_string (current_font) : Qnil; |
99852628 JD |
969 | } |
970 | ||
637fa988 JD |
971 | DEFUN ("font-get-system-font", Ffont_get_system_font, Sfont_get_system_font, |
972 | 0, 0, 0, | |
bf935339 | 973 | doc: /* Get the system default fixed width font. */) |
5842a27b | 974 | (void) |
637fa988 | 975 | { |
2674ddc8 | 976 | return current_mono_font ? build_string (current_mono_font) : Qnil; |
637fa988 JD |
977 | } |
978 | ||
a7ca3326 | 979 | DEFUN ("tool-bar-get-system-style", Ftool_bar_get_system_style, |
16a97296 | 980 | Stool_bar_get_system_style, 0, 0, 0, |
f904c0f9 | 981 | doc: /* Get the system tool bar style. |
4721152c | 982 | If no system tool bar style is known, return `tool-bar-style' if set to a |
f904c0f9 | 983 | known style. Otherwise return image. */) |
5842a27b | 984 | (void) |
f904c0f9 JD |
985 | { |
986 | if (EQ (Vtool_bar_style, Qimage) | |
987 | || EQ (Vtool_bar_style, Qtext) | |
988 | || EQ (Vtool_bar_style, Qboth) | |
8a52f00a JD |
989 | || EQ (Vtool_bar_style, Qboth_horiz) |
990 | || EQ (Vtool_bar_style, Qtext_image_horiz)) | |
f904c0f9 JD |
991 | return Vtool_bar_style; |
992 | if (!NILP (current_tool_bar_style)) | |
993 | return current_tool_bar_style; | |
994 | return Qimage; | |
995 | } | |
996 | ||
637fa988 | 997 | void |
971de7fb | 998 | syms_of_xsettings (void) |
637fa988 JD |
999 | { |
1000 | current_mono_font = NULL; | |
99852628 | 1001 | current_font = NULL; |
637fa988 | 1002 | first_dpyinfo = NULL; |
9851bfc5 JD |
1003 | #ifdef HAVE_GSETTINGS |
1004 | gsettings_client = NULL; | |
869795d6 | 1005 | #endif |
637fa988 JD |
1006 | #ifdef HAVE_GCONF |
1007 | gconf_client = NULL; | |
1008 | #endif | |
1009 | ||
cd3520a4 JB |
1010 | DEFSYM (Qmonospace_font_name, "monospace-font-name"); |
1011 | DEFSYM (Qfont_name, "font-name"); | |
1012 | DEFSYM (Qfont_render, "font-render"); | |
637fa988 | 1013 | defsubr (&Sfont_get_system_font); |
99852628 | 1014 | defsubr (&Sfont_get_system_normal_font); |
637fa988 | 1015 | |
29208e82 | 1016 | DEFVAR_BOOL ("font-use-system-font", use_system_font, |
fb7ada5f | 1017 | doc: /* Non-nil means to apply the system defined font dynamically. |
bf935339 J |
1018 | When this is non-nil and the system defined fixed width font changes, we |
1019 | update frames dynamically. | |
1020 | If this variable is nil, Emacs ignores system font changes. */); | |
dfb3c4c6 JD |
1021 | use_system_font = 0; |
1022 | ||
29208e82 | 1023 | DEFVAR_LISP ("xft-settings", Vxft_settings, |
67477f30 | 1024 | doc: /* Font settings applied to Xft. */); |
4a7edc24 | 1025 | Vxft_settings = empty_unibyte_string; |
67477f30 | 1026 | |
0d1d0d26 JD |
1027 | #ifdef HAVE_XFT |
1028 | Fprovide (intern_c_string ("font-render-setting"), Qnil); | |
9851bfc5 | 1029 | #if defined (HAVE_GCONF) || defined (HAVE_GSETTINGS) |
637fa988 JD |
1030 | Fprovide (intern_c_string ("system-font-setting"), Qnil); |
1031 | #endif | |
637fa988 | 1032 | #endif |
f904c0f9 JD |
1033 | |
1034 | current_tool_bar_style = Qnil; | |
cd3520a4 | 1035 | DEFSYM (Qtool_bar_style, "tool-bar-style"); |
f904c0f9 JD |
1036 | defsubr (&Stool_bar_get_system_style); |
1037 | ||
1038 | Fprovide (intern_c_string ("dynamic-setting"), Qnil); | |
637fa988 | 1039 | } |