This commit is contained in:
Josh Aas 2008-12-16 11:57:47 -05:00
Родитель 117f3bba32 0c449d3f05
Коммит d850fb820f
3 изменённых файлов: 29 добавлений и 8 удалений

Просмотреть файл

@ -62,6 +62,7 @@
// defined in nsChildView.mm
extern nsIRollupListener * gRollupListener;
extern nsIWidget * gRollupWidget;
extern PRUint32 gLastModifierState;
// defined in nsCocoaWindow.mm
extern PRInt32 gXULModalLevel;
@ -816,6 +817,10 @@ nsAppShell::AfterProcessNextEvent(nsIThreadInternal *aThread,
selector:@selector(applicationWillTerminate:)
name:NSApplicationWillTerminateNotification
object:NSApp];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidBecomeActive:)
name:NSApplicationDidBecomeActiveNotification
object:NSApp];
[[NSDistributedNotificationCenter defaultCenter] addObserver:self
selector:@selector(beginMenuTracking:)
name:@"com.apple.HIToolbox.beginMenuTrackingNotification"
@ -850,6 +855,25 @@ nsAppShell::AfterProcessNextEvent(nsIThreadInternal *aThread,
NS_OBJC_END_TRY_ABORT_BLOCK;
}
// applicationDidBecomeActive
//
// Make sure gLastModifierState is updated when we become active (since we
// won't have received [ChildView flagsChanged:] messages while inactive).
- (void)applicationDidBecomeActive:(NSNotification*)aNotification
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
// [NSEvent modifierFlags] is valid on every kind of event, so we don't need
// to worry about getting an NSInternalInconsistencyException here.
NSEvent* currentEvent = [NSApp currentEvent];
if (currentEvent) {
gLastModifierState =
nsCocoaUtils::GetCocoaEventModifierFlags(currentEvent) & NSDeviceIndependentModifierFlagsMask;
}
NS_OBJC_END_TRY_ABORT_BLOCK;
}
// beginMenuTracking
//
// Roll up our context menu (if any) when some other app (or the OS) opens

Просмотреть файл

@ -174,8 +174,6 @@ enum {
// when handling |draggingUpdated:| messages.
nsIDragService* mDragService;
PRUint32 mLastModifierState;
// For use with plugins, so that we can support IME in them. We can't use
// Cocoa TSM documents (those created and managed by the NSTSMInputContext
// class) -- for some reason TSMProcessRawKeyEvent() doesn't work with them.

Просмотреть файл

@ -136,6 +136,8 @@ static void blinkRgn(RgnHandle rgn);
nsIRollupListener * gRollupListener = nsnull;
nsIWidget * gRollupWidget = nsnull;
PRUint32 gLastModifierState = 0;
@interface ChildView(Private)
@ -6021,10 +6023,7 @@ static BOOL keyUpAlreadySentKeyDown = NO;
// CapsLock state and other modifier states are different:
// CapsLock state does not revert when the CapsLock key goes up, as the
// modifier state does for other modifier keys on key up. Also,
// mLastModifierState is set only when this view is the first responder. We
// cannot trust mLastModifierState to accurately reflect the state of CapsLock
// since CapsLock maybe have been toggled when another window was active.
// modifier state does for other modifier keys on key up.
if ([theEvent keyCode] == kCapsLockKeyCode) {
// Fire key down event for caps lock.
[self fireKeyEventForFlagsChanged:theEvent keyDown:YES];
@ -6043,7 +6042,7 @@ static BOOL keyUpAlreadySentKeyDown = NO;
for (PRUint32 i = 0; i < kModifierCount; i++) {
PRUint32 modifierBit = kModifierMaskTable[i];
if ((modifiers & modifierBit) != (mLastModifierState & modifierBit)) {
if ((modifiers & modifierBit) != (gLastModifierState & modifierBit)) {
BOOL isKeyDown = (modifiers & modifierBit) != 0 ? YES : NO;
[self fireKeyEventForFlagsChanged:theEvent keyDown:isKeyDown];
@ -6058,7 +6057,7 @@ static BOOL keyUpAlreadySentKeyDown = NO;
}
}
mLastModifierState = modifiers;
gLastModifierState = modifiers;
}
// check if the hand scroll cursor needs to be set/unset