From 200c9b103f3f54b9f3fa2316cb13655f62edd591 Mon Sep 17 00:00:00 2001 From: "danm%netscape.com" Date: Sat, 27 Mar 1999 00:39:33 +0000 Subject: [PATCH] add modal behaviour to modal dialogs git-svn-id: svn://10.0.0.236/trunk@25278 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/mac/nsAppShell.cpp | 67 ++++++++++++++++++++------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/mozilla/widget/src/mac/nsAppShell.cpp b/mozilla/widget/src/mac/nsAppShell.cpp index baf07346767..cedb66071fc 100644 --- a/mozilla/widget/src/mac/nsAppShell.cpp +++ b/mozilla/widget/src/mac/nsAppShell.cpp @@ -217,36 +217,67 @@ nsAppShell::GetNativeEvent(PRBool &aRealEvent, void *&aEvent) // //------------------------------------------------------------------------- NS_METHOD -nsAppShell::EventIsForModalWindow(PRBool aRealEvent, void *aEvent, nsIWidget *aWidget, +nsAppShell::EventIsForModalWindow(PRBool aRealEvent, void *aEvent, +nsIWidget *aWidget, PRBool *aForWindow) { - *aForWindow = PR_TRUE; - return NS_OK; - *aForWindow = PR_FALSE; EventRecord *theEvent = (EventRecord *) aEvent; - if (aRealEvent == PR_TRUE) { + if ( aRealEvent == PR_TRUE && theEvent->what != nullEvent ) { - // is it in the given window? WindowPtr window = (WindowPtr) aWidget->GetNativeData(NS_NATIVE_DISPLAY); - if (window && window == (WindowPtr) theEvent->message) - *aForWindow = PR_TRUE; + WindowPtr eventWindow = nsnull; + PRInt16 where = ::FindWindow ( theEvent->where, &eventWindow ); - // is it a mouse event? - if (theEvent->what == mouseDown || theEvent->what == mouseUp) - { } - else if (theEvent->what == osEvt) { - unsigned char eventType = (theEvent->message >> 24) & 0x00ff; - if (eventType == mouseMovedMessage) - {} - } -printf("event %d msg %ld win %d\n", theEvent->what, theEvent->message, *aForWindow); + switch ( theEvent->what ) { + // is it a mouse event? + case mouseDown: + case mouseUp: + // is it in the given window? + // (note we also let some events questionable for modal dialogs pass through. + // but it makes sense that the draggability et.al. of a modal window should + // be controlled by whether the window has a drag bar). + if ( window == eventWindow && + ( where == inContent || where == inDrag || where == inGrow || + where == inGoAway || where == inZoomIn || where == inZoomOut )) + *aForWindow = PR_TRUE; + break; + + case updateEvt: + // always let update events through, because if we don't handle them, we're + // doomed! + *aForWindow = PR_TRUE; + break; + + case activateEvt: + // certainly we have to let the obvious activate events through. hopefully + // our consumption of other events will keep any unwanted activate events + // from even getting this far + *aForWindow = PR_TRUE; + break; + + case osEvt: + // check for mouseMoved or suspend/resume events. We especially need to + // let suspend/resume events through in order to make sure the clipboard is + // converted correctly. + unsigned char eventType = (theEvent->message >> 24) & 0x00ff; + if (eventType == mouseMovedMessage) { + // I'm guessing we don't want to let these through unless the mouse is + // in the modal dialog so we don't see rollover feedback in windows behind + // the dialog. + if ( where == inContent && window == eventWindow ) + *aForWindow = PR_TRUE; + } + if ( eventType == suspendResumeMessage ) + *aForWindow = PR_TRUE; + break; + } // case of which event type } else *aForWindow = PR_TRUE; return NS_OK; -} +} // EventIsForModalWindow NS_METHOD nsAppShell::DispatchNativeEvent(PRBool aRealEvent, void *aEvent)