X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d6fd667bc19986e20f7ca33976061d57d89bc41c..da2101204027855793c4264388b95a208967ae15:/src/mac/carbon/toplevel.cpp diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index b30de0aa6d..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 ) @@ -509,7 +521,11 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev wxMacFindControlUnderMouse( windowMouseLocation , window , &dummyPart ) ) ) { EventModifiers modifiers = cEvent.GetParameter(kEventParamKeyModifiers, typeUInt32) ; - HandleControlClick( (ControlRef) currentMouseWindow->GetHandle() , windowMouseLocation , + Point clickLocation = windowMouseLocation ; +#if TARGET_API_MAC_OSX + currentMouseWindow->MacRootWindowToWindow( &clickLocation.h , &clickLocation.v ) ; +#endif + HandleControlClick( (ControlRef) currentMouseWindow->GetHandle() , clickLocation , modifiers , (ControlActionUPP ) -1 ) ; result = noErr ; } @@ -623,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 ; @@ -968,14 +984,20 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title, wxAssociateWinWithMacWindow( (WindowRef) m_macWindow , this ) ; UMASetWTitle( (WindowRef) m_macWindow , title , m_font.GetEncoding() ) ; - if ( m_macUsesCompositing ) - { - ::GetRootControl( (WindowRef)m_macWindow, (ControlRef*)&m_macControl ) ; - } - else + 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 , + *m_peer ) ; + if ( !m_peer->Ok() ) { - ::CreateRootControl( (WindowRef)m_macWindow , (ControlRef*)&m_macControl ) ; + // compatibility mode fallback + GetRootControl( (WindowRef) m_macWindow , *m_peer ) ; } +#else + ::CreateRootControl( (WindowRef)m_macWindow , *m_peer ) ; +#endif // the root control level handleer MacInstallEventHandler() ;