take key modifiers from the current event not the current hardware state. b=320746 r=smichaud sr=roc
authorjoshmoz@gmail.com
Tue, 04 Mar 2008 09:58:52 -0800
changeset 12558 7ad8a39a30ca10f574254a22dbe23d3ab7b86c85
parent 12557 9bb28315d94da298c96e772227c26128ec617d02
child 12559 c6b53feba7f8712fae0f2431f3f51502731aac47
push idunknown
push userunknown
push dateunknown
reviewerssmichaud, roc
bugs320746
milestone1.9b5pre
take key modifiers from the current event not the current hardware state. b=320746 r=smichaud sr=roc
layout/generic/nsObjectFrame.cpp
toolkit/xre/nsAppRunner.cpp
widget/src/cocoa/nsChildView.mm
xpfe/components/startup/src/Makefile.in
xpfe/components/startup/src/nsCommandLineServiceMac.cpp
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -2880,17 +2880,17 @@ nsresult nsPluginInstanceOwner::EnsureCa
 
 #ifdef XP_MACOSX
 
 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()
 {
 #ifndef NP_NO_QUICKDRAW
   NPDrawingModel drawingModel = NPDrawingModelQuickDraw;
 #else
   NPDrawingModel drawingModel = NPDrawingModelCoreGraphics;
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -2682,17 +2682,17 @@ XRE_main(int argc, char* argv[], const n
   if (ar == ARG_BAD) {
     PR_fprintf(PR_STDERR, "Error: argument -safe-mode is invalid when argument -osint is specified\n");
     return 1;
   } else if (ar == ARG_FOUND) {
     gSafeMode = PR_TRUE;
   }
 
 #ifdef XP_MACOSX
-  if (GetCurrentKeyModifiers() & optionKey)
+  if (GetCurrentEventKeyModifiers() & optionKey)
     gSafeMode = PR_TRUE;
 #endif
 
   // Handle -no-remote command line argument. Setup the environment to
   // better accommodate other components and various restart scenarios.
   ar = CheckArg("no-remote", PR_TRUE);
   if (ar == ARG_BAD) {
     PR_fprintf(PR_STDERR, "Error: argument -a requires an application name\n");
--- a/widget/src/cocoa/nsChildView.mm
+++ b/widget/src/cocoa/nsChildView.mm
@@ -1881,17 +1881,17 @@ NS_IMETHODIMP nsChildView::GetToggledKey
       break;
     case NS_VK_NUM_LOCK:
       key = kEventKeyModifierNumLockMask;
       break;
     // Mac doesn't support SCROLL_LOCK state.
     default:
       return NS_ERROR_NOT_IMPLEMENTED;
   }
-  PRUint32 modifierFlags = ::GetCurrentKeyModifiers();
+  PRUint32 modifierFlags = ::GetCurrentEventKeyModifiers();
   *aLEDState = (modifierFlags & key) != 0;
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 
 #pragma mark -
@@ -2829,17 +2829,17 @@ NSEvent* gLastDragEvent = nil;
     geckoEvent.button = nsMouseEvent::eLeftButton;
 
   // create native EventRecord for use by plugins
   EventRecord macEvent;
   macEvent.what = mouseDown;
   macEvent.message = 0;
   macEvent.when = ::TickCount();
   ::GetGlobalMouse(&macEvent.where);
-  macEvent.modifiers = GetCurrentKeyModifiers();
+  macEvent.modifiers = ::GetCurrentEventKeyModifiers();
   geckoEvent.nativeMsg = &macEvent;
 
   mGeckoChild->DispatchMouseEvent(geckoEvent);
 
   // XXX maybe call markedTextSelectionChanged:client: here?
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
@@ -2865,17 +2865,17 @@ NSEvent* gLastDragEvent = nil;
   [self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
 
   // create native EventRecord for use by plugins
   EventRecord macEvent;
   macEvent.what = mouseUp;
   macEvent.message = 0;
   macEvent.when = ::TickCount();
   ::GetGlobalMouse(&macEvent.where);
-  macEvent.modifiers = GetCurrentKeyModifiers();
+  macEvent.modifiers = ::GetCurrentEventKeyModifiers();
   geckoEvent.nativeMsg = &macEvent;
 
   mGeckoChild->DispatchMouseEvent(geckoEvent);
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 
@@ -2895,17 +2895,17 @@ static nsEventStatus SendGeckoMouseEnter
   event.refPoint.x = nscoord((PRInt32)localEventLocation->x);
   event.refPoint.y = nscoord((PRInt32)localEventLocation->y);
 
   EventRecord macEvent;
   macEvent.what = adjustCursorEvent;
   macEvent.message = 0;
   macEvent.when = ::TickCount();
   ::GetGlobalMouse(&macEvent.where);
-  macEvent.modifiers = ::GetCurrentKeyModifiers();
+  macEvent.modifiers = ::GetCurrentEventKeyModifiers();
   event.nativeMsg = &macEvent;
 
   nsEventStatus status;
   widget->DispatchEvent(&event, status);
   return status;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(nsEventStatus_eIgnore);
 }
@@ -3016,17 +3016,17 @@ static nsEventStatus SendGeckoMouseEnter
   [self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
 
   // create native EventRecord for use by plugins
   EventRecord macEvent;
   macEvent.what = adjustCursorEvent;
   macEvent.message = 0;
   macEvent.when = ::TickCount();
   ::GetGlobalMouse(&macEvent.where);
-  macEvent.modifiers = GetCurrentKeyModifiers();
+  macEvent.modifiers = ::GetCurrentEventKeyModifiers();
   geckoEvent.nativeMsg = &macEvent;
 
   mGeckoChild->DispatchMouseEvent(geckoEvent);
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 
@@ -3053,17 +3053,17 @@ static nsEventStatus SendGeckoMouseEnter
   [self convertCocoaMouseEvent:theEvent toGeckoEvent:&geckoEvent];
 
   // create native EventRecord for use by plugins
   EventRecord macEvent;
   macEvent.what = nullEvent;
   macEvent.message = 0;
   macEvent.when = ::TickCount();
   ::GetGlobalMouse(&macEvent.where);
-  macEvent.modifiers = btnState | ::GetCurrentKeyModifiers();
+  macEvent.modifiers = btnState | ::GetCurrentEventKeyModifiers();
   geckoEvent.nativeMsg = &macEvent;
 
   mGeckoChild->DispatchMouseEvent(geckoEvent);
 
   // Note, sending the above event might have destroyed our widget since we didn't retain.
   // Fine so long as we don't access any local variables from here on.
 
   gLastDragView = nil;
@@ -3462,17 +3462,17 @@ static void ConvertCocoaKeyEventToMacEve
               charCode = convertedCharCode;
             //NSLog(@"charcode is %d, converted to %c, char is %@", charCode, convertedCharCode, [cocoaEvent characters]);
             break;
         }
     }
     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;
 }
 
 // Key code constants
 enum
 {
   kEscapeKeyCode      = 0x35,
--- a/xpfe/components/startup/src/Makefile.in
+++ b/xpfe/components/startup/src/Makefile.in
@@ -69,17 +69,17 @@ CPPSRCS = \
 	$(NULL)
 
 ifeq (os2,$(MOZ_WIDGET_TOOLKIT))
 CPPSRCS += nsUserInfoOS2.cpp
 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 \
 	$(NULL)
 
 LOCAL_INCLUDES += -I$(srcdir)/../../../bootstrap/appleevents
 OS_CXXFLAGS += -fexceptions
 else
--- a/xpfe/components/startup/src/nsCommandLineServiceMac.cpp
+++ b/xpfe/components/startup/src/nsCommandLineServiceMac.cpp
@@ -133,26 +133,21 @@ nsresult nsMacCommandLine::Initialize(in
 //----------------------------------------------------------------------------------------
 {
   mArgs = static_cast<char **>(malloc(kArgsGrowSize * sizeof(char *)));
   if (!mArgs)
     return NS_ERROR_FAILURE;
   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);
   if (err != noErr) return NS_ERROR_FAILURE;
 
   // Snarf all the odoc and pdoc apple-events.
   //
   // 1. If they are odoc for 'CMDL' documents, read them into the buffer ready for
@@ -170,18 +165,18 @@ nsresult nsMacCommandLine::Initialize(in
     ::WaitNextEvent(highLevelEventMask, &anEvent, 0, nsnull);
     if (anEvent.what == kHighLevelEvent)
     {
       // here we process startup odoc/pdoc events, which can 
       // add items to the command line.
       err = ::AEProcessAppleEvent(&anEvent);
     }
   }
-  
-  if (GetCurrentKeyModifiers() & optionKey)
+
+  if (::GetCurrentEventKeyModifiers() & optionKey)
     AddToCommandLine("-p");
 
   // we've started up now
   mStartedUp = PR_TRUE;
   
   argc = mArgsUsed;
   argv = mArgs;