]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/app.cpp
Fixed Unicode breakage I caused
[wxWidgets.git] / src / mac / app.cpp
index ac9d45b2c808b3094b6d904a9c1c831aaa74e497..cd7e8d2423f29c1a3192e22f2232fe552b0fa93c 100644 (file)
@@ -690,19 +690,16 @@ int WXDLLEXPORT wxEntryStart( int argc, char *argv[] )
     return wxApp::Initialize();
 }
 
-
 int WXDLLEXPORT wxEntryInitGui()
 {
     return wxTheApp->OnInitGui();
 }
 
-
 void WXDLLEXPORT wxEntryCleanup()
 {
     wxApp::CleanUp();
 }
 
-
 int wxEntry( int argc, char *argv[] , bool enterLoop )
 {
     gCurrentResource = CurResFile() ;
@@ -734,7 +731,22 @@ int wxEntry( int argc, char *argv[] , bool enterLoop )
 
     wxCHECK_MSG( wxTheApp, 0, wxT("You have to define an instance of wxApp!") );
 
-#ifndef __DARWIN__
+#ifdef __DARWIN__
+    // Mac OS X passes a process serial number command line argument when
+    // the application is launched from the Finder. This argument must be
+    // removed from the command line arguments before being handled by the
+    // application (otherwise applications would need to handle it)
+
+    if (argc > 1) {
+        char buf[6] = "";
+        strncpy(buf, argv[1], 5);
+        
+        if (strcmp(buf, "-psn_") == 0) {
+            // assume the argument is always the only one and remove it
+            --argc;
+        }
+    }    
+#else
     argc = 0 ; // currently we don't support files as parameters
 #endif
     // we could try to get the open apple events here to adjust argc and argv better
@@ -745,7 +757,6 @@ int wxEntry( int argc, char *argv[] , bool enterLoop )
     // GUI-specific initialization, such as creating an app context.
     wxEntryInitGui();
 
-
     // Here frames insert themselves automatically
     // into wxTopLevelWindows by getting created
     // in OnInit().
@@ -1753,6 +1764,7 @@ void wxApp::MacHandleOSEvent( WXEVENTREF evr )
                         wxMouseEvent eventleave(event);
                         eventleave.SetEventType( wxEVT_LEAVE_WINDOW );
                         wxWindow::s_lastMouseWindow->ScreenToClient( &eventleave.m_x, &eventleave.m_y );
+                        eventleave.SetEventObject( wxWindow::s_lastMouseWindow ) ;
                         
                         wxWindow::s_lastMouseWindow->GetEventHandler()->ProcessEvent(eventleave);
                     }
@@ -1761,7 +1773,7 @@ void wxApp::MacHandleOSEvent( WXEVENTREF evr )
                         wxMouseEvent evententer(event);
                         evententer.SetEventType( wxEVT_ENTER_WINDOW );
                         currentMouseWindow->ScreenToClient( &evententer.m_x, &evententer.m_y );
-                        
+                        evententer.SetEventObject( currentMouseWindow ) ;
                         currentMouseWindow->GetEventHandler()->ProcessEvent(evententer);
                     }
                     wxWindow::s_lastMouseWindow = currentMouseWindow ;