aboutsummaryrefslogtreecommitdiffstats
path: root/src/xfaces.c
diff options
context:
space:
mode:
authorStefan Monnier2011-03-21 12:42:16 -0400
committerStefan Monnier2011-03-21 12:42:16 -0400
commitcafdcef32d55cbb44389d7e322e7f973cbb72dfd (patch)
tree7ee0c41ea8a589650ce6f4311fb10e61a63807b9 /src/xfaces.c
parenta08a25d7aaf251aa18f2ef747be53734bc55cae9 (diff)
parent4e05e67e4cd0bc1b0a4ef3176a4d0d91c6b3738e (diff)
downloademacs-cafdcef32d55cbb44389d7e322e7f973cbb72dfd.tar.gz
emacs-cafdcef32d55cbb44389d7e322e7f973cbb72dfd.zip
Merge from trunk
Diffstat (limited to 'src/xfaces.c')
-rw-r--r--src/xfaces.c90
1 files changed, 19 insertions, 71 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index 4cc47c85050..0fc5dd6f8a3 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -297,16 +297,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
297 297
298#define DIM(VECTOR) (sizeof (VECTOR) / sizeof *(VECTOR)) 298#define DIM(VECTOR) (sizeof (VECTOR) / sizeof *(VECTOR))
299 299
300/* Make a copy of string S on the stack using alloca. Value is a pointer
301 to the copy. */
302
303#define STRDUPA(S) strcpy ((char *) alloca (strlen ((S)) + 1), (S))
304
305/* Make a copy of the contents of Lisp string S on the stack using
306 alloca. Value is a pointer to the copy. */
307
308#define LSTRDUPA(S) STRDUPA (SDATA ((S)))
309
310/* Size of hash table of realized faces in face caches (should be a 300/* Size of hash table of realized faces in face caches (should be a
311 prime number). */ 301 prime number). */
312 302
@@ -847,7 +837,6 @@ clear_face_cache (int clear_fonts_p)
847{ 837{
848#ifdef HAVE_WINDOW_SYSTEM 838#ifdef HAVE_WINDOW_SYSTEM
849 Lisp_Object tail, frame; 839 Lisp_Object tail, frame;
850 struct frame *f;
851 840
852 if (clear_fonts_p 841 if (clear_fonts_p
853 || ++clear_font_table_count == CLEAR_FONT_TABLE_COUNT) 842 || ++clear_font_table_count == CLEAR_FONT_TABLE_COUNT)
@@ -875,7 +864,7 @@ clear_face_cache (int clear_fonts_p)
875 /* Clear GCs of realized faces. */ 864 /* Clear GCs of realized faces. */
876 FOR_EACH_FRAME (tail, frame) 865 FOR_EACH_FRAME (tail, frame)
877 { 866 {
878 f = XFRAME (frame); 867 struct frame *f = XFRAME (frame);
879 if (FRAME_WINDOW_P (f)) 868 if (FRAME_WINDOW_P (f))
880 clear_face_gcs (FRAME_FACE_CACHE (f)); 869 clear_face_gcs (FRAME_FACE_CACHE (f));
881 } 870 }
@@ -1113,7 +1102,7 @@ tty_lookup_color (struct frame *f, Lisp_Object color, XColor *tty_color, XColor
1113 1102
1114/* A version of defined_color for non-X frames. */ 1103/* A version of defined_color for non-X frames. */
1115 1104
1116int 1105static int
1117tty_defined_color (struct frame *f, const char *color_name, 1106tty_defined_color (struct frame *f, const char *color_name,
1118 XColor *color_def, int alloc) 1107 XColor *color_def, int alloc)
1119{ 1108{
@@ -1721,7 +1710,7 @@ the WIDTH times as wide as FACE on FRAME. */)
1721 (Lisp_Object pattern, Lisp_Object face, Lisp_Object frame, Lisp_Object maximum, Lisp_Object width) 1710 (Lisp_Object pattern, Lisp_Object face, Lisp_Object frame, Lisp_Object maximum, Lisp_Object width)
1722{ 1711{
1723 struct frame *f; 1712 struct frame *f;
1724 int size, avgwidth; 1713 int size, avgwidth IF_LINT (= 0);
1725 1714
1726 check_x (); 1715 check_x ();
1727 CHECK_STRING (pattern); 1716 CHECK_STRING (pattern);
@@ -1754,14 +1743,14 @@ the WIDTH times as wide as FACE on FRAME. */)
1754 /* This is of limited utility since it works with character 1743 /* This is of limited utility since it works with character
1755 widths. Keep it for compatibility. --gerd. */ 1744 widths. Keep it for compatibility. --gerd. */
1756 int face_id = lookup_named_face (f, face, 0); 1745 int face_id = lookup_named_face (f, face, 0);
1757 struct face *face = (face_id < 0 1746 struct face *width_face = (face_id < 0
1758 ? NULL 1747 ? NULL
1759 : FACE_FROM_ID (f, face_id)); 1748 : FACE_FROM_ID (f, face_id));
1760 1749
1761 if (face && face->font) 1750 if (width_face && width_face->font)
1762 { 1751 {
1763 size = face->font->pixel_size; 1752 size = width_face->font->pixel_size;
1764 avgwidth = face->font->average_width; 1753 avgwidth = width_face->font->average_width;
1765 } 1754 }
1766 else 1755 else
1767 { 1756 {
@@ -1838,6 +1827,7 @@ the WIDTH times as wide as FACE on FRAME. */)
1838#define LFACE_INHERIT(LFACE) AREF ((LFACE), LFACE_INHERIT_INDEX) 1827#define LFACE_INHERIT(LFACE) AREF ((LFACE), LFACE_INHERIT_INDEX)
1839#define LFACE_FONTSET(LFACE) AREF ((LFACE), LFACE_FONTSET_INDEX) 1828#define LFACE_FONTSET(LFACE) AREF ((LFACE), LFACE_FONTSET_INDEX)
1840 1829
1830#if XASSERTS
1841/* Non-zero if LFACE is a Lisp face. A Lisp face is a vector of size 1831/* Non-zero if LFACE is a Lisp face. A Lisp face is a vector of size
1842 LFACE_VECTOR_SIZE which has the symbol `face' in slot 0. */ 1832 LFACE_VECTOR_SIZE which has the symbol `face' in slot 0. */
1843 1833
@@ -1845,6 +1835,7 @@ the WIDTH times as wide as FACE on FRAME. */)
1845 (VECTORP (LFACE) \ 1835 (VECTORP (LFACE) \
1846 && XVECTOR (LFACE)->size == LFACE_VECTOR_SIZE \ 1836 && XVECTOR (LFACE)->size == LFACE_VECTOR_SIZE \
1847 && EQ (AREF (LFACE, 0), Qface)) 1837 && EQ (AREF (LFACE, 0), Qface))
1838#endif
1848 1839
1849 1840
1850#if GLYPH_DEBUG 1841#if GLYPH_DEBUG
@@ -2252,7 +2243,7 @@ set_lface_from_font (struct frame *f, Lisp_Object lface, Lisp_Object font_object
2252 `relative' heights; the returned value is always an absolute height 2243 `relative' heights; the returned value is always an absolute height
2253 unless both FROM and TO are relative. */ 2244 unless both FROM and TO are relative. */
2254 2245
2255Lisp_Object 2246static Lisp_Object
2256merge_face_heights (Lisp_Object from, Lisp_Object to, Lisp_Object invalid) 2247merge_face_heights (Lisp_Object from, Lisp_Object to, Lisp_Object invalid)
2257{ 2248{
2258 Lisp_Object result = invalid; 2249 Lisp_Object result = invalid;
@@ -3869,19 +3860,19 @@ return the font name used for CHARACTER. */)
3869 { 3860 {
3870 struct frame *f = frame_or_selected_frame (frame, 1); 3861 struct frame *f = frame_or_selected_frame (frame, 1);
3871 int face_id = lookup_named_face (f, face, 1); 3862 int face_id = lookup_named_face (f, face, 1);
3872 struct face *face = FACE_FROM_ID (f, face_id); 3863 struct face *fface = FACE_FROM_ID (f, face_id);
3873 3864
3874 if (! face) 3865 if (! fface)
3875 return Qnil; 3866 return Qnil;
3876#ifdef HAVE_WINDOW_SYSTEM 3867#ifdef HAVE_WINDOW_SYSTEM
3877 if (FRAME_WINDOW_P (f) && !NILP (character)) 3868 if (FRAME_WINDOW_P (f) && !NILP (character))
3878 { 3869 {
3879 CHECK_CHARACTER (character); 3870 CHECK_CHARACTER (character);
3880 face_id = FACE_FOR_CHAR (f, face, XINT (character), -1, Qnil); 3871 face_id = FACE_FOR_CHAR (f, fface, XINT (character), -1, Qnil);
3881 face = FACE_FROM_ID (f, face_id); 3872 fface = FACE_FROM_ID (f, face_id);
3882 } 3873 }
3883 return (face->font 3874 return (fface->font
3884 ? face->font->props[FONT_NAME_INDEX] 3875 ? fface->font->props[FONT_NAME_INDEX]
3885 : Qnil); 3876 : Qnil);
3886#else /* !HAVE_WINDOW_SYSTEM */ 3877#else /* !HAVE_WINDOW_SYSTEM */
3887 return build_string (FRAME_MSDOS_P (f) 3878 return build_string (FRAME_MSDOS_P (f)
@@ -4313,45 +4304,6 @@ free_realized_faces (struct face_cache *c)
4313} 4304}
4314 4305
4315 4306
4316/* Free all realized faces that are using FONTSET on frame F. */
4317
4318void
4319free_realized_faces_for_fontset (struct frame *f, int fontset)
4320{
4321 struct face_cache *cache = FRAME_FACE_CACHE (f);
4322 struct face *face;
4323 int i;
4324
4325 /* We must block input here because we can't process X events safely
4326 while only some faces are freed, or when the frame's current
4327 matrix still references freed faces. */
4328 BLOCK_INPUT;
4329
4330 for (i = 0; i < cache->used; i++)
4331 {
4332 face = cache->faces_by_id[i];
4333 if (face
4334 && face->fontset == fontset)
4335 {
4336 uncache_face (cache, face);
4337 free_realized_face (f, face);
4338 }
4339 }
4340
4341 /* Must do a thorough redisplay the next time. Mark current
4342 matrices as invalid because they will reference faces freed
4343 above. This function is also called when a frame is destroyed.
4344 In this case, the root window of F is nil. */
4345 if (WINDOWP (f->root_window))
4346 {
4347 clear_current_matrices (f);
4348 ++windows_or_buffers_changed;
4349 }
4350
4351 UNBLOCK_INPUT;
4352}
4353
4354
4355/* Free all realized faces on FRAME or on all frames if FRAME is nil. 4307/* Free all realized faces on FRAME or on all frames if FRAME is nil.
4356 This is done after attributes of a named face have been changed, 4308 This is done after attributes of a named face have been changed,
4357 because we can't tell which realized faces depend on that face. */ 4309 because we can't tell which realized faces depend on that face. */
@@ -5287,10 +5239,6 @@ be found. Value is ALIST. */)
5287 5239
5288#ifdef HAVE_WINDOW_SYSTEM 5240#ifdef HAVE_WINDOW_SYSTEM
5289 5241
5290/* Ignore the difference of font point size less than this value. */
5291
5292#define FONT_POINT_SIZE_QUANTUM 5
5293
5294/* Return the fontset id of the base fontset name or alias name given 5242/* Return the fontset id of the base fontset name or alias name given
5295 by the fontset attribute of ATTRS. Value is -1 if the fontset 5243 by the fontset attribute of ATTRS. Value is -1 if the fontset
5296 attribute of ATTRS doesn't name a fontset. */ 5244 attribute of ATTRS doesn't name a fontset. */
@@ -6349,7 +6297,7 @@ where R,G,B are numbers between 0 and 255 and name is an arbitrary string. */)
6349 CHECK_STRING (filename); 6297 CHECK_STRING (filename);
6350 abspath = Fexpand_file_name (filename, Qnil); 6298 abspath = Fexpand_file_name (filename, Qnil);
6351 6299
6352 fp = fopen (SDATA (filename), "rt"); 6300 fp = fopen (SDATA (abspath), "rt");
6353 if (fp) 6301 if (fp)
6354 { 6302 {
6355 char buf[512]; 6303 char buf[512];