emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] [emacs] 01/01: Redo the fix, the old takes too much CPU.


From: Jan D.
Subject: [Emacs-diffs] [emacs] 01/01: Redo the fix, the old takes too much CPU.
Date: Sat, 15 Nov 2014 18:10:08 +0000

jhd pushed a commit to branch master
in repository emacs.

commit 0d9bf9725af8d819709ab775c380cc6cadddc5b5
Author: Jan D <address@hidden>
Date:   Sat Nov 15 19:09:58 2014 +0100

    Redo the fix, the old takes too much CPU.
    
    Fixes: 18993
    
    * nsterm.m (ns_send_appdefined): Check for application defined
    event on Cocoa (Bug#18993).
    (run): Restore code before the previous 18993 fix.
---
 src/ChangeLog |    6 ++++++
 src/nsterm.m  |   37 ++++++++++++++++++++++++++-----------
 2 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 71b2938..cf35218 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2014-11-15  Jan Djärv  <address@hidden>
+
+       * nsterm.m (ns_send_appdefined): Check for application defined
+       event on Cocoa (Bug#18993).
+       (run): Restore code before the previous 18993 fix.
+
 2014-11-14  David Reitter  <address@hidden>
 
        * nsterm.m (run): set timeout for event loop to prevent hang.
diff --git a/src/nsterm.m b/src/nsterm.m
index 539f77e..c36b9ed 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -3377,6 +3377,21 @@ ns_send_appdefined (int value)
   /* Only post this event if we haven't already posted one.  This will end
        the [NXApp run] main loop after having processed all events queued at
        this moment.  */
+
+#ifdef NS_IMPL_COCOA
+  if (! send_appdefined)
+    {
+      /* OSX 10.10.1 swallows the AppDefined event we are sending ourselves
+         in certain situations (rapid incoming events).
+         So check if we have one, if not add one.  */
+      NSEvent *appev = [NSApp nextEventMatchingMask:NSApplicationDefinedMask
+                                          untilDate:[NSDate distantPast]
+                                             inMode:NSDefaultRunLoopMode
+                                            dequeue:NO];
+      if (! appev) send_appdefined = YES;
+    }
+#endif
+
   if (send_appdefined)
     {
       NSEvent *nxev;
@@ -4511,6 +4526,15 @@ ns_term_shutdown (int sig)
 #ifdef NS_IMPL_COCOA
 - (void)run
 {
+#ifndef NSAppKitVersionNumber10_9
+#define NSAppKitVersionNumber10_9 1265
+#endif
+
+    if ((int)NSAppKitVersionNumber != NSAppKitVersionNumber10_9)
+      {
+        [super run];
+        return;
+      }
 
   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 
@@ -4523,22 +4547,13 @@ ns_term_shutdown (int sig)
       [pool release];
       pool = [[NSAutoreleasePool alloc] init];
 
-      /* OSX 10.10.1 swallows the AppDefined event we are sending ourselves
-        in certain situations (rapid incoming events).
-        The timeout we set with untilDate is necessary to prevent a hang.
-        Bug #18993 */
-
       NSEvent *event =
         [self nextEventMatchingMask:NSAnyEventMask
-                          untilDate:[NSDate dateWithTimeIntervalSinceNow:0.5]
+                          untilDate:[NSDate distantFuture]
                              inMode:NSDefaultRunLoopMode
                             dequeue:YES];
 
-      if (event == nil) // timeout
-       shouldKeepRunning = NO;
-      else
-       [self sendEvent:event];
-
+      [self sendEvent:event];
       [self updateWindows];
     } while (shouldKeepRunning);
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]