aboutsummaryrefslogtreecommitdiffstats
path: root/src/xsettings.c
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2019-04-24 12:31:37 +0900
committerYAMAMOTO Mitsuharu2019-04-24 12:31:37 +0900
commit5f4e8e2e088de9fb76cb631077c6eddd3219f594 (patch)
treeabb80bc8ec36c28d4eef08b92db90a142f641be6 /src/xsettings.c
parent1828e9a9b7481572448284a8e5925bf97f2145f7 (diff)
downloademacs-5f4e8e2e088de9fb76cb631077c6eddd3219f594.tar.gz
emacs-5f4e8e2e088de9fb76cb631077c6eddd3219f594.zip
Don't link libXft when using cairo
* configure.ac: Check cairo early. Don't try Xft if cairo is used. * lwlib/lwlib-utils.h [USE_CAIRO]: Include cairo.h and fontconfig.h. (XftFont, XftDraw, XftColor, XGlyphInfo) [USE_CAIRO]: New typedefs. (XftFontOpenName, XftFontClose, XftDrawCreate, XftDrawDestroy) (XftDrawRect, XftDrawStringUtf8, XftTextExtentsUtf8) [USE_CAIRO]: New macros. (crxft_font_open_name, crxft_font_close, crxft_draw_create) (crxft_draw_rect, crxft_draw_string, crxft_text_extents) [USE_CAIRO]: New externs. * lwlib/lwlib-utils.c [USE_CAIRO]: Include math.h, cairo-ft.h, and cairo-xlib.h. (crxft_font_open_name, crxft_font_close, crxft_draw_create) (crxft_set_source_color, crxft_draw_rect, crxft_draw_string) (crxft_text_extents) [USE_CAIRO]: New Xft compatibility functions. * lwlib/xlwmenuP.h [USE_CAIRO]: Include lwlib-utils.h. * lwlib/xlwmenu.c (display_menu_item) [USE_CAIRO]: Call cairo_surface_mark_dirty and cairo_surface_flush. * lwlib/lwlib-Xaw.c [USE_CAIRO]: Include stdlib.h and lwlib-utils.h. (draw_text) [USE_CAIRO]: Call cairo_surface_flush. * src/xsettings.c [USE_CAIRO]: Include fontconfig.h (apply_xft_settings) [!HAVE_XFT]: Don't call XftDefaultSubstitute or XftDefaultSet. * lwlib/lwlib-Xaw.c: * lwlib/lwlib-int.h: * lwlib/xlwmenu.c: * lwlib/xlwmenuP.h: * src/xrdb.c: * src/xsettings.c: * src/xterm.c: Replace all #ifdef HAVE_XFT with #if defined USE_CAIRO || defined HAVE_XFT. * src/xfns.c (x_default_font_parameter): Replace #ifdef HAVE_XFT with #if defined USE_CAIRO || defined HAVE_XFT.
Diffstat (limited to 'src/xsettings.c')
-rw-r--r--src/xsettings.c58
1 files changed, 33 insertions, 25 deletions
diff --git a/src/xsettings.c b/src/xsettings.c
index 947d5cfb7b6..3e9012e3ab1 100644
--- a/src/xsettings.c
+++ b/src/xsettings.c
@@ -45,9 +45,13 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
45#include <gconf/gconf-client.h> 45#include <gconf/gconf-client.h>
46#endif 46#endif
47 47
48#ifdef HAVE_XFT 48#if defined USE_CAIRO || defined HAVE_XFT
49#ifdef USE_CAIRO
50#include <fontconfig/fontconfig.h>
51#else /* HAVE_XFT */
49#include <X11/Xft/Xft.h> 52#include <X11/Xft/Xft.h>
50#endif 53#endif
54#endif
51 55
52static char *current_mono_font; 56static char *current_mono_font;
53static char *current_font; 57static char *current_font;
@@ -83,7 +87,7 @@ dpyinfo_valid (struct x_display_info *dpyinfo)
83 87
84/* Store a monospace font change event if the monospaced font changed. */ 88/* Store a monospace font change event if the monospaced font changed. */
85 89
86#if defined HAVE_XFT && (defined HAVE_GSETTINGS || defined HAVE_GCONF) 90#if (defined USE_CAIRO || defined HAVE_XFT) && (defined HAVE_GSETTINGS || defined HAVE_GCONF)
87static void 91static void
88store_monospaced_changed (const char *newfont) 92store_monospaced_changed (const char *newfont)
89{ 93{
@@ -102,7 +106,7 @@ store_monospaced_changed (const char *newfont)
102 106
103/* Store a font name change event if the font name changed. */ 107/* Store a font name change event if the font name changed. */
104 108
105#ifdef HAVE_XFT 109#if defined USE_CAIRO || defined HAVE_XFT
106static void 110static void
107store_font_name_changed (const char *newfont) 111store_font_name_changed (const char *newfont)
108{ 112{
@@ -117,7 +121,7 @@ store_font_name_changed (const char *newfont)
117 XCAR (first_dpyinfo->name_list_element)); 121 XCAR (first_dpyinfo->name_list_element));
118 } 122 }
119} 123}
120#endif /* HAVE_XFT */ 124#endif /* USE_CAIRO || HAVE_XFT */
121 125
122/* Map TOOL_BAR_STYLE from a string to its corresponding Lisp value. 126/* Map TOOL_BAR_STYLE from a string to its corresponding Lisp value.
123 Return Qnil if TOOL_BAR_STYLE is not known. */ 127 Return Qnil if TOOL_BAR_STYLE is not known. */
@@ -157,7 +161,7 @@ store_tool_bar_style_changed (const char *newstyle,
157 XCAR (dpyinfo->name_list_element)); 161 XCAR (dpyinfo->name_list_element));
158} 162}
159 163
160#ifdef HAVE_XFT 164#if defined USE_CAIRO || defined HAVE_XFT
161#define XSETTINGS_FONT_NAME "Gtk/FontName" 165#define XSETTINGS_FONT_NAME "Gtk/FontName"
162#endif 166#endif
163#define XSETTINGS_TOOL_BAR_STYLE "Gtk/ToolbarStyle" 167#define XSETTINGS_TOOL_BAR_STYLE "Gtk/ToolbarStyle"
@@ -174,7 +178,7 @@ enum {
174}; 178};
175struct xsettings 179struct xsettings
176{ 180{
177#ifdef HAVE_XFT 181#if defined USE_CAIRO || defined HAVE_XFT
178 FcBool aa, hinting; 182 FcBool aa, hinting;
179 int rgba, lcdfilter, hintstyle; 183 int rgba, lcdfilter, hintstyle;
180 double dpi; 184 double dpi;
@@ -191,7 +195,7 @@ struct xsettings
191#define GSETTINGS_SCHEMA "org.gnome.desktop.interface" 195#define GSETTINGS_SCHEMA "org.gnome.desktop.interface"
192#define GSETTINGS_TOOL_BAR_STYLE "toolbar-style" 196#define GSETTINGS_TOOL_BAR_STYLE "toolbar-style"
193 197
194#ifdef HAVE_XFT 198#if defined USE_CAIRO || defined HAVE_XFT
195#define GSETTINGS_MONO_FONT "monospace-font-name" 199#define GSETTINGS_MONO_FONT "monospace-font-name"
196#define GSETTINGS_FONT_NAME "font-name" 200#define GSETTINGS_FONT_NAME "font-name"
197#endif 201#endif
@@ -224,7 +228,7 @@ something_changed_gsettingsCB (GSettings *settings,
224 g_variant_unref (val); 228 g_variant_unref (val);
225 } 229 }
226 } 230 }
227#ifdef HAVE_XFT 231#if defined USE_CAIRO || defined HAVE_XFT
228 else if (strcmp (key, GSETTINGS_MONO_FONT) == 0) 232 else if (strcmp (key, GSETTINGS_MONO_FONT) == 0)
229 { 233 {
230 val = g_settings_get_value (settings, GSETTINGS_MONO_FONT); 234 val = g_settings_get_value (settings, GSETTINGS_MONO_FONT);
@@ -253,14 +257,14 @@ something_changed_gsettingsCB (GSettings *settings,
253 g_variant_unref (val); 257 g_variant_unref (val);
254 } 258 }
255 } 259 }
256#endif /* HAVE_XFT */ 260#endif /* USE_CAIRO || HAVE_XFT */
257} 261}
258 262
259#endif /* HAVE_GSETTINGS */ 263#endif /* HAVE_GSETTINGS */
260 264
261#ifdef HAVE_GCONF 265#ifdef HAVE_GCONF
262#define GCONF_TOOL_BAR_STYLE "/desktop/gnome/interface/toolbar_style" 266#define GCONF_TOOL_BAR_STYLE "/desktop/gnome/interface/toolbar_style"
263#ifdef HAVE_XFT 267#if defined USE_CAIRO || defined HAVE_XFT
264#define GCONF_MONO_FONT "/desktop/gnome/interface/monospace_font_name" 268#define GCONF_MONO_FONT "/desktop/gnome/interface/monospace_font_name"
265#define GCONF_FONT_NAME "/desktop/gnome/interface/font_name" 269#define GCONF_FONT_NAME "/desktop/gnome/interface/font_name"
266#endif 270#endif
@@ -286,7 +290,7 @@ something_changed_gconfCB (GConfClient *client,
286 const char *value = gconf_value_get_string (v); 290 const char *value = gconf_value_get_string (v);
287 store_tool_bar_style_changed (value, first_dpyinfo); 291 store_tool_bar_style_changed (value, first_dpyinfo);
288 } 292 }
289#ifdef HAVE_XFT 293#if defined USE_CAIRO || defined HAVE_XFT
290 else if (strcmp (key, GCONF_MONO_FONT) == 0) 294 else if (strcmp (key, GCONF_MONO_FONT) == 0)
291 { 295 {
292 const char *value = gconf_value_get_string (v); 296 const char *value = gconf_value_get_string (v);
@@ -297,12 +301,12 @@ something_changed_gconfCB (GConfClient *client,
297 const char *value = gconf_value_get_string (v); 301 const char *value = gconf_value_get_string (v);
298 store_font_name_changed (value); 302 store_font_name_changed (value);
299 } 303 }
300#endif /* HAVE_XFT */ 304#endif /* USE_CAIRO || HAVE_XFT */
301} 305}
302 306
303#endif /* HAVE_GCONF */ 307#endif /* HAVE_GCONF */
304 308
305#ifdef HAVE_XFT 309#if defined USE_CAIRO || defined HAVE_XFT
306 310
307/* Older fontconfig versions don't have FC_LCD_*. */ 311/* Older fontconfig versions don't have FC_LCD_*. */
308#ifndef FC_LCD_NONE 312#ifndef FC_LCD_NONE
@@ -315,7 +319,7 @@ something_changed_gconfCB (GConfClient *client,
315#define FC_LCD_FILTER "lcdfilter" 319#define FC_LCD_FILTER "lcdfilter"
316#endif 320#endif
317 321
318#endif /* HAVE_XFT */ 322#endif /* USE_CAIRO || HAVE_XFT */
319 323
320/* Find the window that contains the XSETTINGS property values. */ 324/* Find the window that contains the XSETTINGS property values. */
321 325
@@ -440,7 +444,7 @@ parse_settings (unsigned char *prop,
440 if (bytes_parsed > bytes) return settings_seen; 444 if (bytes_parsed > bytes) return settings_seen;
441 445
442 want_this = strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0; 446 want_this = strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0;
443#ifdef HAVE_XFT 447#if defined USE_CAIRO || defined HAVE_XFT
444 if ((nlen > 6 && memcmp (name, "Xft/", 4) == 0) 448 if ((nlen > 6 && memcmp (name, "Xft/", 4) == 0)
445 || strcmp (XSETTINGS_FONT_NAME, name) == 0) 449 || strcmp (XSETTINGS_FONT_NAME, name) == 0)
446 want_this = true; 450 want_this = true;
@@ -490,7 +494,7 @@ parse_settings (unsigned char *prop,
490 dupstring (&settings->tb_style, sval); 494 dupstring (&settings->tb_style, sval);
491 settings->seen |= SEEN_TB_STYLE; 495 settings->seen |= SEEN_TB_STYLE;
492 } 496 }
493#ifdef HAVE_XFT 497#if defined USE_CAIRO || defined HAVE_XFT
494 else if (strcmp (name, XSETTINGS_FONT_NAME) == 0) 498 else if (strcmp (name, XSETTINGS_FONT_NAME) == 0)
495 { 499 {
496 dupstring (&settings->font, sval); 500 dupstring (&settings->font, sval);
@@ -553,7 +557,7 @@ parse_settings (unsigned char *prop,
553 else 557 else
554 settings->seen &= ~SEEN_LCDFILTER; 558 settings->seen &= ~SEEN_LCDFILTER;
555 } 559 }
556#endif /* HAVE_XFT */ 560#endif /* USE_CAIRO || HAVE_XFT */
557 else 561 else
558 want_this = false; 562 want_this = false;
559 settings_seen += want_this; 563 settings_seen += want_this;
@@ -604,16 +608,18 @@ static void
604apply_xft_settings (struct x_display_info *dpyinfo, 608apply_xft_settings (struct x_display_info *dpyinfo,
605 struct xsettings *settings) 609 struct xsettings *settings)
606{ 610{
607#ifdef HAVE_XFT 611#if defined USE_CAIRO || defined HAVE_XFT
608 FcPattern *pat; 612 FcPattern *pat;
609 struct xsettings oldsettings; 613 struct xsettings oldsettings;
610 bool changed = false; 614 bool changed = false;
611 615
612 memset (&oldsettings, 0, sizeof (oldsettings)); 616 memset (&oldsettings, 0, sizeof (oldsettings));
613 pat = FcPatternCreate (); 617 pat = FcPatternCreate ();
618#ifdef HAVE_XFT
614 XftDefaultSubstitute (dpyinfo->display, 619 XftDefaultSubstitute (dpyinfo->display,
615 XScreenNumberOfScreen (dpyinfo->screen), 620 XScreenNumberOfScreen (dpyinfo->screen),
616 pat); 621 pat);
622#endif
617 FcPatternGetBool (pat, FC_ANTIALIAS, 0, &oldsettings.aa); 623 FcPatternGetBool (pat, FC_ANTIALIAS, 0, &oldsettings.aa);
618 FcPatternGetBool (pat, FC_HINTING, 0, &oldsettings.hinting); 624 FcPatternGetBool (pat, FC_HINTING, 0, &oldsettings.hinting);
619#ifdef FC_HINT_STYLE 625#ifdef FC_HINT_STYLE
@@ -713,7 +719,9 @@ apply_xft_settings (struct x_display_info *dpyinfo,
713 }; 719 };
714 char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth]; 720 char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth];
715 721
722#ifdef HAVE_XFT
716 XftDefaultSet (dpyinfo->display, pat); 723 XftDefaultSet (dpyinfo->display, pat);
724#endif
717 store_config_changed_event (Qfont_render, 725 store_config_changed_event (Qfont_render,
718 XCAR (dpyinfo->name_list_element)); 726 XCAR (dpyinfo->name_list_element));
719 Vxft_settings 727 Vxft_settings
@@ -725,7 +733,7 @@ apply_xft_settings (struct x_display_info *dpyinfo,
725 } 733 }
726 else 734 else
727 FcPatternDestroy (pat); 735 FcPatternDestroy (pat);
728#endif /* HAVE_XFT */ 736#endif /* USE_CAIRO || HAVE_XFT */
729} 737}
730 738
731/* Read XSettings from the display for DPYINFO. 739/* Read XSettings from the display for DPYINFO.
@@ -748,7 +756,7 @@ read_and_apply_settings (struct x_display_info *dpyinfo, bool send_event_p)
748 current_tool_bar_style = map_tool_bar_style (settings.tb_style); 756 current_tool_bar_style = map_tool_bar_style (settings.tb_style);
749 xfree (settings.tb_style); 757 xfree (settings.tb_style);
750 } 758 }
751#ifdef HAVE_XFT 759#if defined USE_CAIRO || defined HAVE_XFT
752 if (settings.seen & SEEN_FONT) 760 if (settings.seen & SEEN_FONT)
753 { 761 {
754 if (send_event_p) 762 if (send_event_p)
@@ -850,7 +858,7 @@ init_gsettings (void)
850 g_variant_unref (val); 858 g_variant_unref (val);
851 } 859 }
852 860
853#ifdef HAVE_XFT 861#if defined USE_CAIRO || defined HAVE_XFT
854 val = g_settings_get_value (gsettings_client, GSETTINGS_MONO_FONT); 862 val = g_settings_get_value (gsettings_client, GSETTINGS_MONO_FONT);
855 if (val) 863 if (val)
856 { 864 {
@@ -868,7 +876,7 @@ init_gsettings (void)
868 dupstring (&current_font, g_variant_get_string (val, NULL)); 876 dupstring (&current_font, g_variant_get_string (val, NULL));
869 g_variant_unref (val); 877 g_variant_unref (val);
870 } 878 }
871#endif /* HAVE_XFT */ 879#endif /* USE_CAIRO || HAVE_XFT */
872 880
873#endif /* HAVE_GSETTINGS */ 881#endif /* HAVE_GSETTINGS */
874} 882}
@@ -903,7 +911,7 @@ init_gconf (void)
903 g_free (s); 911 g_free (s);
904 } 912 }
905 913
906#ifdef HAVE_XFT 914#if defined USE_CAIRO || defined HAVE_XFT
907 s = gconf_client_get_string (gconf_client, GCONF_MONO_FONT, NULL); 915 s = gconf_client_get_string (gconf_client, GCONF_MONO_FONT, NULL);
908 if (s) 916 if (s)
909 { 917 {
@@ -932,7 +940,7 @@ init_gconf (void)
932 GCONF_FONT_NAME, 940 GCONF_FONT_NAME,
933 something_changed_gconfCB, 941 something_changed_gconfCB,
934 NULL, NULL, NULL); 942 NULL, NULL, NULL);
935#endif /* HAVE_XFT */ 943#endif /* USE_CAIRO || HAVE_XFT */
936#endif /* HAVE_GCONF */ 944#endif /* HAVE_GCONF */
937} 945}
938 946
@@ -1055,7 +1063,7 @@ If this variable is nil, Emacs ignores system font changes. */);
1055 doc: /* Font settings applied to Xft. */); 1063 doc: /* Font settings applied to Xft. */);
1056 Vxft_settings = empty_unibyte_string; 1064 Vxft_settings = empty_unibyte_string;
1057 1065
1058#ifdef HAVE_XFT 1066#if defined USE_CAIRO || defined HAVE_XFT
1059 Fprovide (intern_c_string ("font-render-setting"), Qnil); 1067 Fprovide (intern_c_string ("font-render-setting"), Qnil);
1060#if defined (HAVE_GCONF) || defined (HAVE_GSETTINGS) 1068#if defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
1061 Fprovide (intern_c_string ("system-font-setting"), Qnil); 1069 Fprovide (intern_c_string ("system-font-setting"), Qnil);