aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorK. Handa2015-10-05 22:56:26 +0900
committerK. Handa2015-10-05 22:56:26 +0900
commit47e9556c70a7009d7c750fd7bf10a0e6cf41cdce (patch)
tree4e944bd68080adee76291dd7d4f34103e2b55d50 /src
parent52beda922d2cb523a03661bf74b8678c8b45e440 (diff)
parentef171d1d0b42758b5f705847d558436e867372f4 (diff)
downloademacs-47e9556c70a7009d7c750fd7bf10a0e6cf41cdce.tar.gz
emacs-47e9556c70a7009d7c750fd7bf10a0e6cf41cdce.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'src')
-rw-r--r--src/cmds.c2
-rw-r--r--src/coding.c3
-rw-r--r--src/dired.c13
-rw-r--r--src/fileio.c33
-rw-r--r--src/font.c2
-rw-r--r--src/frame.c4
-rw-r--r--src/gfilenotify.c1
-rw-r--r--src/macfont.m171
-rw-r--r--src/nsterm.m5
-rw-r--r--src/process.c18
-rw-r--r--src/window.c7
-rw-r--r--src/xdisp.c87
-rw-r--r--src/xfaces.c28
-rw-r--r--src/xfns.c5
14 files changed, 253 insertions, 126 deletions
diff --git a/src/cmds.c b/src/cmds.c
index 7a575ae7348..ccc68911624 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -264,7 +264,7 @@ because it respects values of `delete-active-region' and `overwrite-mode'. */)
264 264
265 CHECK_NUMBER (n); 265 CHECK_NUMBER (n);
266 266
267 if (abs (XINT (n)) < 2) 267 if (eabs (XINT (n)) < 2)
268 remove_excessive_undo_boundaries (); 268 remove_excessive_undo_boundaries ();
269 269
270 pos = PT + XINT (n); 270 pos = PT + XINT (n);
diff --git a/src/coding.c b/src/coding.c
index 3fc6fb684c6..c5099a7b0b9 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -6004,6 +6004,8 @@ coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent)
6004 6004
6005 if (NILP (coding_system)) 6005 if (NILP (coding_system))
6006 coding_system = Qraw_text; 6006 coding_system = Qraw_text;
6007 else
6008 CHECK_CODING_SYSTEM (coding_system);
6007 spec = CODING_SYSTEM_SPEC (coding_system); 6009 spec = CODING_SYSTEM_SPEC (coding_system);
6008 eol_type = AREF (spec, 2); 6010 eol_type = AREF (spec, 2);
6009 if (VECTORP (eol_type)) 6011 if (VECTORP (eol_type))
@@ -6014,6 +6016,7 @@ coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent)
6014 { 6016 {
6015 Lisp_Object parent_spec; 6017 Lisp_Object parent_spec;
6016 6018
6019 CHECK_CODING_SYSTEM (parent);
6017 parent_spec = CODING_SYSTEM_SPEC (parent); 6020 parent_spec = CODING_SYSTEM_SPEC (parent);
6018 parent_eol_type = AREF (parent_spec, 2); 6021 parent_eol_type = AREF (parent_spec, 2);
6019 if (VECTORP (parent_eol_type)) 6022 if (VECTORP (parent_eol_type))
diff --git a/src/dired.c b/src/dired.c
index 97736673f5d..3486e49b566 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -397,8 +397,10 @@ Returns nil if DIRECTORY contains no name starting with FILE.
397If PREDICATE is non-nil, call PREDICATE with each possible 397If PREDICATE is non-nil, call PREDICATE with each possible
398completion (in absolute form) and ignore it if PREDICATE returns nil. 398completion (in absolute form) and ignore it if PREDICATE returns nil.
399 399
400This function ignores some of the possible completions as 400This function ignores some of the possible completions as determined
401determined by the variable `completion-ignored-extensions', which see. */) 401by the variables `completion-regexp-list' and
402`completion-ignored-extensions', which see. `completion-regexp-list'
403is matched against file and directory names relative to DIRECTORY. */)
402 (Lisp_Object file, Lisp_Object directory, Lisp_Object predicate) 404 (Lisp_Object file, Lisp_Object directory, Lisp_Object predicate)
403{ 405{
404 Lisp_Object handler; 406 Lisp_Object handler;
@@ -422,7 +424,12 @@ determined by the variable `completion-ignored-extensions', which see. */)
422DEFUN ("file-name-all-completions", Ffile_name_all_completions, 424DEFUN ("file-name-all-completions", Ffile_name_all_completions,
423 Sfile_name_all_completions, 2, 2, 0, 425 Sfile_name_all_completions, 2, 2, 0,
424 doc: /* Return a list of all completions of file name FILE in directory DIRECTORY. 426 doc: /* Return a list of all completions of file name FILE in directory DIRECTORY.
425These are all file names in directory DIRECTORY which begin with FILE. */) 427These are all file names in directory DIRECTORY which begin with FILE.
428
429This function ignores some of the possible completions as determined
430by the variables `completion-regexp-list' and
431`completion-ignored-extensions', which see. `completion-regexp-list'
432is matched against file and directory names relative to DIRECTORY. */)
426 (Lisp_Object file, Lisp_Object directory) 433 (Lisp_Object file, Lisp_Object directory)
427{ 434{
428 Lisp_Object handler; 435 Lisp_Object handler;
diff --git a/src/fileio.c b/src/fileio.c
index e4b255a53ac..3155ef0edf1 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3470,7 +3470,11 @@ by calling `format-decode', which see. */)
3470 mtime = time_error_value (save_errno); 3470 mtime = time_error_value (save_errno);
3471 st.st_size = -1; 3471 st.st_size = -1;
3472 if (!NILP (Vcoding_system_for_read)) 3472 if (!NILP (Vcoding_system_for_read))
3473 Fset (Qbuffer_file_coding_system, Vcoding_system_for_read); 3473 {
3474 /* Don't let invalid values into buffer-file-coding-system. */
3475 CHECK_CODING_SYSTEM (Vcoding_system_for_read);
3476 Fset (Qbuffer_file_coding_system, Vcoding_system_for_read);
3477 }
3474 goto notfound; 3478 goto notfound;
3475 } 3479 }
3476 3480
@@ -4569,7 +4573,7 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
4569 if (NILP (val)) 4573 if (NILP (val))
4570 { 4574 {
4571 /* If we still have not decided a coding system, use the 4575 /* If we still have not decided a coding system, use the
4572 default value of buffer-file-coding-system. */ 4576 current buffer's value of buffer-file-coding-system. */
4573 val = BVAR (current_buffer, buffer_file_coding_system); 4577 val = BVAR (current_buffer, buffer_file_coding_system);
4574 using_default_coding = 1; 4578 using_default_coding = 1;
4575 } 4579 }
@@ -4578,6 +4582,7 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
4578 { 4582 {
4579 Lisp_Object spec, attrs; 4583 Lisp_Object spec, attrs;
4580 4584
4585 CHECK_CODING_SYSTEM (val);
4581 CHECK_CODING_SYSTEM_GET_SPEC (val, spec); 4586 CHECK_CODING_SYSTEM_GET_SPEC (val, spec);
4582 attrs = AREF (spec, 0); 4587 attrs = AREF (spec, 0);
4583 if (EQ (CODING_ATTR_TYPE (attrs), Qraw_text)) 4588 if (EQ (CODING_ATTR_TYPE (attrs), Qraw_text))
@@ -4586,17 +4591,27 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file
4586 4591
4587 if (!force_raw_text 4592 if (!force_raw_text
4588 && !NILP (Ffboundp (Vselect_safe_coding_system_function))) 4593 && !NILP (Ffboundp (Vselect_safe_coding_system_function)))
4589 /* Confirm that VAL can surely encode the current region. */ 4594 {
4590 val = call5 (Vselect_safe_coding_system_function, 4595 /* Confirm that VAL can surely encode the current region. */
4591 start, end, val, Qnil, filename); 4596 val = call5 (Vselect_safe_coding_system_function,
4597 start, end, val, Qnil, filename);
4598 /* As the function specified by select-safe-coding-system-function
4599 is out of our control, make sure we are not fed by bogus
4600 values. */
4601 if (!NILP (val))
4602 CHECK_CODING_SYSTEM (val);
4603 }
4592 4604
4593 /* If the decided coding-system doesn't specify end-of-line 4605 /* If the decided coding-system doesn't specify end-of-line
4594 format, we use that of 4606 format, we use that of
4595 `default-buffer-file-coding-system'. */ 4607 `default-buffer-file-coding-system'. */
4596 if (! using_default_coding 4608 if (! using_default_coding)
4597 && ! NILP (BVAR (&buffer_defaults, buffer_file_coding_system))) 4609 {
4598 val = (coding_inherit_eol_type 4610 Lisp_Object dflt = BVAR (&buffer_defaults, buffer_file_coding_system);
4599 (val, BVAR (&buffer_defaults, buffer_file_coding_system))); 4611
4612 if (! NILP (dflt))
4613 val = coding_inherit_eol_type (val, dflt);
4614 }
4600 4615
4601 /* If we decide not to encode text, use `raw-text' or one of its 4616 /* If we decide not to encode text, use `raw-text' or one of its
4602 subsidiaries. */ 4617 subsidiaries. */
diff --git a/src/font.c b/src/font.c
index ce144e78a08..a52a653d29b 100644
--- a/src/font.c
+++ b/src/font.c
@@ -1770,7 +1770,7 @@ font_parse_family_registry (Lisp_Object family, Lisp_Object registry, Lisp_Objec
1770 p1 = strchr (p0, '-'); 1770 p1 = strchr (p0, '-');
1771 if (! p1) 1771 if (! p1)
1772 { 1772 {
1773 AUTO_STRING (extra, ("*-*" + (len && p0[len - 1] == '*'))); 1773 AUTO_STRING (extra, (&"*-*"[len && p0[len - 1] == '*']));
1774 registry = concat2 (registry, extra); 1774 registry = concat2 (registry, extra);
1775 } 1775 }
1776 registry = Fdowncase (registry); 1776 registry = Fdowncase (registry);
diff --git a/src/frame.c b/src/frame.c
index 121c55fdb20..f1a78fbdbf8 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -3539,8 +3539,8 @@ x_set_screen_gamma (struct frame *f, Lisp_Object new_value, Lisp_Object old_valu
3539 (f, bgcolor, Qnil); 3539 (f, bgcolor, Qnil);
3540 } 3540 }
3541 3541
3542 clear_face_cache (true); 3542 clear_face_cache (true); /* FIXME: Why of all frames? */
3543 windows_or_buffers_changed = 70; 3543 fset_redisplay (f);
3544} 3544}
3545 3545
3546 3546
diff --git a/src/gfilenotify.c b/src/gfilenotify.c
index 8b6b0a0cd2d..69f635d4115 100644
--- a/src/gfilenotify.c
+++ b/src/gfilenotify.c
@@ -195,6 +195,7 @@ will be reported only in case of the `moved' event. */)
195 195
196 /* Enable watch. */ 196 /* Enable watch. */
197 monitor = g_file_monitor (gfile, gflags, NULL, &gerror); 197 monitor = g_file_monitor (gfile, gflags, NULL, &gerror);
198 g_object_unref (gfile);
198 if (gerror) 199 if (gerror)
199 { 200 {
200 char msg[1024]; 201 char msg[1024];
diff --git a/src/macfont.m b/src/macfont.m
index 97a255bf018..fae284fad89 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -190,6 +190,14 @@ cfstring_create_with_string_noencode (Lisp_Object s)
190 return string; 190 return string;
191} 191}
192 192
193static CFIndex
194mac_font_get_weight (CTFontRef font)
195{
196 NSFont *nsFont = (NSFont *) font;
197
198 return [[NSFontManager sharedFontManager] weightOfFont:nsFont];
199}
200
193static CGFloat 201static CGFloat
194mac_screen_font_get_advance_width_for_glyph (ScreenFontRef font, CGGlyph glyph) 202mac_screen_font_get_advance_width_for_glyph (ScreenFontRef font, CGGlyph glyph)
195{ 203{
@@ -198,57 +206,53 @@ mac_screen_font_get_advance_width_for_glyph (ScreenFontRef font, CGGlyph glyph)
198 return advancement.width; 206 return advancement.width;
199} 207}
200 208
209#if !USE_CT_GLYPH_INFO
201static CGGlyph 210static CGGlyph
202mac_font_get_glyph_for_cid (CTFontRef font, CTCharacterCollection collection, 211mac_font_get_glyph_for_cid (CTFontRef font, CTCharacterCollection collection,
203 CGFontIndex cid) 212 CGFontIndex cid)
204{ 213{
205#if USE_CT_GLYPH_INFO 214 CGGlyph result = kCGFontIndexInvalid;
206 return mac_ctfont_get_glyph_for_cid ((CTFontRef) font, collection, cid); 215 NSFont *nsFont = (NSFont *) font;
207#else 216 unichar characters[] = {0xfffd};
208 { 217 NSString *string =
209 CGGlyph result = kCGFontIndexInvalid; 218 [NSString stringWithCharacters:characters
210 NSFont *nsFont = (NSFont *) font; 219 length:ARRAYELTS (characters)];
211 unichar characters[] = {0xfffd}; 220 NSGlyphInfo *glyphInfo =
212 NSString *string = 221 [NSGlyphInfo glyphInfoWithCharacterIdentifier:cid
213 [NSString stringWithCharacters:characters 222 collection:collection
214 length:ARRAYELTS (characters)]; 223 baseString:string];
215 NSGlyphInfo *glyphInfo = 224 NSDictionary *attributes =
216 [NSGlyphInfo glyphInfoWithCharacterIdentifier:cid 225 [NSDictionary dictionaryWithObjectsAndKeys:nsFont,NSFontAttributeName,
217 collection:collection 226 glyphInfo,NSGlyphInfoAttributeName,nil];
218 baseString:string]; 227 NSTextStorage *textStorage =
219 NSDictionary *attributes = 228 [[NSTextStorage alloc] initWithString:string
220 [NSDictionary dictionaryWithObjectsAndKeys:nsFont,NSFontAttributeName, 229 attributes:attributes];
221 glyphInfo,NSGlyphInfoAttributeName,nil]; 230 NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
222 NSTextStorage *textStorage = 231 NSTextContainer *textContainer = [[NSTextContainer alloc] init];
223 [[NSTextStorage alloc] initWithString:string 232 NSFont *fontInTextStorage;
224 attributes:attributes];
225 NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
226 NSTextContainer *textContainer = [[NSTextContainer alloc] init];
227 NSFont *fontInTextStorage;
228
229 [layoutManager addTextContainer:textContainer];
230 [textContainer release];
231 [textStorage addLayoutManager:layoutManager];
232 [layoutManager release];
233
234 /* Force layout. */
235 (void) [layoutManager glyphRangeForTextContainer:textContainer];
236
237 fontInTextStorage = [textStorage attribute:NSFontAttributeName atIndex:0
238 effectiveRange:NULL];
239 if (fontInTextStorage == nsFont
240 || [[fontInTextStorage fontName] isEqualToString:[nsFont fontName]])
241 {
242 NSGlyph glyph = [layoutManager glyphAtIndex:0];
243 233
244 if (glyph < [nsFont numberOfGlyphs]) 234 [layoutManager addTextContainer:textContainer];
245 result = glyph; 235 [textContainer release];
246 } 236 [textStorage addLayoutManager:layoutManager];
237 [layoutManager release];
247 238
248 [textStorage release]; 239 /* Force layout. */
240 (void) [layoutManager glyphRangeForTextContainer:textContainer];
249 241
250 return result; 242 fontInTextStorage = [textStorage attribute:NSFontAttributeName atIndex:0
251 } 243 effectiveRange:NULL];
244 if (fontInTextStorage == nsFont
245 || [[fontInTextStorage fontName] isEqualToString:[nsFont fontName]])
246 {
247 NSGlyph glyph = [layoutManager glyphAtIndex:0];
248
249 if (glyph < [nsFont numberOfGlyphs])
250 result = glyph;
251 }
252
253 [textStorage release];
254
255 return result;
252} 256}
253#endif 257#endif
254 258
@@ -762,6 +766,46 @@ cfnumber_get_font_symbolic_traits_value (CFNumberRef number,
762 return false; 766 return false;
763} 767}
764 768
769static CGFloat
770mac_font_descriptor_get_adjusted_weight (CTFontDescriptorRef desc, CGFloat val)
771{
772 long percent_val = lround (val * 100);
773
774 if (percent_val == -40 || percent_val == 56)
775 {
776 CTFontRef font = NULL;
777 CFStringRef name =
778 CTFontDescriptorCopyAttribute (desc, kCTFontNameAttribute);
779
780 if (name)
781 {
782 font = CTFontCreateWithName (name, 0, NULL);
783 CFRelease (name);
784 }
785 if (font)
786 {
787 CFIndex weight = mac_font_get_weight (font);
788
789 if (percent_val == -40)
790 {
791 /* Workaround for crash when displaying Oriya characters
792 with Arial Unicode MS on OS X 10.11. */
793 if (weight == 5)
794 val = 0;
795 }
796 else /* percent_val == 56 */
797 {
798 if (weight == 9)
799 /* Adjustment for HiraginoSans-W7 on OS X 10.11. */
800 val = 0.4;
801 }
802 CFRelease (font);
803 }
804 }
805
806 return val;
807}
808
765static void 809static void
766macfont_store_descriptor_attributes (CTFontDescriptorRef desc, 810macfont_store_descriptor_attributes (CTFontDescriptorRef desc,
767 Lisp_Object spec_or_entity) 811 Lisp_Object spec_or_entity)
@@ -785,6 +829,7 @@ macfont_store_descriptor_attributes (CTFontDescriptorRef desc,
785 enum font_property_index index; 829 enum font_property_index index;
786 CFStringRef trait; 830 CFStringRef trait;
787 CGPoint points[6]; 831 CGPoint points[6];
832 CGFloat (*adjust_func) (CTFontDescriptorRef, CGFloat);
788 } numeric_traits[] = 833 } numeric_traits[] =
789 {{FONT_WEIGHT_INDEX, kCTFontWeightTrait, 834 {{FONT_WEIGHT_INDEX, kCTFontWeightTrait,
790 {{-0.4, 50}, /* light */ 835 {{-0.4, 50}, /* light */
@@ -792,11 +837,12 @@ macfont_store_descriptor_attributes (CTFontDescriptorRef desc,
792 {0, 100}, /* normal */ 837 {0, 100}, /* normal */
793 {0.24, 140}, /* (semi-bold + normal) / 2 */ 838 {0.24, 140}, /* (semi-bold + normal) / 2 */
794 {0.4, 200}, /* bold */ 839 {0.4, 200}, /* bold */
795 {CGFLOAT_MAX, CGFLOAT_MAX}}}, 840 {CGFLOAT_MAX, CGFLOAT_MAX}},
841 mac_font_descriptor_get_adjusted_weight},
796 {FONT_SLANT_INDEX, kCTFontSlantTrait, 842 {FONT_SLANT_INDEX, kCTFontSlantTrait,
797 {{0, 100}, {0.1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}}, 843 {{0, 100}, {0.1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}, NULL},
798 {FONT_WIDTH_INDEX, kCTFontWidthTrait, 844 {FONT_WIDTH_INDEX, kCTFontWidthTrait,
799 {{0, 100}, {1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}}}; 845 {{0, 100}, {1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}, NULL}};
800 int i; 846 int i;
801 847
802 for (i = 0; i < ARRAYELTS (numeric_traits); i++) 848 for (i = 0; i < ARRAYELTS (numeric_traits); i++)
@@ -806,6 +852,8 @@ macfont_store_descriptor_attributes (CTFontDescriptorRef desc,
806 { 852 {
807 CGPoint *point = numeric_traits[i].points; 853 CGPoint *point = numeric_traits[i].points;
808 854
855 if (numeric_traits[i].adjust_func)
856 floatval = (*numeric_traits[i].adjust_func) (desc, floatval);
809 while (point->x < floatval) 857 while (point->x < floatval)
810 point++; 858 point++;
811 if (point == numeric_traits[i].points) 859 if (point == numeric_traits[i].points)
@@ -2717,7 +2765,6 @@ macfont_has_char (Lisp_Object font, int c)
2717static unsigned 2765static unsigned
2718macfont_encode_char (struct font *font, int c) 2766macfont_encode_char (struct font *font, int c)
2719{ 2767{
2720 struct macfont_info *macfont_info = (struct macfont_info *) font;
2721 CGGlyph glyph; 2768 CGGlyph glyph;
2722 2769
2723 block_input (); 2770 block_input ();
@@ -3379,18 +3426,24 @@ mac_font_descriptor_supports_languages (CTFontDescriptorRef descriptor,
3379 result = false; 3426 result = false;
3380 else 3427 else
3381 { 3428 {
3382 CFIndex desc_languages_count, i, languages_count; 3429 CFRange range = CFRangeMake (0, CFArrayGetCount (desc_languages));
3430 CFIndex i, languages_count = CFArrayGetCount (languages);
3383 3431
3384 desc_languages_count = CFArrayGetCount (desc_languages);
3385 languages_count = CFArrayGetCount (languages);
3386 for (i = 0; i < languages_count; i++) 3432 for (i = 0; i < languages_count; i++)
3387 if (!CFArrayContainsValue (desc_languages, 3433 {
3388 CFRangeMake (0, desc_languages_count), 3434 CFStringRef language = CFArrayGetValueAtIndex (languages, i);
3389 CFArrayGetValueAtIndex (languages, i))) 3435
3390 { 3436 if (!CFArrayContainsValue (desc_languages, range, language)
3391 result = false; 3437 /* PingFang SC contains "zh" and "zh-Hant" as covered
3392 break; 3438 languages, but does not contain "zh-Hans". */
3393 } 3439 && !(CFEqual (language, CFSTR ("zh-Hans"))
3440 && CFArrayContainsValue (desc_languages, range,
3441 CFSTR ("zh"))))
3442 {
3443 result = false;
3444 break;
3445 }
3446 }
3394 CFRelease (desc_languages); 3447 CFRelease (desc_languages);
3395 } 3448 }
3396 3449
@@ -3998,8 +4051,6 @@ mac_register_font_driver (struct frame *f)
3998void 4051void
3999syms_of_macfont (void) 4052syms_of_macfont (void)
4000{ 4053{
4001 static struct font_driver mac_font_driver;
4002
4003 /* Core Text, for Mac OS X. */ 4054 /* Core Text, for Mac OS X. */
4004 DEFSYM (Qmac_ct, "mac-ct"); 4055 DEFSYM (Qmac_ct, "mac-ct");
4005 macfont_driver.type = Qmac_ct; 4056 macfont_driver.type = Qmac_ct;
diff --git a/src/nsterm.m b/src/nsterm.m
index a5bf06a70af..65d07b2f1e4 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -6724,6 +6724,11 @@ if (cols > 0 && rows > 0)
6724{ 6724{
6725 if (fs_state != emacsframe->want_fullscreen) 6725 if (fs_state != emacsframe->want_fullscreen)
6726 { 6726 {
6727 NSSize sz;
6728 sz.width = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (emacsframe);
6729 sz.height = frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (emacsframe);
6730 [[self window] setResizeIncrements:sz];
6731
6727 if (fs_state == FULLSCREEN_BOTH) 6732 if (fs_state == FULLSCREEN_BOTH)
6728 { 6733 {
6729 [self toggleFullScreen:self]; 6734 [self toggleFullScreen:self];
diff --git a/src/process.c b/src/process.c
index 42dd17c57e0..55f31a02673 100644
--- a/src/process.c
+++ b/src/process.c
@@ -5031,18 +5031,12 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
5031 for (channel = 0; channel <= max_input_desc; ++channel) 5031 for (channel = 0; channel <= max_input_desc; ++channel)
5032 { 5032 {
5033 struct fd_callback_data *d = &fd_callback_info[channel]; 5033 struct fd_callback_data *d = &fd_callback_info[channel];
5034 if (d->func) 5034 if (d->func
5035 { 5035 && ((d->condition & FOR_READ
5036 if (d->condition & FOR_READ 5036 && FD_ISSET (channel, &Available))
5037 && FD_ISSET (channel, &Available)) 5037 || (d->condition & FOR_WRITE
5038 { 5038 && FD_ISSET (channel, &write_mask))))
5039 d->func (channel, d->data); 5039 d->func (channel, d->data);
5040 FD_CLR (channel, &Available);
5041 }
5042 else if (d->condition & FOR_WRITE
5043 && FD_ISSET (channel, &write_mask))
5044 d->func (channel, d->data);
5045 }
5046 } 5040 }
5047 5041
5048 for (channel = 0; channel <= max_process_desc; channel++) 5042 for (channel = 0; channel <= max_process_desc; channel++)
diff --git a/src/window.c b/src/window.c
index 42a2ca68f14..6d06e548094 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1686,8 +1686,10 @@ Return nil if that position is scrolled vertically out of view. If a
1686character is only partially visible, nil is returned, unless the 1686character is only partially visible, nil is returned, unless the
1687optional argument PARTIALLY is non-nil. If POS is only out of view 1687optional argument PARTIALLY is non-nil. If POS is only out of view
1688because of horizontal scrolling, return non-nil. If POS is t, it 1688because of horizontal scrolling, return non-nil. If POS is t, it
1689specifies the position of the last visible glyph in WINDOW. POS 1689specifies either the first position displayed on the last visible
1690defaults to point in WINDOW; WINDOW defaults to the selected window. 1690screen line in WINDOW, or the end-of-buffer position, whichever comes
1691first. POS defaults to point in WINDOW; WINDOW defaults to the
1692selected window.
1691 1693
1692If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil, 1694If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil,
1693the return value is a list of 2 or 6 elements (X Y [RTOP RBOT ROWH VPOS]), 1695the return value is a list of 2 or 6 elements (X Y [RTOP RBOT ROWH VPOS]),
@@ -6607,7 +6609,6 @@ apply_window_adjustment (struct window *w)
6607 eassert (w); 6609 eassert (w);
6608 clear_glyph_matrix (w->current_matrix); 6610 clear_glyph_matrix (w->current_matrix);
6609 w->window_end_valid = false; 6611 w->window_end_valid = false;
6610 windows_or_buffers_changed = 30;
6611 wset_redisplay (w); 6612 wset_redisplay (w);
6612 adjust_frame_glyphs (XFRAME (WINDOW_FRAME (w))); 6613 adjust_frame_glyphs (XFRAME (WINDOW_FRAME (w)));
6613} 6614}
diff --git a/src/xdisp.c b/src/xdisp.c
index 2c38aa9ccff..44983bb4f9d 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -434,22 +434,54 @@ static Lisp_Object Vmessage_stack;
434 434
435static bool message_enable_multibyte; 435static bool message_enable_multibyte;
436 436
437/* Nonzero if we should redraw the mode lines on the next redisplay. 437/* At each redisplay cycle, we should refresh everything there is to refresh.
438 If it has value REDISPLAY_SOME, then only redisplay the mode lines where 438 To do that efficiently, we use many optimizations that try to make sure we
439 the `redisplay' bit has been set. Otherwise, redisplay all mode lines 439 don't waste too much time updating things that haven't changed.
440 (the number used is then only used to track down the cause for this 440 The coarsest such optimization is that, in the most common cases, we only
441 full-redisplay). */ 441 look at the selected-window.
442
443 To know whether other windows should be considered for redisplay, we use the
444 variable windows_or_buffers_changed: as long as it is 0, it means that we
445 have not noticed anything that should require updating anything else than
446 the selected-window. If it is set to REDISPLAY_SOME, it means that since
447 last redisplay, some changes have been made which could impact other
448 windows. To know which ones need redisplay, every buffer, window, and frame
449 has a `redisplay' bit, which (if true) means that this object needs to be
450 redisplayed. If windows_or_buffers_changed is 0, we know there's no point
451 looking for those `redisplay' bits (actually, there might be some such bits
452 set, but then only on objects which aren't displayed anyway).
453
454 OTOH if it's non-zero we wil have to loop through all windows and then check
455 the `redisplay' bit of the corresponding window, frame, and buffer, in order
456 to decide whether that window needs attention or not. Not that we can't
457 just look at the frame's redisplay bit to decide that the whole frame can be
458 skipped, since even if the frame's redisplay bit is unset, some of its
459 windows's redisplay bits may be set.
460
461 Mostly for historical reasons, windows_or_buffers_changed can also take
462 other non-zero values. In that case, the precise value doesn't matter (it
463 encodes the cause of the setting but is only used for debugging purposes),
464 and what it means is that we shouldn't pay attention to any `redisplay' bits
465 and we should simply try and redisplay every window out there. */
442 466
443int update_mode_lines; 467int windows_or_buffers_changed;
444 468
445/* Nonzero if window sizes or contents other than selected-window have changed 469/* Nonzero if we should redraw the mode lines on the next redisplay.
446 since last redisplay that finished. 470 Similarly to `windows_or_buffers_changed', If it has value REDISPLAY_SOME,
447 If it has value REDISPLAY_SOME, then only redisplay the windows where 471 then only redisplay the mode lines in those buffers/windows/frames where the
448 the `redisplay' bit has been set. Otherwise, redisplay all windows 472 `redisplay' bit has been set.
449 (the number used is then only used to track down the cause for this 473 For any other value, redisplay all mode lines (the number used is then only
450 full-redisplay). */ 474 used to track down the cause for this full-redisplay).
475
476 The `redisplay' bits are the same as those used for
477 windows_or_buffers_changed, and setting windows_or_buffers_changed also
478 causes recomputation of the mode lines of all those windows. IOW this
479 variable only has an effect if windows_or_buffers_changed is zero, in which
480 case we should only need to redisplay the mode-line of those objects with
481 a `redisplay' bit set but not the window's text content (tho we may still
482 need to refresh the text content of the selected-window). */
451 483
452int windows_or_buffers_changed; 484int update_mode_lines;
453 485
454/* True after display_mode_line if %l was used and it displayed a 486/* True after display_mode_line if %l was used and it displayed a
455 line number. */ 487 line number. */
@@ -13383,6 +13415,8 @@ redisplay_internal (void)
13383 pending = false; 13415 pending = false;
13384 forget_escape_and_glyphless_faces (); 13416 forget_escape_and_glyphless_faces ();
13385 13417
13418 inhibit_free_realized_faces = false;
13419
13386 /* If face_change, init_iterator will free all realized faces, which 13420 /* If face_change, init_iterator will free all realized faces, which
13387 includes the faces referenced from current matrices. So, we 13421 includes the faces referenced from current matrices. So, we
13388 can't reuse current matrices in this case. */ 13422 can't reuse current matrices in this case. */
@@ -13430,7 +13464,7 @@ redisplay_internal (void)
13430 /* If cursor type has been changed on the frame 13464 /* If cursor type has been changed on the frame
13431 other than selected, consider all frames. */ 13465 other than selected, consider all frames. */
13432 if (f != sf && f->cursor_type_changed) 13466 if (f != sf && f->cursor_type_changed)
13433 update_mode_lines = 31; 13467 fset_redisplay (f);
13434 } 13468 }
13435 clear_desired_matrices (f); 13469 clear_desired_matrices (f);
13436 } 13470 }
@@ -13528,9 +13562,12 @@ redisplay_internal (void)
13528 consider_all_windows_p = (update_mode_lines 13562 consider_all_windows_p = (update_mode_lines
13529 || windows_or_buffers_changed); 13563 || windows_or_buffers_changed);
13530 13564
13531#define AINC(a,i) \ 13565#define AINC(a,i) \
13532 if (VECTORP (a) && i >= 0 && i < ASIZE (a) && INTEGERP (AREF (a, i))) \ 13566 { \
13533 ASET (a, i, make_number (1 + XINT (AREF (a, i)))) 13567 Lisp_Object entry = Fgethash (make_number (i), a, make_number (0)); \
13568 if (INTEGERP (entry)) \
13569 Fputhash (make_number (i), make_number (1 + XINT (entry)), a); \
13570 }
13534 13571
13535 AINC (Vredisplay__all_windows_cause, windows_or_buffers_changed); 13572 AINC (Vredisplay__all_windows_cause, windows_or_buffers_changed);
13536 AINC (Vredisplay__mode_lines_cause, update_mode_lines); 13573 AINC (Vredisplay__mode_lines_cause, update_mode_lines);
@@ -13745,7 +13782,8 @@ redisplay_internal (void)
13745#endif 13782#endif
13746 13783
13747 /* Build desired matrices, and update the display. If 13784 /* Build desired matrices, and update the display. If
13748 consider_all_windows_p, do it for all windows on all frames. 13785 consider_all_windows_p, do it for all windows on all frames that
13786 require redisplay, as specified by their 'redisplay' flag.
13749 Otherwise do it for selected_window, only. */ 13787 Otherwise do it for selected_window, only. */
13750 13788
13751 if (consider_all_windows_p) 13789 if (consider_all_windows_p)
@@ -13871,6 +13909,10 @@ redisplay_internal (void)
13871 if (sf->fonts_changed) 13909 if (sf->fonts_changed)
13872 goto retry; 13910 goto retry;
13873 13911
13912 /* Prevent freeing of realized faces, since desired matrices are
13913 pending that reference the faces we computed and cached. */
13914 inhibit_free_realized_faces = true;
13915
13874 /* Prevent various kinds of signals during display update. 13916 /* Prevent various kinds of signals during display update.
13875 stdio is not robust about handling signals, 13917 stdio is not robust about handling signals,
13876 which can cause an apparent I/O error. */ 13918 which can cause an apparent I/O error. */
@@ -19802,7 +19844,8 @@ push_prefix_prop (struct it *it, Lisp_Object prop)
19802 19844
19803 eassert (it->method == GET_FROM_BUFFER 19845 eassert (it->method == GET_FROM_BUFFER
19804 || it->method == GET_FROM_DISPLAY_VECTOR 19846 || it->method == GET_FROM_DISPLAY_VECTOR
19805 || it->method == GET_FROM_STRING); 19847 || it->method == GET_FROM_STRING
19848 || it->method == GET_FROM_IMAGE);
19806 19849
19807 /* We need to save the current buffer/string position, so it will be 19850 /* We need to save the current buffer/string position, so it will be
19808 restored by pop_it, because iterate_out_of_display_property 19851 restored by pop_it, because iterate_out_of_display_property
@@ -31381,13 +31424,11 @@ display table takes effect; in this case, Emacs does not consult
31381 31424
31382 DEFVAR_LISP ("redisplay--all-windows-cause", Vredisplay__all_windows_cause, 31425 DEFVAR_LISP ("redisplay--all-windows-cause", Vredisplay__all_windows_cause,
31383 doc: /* */); 31426 doc: /* */);
31384 Vredisplay__all_windows_cause 31427 Vredisplay__all_windows_cause = Fmake_hash_table (0, NULL);
31385 = Fmake_vector (make_number (100), make_number (0));
31386 31428
31387 DEFVAR_LISP ("redisplay--mode-lines-cause", Vredisplay__mode_lines_cause, 31429 DEFVAR_LISP ("redisplay--mode-lines-cause", Vredisplay__mode_lines_cause,
31388 doc: /* */); 31430 doc: /* */);
31389 Vredisplay__mode_lines_cause 31431 Vredisplay__mode_lines_cause = Fmake_hash_table (0, NULL);
31390 = Fmake_vector (make_number (100), make_number (0));
31391} 31432}
31392 31433
31393 31434
diff --git a/src/xfaces.c b/src/xfaces.c
index 40713f167ff..8cf0b427799 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -631,7 +631,7 @@ free_frame_faces (struct frame *f)
631/* Clear face caches, and recompute basic faces for frame F. Call 631/* Clear face caches, and recompute basic faces for frame F. Call
632 this after changing frame parameters on which those faces depend, 632 this after changing frame parameters on which those faces depend,
633 or when realized faces have been freed due to changing attributes 633 or when realized faces have been freed due to changing attributes
634 of named faces. */ 634 of named faces. */
635 635
636void 636void
637recompute_basic_faces (struct frame *f) 637recompute_basic_faces (struct frame *f)
@@ -2528,10 +2528,15 @@ Value is a vector of face attributes. */)
2528 if (NILP (Fget (face, Qface_no_inherit))) 2528 if (NILP (Fget (face, Qface_no_inherit)))
2529 { 2529 {
2530 if (f) 2530 if (f)
2531 f->face_change = 1; 2531 {
2532 f->face_change = true;
2533 fset_redisplay (f);
2534 }
2532 else 2535 else
2533 face_change = true; 2536 {
2534 windows_or_buffers_changed = 54; 2537 face_change = true;
2538 windows_or_buffers_changed = 54;
2539 }
2535 } 2540 }
2536 2541
2537 eassert (LFACEP (lface)); 2542 eassert (LFACEP (lface));
@@ -2613,10 +2618,15 @@ The value is TO. */)
2613 if (NILP (Fget (to, Qface_no_inherit))) 2618 if (NILP (Fget (to, Qface_no_inherit)))
2614 { 2619 {
2615 if (f) 2620 if (f)
2616 f->face_change = 1; 2621 {
2622 f->face_change = true;
2623 fset_redisplay (f);
2624 }
2617 else 2625 else
2618 face_change = true; 2626 {
2619 windows_or_buffers_changed = 55; 2627 face_change = true;
2628 windows_or_buffers_changed = 55;
2629 }
2620 } 2630 }
2621 2631
2622 return to; 2632 return to;
@@ -3120,7 +3130,7 @@ FRAME 0 means change the face on all frames, and change the default
3120 && NILP (Fequal (old_value, value))) 3130 && NILP (Fequal (old_value, value)))
3121 { 3131 {
3122 f->face_change = true; 3132 f->face_change = true;
3123 windows_or_buffers_changed = 56; 3133 fset_redisplay (f);
3124 } 3134 }
3125 3135
3126 if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value) 3136 if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value)
@@ -3293,7 +3303,7 @@ update_face_from_frame_parameter (struct frame *f, Lisp_Object param,
3293 && NILP (Fget (face, Qface_no_inherit))) 3303 && NILP (Fget (face, Qface_no_inherit)))
3294 { 3304 {
3295 f->face_change = true; 3305 f->face_change = true;
3296 windows_or_buffers_changed = 57; 3306 fset_redisplay (f);
3297 } 3307 }
3298} 3308}
3299 3309
diff --git a/src/xfns.c b/src/xfns.c
index d6a3d76e948..fc6111c4fab 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1041,7 +1041,7 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
1041 nlines = 0; 1041 nlines = 0;
1042 1042
1043 /* Make sure we redisplay all windows in this frame. */ 1043 /* Make sure we redisplay all windows in this frame. */
1044 windows_or_buffers_changed = 59; 1044 fset_redisplay (f);
1045 1045
1046#if defined (USE_X_TOOLKIT) || defined (USE_GTK) 1046#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
1047 FRAME_MENU_BAR_LINES (f) = 0; 1047 FRAME_MENU_BAR_LINES (f) = 0;
@@ -1160,8 +1160,7 @@ x_change_tool_bar_height (struct frame *f, int height)
1160 Lisp_Object fullscreen; 1160 Lisp_Object fullscreen;
1161 1161
1162 /* Make sure we redisplay all windows in this frame. */ 1162 /* Make sure we redisplay all windows in this frame. */
1163 windows_or_buffers_changed = 60; 1163 fset_redisplay (f);
1164
1165 1164
1166 /* Recalculate tool bar and frame text sizes. */ 1165 /* Recalculate tool bar and frame text sizes. */
1167 FRAME_TOOL_BAR_HEIGHT (f) = height; 1166 FRAME_TOOL_BAR_HEIGHT (f) = height;