X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f124c9086b8eda2cf3c9d219f931fb293a281ea6..fec9cc08e7d94574af3f04b4c5fbafde63ac0b31:/src/mac/carbon/toplevel.cpp diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index 7a58cf7506..0211fa1a4a 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -38,7 +38,6 @@ #include "wx/mac/uma.h" #include "wx/mac/aga.h" -#include "wx/app.h" #include "wx/tooltip.h" #include "wx/dnd.h" @@ -86,12 +85,14 @@ extern long wxMacTranslateKey(unsigned char key, unsigned char code) ; static const EventTypeSpec eventList[] = { // TODO: remove control related event like key and mouse (except for WindowLeave events) -#if 1 + { kEventClassKeyboard, kEventRawKeyDown } , { kEventClassKeyboard, kEventRawKeyRepeat } , { kEventClassKeyboard, kEventRawKeyUp } , { kEventClassKeyboard, kEventRawKeyModifiersChanged } , -#endif + + { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } , + { kEventClassTextInput, kEventTextInputUpdateActiveInputArea } , { kEventClassWindow , kEventWindowShown } , { kEventClassWindow , kEventWindowActivated } , @@ -120,7 +121,10 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event focus = (wxTopLevelWindowMac*) data ; unsigned char charCode ; - wxChar uniChar = 0 ; + wxChar uniChar[2] ; + uniChar[0] = 0; + uniChar[1] = 0; + UInt32 keyCode ; UInt32 modifiers ; Point point ; @@ -131,21 +135,23 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event if ( GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, 0 , &dataSize, NULL ) == noErr ) { UniChar buf[2] ; + int numChars = dataSize / sizeof( UniChar) + 1; UniChar* charBuf = buf ; - if ( dataSize > 4 ) - charBuf = new UniChar[ dataSize / sizeof( UniChar) ] ; + if ( numChars * 2 > 4 ) + charBuf = new UniChar[ numChars ] ; GetEventParameter( event, kEventParamKeyUnicodes, typeUnicodeText, NULL, dataSize , NULL , charBuf ) ; + charBuf[ numChars - 1 ] = 0; #if SIZEOF_WCHAR_T == 2 uniChar = charBuf[0] ; #else wxMBConvUTF16 converter ; - converter.MB2WC( &uniChar , (const char*)charBuf , 1 ) ; + converter.MB2WC( uniChar , (const char*)charBuf , 2 ) ; #endif - if ( dataSize > 4 ) + if ( numChars * 2 > 4 ) delete[] charBuf ; } #endif @@ -165,7 +171,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event WXEVENTHANDLERCALLREF formerHandler = wxTheApp->MacGetCurrentEventHandlerCallRef() ; wxTheApp->MacSetCurrentEvent( event , handler ) ; if ( /* focus && */ wxTheApp->MacSendKeyDownEvent( - focus , message , modifiers , when , point.h , point.v , uniChar ) ) + focus , message , modifiers , when , point.h , point.v , uniChar[0] ) ) { result = noErr ; } @@ -175,7 +181,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event case kEventRawKeyUp : if ( /* focus && */ wxTheApp->MacSendKeyUpEvent( - focus , message , modifiers , when , point.h , point.v , uniChar ) ) + focus , message , modifiers , when , point.h , point.v , uniChar[0] ) ) { result = noErr ; } @@ -193,7 +199,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event event.m_y = point.v; #if wxUSE_UNICODE - event.m_uniChar = uniChar ; + event.m_uniChar = uniChar[0] ; #endif event.SetTimestamp(when); @@ -446,7 +452,7 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev Point screenMouseLocation = cEvent.GetParameter(kEventParamMouseLocation) ; Point windowMouseLocation = screenMouseLocation ; - WindowRef window ; + WindowRef window = NULL; short windowPart = ::FindWindow(screenMouseLocation, &window); wxWindow* currentMouseWindow = NULL ; @@ -497,6 +503,10 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev #endif } } + + // disabled windows must not get any input messages + if ( currentMouseWindow && !currentMouseWindow->MacIsReallyEnabled() ) + currentMouseWindow = NULL; } } @@ -791,12 +801,19 @@ static pascal OSStatus wxMacTopLevelWindowEventHandler( EventHandlerCallRef hand return result ; } +// mix this in from window.cpp +pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) ; + pascal OSStatus wxMacTopLevelEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; switch ( GetEventClass( event ) ) { + case kEventClassTextInput : + result = wxMacUnicodeTextEventHandler( handler, event , data ) ; + break ; + case kEventClassKeyboard : result = KeyboardEventHandler( handler, event , data ) ; break ; @@ -977,7 +994,7 @@ void wxTopLevelWindowMac::Maximize(bool maximize) wxMacPortStateHelper help( (GrafPtr)GetWindowPort( (WindowRef)m_macWindow) ) ; wxMacWindowClipper clip( this ); #endif - +#if 0 if ( !IsWindowInStandardState( (WindowRef)m_macWindow, NULL, NULL ) ) { Rect rect; @@ -986,8 +1003,18 @@ void wxTopLevelWindowMac::Maximize(bool maximize) SetWindowIdealUserState((WindowRef)m_macWindow, &rect); SetWindowUserState((WindowRef)m_macWindow, &rect); } - ZoomWindow( (WindowRef)m_macWindow , maximize ? inZoomOut : inZoomIn , false ) ; +#else + Point idealSize = { 0 , 0 } ; + if ( maximize ) + { + Rect rect ; + GetAvailableWindowPositioningBounds(GetMainDevice(),&rect) ; + idealSize.h = rect.right - rect.left ; + idealSize.v = rect.bottom - rect.top ; + } + ZoomWindowIdeal( (WindowRef)m_macWindow , maximize ? inZoomOut : inZoomIn , &idealSize ) ; +#endif } bool wxTopLevelWindowMac::IsMaximized() const @@ -1206,7 +1233,9 @@ void wxTopLevelWindowMac::MacCreateRealWindow( // the root control level handler MacInstallEventHandler( (WXWidget) m_peer->GetControlRef() ) ; -#if TARGET_API_MAC_OSX + // Causes the inner part of the window not to be metal + // if the style is used before window creation. +#if 0 // TARGET_API_MAC_OSX if ( m_macUsesCompositing && m_macWindow != NULL ) { if ( GetExtraStyle() & wxFRAME_EX_METAL ) @@ -1401,11 +1430,11 @@ bool wxTopLevelWindowMac::IsFullScreen() const return m_macFullScreenData != NULL ; } -void wxTopLevelWindowMac::SetExtraStyle(long exStyle) +void wxTopLevelWindowMac::SetExtraStyle(long exStyle) { if ( GetExtraStyle() == exStyle ) return ; - + wxTopLevelWindowBase::SetExtraStyle( exStyle ) ; #if TARGET_API_MAC_OSX @@ -1418,8 +1447,8 @@ void wxTopLevelWindowMac::SetExtraStyle(long exStyle) #endif } +// TODO: switch to structure bounds - // we are still using coordinates of the content view -// TODO: switch to structure bounds // void wxTopLevelWindowMac::MacGetContentAreaInset( int &left , int &top , int &right , int &bottom ) { @@ -1769,4 +1798,3 @@ static pascal long wxShapedMacWindowDef(short varCode, WindowRef window, SInt16 return 0; } -