Commit a39b02c3 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

winemac: Dispatch key-up events directly to window to be sure to get them.

For keys pressed in combination with Command, -[NSApplication sendEvent:] simply doesn't pass the key-up event through to the window. We have to track which keys we've told Wine are pressed because Cocoa may consume key-downs that trigger menus or system behaviors.
parent a723af61
......@@ -54,6 +54,7 @@ enum {
NSEvent* lastFlagsChanged;
BOOL inputSourceIsInputMethod;
BOOL inputSourceIsInputMethodValid;
uint32_t pressedKeyCodes[128 / 32];
CGFloat primaryScreenHeight;
BOOL primaryScreenHeightValid;
......@@ -105,6 +106,7 @@ enum {
- (BOOL) waitUntilQueryDone:(int*)done timeout:(NSDate*)timeout processEvents:(BOOL)processEvents;
- (void) keyboardSelectionDidChange;
- (void) noteKey:(uint16_t)keyCode pressed:(BOOL)pressed;
- (void) flipRect:(NSRect*)rect;
......
......@@ -1280,6 +1280,25 @@ int macdrv_err_on;
return TRUE;
}
- (BOOL) isKeyPressed:(uint16_t)keyCode
{
int bits = sizeof(pressedKeyCodes[0]) * 8;
int index = keyCode / bits;
uint32_t mask = 1 << (keyCode % bits);
return (pressedKeyCodes[index] & mask) != 0;
}
- (void) noteKey:(uint16_t)keyCode pressed:(BOOL)pressed
{
int bits = sizeof(pressedKeyCodes[0]) * 8;
int index = keyCode / bits;
uint32_t mask = 1 << (keyCode % bits);
if (pressed)
pressedKeyCodes[index] |= mask;
else
pressedKeyCodes[index] &= ~mask;
}
- (void) handleMouseMove:(NSEvent*)anEvent
{
WineWindow* targetWindow;
......@@ -1692,6 +1711,17 @@ int macdrv_err_on;
[self handleScrollWheel:anEvent];
ret = mouseCaptureWindow != nil;
}
else if (type == NSKeyUp)
{
uint16_t keyCode = [anEvent keyCode];
if ([self isKeyPressed:keyCode])
{
WineWindow* window = (WineWindow*)[anEvent window];
[self noteKey:keyCode pressed:FALSE];
if ([window isKindOfClass:[WineWindow class]])
[window postKeyEvent:anEvent];
}
}
return ret;
}
......
......@@ -68,4 +68,6 @@
- (NSInteger) minimumLevelForActive:(BOOL)active;
- (void) updateFullscreen;
- (void) postKeyEvent:(NSEvent *)theEvent;
@end
......@@ -1117,6 +1117,8 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
[queue postEvent:event];
macdrv_release_event(event);
[controller noteKey:keyCode pressed:pressed];
}
- (void) postKeyEvent:(NSEvent *)theEvent
......@@ -1243,7 +1245,6 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
* ---------- NSResponder method overrides ----------
*/
- (void) keyDown:(NSEvent *)theEvent { [self postKeyEvent:theEvent]; }
- (void) keyUp:(NSEvent *)theEvent { [self postKeyEvent:theEvent]; }
- (void) flagsChanged:(NSEvent *)theEvent
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment