annotate src/xsettings.c @ 106085:cd4cbab8bb21

Handle system default font and changing font parameters. * xterm.h (struct x_display_info): Add atoms and Window for xsettings. * xterm.c (handle_one_xevent): Call xft_settings_event for ClientMessage, PropertyNotify and DestroyNotify. (x_term_init): If we have XFT, get DPI from Xft.dpi. Call xsettings_initialize. * xftfont.c (xftfont_fix_match): New function. (xftfont_open): Call XftDefaultSubstitute before XftFontMatch. Call xftfont_fix_match after XftFontMatch. * xfont.c (xfont_driver): Initialize all members. * xfns.c (x_default_font_parameter): Try font from Ffont_get_system_font. Do not get font from x_default_parameter if we got one from Ffont_get_system_font. (Fx_select_font): Get the defaut font name from :name of FRAME_FONT (f). * w32font.c (w32font_driver): Initialize all members. * termhooks.h (enum event_kind): CONFIG_CHANGED_EVENT is new. * lisp.h: Declare syms_of_xsettings. * keyboard.c (kbd_buffer_get_event, make_lispy_event): Handle CONFIG_CHANGED_EVENT. * ftfont.c (ftfont_filter_properties): New function. * frame.c (x_set_font): Remove unused variable lval. * font.h (struct font_driver): filter_properties is new. * font.c (font_put_extra): Don't return if val is nil, it means boolean option is off. (font_parse_fcname): Collect all extra properties in extra_props and call filter_properties for all drivers with extra_props and font as parameter. (font_open_entity): Do not use cache, it does not pick up new fontconfig settings like hinting. (font_load_for_lface): If spec had a name in it, store it in entity. * emacs.c (main): Call syms_of_xsettings * config.in: HAVE_GCONF is new. * Makefile.in (GCONF_CFLAGS, GCONF_LIBS): New variables for HAVE_GCONF. xsettings.o is new. * menu-bar.el: Put "Use system font" in Option-menu. * loadup.el: If feature system-font-setting or font-render-setting is there, load font-setting. * Makefile.in (ELCFILES): font-settings.el is new. * font-setting.el: New file. * NEWS: Mention dynamic font changes (font-use-system-font). * configure.in: New option: --with(out)-gconf. Set HAVE_GCONF if we find gconf.
author Jan Djärv <jan.h.d@swipnet.se>
date Tue, 17 Nov 2009 08:21:23 +0000
parents
children b40edfe3e412
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
106085
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
1 /* Functions for handle font changes dynamically.
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
2 Copyright (C) 2009
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
3 Free Software Foundation, Inc.
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
4
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
5 This file is part of GNU Emacs.
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
6
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
7 GNU Emacs is free software: you can redistribute it and/or modify
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
10 (at your option) any later version.
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
11
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
12 GNU Emacs is distributed in the hope that it will be useful,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
15 GNU General Public License for more details.
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
16
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
19
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
20 #include "config.h"
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
21 #include <setjmp.h>
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
22 #include <fcntl.h>
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
23 #include "lisp.h"
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
24 #include "xterm.h"
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
25 #include "xsettings.h"
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
26 #include "frame.h"
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
27 #include "blockinput.h"
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
28 #include "termhooks.h"
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
29 #include "termopts.h"
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
30
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
31 #include <X11/Xproto.h>
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
32
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
33 #ifdef HAVE_GCONF
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
34 #include <gconf/gconf-client.h>
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
35 #endif
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
36 #ifdef HAVE_XFT
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
37 #include <X11/Xft/Xft.h>
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
38 #endif
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
39
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
40 static char *current_mono_font;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
41 static struct x_display_info *first_dpyinfo;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
42 static Lisp_Object Qfont_name, Qfont_render;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
43
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
44 #ifdef HAVE_GCONF
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
45 static GConfClient *gconf_client;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
46 #endif
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
47
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
48
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
49 static void
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
50 store_font_changed_event (arg, display_name)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
51 Lisp_Object arg;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
52 Lisp_Object display_name;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
53 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
54 struct input_event event;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
55 EVENT_INIT (event);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
56 event.kind = CONFIG_CHANGED_EVENT;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
57 event.frame_or_window = display_name;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
58 event.arg = arg;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
59 kbd_buffer_store_event (&event);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
60 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
61
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
62 #ifdef HAVE_GCONF
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
63
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
64 #define SYSTEM_MONO_FONT "/desktop/gnome/interface/monospace_font_name"
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
65
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
66 /* Callback called when something changed in GConf that we care about,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
67 that is SYSTEM_MONO_FONT. */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
68
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
69 static void
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
70 something_changedCB (client, cnxn_id, entry, user_data)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
71 GConfClient *client;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
72 guint cnxn_id;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
73 GConfEntry *entry;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
74 gpointer user_data;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
75 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
76 GConfValue *v = gconf_entry_get_value (entry);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
77
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
78 if (!v) return;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
79 if (v->type == GCONF_VALUE_STRING)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
80 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
81 const char *value = gconf_value_get_string (v);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
82 int i;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
83 if (current_mono_font != NULL && strcmp (value, current_mono_font) == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
84 return; // No change.
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
85
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
86 xfree (current_mono_font);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
87 current_mono_font = xstrdup (value);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
88 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
89
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
90
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
91 if (first_dpyinfo != NULL)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
92 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
93 /* Check if display still open */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
94 struct x_display_info *dpyinfo;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
95 int found = 0;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
96 for (dpyinfo = x_display_list; !found && dpyinfo; dpyinfo = dpyinfo->next)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
97 found = dpyinfo == first_dpyinfo;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
98
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
99 if (found)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
100 store_font_changed_event (Qfont_name,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
101 XCAR (first_dpyinfo->name_list_element));
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
102 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
103 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
104 #endif /* HAVE_GCONF */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
105
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
106 #ifdef HAVE_XFT
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
107
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
108 /* Find the window that contains the XSETTINGS property values. */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
109
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
110 static void
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
111 get_prop_window (dpyinfo)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
112 struct x_display_info *dpyinfo;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
113 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
114 Display *dpy = dpyinfo->display;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
115
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
116 XGrabServer (dpy);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
117 dpyinfo->xsettings_window = XGetSelectionOwner (dpy,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
118 dpyinfo->Xatom_xsettings_sel);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
119 if (dpyinfo->xsettings_window != None)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
120 /* Select events so we can detect if window is deleted or if settings
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
121 are changed. */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
122 XSelectInput (dpy, dpyinfo->xsettings_window,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
123 PropertyChangeMask|StructureNotifyMask);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
124
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
125 XUngrabServer (dpy);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
126 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
127
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
128 struct xsettings
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
129 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
130 FcBool aa, hinting;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
131 int rgba, lcdfilter, hintstyle;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
132 double dpi;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
133 };
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
134
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
135 #define SWAP32(nr) (((nr) << 24) | (((nr) << 8) & 0xff0000) \
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
136 | (((nr) >> 8) & 0xff00) | ((nr) >> 24))
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
137 #define SWAP16(nr) (((nr) << 8) | ((nr) >> 8))
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
138 #define PAD(nr) (((nr) + 3) & ~3)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
139
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
140 /* Parse xsettings and extract those that deal with Xft.
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
141 See http://freedesktop.org/wiki/Specifications/XSettingsRegistry
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
142 and http://standards.freedesktop.org/xsettings-spec/xsettings-spec-0.5.html.
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
143
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
144 Layout of prop. First is a header:
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
145
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
146 bytes type what
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
147 ------------------------------------
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
148 1 CARD8 byte-order
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
149 3 unused
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
150 4 CARD32 SERIAL
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
151 4 CARD32 N_SETTINGS
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
152
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
153 Then N_SETTINGS records, with header:
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
154
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
155 bytes type what
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
156 ------------------------------------
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
157 1 SETTING_TYPE type (0 = integer, 1 = string, 2 RGB color).
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
158 1 unused
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
159 2 CARD16 n == name-length
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
160 n STRING8 name
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
161 p unused, p=pad_to_even_4(n)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
162 4 CARD32 last-change-serial
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
163
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
164 and then the value, For string:
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
165
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
166 bytes type what
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
167 ------------------------------------
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
168 4 CARD32 n = value-length
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
169 n STRING8 value
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
170 p unused, p=pad_to_even_4(n)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
171
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
172 For integer:
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
173
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
174 bytes type what
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
175 ------------------------------------
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
176 4 INT32 value
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
177
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
178 For RGB color:
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
179
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
180 bytes type what
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
181 ------------------------------------
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
182 2 CARD16 red
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
183 2 CARD16 blue
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
184 2 CARD16 green
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
185 2 CARD16 alpha
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
186
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
187 */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
188
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
189 static int
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
190 parse_xft_settings (prop, bytes, settings)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
191 unsigned char *prop;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
192 unsigned long bytes;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
193 struct xsettings *settings;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
194 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
195 Lisp_Object byteorder = Fbyteorder ();
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
196 int my_bo = XFASTINT (byteorder) == 'B' ? MSBFirst : LSBFirst;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
197 int that_bo = prop[0];
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
198 CARD32 n_settings;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
199 int bytes_parsed = 0;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
200 int settings_seen = 0;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
201 int i = 0;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
202
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
203 /* First 4 bytes is a serial number, skip that. */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
204
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
205 if (bytes < 12) return BadLength;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
206 memcpy (&n_settings, prop+8, 4);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
207 if (my_bo != that_bo) n_settings = SWAP32 (n_settings);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
208 bytes_parsed = 12;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
209
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
210 memset (settings, 0, sizeof (*settings));
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
211
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
212 while (bytes_parsed+4 < bytes && settings_seen < 6
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
213 && i < n_settings)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
214 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
215 int type = prop[bytes_parsed++];
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
216 CARD16 nlen;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
217 CARD32 vlen, ival = 0;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
218 char name[128]; /* The names we are looking for are not this long. */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
219 char sval[128]; /* The values we are looking for are not this long. */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
220 int is_xft;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
221 int to_cpy;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
222
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
223 sval[0] = '\0';
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
224 ++i;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
225 ++bytes_parsed; /* Padding */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
226
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
227 memcpy (&nlen, prop+bytes_parsed, 2);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
228 bytes_parsed += 2;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
229 if (my_bo != that_bo) nlen = SWAP16 (nlen);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
230 if (bytes_parsed+nlen > bytes) return BadLength;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
231 to_cpy = nlen > 127 ? 127 : nlen;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
232 memcpy (name, prop+bytes_parsed, to_cpy);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
233 name[to_cpy] = '\0';
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
234
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
235 bytes_parsed += nlen;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
236 bytes_parsed = PAD (bytes_parsed);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
237
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
238 bytes_parsed += 4; /* Skip serial for this value */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
239 if (bytes_parsed > bytes) return BadLength;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
240
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
241 is_xft = nlen > 6 && strncmp (name, "Xft/", 4) == 0;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
242
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
243 switch (type)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
244 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
245 case 0: /* Integer */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
246 if (bytes_parsed+4 > bytes) return BadLength;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
247 if (is_xft)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
248 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
249 memcpy (&ival, prop+bytes_parsed, 4);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
250 if (my_bo != that_bo) ival = SWAP32 (ival);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
251 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
252 bytes_parsed += 4;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
253 break;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
254
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
255 case 1: /* String */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
256 if (bytes_parsed+4 > bytes) return BadLength;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
257 memcpy (&vlen, prop+bytes_parsed, 4);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
258 bytes_parsed += 4;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
259 if (my_bo != that_bo) vlen = SWAP32 (vlen);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
260 if (is_xft)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
261 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
262 to_cpy = vlen > 127 ? 127 : vlen;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
263 memcpy (sval, prop+bytes_parsed, to_cpy);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
264 sval[to_cpy] = '\0';
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
265 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
266 bytes_parsed += vlen;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
267 bytes_parsed = PAD (bytes_parsed);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
268 break;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
269
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
270 case 2: /* RGB value */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
271 /* No need to parse this */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
272 if (bytes_parsed+8 > bytes) return BadLength;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
273 bytes_parsed += 8; /* 4 values (r, b, g, alpha), 2 bytes each. */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
274 break;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
275
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
276 default: /* Parse Error */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
277 return BadValue;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
278 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
279
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
280 if (is_xft)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
281 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
282 ++settings_seen;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
283 if (strcmp (name, "Xft/Antialias") == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
284 settings->aa = ival != 0;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
285 else if (strcmp (name, "Xft/Hinting") == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
286 settings->hinting = ival != 0;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
287 else if (strcmp (name, "Xft/HintStyle") == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
288 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
289 if (strcmp (sval, "hintnone") == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
290 settings->hintstyle = FC_HINT_NONE;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
291 else if (strcmp (sval, "hintslight") == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
292 settings->hintstyle = FC_HINT_SLIGHT;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
293 else if (strcmp (sval, "hintmedium") == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
294 settings->hintstyle = FC_HINT_MEDIUM;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
295 else if (strcmp (sval, "hintfull") == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
296 settings->hintstyle = FC_HINT_FULL;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
297 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
298 else if (strcmp (name, "Xft/RGBA") == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
299 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
300 if (strcmp (sval, "none") == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
301 settings->rgba = FC_RGBA_NONE;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
302 else if (strcmp (sval, "rgb") == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
303 settings->rgba = FC_RGBA_RGB;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
304 else if (strcmp (sval, "bgr") == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
305 settings->rgba = FC_RGBA_BGR;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
306 else if (strcmp (sval, "vrgb") == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
307 settings->rgba = FC_RGBA_VRGB;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
308 else if (strcmp (sval, "vbgr") == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
309 settings->rgba = FC_RGBA_VBGR;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
310 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
311 else if (strcmp (name, "Xft/DPI") == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
312 settings->dpi = (double)ival/1024.0;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
313 else if (strcmp (name, "Xft/lcdfilter") == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
314 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
315 if (strcmp (sval, "none") == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
316 settings->lcdfilter = FC_LCD_NONE;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
317 else if (strcmp (sval, "lcddefault") == 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
318 settings->lcdfilter = FC_LCD_DEFAULT;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
319 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
320 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
321 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
322
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
323 return Success;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
324 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
325
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
326 static int
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
327 read_xft_settings (dpyinfo, settings)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
328 struct x_display_info *dpyinfo;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
329 struct xsettings *settings;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
330 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
331 long long_len;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
332 Atom act_type;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
333 int act_form;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
334 unsigned long nitems, bytes_after;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
335 unsigned char *prop = NULL;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
336 Display *dpy = dpyinfo->display;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
337 int rc;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
338
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
339 x_catch_errors (dpy);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
340 rc = XGetWindowProperty (dpy,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
341 dpyinfo->xsettings_window,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
342 dpyinfo->Xatom_xsettings_prop,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
343 0, LONG_MAX, False, AnyPropertyType,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
344 &act_type, &act_form, &nitems, &bytes_after,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
345 &prop);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
346
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
347 if (rc == Success && prop != NULL && act_form == 8 && nitems > 0
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
348 && act_type == dpyinfo->Xatom_xsettings_prop)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
349 rc = parse_xft_settings (prop, nitems, settings);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
350
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
351 XFree (prop);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
352
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
353 x_uncatch_errors ();
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
354
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
355 return rc == Success;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
356 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
357
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
358 static void
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
359 apply_xft_settings (dpyinfo, send_event_p)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
360 struct x_display_info *dpyinfo;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
361 int send_event_p;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
362 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
363 FcPattern *pat;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
364 struct xsettings settings, oldsettings;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
365 int changed = 0;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
366
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
367 if (!read_xft_settings (dpyinfo, &settings))
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
368 return;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
369
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
370 memset (&oldsettings, 0, sizeof (oldsettings));
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
371
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
372 pat = FcPatternCreate ();
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
373 XftDefaultSubstitute (dpyinfo->display,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
374 XScreenNumberOfScreen (dpyinfo->screen),
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
375 pat);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
376 FcPatternGetBool (pat, FC_ANTIALIAS, 0, &oldsettings.aa);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
377 FcPatternGetBool (pat, FC_HINTING, 0, &oldsettings.hinting);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
378 FcPatternGetInteger (pat, FC_HINT_STYLE, 0, &oldsettings.hintstyle);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
379 FcPatternGetInteger (pat, FC_LCD_FILTER, 0, &oldsettings.lcdfilter);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
380 FcPatternGetInteger (pat, FC_RGBA, 0, &oldsettings.rgba);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
381 FcPatternGetDouble (pat, FC_DPI, 0, &oldsettings.dpi);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
382
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
383 if (oldsettings.aa != settings.aa)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
384 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
385 FcPatternDel (pat, FC_ANTIALIAS);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
386 FcPatternAddBool (pat, FC_ANTIALIAS, settings.aa);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
387 ++changed;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
388 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
389 if (oldsettings.hinting != settings.hinting)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
390 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
391 FcPatternDel (pat, FC_HINTING);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
392 FcPatternAddBool (pat, FC_HINTING, settings.hinting);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
393 ++changed;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
394 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
395 if (oldsettings.rgba != settings.rgba)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
396 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
397 FcPatternDel (pat, FC_RGBA);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
398 FcPatternAddInteger (pat, FC_RGBA, settings.rgba);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
399 ++changed;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
400 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
401 if (oldsettings.lcdfilter != settings.lcdfilter)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
402 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
403 FcPatternDel (pat, FC_LCD_FILTER);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
404 FcPatternAddInteger (pat, FC_LCD_FILTER, settings.lcdfilter);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
405 ++changed;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
406 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
407 if (oldsettings.hintstyle != settings.hintstyle)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
408 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
409 FcPatternDel (pat, FC_HINT_STYLE);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
410 FcPatternAddInteger (pat, FC_HINT_STYLE, settings.hintstyle);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
411 ++changed;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
412 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
413 if (oldsettings.dpi != settings.dpi)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
414 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
415 Lisp_Object frame, tail;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
416
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
417 FcPatternDel (pat, FC_DPI);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
418 FcPatternAddDouble (pat, FC_DPI, settings.dpi);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
419 ++changed;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
420
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
421 /* Change the DPI on this display and all frames on the display. */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
422 dpyinfo->resy = dpyinfo->resx = settings.dpi;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
423 FOR_EACH_FRAME (tail, frame)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
424 if (FRAME_X_P (XFRAME (frame))
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
425 && FRAME_X_DISPLAY_INFO (XFRAME (frame)) == dpyinfo)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
426 XFRAME (frame)->resy = XFRAME (frame)->resx = settings.dpi;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
427 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
428
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
429 if (changed)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
430 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
431 XftDefaultSet (dpyinfo->display, pat);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
432 if (send_event_p)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
433 store_font_changed_event (Qfont_render,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
434 XCAR (dpyinfo->name_list_element));
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
435 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
436 else
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
437 FcPatternDestroy (pat);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
438 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
439
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
440 #endif /* HAVE_XFT */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
441
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
442 void
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
443 xft_settings_event (dpyinfo, event)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
444 struct x_display_info *dpyinfo;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
445 XEvent *event;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
446 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
447 #ifdef HAVE_XFT
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
448 int check_window_p = 0;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
449
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
450 switch (event->type)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
451 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
452 case DestroyNotify:
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
453 if (dpyinfo->xsettings_window == event->xany.window)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
454 check_window_p = 1;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
455 break;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
456
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
457 case ClientMessage:
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
458 if (event->xclient.message_type == dpyinfo->Xatom_xsettings_mgr
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
459 && event->xclient.data.l[1] == dpyinfo->Xatom_xsettings_sel
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
460 && event->xclient.window == dpyinfo->root_window)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
461 check_window_p = 1;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
462 break;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
463
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
464 case PropertyNotify:
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
465 if (event->xproperty.window == dpyinfo->xsettings_window
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
466 && event->xproperty.state == PropertyNewValue
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
467 && event->xproperty.atom == dpyinfo->Xatom_xsettings_prop)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
468 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
469 apply_xft_settings (dpyinfo, True);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
470 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
471 break;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
472 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
473
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
474 if (check_window_p)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
475 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
476 dpyinfo->xsettings_window = None;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
477 get_prop_window (dpyinfo);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
478 if (dpyinfo->xsettings_window != None)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
479 apply_xft_settings (dpyinfo, True);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
480 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
481 #endif /* HAVE_XFT */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
482 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
483
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
484
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
485 static void
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
486 init_gconf ()
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
487 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
488 #ifdef HAVE_GCONF
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
489 int i;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
490 char *s;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
491 /* Should be enough, this is called at startup */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
492 #define N_FDS 1024
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
493 int fd_before[N_FDS], fd_before1[N_FDS];
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
494 int dummy, n_fds;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
495 GPollFD gfds[N_FDS];
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
496
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
497 /* To find out which filedecriptors GConf uses, check before and after.
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
498 If we do not do this, GConf changes will only happen when Emacs gets
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
499 an X event. */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
500 memset (fd_before, 0, sizeof (fd_before));
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
501 n_fds = g_main_context_query (g_main_context_default (),
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
502 G_PRIORITY_LOW,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
503 &dummy,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
504 gfds,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
505 N_FDS);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
506 for (i = 0; i < n_fds; ++i)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
507 if (gfds[i].fd < N_FDS && gfds[i].fd > 0 && gfds[i].events > 0)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
508 fd_before[gfds[i].fd] = 1;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
509
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
510 g_type_init ();
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
511 gconf_client = gconf_client_get_default ();
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
512 s = gconf_client_get_string (gconf_client, SYSTEM_MONO_FONT, NULL);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
513 if (s)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
514 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
515 current_mono_font = xstrdup (s);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
516 g_free (s);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
517 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
518 gconf_client_set_error_handling (gconf_client, GCONF_CLIENT_HANDLE_NONE);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
519 gconf_client_add_dir (gconf_client,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
520 SYSTEM_MONO_FONT,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
521 GCONF_CLIENT_PRELOAD_ONELEVEL,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
522 NULL);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
523 gconf_client_notify_add (gconf_client,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
524 SYSTEM_MONO_FONT,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
525 something_changedCB,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
526 NULL, NULL, NULL);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
527 n_fds = g_main_context_query (g_main_context_default (),
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
528 G_PRIORITY_LOW,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
529 &dummy,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
530 gfds,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
531 N_FDS);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
532
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
533 for (i = 0; i < n_fds; ++i)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
534 if (gfds[i].fd < N_FDS && gfds[i].fd > 0 && gfds[i].events > 0
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
535 && !fd_before[gfds[i].fd])
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
536 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
537 #ifdef F_SETOWN
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
538 fcntl (i, F_SETOWN, getpid ());
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
539 #endif /* ! defined (F_SETOWN) */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
540
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
541 #ifdef SIGIO
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
542 if (interrupt_input)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
543 init_sigio (i);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
544 #endif /* ! defined (SIGIO) */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
545 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
546 #endif /* HAVE_GCONF */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
547 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
548
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
549 static void
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
550 init_xfd_settings (dpyinfo)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
551 struct x_display_info *dpyinfo;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
552 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
553 #ifdef HAVE_XFT
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
554 char sel[64];
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
555 Display *dpy = dpyinfo->display;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
556
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
557 BLOCK_INPUT;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
558
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
559 sprintf (sel, "_XSETTINGS_S%d", XScreenNumberOfScreen (dpyinfo->screen));
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
560 dpyinfo->Xatom_xsettings_sel = XInternAtom (dpy, sel, False);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
561 dpyinfo->Xatom_xsettings_prop = XInternAtom (dpy,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
562 "_XSETTINGS_SETTINGS",
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
563 False);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
564 dpyinfo->Xatom_xsettings_mgr = XInternAtom (dpy, "MANAGER", False);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
565
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
566 /* Select events so we can detect client messages sent when selection
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
567 owner changes. */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
568 XSelectInput (dpy, dpyinfo->root_window, StructureNotifyMask);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
569
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
570 get_prop_window (dpyinfo);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
571 if (dpyinfo->xsettings_window != None)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
572 apply_xft_settings (dpyinfo, False);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
573
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
574 UNBLOCK_INPUT;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
575
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
576 #else /* ! HAVE_XFT */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
577
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
578 dpyinfo->Xatom_xsettings_sel = None;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
579 dpyinfo->Xatom_xsettings_prop = None;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
580 dpyinfo->Xatom_xsettings_mgr = None;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
581 dpyinfo->xsettings_window = None;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
582
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
583 #endif /* ! HAVE_XFT */
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
584 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
585
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
586 void
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
587 xsettings_initialize (dpyinfo)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
588 struct x_display_info *dpyinfo;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
589 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
590 if (first_dpyinfo == NULL) first_dpyinfo = dpyinfo;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
591 init_gconf ();
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
592 init_xfd_settings (dpyinfo);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
593 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
594
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
595
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
596 DEFUN ("font-get-system-font", Ffont_get_system_font, Sfont_get_system_font,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
597 0, 0, 0,
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
598 doc: /* Get the system default monospaced font. */)
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
599 ()
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
600 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
601 return current_mono_font
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
602 ? make_string (current_mono_font, strlen (current_mono_font))
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
603 : Qnil;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
604 }
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
605
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
606 void
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
607 syms_of_xsettings ()
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
608 {
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
609 current_mono_font = NULL;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
610 first_dpyinfo = NULL;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
611 #ifdef HAVE_GCONF
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
612 gconf_client = NULL;
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
613 #endif
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
614
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
615 Qfont_name = intern_c_string ("font-name");
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
616 staticpro (&Qfont_name);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
617 Qfont_render = intern_c_string ("font-render");
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
618 staticpro (&Qfont_render);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
619 defsubr (&Sfont_get_system_font);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
620
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
621 #ifdef HAVE_GCONF
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
622 Fprovide (intern_c_string ("system-font-setting"), Qnil);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
623 #endif
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
624 #ifdef HAVE_XFT
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
625 Fprovide (intern_c_string ("font-render-setting"), Qnil);
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
626 #endif
cd4cbab8bb21 Handle system default font and changing font parameters.
Jan Djärv <jan.h.d@swipnet.se>
parents:
diff changeset
627 }