aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Djärv2009-12-12 16:12:59 +0000
committerJan Djärv2009-12-12 16:12:59 +0000
commit3c055b77ae8a343ce9ff579cf662ab63ab788e38 (patch)
treed83fae423f59240d00ece92104f999e0fbc36016 /src
parent05fe33ff4cd1736a53f495439b402a4e5be09bb2 (diff)
downloademacs-3c055b77ae8a343ce9ff579cf662ab63ab788e38.tar.gz
emacs-3c055b77ae8a343ce9ff579cf662ab63ab788e38.zip
DPI might get set to 0 if we saw some Xsettings, but not DPI.
xsettings.c (struct xsettings): Add member seen. (parse_xft_settings): Update member seen with what we have read. Return 0 if Xft-settings have been parsed, 0 otherwise. (apply_xft_settings): Only update Xft settings with what member seen indicates as new.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/xsettings.c55
2 files changed, 52 insertions, 11 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 5e44bdf6ec8..2b0b064a956 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12009-12-12 Jan Djärv <jan.h.d@swipnet.se>
2
3 * xsettings.c (struct xsettings): Add member seen.
4 (parse_xft_settings): Update member seen with what we have read.
5 Return 0 if Xft-settings have been parsed, 0 otherwise.
6 (apply_xft_settings): Only update Xft settings with what member seen
7 indicates as new.
8
12009-12-12 Eli Zaretskii <eliz@gnu.org> 92009-12-12 Eli Zaretskii <eliz@gnu.org>
2 10
3 * dispextern.h (struct text_pos): Use EMACS_INT; 11 * dispextern.h (struct text_pos): Use EMACS_INT;
diff --git a/src/xsettings.c b/src/xsettings.c
index 946cfe7b899..d0d676125d9 100644
--- a/src/xsettings.c
+++ b/src/xsettings.c
@@ -138,11 +138,21 @@ get_prop_window (dpyinfo)
138 XUngrabServer (dpy); 138 XUngrabServer (dpy);
139} 139}
140 140
141enum {
142 SEEN_AA = 0x01,
143 SEEN_HINTING = 0x02,
144 SEEN_RGBA = 0x04,
145 SEEN_LCDFILTER = 0x08,
146 SEEN_HINTSTYLE = 0x10,
147 SEEN_DPI = 0x20,
148};
141struct xsettings 149struct xsettings
142{ 150{
143 FcBool aa, hinting; 151 FcBool aa, hinting;
144 int rgba, lcdfilter, hintstyle; 152 int rgba, lcdfilter, hintstyle;
145 double dpi; 153 double dpi;
154
155 unsigned seen;
146}; 156};
147 157
148#define SWAP32(nr) (((nr) << 24) | (((nr) << 8) & 0xff0000) \ 158#define SWAP32(nr) (((nr) << 24) | (((nr) << 8) & 0xff0000) \
@@ -197,6 +207,7 @@ struct xsettings
197 2 CARD16 green 207 2 CARD16 green
198 2 CARD16 alpha 208 2 CARD16 alpha
199 209
210 Returns non-zero if some Xft settings was seen, zero otherwise.
200*/ 211*/
201 212
202static int 213static int
@@ -294,11 +305,18 @@ parse_xft_settings (prop, bytes, settings)
294 { 305 {
295 ++settings_seen; 306 ++settings_seen;
296 if (strcmp (name, "Xft/Antialias") == 0) 307 if (strcmp (name, "Xft/Antialias") == 0)
297 settings->aa = ival != 0; 308 {
309 settings->seen |= SEEN_AA;
310 settings->aa = ival != 0;
311 }
298 else if (strcmp (name, "Xft/Hinting") == 0) 312 else if (strcmp (name, "Xft/Hinting") == 0)
299 settings->hinting = ival != 0; 313 {
314 settings->seen |= SEEN_HINTING;
315 settings->hinting = ival != 0;
316 }
300 else if (strcmp (name, "Xft/HintStyle") == 0) 317 else if (strcmp (name, "Xft/HintStyle") == 0)
301 { 318 {
319 settings->seen |= SEEN_HINTSTYLE;
302 if (strcmp (sval, "hintnone") == 0) 320 if (strcmp (sval, "hintnone") == 0)
303 settings->hintstyle = FC_HINT_NONE; 321 settings->hintstyle = FC_HINT_NONE;
304 else if (strcmp (sval, "hintslight") == 0) 322 else if (strcmp (sval, "hintslight") == 0)
@@ -307,9 +325,12 @@ parse_xft_settings (prop, bytes, settings)
307 settings->hintstyle = FC_HINT_MEDIUM; 325 settings->hintstyle = FC_HINT_MEDIUM;
308 else if (strcmp (sval, "hintfull") == 0) 326 else if (strcmp (sval, "hintfull") == 0)
309 settings->hintstyle = FC_HINT_FULL; 327 settings->hintstyle = FC_HINT_FULL;
328 else
329 settings->seen &= ~SEEN_HINTSTYLE;
310 } 330 }
311 else if (strcmp (name, "Xft/RGBA") == 0) 331 else if (strcmp (name, "Xft/RGBA") == 0)
312 { 332 {
333 settings->seen |= SEEN_RGBA;
313 if (strcmp (sval, "none") == 0) 334 if (strcmp (sval, "none") == 0)
314 settings->rgba = FC_RGBA_NONE; 335 settings->rgba = FC_RGBA_NONE;
315 else if (strcmp (sval, "rgb") == 0) 336 else if (strcmp (sval, "rgb") == 0)
@@ -320,20 +341,28 @@ parse_xft_settings (prop, bytes, settings)
320 settings->rgba = FC_RGBA_VRGB; 341 settings->rgba = FC_RGBA_VRGB;
321 else if (strcmp (sval, "vbgr") == 0) 342 else if (strcmp (sval, "vbgr") == 0)
322 settings->rgba = FC_RGBA_VBGR; 343 settings->rgba = FC_RGBA_VBGR;
344 else
345 settings->seen &= ~SEEN_RGBA;
323 } 346 }
324 else if (strcmp (name, "Xft/DPI") == 0) 347 else if (strcmp (name, "Xft/DPI") == 0)
325 settings->dpi = (double)ival/1024.0; 348 {
349 settings->seen |= SEEN_DPI;
350 settings->dpi = (double)ival/1024.0;
351 }
326 else if (strcmp (name, "Xft/lcdfilter") == 0) 352 else if (strcmp (name, "Xft/lcdfilter") == 0)
327 { 353 {
354 settings->seen |= SEEN_LCDFILTER;
328 if (strcmp (sval, "none") == 0) 355 if (strcmp (sval, "none") == 0)
329 settings->lcdfilter = FC_LCD_NONE; 356 settings->lcdfilter = FC_LCD_NONE;
330 else if (strcmp (sval, "lcddefault") == 0) 357 else if (strcmp (sval, "lcddefault") == 0)
331 settings->lcdfilter = FC_LCD_DEFAULT; 358 settings->lcdfilter = FC_LCD_DEFAULT;
359 else
360 settings->seen &= ~SEEN_LCDFILTER;
332 } 361 }
333 } 362 }
334 } 363 }
335 364
336 return Success; 365 return settings_seen;
337} 366}
338 367
339static int 368static int
@@ -365,7 +394,7 @@ read_xft_settings (dpyinfo, settings)
365 394
366 x_uncatch_errors (); 395 x_uncatch_errors ();
367 396
368 return rc == Success; 397 return rc != 0;
369} 398}
370 399
371 400
@@ -394,38 +423,42 @@ apply_xft_settings (dpyinfo, send_event_p)
394 FcPatternGetInteger (pat, FC_RGBA, 0, &oldsettings.rgba); 423 FcPatternGetInteger (pat, FC_RGBA, 0, &oldsettings.rgba);
395 FcPatternGetDouble (pat, FC_DPI, 0, &oldsettings.dpi); 424 FcPatternGetDouble (pat, FC_DPI, 0, &oldsettings.dpi);
396 425
397 if (oldsettings.aa != settings.aa) 426 if ((settings.seen & SEEN_AA) != 0 && oldsettings.aa != settings.aa)
398 { 427 {
399 FcPatternDel (pat, FC_ANTIALIAS); 428 FcPatternDel (pat, FC_ANTIALIAS);
400 FcPatternAddBool (pat, FC_ANTIALIAS, settings.aa); 429 FcPatternAddBool (pat, FC_ANTIALIAS, settings.aa);
401 ++changed; 430 ++changed;
402 } 431 }
403 if (oldsettings.hinting != settings.hinting) 432 if ((settings.seen & SEEN_HINTING) != 0
433 && oldsettings.hinting != settings.hinting)
404 { 434 {
405 FcPatternDel (pat, FC_HINTING); 435 FcPatternDel (pat, FC_HINTING);
406 FcPatternAddBool (pat, FC_HINTING, settings.hinting); 436 FcPatternAddBool (pat, FC_HINTING, settings.hinting);
407 ++changed; 437 ++changed;
408 } 438 }
409 if (oldsettings.rgba != settings.rgba) 439 if ((settings.seen & SEEN_RGBA) != 0 && oldsettings.rgba != settings.rgba)
410 { 440 {
411 FcPatternDel (pat, FC_RGBA); 441 FcPatternDel (pat, FC_RGBA);
412 FcPatternAddInteger (pat, FC_RGBA, settings.rgba); 442 FcPatternAddInteger (pat, FC_RGBA, settings.rgba);
413 ++changed; 443 ++changed;
414 } 444 }
415 /* Older fontconfig versions don't have FC_LCD_FILTER. */ 445 /* Older fontconfig versions don't have FC_LCD_FILTER. */
416 if (oldsettings.lcdfilter != settings.lcdfilter) 446 if ((settings.seen & SEEN_LCDFILTER) != 0
447 && oldsettings.lcdfilter != settings.lcdfilter)
417 { 448 {
418 FcPatternDel (pat, FC_LCD_FILTER); 449 FcPatternDel (pat, FC_LCD_FILTER);
419 FcPatternAddInteger (pat, FC_LCD_FILTER, settings.lcdfilter); 450 FcPatternAddInteger (pat, FC_LCD_FILTER, settings.lcdfilter);
420 ++changed; 451 ++changed;
421 } 452 }
422 if (oldsettings.hintstyle != settings.hintstyle) 453 if ((settings.seen & SEEN_HINTSTYLE) != 0
454 && oldsettings.hintstyle != settings.hintstyle)
423 { 455 {
424 FcPatternDel (pat, FC_HINT_STYLE); 456 FcPatternDel (pat, FC_HINT_STYLE);
425 FcPatternAddInteger (pat, FC_HINT_STYLE, settings.hintstyle); 457 FcPatternAddInteger (pat, FC_HINT_STYLE, settings.hintstyle);
426 ++changed; 458 ++changed;
427 } 459 }
428 if (oldsettings.dpi != settings.dpi) 460 if ((settings.seen & SEEN_DPI) != 0 && oldsettings.dpi != settings.dpi
461 && settings.dpi > 0)
429 { 462 {
430 Lisp_Object frame, tail; 463 Lisp_Object frame, tail;
431 464