diff options
| author | Jan D | 2014-11-15 19:09:58 +0100 |
|---|---|---|
| committer | Jan D | 2014-11-15 19:09:58 +0100 |
| commit | 0d9bf9725af8d819709ab775c380cc6cadddc5b5 (patch) | |
| tree | 00e10219d1c3fee661525ceebd7675a1c843e281 /src | |
| parent | 788bc73c80bcd1e748a389692963c1464ba963df (diff) | |
| download | emacs-0d9bf9725af8d819709ab775c380cc6cadddc5b5.tar.gz emacs-0d9bf9725af8d819709ab775c380cc6cadddc5b5.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/nsterm.m | 37 |
2 files changed, 32 insertions, 11 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 71b2938694b..cf352183414 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2014-11-15 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * nsterm.m (ns_send_appdefined): Check for application defined | ||
| 4 | event on Cocoa (Bug#18993). | ||
| 5 | (run): Restore code before the previous 18993 fix. | ||
| 6 | |||
| 1 | 2014-11-14 David Reitter <david.reitter@gmail.com> | 7 | 2014-11-14 David Reitter <david.reitter@gmail.com> |
| 2 | 8 | ||
| 3 | * nsterm.m (run): set timeout for event loop to prevent hang. | 9 | * nsterm.m (run): set timeout for event loop to prevent hang. |
diff --git a/src/nsterm.m b/src/nsterm.m index 539f77e512e..c36b9ed4554 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -3377,6 +3377,21 @@ ns_send_appdefined (int value) | |||
| 3377 | /* Only post this event if we haven't already posted one. This will end | 3377 | /* Only post this event if we haven't already posted one. This will end |
| 3378 | the [NXApp run] main loop after having processed all events queued at | 3378 | the [NXApp run] main loop after having processed all events queued at |
| 3379 | this moment. */ | 3379 | this moment. */ |
| 3380 | |||
| 3381 | #ifdef NS_IMPL_COCOA | ||
| 3382 | if (! send_appdefined) | ||
| 3383 | { | ||
| 3384 | /* OSX 10.10.1 swallows the AppDefined event we are sending ourselves | ||
| 3385 | in certain situations (rapid incoming events). | ||
| 3386 | So check if we have one, if not add one. */ | ||
| 3387 | NSEvent *appev = [NSApp nextEventMatchingMask:NSApplicationDefinedMask | ||
| 3388 | untilDate:[NSDate distantPast] | ||
| 3389 | inMode:NSDefaultRunLoopMode | ||
| 3390 | dequeue:NO]; | ||
| 3391 | if (! appev) send_appdefined = YES; | ||
| 3392 | } | ||
| 3393 | #endif | ||
| 3394 | |||
| 3380 | if (send_appdefined) | 3395 | if (send_appdefined) |
| 3381 | { | 3396 | { |
| 3382 | NSEvent *nxev; | 3397 | NSEvent *nxev; |
| @@ -4511,6 +4526,15 @@ ns_term_shutdown (int sig) | |||
| 4511 | #ifdef NS_IMPL_COCOA | 4526 | #ifdef NS_IMPL_COCOA |
| 4512 | - (void)run | 4527 | - (void)run |
| 4513 | { | 4528 | { |
| 4529 | #ifndef NSAppKitVersionNumber10_9 | ||
| 4530 | #define NSAppKitVersionNumber10_9 1265 | ||
| 4531 | #endif | ||
| 4532 | |||
| 4533 | if ((int)NSAppKitVersionNumber != NSAppKitVersionNumber10_9) | ||
| 4534 | { | ||
| 4535 | [super run]; | ||
| 4536 | return; | ||
| 4537 | } | ||
| 4514 | 4538 | ||
| 4515 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | 4539 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
| 4516 | 4540 | ||
| @@ -4523,22 +4547,13 @@ ns_term_shutdown (int sig) | |||
| 4523 | [pool release]; | 4547 | [pool release]; |
| 4524 | pool = [[NSAutoreleasePool alloc] init]; | 4548 | pool = [[NSAutoreleasePool alloc] init]; |
| 4525 | 4549 | ||
| 4526 | /* OSX 10.10.1 swallows the AppDefined event we are sending ourselves | ||
| 4527 | in certain situations (rapid incoming events). | ||
| 4528 | The timeout we set with untilDate is necessary to prevent a hang. | ||
| 4529 | Bug #18993 */ | ||
| 4530 | |||
| 4531 | NSEvent *event = | 4550 | NSEvent *event = |
| 4532 | [self nextEventMatchingMask:NSAnyEventMask | 4551 | [self nextEventMatchingMask:NSAnyEventMask |
| 4533 | untilDate:[NSDate dateWithTimeIntervalSinceNow:0.5] | 4552 | untilDate:[NSDate distantFuture] |
| 4534 | inMode:NSDefaultRunLoopMode | 4553 | inMode:NSDefaultRunLoopMode |
| 4535 | dequeue:YES]; | 4554 | dequeue:YES]; |
| 4536 | 4555 | ||
| 4537 | if (event == nil) // timeout | 4556 | [self sendEvent:event]; |
| 4538 | shouldKeepRunning = NO; | ||
| 4539 | else | ||
| 4540 | [self sendEvent:event]; | ||
| 4541 | |||
| 4542 | [self updateWindows]; | 4557 | [self updateWindows]; |
| 4543 | } while (shouldKeepRunning); | 4558 | } while (shouldKeepRunning); |
| 4544 | 4559 | ||