]> code.delx.au - gnu-emacs/commitdiff
More flicker fixes for OSX, related to bug 18757.
authorJan Djärv <jan.h.d@swipnet.se>
Tue, 2 Dec 2014 13:05:27 +0000 (14:05 +0100)
committerJan Djärv <jan.h.d@swipnet.se>
Tue, 2 Dec 2014 13:05:27 +0000 (14:05 +0100)
* nsfns.m (ns_set_name_as_filename): Don't set represented filename
at once, call ns_set_represented_filename instead.

* nsterm.h: Declare ns_set_represented_filename.

* nsterm.m (represented_filename, represented_frame): New variables.
(ns_set_represented_filename): New function.
(sendEvent:): Set represented filename here to avoid flicker,
related to Bug#18757.

src/ChangeLog
src/nsfns.m
src/nsterm.h
src/nsterm.m

index 5ecb0220026e7bfd5eff020dd589e956d591b508..952e4abd230ca2356be36e5cc3c5c4eecf7bbaf2 100644 (file)
@@ -1,3 +1,15 @@
+2014-12-02  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * nsterm.m (represented_filename, represented_frame): New variables.
+       (ns_set_represented_filename): New function.
+       (sendEvent:): Set represented filename here to avoid flicker,
+       related to Bug#18757.
+
+       * nsterm.h: Declare ns_set_represented_filename.
+
+       * nsfns.m (ns_set_name_as_filename): Don't set represented filename
+       at once, call ns_set_represented_filename instead.
+
 2014-11-27  Eli Zaretskii  <eliz@gnu.org>
 
        * xdisp.c (handle_single_display_spec): When ignoring a fringe
index e0f8cfee14a5993bd20b44eedd624d2959244ea7..ec4761b773a97db8da5b176510ea0b5eb888fb47 100644 (file)
@@ -621,18 +621,11 @@ ns_set_name_as_filename (struct frame *f)
 
           fstr = [NSString stringWithUTF8String: SSDATA (encoded_filename)];
           if (fstr == nil) fstr = @"";
-#ifdef NS_IMPL_COCOA
-          /* work around a bug observed on 10.3 and later where
-             setTitleWithRepresentedFilename does not clear out previous state
-             if given filename does not exist */
-          if (! [[NSFileManager defaultManager] fileExistsAtPath: fstr])
-            [[view window] setRepresentedFilename: @""];
-#endif
         }
       else
         fstr = @"";
 
-      [[view window] setRepresentedFilename: fstr];
+      ns_set_represented_filename (fstr, f);
       [[view window] setTitle: str];
       fset_name (f, name);
     }
index 1c3fda82649ef542fbe82244cda9ee16f519ee13..115d7ac6779f1716733ea8bf8f2fbfb884ca4a97 100644 (file)
@@ -895,11 +895,15 @@ extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds,
 extern unsigned long ns_get_rgb_color (struct frame *f,
                                        float r, float g, float b, float a);
 
-/* From nsterm.m, needed in nsfont.m. */
 #ifdef __OBJC__
+/* From nsterm.m, needed in nsfont.m. */
 extern void
 ns_draw_text_decoration (struct glyph_string *s, struct face *face,
                          NSColor *defaultCol, CGFloat width, CGFloat x);
+/* Needed in nsfns.m.  */
+extern void
+ns_set_represented_filename (NSString* fstr, struct frame *f);
+
 #endif
 
 #ifdef NS_IMPL_GNUSTEP
index 7e2d4beac6abd5a2b99560c96c5a9c60379ae061..656d86687171ce324ccfdc77ec2c62b111831ddc 100644 (file)
@@ -290,6 +290,9 @@ static struct {
   NULL, 0, 0
 };
 
+static NSString *represented_filename = nil;
+static struct frame *represented_frame = 0;
+
 #ifdef NS_IMPL_COCOA
 /*
  * State for pending menu activation:
@@ -396,6 +399,14 @@ void x_set_frame_alpha (struct frame *f);
 
    ========================================================================== */
 
+void
+ns_set_represented_filename (NSString* fstr, struct frame *f)
+{
+  represented_filename = [fstr retain];
+  represented_frame = f;
+}
+
+
 static void
 hold_event (struct input_event *event)
 {
@@ -4560,6 +4571,23 @@ ns_term_shutdown (int sig)
     }
 #endif
 
+  if (represented_filename != nil && represented_frame)
+    {
+      NSString *fstr = represented_filename;
+      NSView *view = FRAME_NS_VIEW (represented_frame);
+#ifdef NS_IMPL_COCOA
+      /* work around a bug observed on 10.3 and later where
+         setTitleWithRepresentedFilename does not clear out previous state
+         if given filename does not exist */
+      if (! [[NSFileManager defaultManager] fileExistsAtPath: fstr])
+        [[view window] setRepresentedFilename: @""];
+#endif
+      [[view window] setRepresentedFilename: fstr];
+      [represented_filename release];
+      represented_filename = nil;
+      represented_frame = NULL;
+    }
+
   if (type == NSApplicationDefined)
     {
       switch ([theEvent data2])