From df3cd329a5d82fbce5da4efd45e7936d930cc47f Mon Sep 17 00:00:00 2001 From: "joshmoz@gmail.com" Date: Tue, 4 Mar 2008 09:58:52 -0800 Subject: [PATCH] take key modifiers from the current event not the current hardware state. b=320746 r=smichaud sr=roc --- layout/generic/nsObjectFrame.cpp | 2 +- toolkit/xre/nsAppRunner.cpp | 2 +- widget/src/cocoa/nsChildView.mm | 14 +++++++------- xpfe/components/startup/src/Makefile.in | 2 +- .../startup/src/nsCommandLineServiceMac.cpp | 11 +++-------- 5 files changed, 13 insertions(+), 18 deletions(-) diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index e206865b25b..fa6c6e2e685 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -2885,7 +2885,7 @@ static void InitializeEventRecord(EventRecord* event) memset(event, 0, sizeof(EventRecord)); ::GetGlobalMouse(&event->where); event->when = ::TickCount(); - event->modifiers = ::GetCurrentKeyModifiers(); + event->modifiers = ::GetCurrentEventKeyModifiers(); } NPDrawingModel nsPluginInstanceOwner::GetDrawingModel() diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 929f22968af..9a81f64d945 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -2687,7 +2687,7 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData) } #ifdef XP_MACOSX - if (GetCurrentKeyModifiers() & optionKey) + if (GetCurrentEventKeyModifiers() & optionKey) gSafeMode = PR_TRUE; #endif diff --git a/widget/src/cocoa/nsChildView.mm b/widget/src/cocoa/nsChildView.mm index 1dbbd603b55..4f237d1fd10 100644 --- a/widget/src/cocoa/nsChildView.mm +++ b/widget/src/cocoa/nsChildView.mm @@ -1886,7 +1886,7 @@ NS_IMETHODIMP nsChildView::GetToggledKeyState(PRUint32 aKeyCode, default: return NS_ERROR_NOT_IMPLEMENTED; } - PRUint32 modifierFlags = ::GetCurrentKeyModifiers(); + PRUint32 modifierFlags = ::GetCurrentEventKeyModifiers(); *aLEDState = (modifierFlags & key) != 0; return NS_OK; @@ -2834,7 +2834,7 @@ NSEvent* gLastDragEvent = nil; macEvent.message = 0; macEvent.when = ::TickCount(); ::GetGlobalMouse(&macEvent.where); - macEvent.modifiers = GetCurrentKeyModifiers(); + macEvent.modifiers = ::GetCurrentEventKeyModifiers(); geckoEvent.nativeMsg = &macEvent; mGeckoChild->DispatchMouseEvent(geckoEvent); @@ -2870,7 +2870,7 @@ NSEvent* gLastDragEvent = nil; macEvent.message = 0; macEvent.when = ::TickCount(); ::GetGlobalMouse(&macEvent.where); - macEvent.modifiers = GetCurrentKeyModifiers(); + macEvent.modifiers = ::GetCurrentEventKeyModifiers(); geckoEvent.nativeMsg = &macEvent; mGeckoChild->DispatchMouseEvent(geckoEvent); @@ -2900,7 +2900,7 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted, macEvent.message = 0; macEvent.when = ::TickCount(); ::GetGlobalMouse(&macEvent.where); - macEvent.modifiers = ::GetCurrentKeyModifiers(); + macEvent.modifiers = ::GetCurrentEventKeyModifiers(); event.nativeMsg = &macEvent; nsEventStatus status; @@ -3021,7 +3021,7 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted, macEvent.message = 0; macEvent.when = ::TickCount(); ::GetGlobalMouse(&macEvent.where); - macEvent.modifiers = GetCurrentKeyModifiers(); + macEvent.modifiers = ::GetCurrentEventKeyModifiers(); geckoEvent.nativeMsg = &macEvent; mGeckoChild->DispatchMouseEvent(geckoEvent); @@ -3058,7 +3058,7 @@ static nsEventStatus SendGeckoMouseEnterOrExitEvent(PRBool isTrusted, macEvent.message = 0; macEvent.when = ::TickCount(); ::GetGlobalMouse(&macEvent.where); - macEvent.modifiers = btnState | ::GetCurrentKeyModifiers(); + macEvent.modifiers = btnState | ::GetCurrentEventKeyModifiers(); geckoEvent.nativeMsg = &macEvent; mGeckoChild->DispatchMouseEvent(geckoEvent); @@ -3467,7 +3467,7 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac macEvent.message = (charCode & 0x00FF) | ([cocoaEvent keyCode] << 8); macEvent.when = ::TickCount(); ::GetGlobalMouse(&macEvent.where); - macEvent.modifiers = ::GetCurrentKeyModifiers(); + macEvent.modifiers = ::GetCurrentEventKeyModifiers(); NS_OBJC_END_TRY_ABORT_BLOCK; } diff --git a/xpfe/components/startup/src/Makefile.in b/xpfe/components/startup/src/Makefile.in index 7ebaf931652..3b3b6cbb2e5 100644 --- a/xpfe/components/startup/src/Makefile.in +++ b/xpfe/components/startup/src/Makefile.in @@ -74,7 +74,7 @@ else ifeq (WINNT,$(OS_ARCH)) CPPSRCS += nsUserInfoWin.cpp else -ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) +ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) CPPSRCS += \ nsUserInfoMac.cpp \ nsCommandLineServiceMac.cpp \ diff --git a/xpfe/components/startup/src/nsCommandLineServiceMac.cpp b/xpfe/components/startup/src/nsCommandLineServiceMac.cpp index 042e10dd732..809cddcecd4 100644 --- a/xpfe/components/startup/src/nsCommandLineServiceMac.cpp +++ b/xpfe/components/startup/src/nsCommandLineServiceMac.cpp @@ -138,16 +138,11 @@ nsresult nsMacCommandLine::Initialize(int& argc, char**& argv) mArgs[0] = nsnull; mArgsAllocated = kArgsGrowSize; mArgsUsed = 0; - -#if defined(XP_MACOSX) + // Here, we may actually get useful args. // Copy them first to mArgv. for (int arg = 0; arg < argc; arg++) AddToCommandLine(argv[arg]); -#else - // init the args buffer with the program name - AddToCommandLine("mozilla"); -#endif // Set up AppleEvent handling. OSErr err = CreateAEHandlerClasses(false); @@ -175,8 +170,8 @@ nsresult nsMacCommandLine::Initialize(int& argc, char**& argv) err = ::AEProcessAppleEvent(&anEvent); } } - - if (GetCurrentKeyModifiers() & optionKey) + + if (::GetCurrentEventKeyModifiers() & optionKey) AddToCommandLine("-p"); // we've started up now