X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6d63e2fc1689eaf28387eff7e836f49ebb62da51..0bd3b8eca1d6ef2749797f34216493fce0edd8d6:/src/mac/carbon/toplevel.cpp?ds=sidebyside diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index 659e5ba78e..1fbb44d100 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -159,8 +159,9 @@ static pascal OSStatus TextInputEventHandler( EventHandlerCallRef handler , Even static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; - - wxWindow* focus = wxWindow::FindFocus() ; + // call DoFindFocus instead of FindFocus, because for Composite Windows(like WxGenericListCtrl) + // FindFocus does not return the actual focus window,but the enclosing window + wxWindow* focus = wxWindow::DoFindFocus(); if ( focus == NULL ) return result ; @@ -211,8 +212,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event event.m_x = point.h; event.m_y = point.v; - event.m_timeStamp = when; - wxWindow* focus = wxWindow::FindFocus() ; + event.SetTimestamp(when); event.SetEventObject(focus); if ( focus && (modifiers ^ wxTheApp->s_lastModifiers ) & controlKey ) @@ -505,6 +505,8 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev } // if ( windowPart == inMenuBar ) else if ( currentMouseWindow ) { + wxWindow *currentMouseWindowParent = currentMouseWindow->GetParent(); + currentMouseWindow->ScreenToClient( &wxevent.m_x , &wxevent.m_y ) ; wxevent.SetEventObject( currentMouseWindow ) ; @@ -518,7 +520,13 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev wxToolTip::RelayEvent( currentMouseWindow , wxevent); #endif // wxUSE_TOOLTIPS if ( currentMouseWindow->GetEventHandler()->ProcessEvent(wxevent) ) + { + if ((currentMouseWindowParent != NULL) && + (currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL)) + currentMouseWindow = NULL; + result = noErr; + } else { // if the user code did _not_ handle the event, then perform the @@ -547,6 +555,10 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev #endif HandleControlClick( (ControlRef) currentMouseWindow->GetHandle() , clickLocation , modifiers , (ControlActionUPP ) -1 ) ; + + if ((currentMouseWindowParent != NULL) && + (currentMouseWindowParent->GetChildren().Find(currentMouseWindow) == NULL)) + currentMouseWindow = NULL; } result = noErr ; } @@ -566,7 +578,7 @@ pascal OSStatus wxMacTopLevelMouseEventHandler( EventHandlerCallRef handler , Ev { cursorTarget = cursorTarget->GetParent() ; if ( cursorTarget ) - cursorPoint += cursorTarget->GetPosition() ; + cursorPoint += cursorTarget->GetPosition(); } } // else if ( currentMouseWindow ) @@ -1373,6 +1385,31 @@ wxUint32 wxTopLevelWindowMac::MacGetWindowAttributes() const return attr ; } +// Attracts the users attention to this window if the application is +// inactive (should be called when a background event occurs) + +static pascal void wxMacNMResponse( NMRecPtr ptr ) +{ + NMRemove( ptr ) ; + DisposePtr( (Ptr) ptr ) ; +} + + +void wxTopLevelWindowMac::RequestUserAttention(int flags ) +{ + NMRecPtr notificationRequest = (NMRecPtr) NewPtr( sizeof( NMRec) ) ; + static wxMacNMUPP nmupp( wxMacNMResponse ) + ; + memset( notificationRequest , 0 , sizeof(*notificationRequest) ) ; + notificationRequest->qType = nmType ; + notificationRequest->nmMark = 1 ; + notificationRequest->nmIcon = 0 ; + notificationRequest->nmSound = 0 ; + notificationRequest->nmStr = NULL ; + notificationRequest->nmResp = nmupp ; + verify_noerr( NMInstall( notificationRequest ) ) ; +} + // --------------------------------------------------------------------------- // Shape implementation // ---------------------------------------------------------------------------