r=mkaply, a=brendan
OS/2 bring up - Make menus disappear when frame is clicked on
This commit is contained in:
mkaply%us.ibm.com 2000-06-22 14:00:16 +00:00
Родитель 5c79d2418c
Коммит 4e0a862f81
3 изменённых файлов: 56 добавлений и 6 удалений

Просмотреть файл

@ -29,14 +29,20 @@
* 03/23/2000 IBM Corp. Fix missing title bars on profile wizard windows.
* 04/11/2000 IBM Corp. Remove assertion.
* 05/10/2000 IBM Corp. Correct initial position of frame w/titlebar
* 06/21/2000 IBM Corp. Use rollup listener from nsWindow
*/
// Frame window - produced when NS_WINDOW_CID is required.
#include "nsFrameWindow.h"
#include "nsIRollupListener.h"
static PRBool haveHiddenWindow = PR_FALSE;
extern nsIRollupListener * gRollupListener;
extern nsIWidget * gRollupWidget;
extern PRBool gRollupConsumeRollupEvent;
nsFrameWindow::nsFrameWindow() : nsCanvas()
{
hwndFrame = 0;
@ -60,7 +66,7 @@ void nsFrameWindow::RealDoCreate( HWND hwndP, nsWindow *aParent,
/* NS_ASSERTION( hwndP == HWND_DESKTOP && aParent == nsnull,
"Attempt to create non-top-level frame"); */
#if DEBUG_sobotka
#if DEBUG
printf("\nIn nsFrameWindow::RealDoCreate:\n");
printf(" hwndP = %lu\n", hwndP);
printf(" aParent = 0x%lx\n", &aParent);
@ -199,6 +205,23 @@ nsresult nsFrameWindow::Show( PRBool bState)
// Subclass for frame window
MRESULT EXPENTRY fnwpFrame( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
// check to see if we have a rollup listener registered
if (nsnull != gRollupListener && nsnull != gRollupWidget) {
if (msg == WM_ACTIVATE || msg == WM_BUTTON1DOWN ||
msg == WM_BUTTON2DOWN || msg == WM_BUTTON3DOWN) {
// Rollup if the event is outside the popup
if (PR_FALSE == nsWindow::EventIsInsideWindow((nsWindow*)gRollupWidget)) {
gRollupListener->Rollup();
// if we are supposed to be consuming events and it is
// a Mouse Button down, let it go through
if (gRollupConsumeRollupEvent && msg != WM_BUTTON1DOWN) {
return FALSE;
}
}
}
}
nsFrameWindow *pFrame = (nsFrameWindow*) WinQueryWindowPtr( hwnd, QWL_USER);
return pFrame->FrameMessage( msg, mp1, mp2);
}

Просмотреть файл

@ -34,6 +34,7 @@
* 06/09/2000 IBM Corp. Added cases for more cursors in SetCursor.
* 06/14/2000 IBM Corp. Removed dead menu code to fix build break.
* 06/15/2000 IBM Corp. Created NS2PM for rectangles.
* 06/21/2000 IBM Corp. Corrected menu parentage; added CaptureMouse.
*
*/
@ -102,9 +103,9 @@ BOOL g_bHandlingMouseClick = FALSE;
nsWindow* nsWindow::gCurrentWindow = nsnull;
static nsIRollupListener * gRollupListener = nsnull;
static nsIWidget * gRollupWidget = nsnull;
static PRBool gRollupConsumeRollupEvent = PR_FALSE;
nsIRollupListener * gRollupListener = nsnull;
nsIWidget * gRollupWidget = nsnull;
PRBool gRollupConsumeRollupEvent = PR_FALSE;
// --------------------------------------------------------------------------
// HWND -> (nsWindow *) conversion ------------------------------------------
@ -199,6 +200,13 @@ void nsWindow::DoCreate( HWND hwndP, nsWindow *aParent, const nsRect &aRect,
{
mWindowState = nsWindowState_eInCreate;
if( hwndP != HWND_DESKTOP && aInitData &&
( aInitData->mWindowType == eWindowType_dialog ||
aInitData->mWindowType == eWindowType_popup ||
aInitData->mWindowType == eWindowType_toplevel) ) {
hwndP = HWND_DESKTOP;
}
// Must ensure toolkit before attempting to thread-switch!
if( !mToolkit)
{
@ -462,6 +470,18 @@ nsWindow::EventIsInsideWindow(nsWindow* aWindow)
return PR_TRUE;
}
NS_METHOD nsWindow::CaptureMouse(PRBool aCapture)
{
if (PR_TRUE == aCapture) {
WinSetCapture( HWND_DESKTOP, mWnd);
} else {
WinSetCapture( HWND_DESKTOP, NULLHANDLE);
}
// mIsInMouseCapture = aCapture;
return NS_OK;
}
// --------------------------------------------------------------------------
// PM messaging layer - wndproc, subclasser, default handler ----------------
@ -482,13 +502,12 @@ MRESULT EXPENTRY fnwpNSWindow( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
msg == WM_BUTTON2DOWN || msg == WM_BUTTON3DOWN) {
// Rollup if the event is outside the popup
if (PR_FALSE == nsWindow::EventIsInsideWindow((nsWindow*)gRollupWidget)) {
/* OS2TODO - This is causing the menu bar dropdowns to disappear too quickly */
gRollupListener->Rollup();
// if we are supposed to be consuming events and it is
// a Mouse Button down, let it go through
if (gRollupConsumeRollupEvent && msg != WM_BUTTON1DOWN) {
// return FALSE;
return FALSE;
}
}
}
@ -1201,6 +1220,7 @@ PRBool nsWindow::OnReposition( PSWP pSwp)
{
// need screen coords.
POINTL ptl = { pSwp->x, pSwp->y + pSwp->cy - 1 };
WinMapWindowPoints( WinQueryWindow( mWnd, QW_PARENT), GetParentHWND(), &ptl, 1);
PM2NS_PARENT( ptl);
mBounds.x = ptl.x;
mBounds.y = ptl.y;
@ -1544,6 +1564,10 @@ nsresult nsWindow::Resize( PRInt32 aX, PRInt32 aY, PRInt32 w, PRInt32 h,
NS2PM_PARENT( ptl);
// work out real coords of bottom left
ptl.y -= GetHeight( h) - 1;
if( mParent)
{
WinMapWindowPoints( mParent->mWnd, WinQueryWindow(mWnd, QW_PARENT), &ptl, 1);
}
if( !SetWindowPos( 0, ptl.x, ptl.y, w, GetHeight(h), SWP_MOVE | SWP_SIZE))
if( aRepaint)

Просмотреть файл

@ -28,6 +28,8 @@
* 03/23/2000 IBM Corp. Added InvalidateRegion method.
* 04/12/2000 IBM Corp. Changed params on DispatchMouseEvent to match Windows..
* 04/14/2000 IBM Corp. Declared EventIsInsideWindow for CaptureRollupEvents
* 06/15/2000 IBM Corp. Added NS2PM for rectangles
* 06/21/2000 IBM Corp. Added CaptureMouse
*
*/
@ -100,6 +102,7 @@ class nsWindow : public nsBaseWidget,
NS_IMETHOD Enable( PRBool bState);
NS_IMETHOD SetFocus();
NS_IMETHOD IsVisible( PRBool &aState);
NS_IMETHOD CaptureMouse(PRBool aCapture);
NS_IMETHOD ModalEventFilter( PRBool aRealEvent, void *aEvent,
PRBool *aForWindow );