X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/333a0af9f9fb7822e4dba0796fe4a6cf550f7050..7d9bf1f11cc6c2067af6285682f096d98e523540:/src/mac/carbon/app.cpp diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index f1c05f9aec..082a1c35ed 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -59,6 +59,8 @@ # if defined(WXMAKINGDLL_CORE) # include # endif +// include hid keyboard +# include "wx/mac/carbon/private/hid.h" #else # include # include @@ -119,6 +121,10 @@ long wxApp::s_macPreferencesMenuItemId = wxID_PREFERENCES ; long wxApp::s_macExitMenuItemId = wxID_EXIT ; wxString wxApp::s_macHelpMenuTitleName = wxT("&Help") ; +#ifdef __DARWIN__ + wxHIDKeyboard* wxApp::s_macHIDKeyboard = NULL; +#endif + // Normally we're not a plugin bool wxApp::sm_isEmbedded = false; //---------------------------------------------------------------------- @@ -402,7 +408,7 @@ wxMacAppMenuEventHandler( EventHandlerCallRef handler , EventRef event , void *d if ( type ) { - wxMenuEvent wxevent(type, cmd); + wxMenuEvent wxevent(type, cmd, menu); wxevent.SetEventObject(menu); wxEvtHandler* handler = menu->GetEventHandler(); @@ -520,7 +526,17 @@ pascal OSStatus wxMacAppEventHandler( EventHandlerCallRef handler , EventRef eve result = wxMacAppMenuEventHandler( handler , event , data ) ; break ; case kEventClassMouse : - result = wxMacTopLevelMouseEventHandler( handler , event , NULL ) ; + { + wxMacCarbonEvent cEvent( event ) ; + + WindowRef window ; + Point screenMouseLocation = cEvent.GetParameter(kEventParamMouseLocation) ; + ::FindWindow(screenMouseLocation, &window); + // only send this event in case it had not already been sent to a tlw, as we get + // double events otherwise (in case event.skip) was called + if ( window == NULL ) + result = wxMacTopLevelMouseEventHandler( handler , event , NULL ) ; + } break ; case kEventClassAppleEvent : { @@ -545,6 +561,8 @@ DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacAppEventHandler ) WXIMPORT char std::__throws_bad_alloc ; #endif +#if __WXDEBUG__ + pascal static void wxMacAssertOutputHandler(OSType componentSignature, UInt32 options, const char *assertionString, const char *exceptionLabelString, const char *errorString, const char *fileName, long lineNumber, void *value, ConstStr255Param outputMsg) @@ -581,6 +599,8 @@ pascal static void wxMacAssertOutputHandler(OSType componentSignature, UInt32 op #endif } +#endif //__WXDEBUG__ + bool wxApp::Initialize(int& argc, wxChar **argv) { // Mac-specific @@ -703,6 +723,10 @@ void wxApp::CleanUp() ProfilerDump( (StringPtr)"\papp.prof" ) ; ProfilerTerm() ; # endif + + // clean up HID Keyboard + if (s_macHIDKeyboard) + delete s_macHIDKeyboard; #endif UMACleanupToolbox() ; @@ -1155,11 +1179,16 @@ int wxMacKeyCodeToModifier(wxKeyCode key) bool wxGetKeyState(wxKeyCode key) //virtual key code if < 10.2.x, else see below { -//#ifdef __DARWIN__ -// wxHIDKeyboard keyboard; -// return keyboard.IsActive(key); -//#else -// TODO: Have it use HID Manager on OSX... +#ifdef __DARWIN__ + // Startup HID keyboard for getting key codes on DARWIN + if (!wxApp::s_macHIDKeyboard) + { + wxApp::s_macHIDKeyboard = new wxHIDKeyboard(); + wxApp::s_macHIDKeyboard->Create(); + } + + return wxApp::s_macHIDKeyboard->IsActive(key); +#else //if OS X > 10.2 (i.e. 10.2.x) //a known apple bug prevents the system from determining led //states with GetKeys... can only determine caps lock led @@ -1168,7 +1197,7 @@ bool wxGetKeyState(wxKeyCode key) //virtual key code if < 10.2.x, else see below // KeyMapByteArray keymap; // GetKeys((BigEndianLong*)keymap); // return !!(BitTst(keymap, (sizeof(KeyMapByteArray)*8) - iKey)); -//#endif +#endif }