Module: wine Branch: master Commit: c5eca7be915af1eb88faf181e9a6181981ce8c24 URL: http://source.winehq.org/git/wine.git/?a=commit;h=c5eca7be915af1eb88faf181e9...
Author: Ken Thomases ken@codeweavers.com Date: Fri Mar 10 02:22:02 2017 -0600
winemac: Discard key repeat events after a modifier key has been pressed.
Sierra (macOS 10.12) changed the behavior of key repeat. In previous versions of macOS, key repeat stops when a modifier key is pressed or released. In Sierra, it does not; it just keeps repeating as newly-modified.
On Windows, key repeat stops when a modifier key is pressed, although not when one is released. Some programs depend on this behavior. So, the Mac driver emulates it.
Signed-off-by: Ken Thomases ken@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/winemac.drv/cocoa_window.h | 2 ++ dlls/winemac.drv/cocoa_window.m | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/dlls/winemac.drv/cocoa_window.h b/dlls/winemac.drv/cocoa_window.h index f037b08..b4cc018 100644 --- a/dlls/winemac.drv/cocoa_window.h +++ b/dlls/winemac.drv/cocoa_window.h @@ -81,6 +81,8 @@
NSTimeInterval lastDockIconSnapshot;
+ BOOL allowKeyRepeats; + BOOL ignore_windowDeminiaturize; BOOL ignore_windowResize; BOOL fakingClose; diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m index 118bf3c..af8ebe7 100644 --- a/dlls/winemac.drv/cocoa_window.m +++ b/dlls/winemac.drv/cocoa_window.m @@ -2424,7 +2424,18 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi /* * ---------- NSResponder method overrides ---------- */ - - (void) keyDown:(NSEvent *)theEvent { [self postKeyEvent:theEvent]; } + - (void) keyDown:(NSEvent *)theEvent + { + if ([theEvent isARepeat]) + { + if (!allowKeyRepeats) + return; + } + else + allowKeyRepeats = YES; + + [self postKeyEvent:theEvent]; + }
- (void) flagsChanged:(NSEvent *)theEvent { @@ -2461,6 +2472,9 @@ static CVReturn WineDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTi { BOOL pressed = (modifierFlags & modifiers[i].mask) != 0;
+ if (pressed) + allowKeyRepeats = NO; + if (i == last_changed) lastModifierFlags = modifierFlags; else