X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3a9dc0619f7873947269dc29bd7410f4f80d4f34..da2101204027855793c4264388b95a208967ae15:/src/mac/carbon/toplevel.cpp diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index e97fc6b17a..afeecbafc4 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -252,6 +252,8 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event wxWindow* g_MacLastWindow = NULL ; +static EventMouseButton lastButton = 0 ; + static void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent ) { UInt32 modifiers = cEvent.GetParameter(kEventParamKeyModifiers, typeUInt32) ; @@ -275,6 +277,14 @@ static void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent ) { button = kEventMouseButtonSecondary ; } + + // we must make sure that our synthetic 'right' button corresponds in + // mouse down, moved and mouse up, and does not deliver a right down and left up + + if ( cEvent.GetKind() == kEventMouseDown ) + lastButton = button ; + else if ( lastButton ) + button = lastButton ; // determinate the correct down state, wx does not want a 'down' for a mouseUp event, while mac delivers // this button @@ -328,6 +338,8 @@ static void SetupMouseEvent( wxMouseEvent &wxevent , wxMacCarbonEvent &cEvent ) else wxevent.SetEventType(wxEVT_MOTION ) ; } + if ( cEvent.GetKind() == kEventMouseUp ) + lastButton = 0 ; } ControlRef wxMacFindSubControl( Point location , ControlRef superControl , ControlPartCode *outPart ) @@ -627,9 +639,9 @@ static pascal OSStatus wxMacTopLevelWindowEventHandler( EventHandlerCallRef hand adjustR.SetWidth( toplevelWindow->GetMinWidth() ) ; if ( toplevelWindow->GetMinHeight() != -1 && adjustR.GetHeight() < toplevelWindow->GetMinHeight() ) adjustR.SetHeight( toplevelWindow->GetMinHeight() ) ; - Rect adjustedRect = { adjustR.y + top , adjustR.x + left , adjustR.y + adjustR.height - bottom , adjustR.x + adjustR.width - right } ; + const Rect adjustedRect = { adjustR.y + top , adjustR.x + left , adjustR.y + adjustR.height - bottom , adjustR.x + adjustR.width - right } ; if ( !EqualRect( &newRect , &adjustedRect ) ) - cEvent.SetParameter( kEventParamCurrentBounds , &adjustedRect ) ; + cEvent.SetParameter( kEventParamCurrentBounds , &adjustedRect ) ; } result = noErr ; @@ -972,13 +984,19 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, wxAssociateWinWithMacWindow( (WindowRef) m_macWindow , this ) ; UMASetWTitle( (WindowRef) m_macWindow , title , m_font.GetEncoding() ) ; + m_peer = new wxMacControl() ; #if TARGET_API_MAC_OSX // There is a bug in 10.2.X for ::GetRootControl returning the window view instead of // the content view, so we have to retrieve it explicitely HIViewFindByID( HIViewGetRoot( (WindowRef) m_macWindow ) , kHIViewWindowContentID , - (ControlRef*)&m_macControl ) ; + *m_peer ) ; + if ( !m_peer->Ok() ) + { + // compatibility mode fallback + GetRootControl( (WindowRef) m_macWindow , *m_peer ) ; + } #else - ::CreateRootControl( (WindowRef)m_macWindow , (ControlRef*)&m_macControl ) ; + ::CreateRootControl( (WindowRef)m_macWindow , *m_peer ) ; #endif // the root control level handleer MacInstallEventHandler() ;