r=mkaply, sr=blizzard
OS/2 only - Print Preview cleanup
This commit is contained in:
mkaply%us.ibm.com 2002-05-31 18:48:25 +00:00
Родитель 61b0446ca9
Коммит cfb78070c6
4 изменённых файлов: 105 добавлений и 75 удалений

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

@ -41,9 +41,6 @@ extern nsIRollupListener * gRollupListener;
extern nsIWidget * gRollupWidget;
extern PRBool gRollupConsumeRollupEvent;
extern PRBool gJustGotDeactivate;
extern HWND gHwndBeingDestroyed;
BOOL nsFrameWindow::fHiddenWindowCreated = FALSE;
nsFrameWindow::nsFrameWindow() : nsWindow()
@ -393,22 +390,6 @@ MRESULT nsFrameWindow::FrameMessage( ULONG msg, MPARAM mp1, MPARAM mp2)
WinRemoveProperty(mFrameWnd, "hwndMinMax");
WinRemoveProperty(mFrameWnd, "ulStyle");
break;
case WM_ACTIVATE:
if( !mp1)
{
/* we don't want to go through all of this deactivation stuff if
* the window is just going away anyhow. Causes problems to process
* the deactivation event if we've hit some destructors or done
* some destroy work. Especially w.r.t the focus controller
*/
if( (mFrameWnd != gHwndBeingDestroyed) ||
(!WinIsChild( mFrameWnd, gHwndBeingDestroyed )) )
{
gJustGotDeactivate = PR_TRUE;
}
}
break;
}
if( !bDone)

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

@ -43,7 +43,6 @@ class nsFrameWindow : public nsWindow
HWND GetMainWindow() const { return mFrameWnd; }
protected:
HWND mFrameWnd;
PFNWP fnwpDefFrame;
nsSize mSizeClient;
nsSize mSizeBorder;

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

@ -105,8 +105,7 @@ PRBool gRollupConsumeRollupEvent = PR_FALSE;
PRBool gJustGotActivate = PR_FALSE;
PRBool gJustGotDeactivate = PR_FALSE;
HWND gHwndBeingDestroyed = NULLHANDLE;
PRBool gIsDestroyingAny = PR_FALSE;
////////////////////////////////////////////////////
// Mouse Clicks - static variable defintions
@ -117,6 +116,10 @@ static LONG gLastMsgTime = 0;
static LONG gLastClickCount = 0;
////////////////////////////////////////////////////
#ifdef DEBUG_FOCUS
static int currentWindowIdentifier = 0;
#endif
//-------------------------------------------------------------------------
//
// nsWindow constructor
@ -126,6 +129,7 @@ nsWindow::nsWindow() : nsBaseWidget()
{
NS_INIT_REFCNT();
mWnd = 0;
mFrameWnd = 0;
mPrevWndProc = NULL;
mParent = 0;
mNextID = 1;
@ -148,8 +152,6 @@ nsWindow::nsWindow() : nsBaseWidget()
mBorderStyle = eBorderStyle_default;
mFont = nsnull;
mOS2Toolkit = nsnull;
mMenuBar = nsnull;
// mActiveMenu = nsnull;
mIsTopWidgetWindow = PR_FALSE;
}
@ -798,6 +800,16 @@ void nsWindow::RealDoCreate( HWND hwndP,
}
}
#ifdef DEBUG_FOCUS
mWindowIdentifier = currentWindowIdentifier;
currentWindowIdentifier++;
if (aInitData && (aInitData->mWindowType == eWindowType_toplevel)) {
printf("[%x] Create Frame Window (%d)\n", this, mWindowIdentifier);
} else {
printf("[%x] Create Window (%d)\n", this, mWindowIdentifier);
}
#endif
// Create a window: create hidden & then size to avoid swp_noadjust problems
// owner == parent except for 'borderless top-level' -- see nsCanvas.cpp
mWnd = WinCreateWindow( hwndP,
@ -961,9 +973,16 @@ NS_METHOD nsWindow::Destroy()
if( mWnd)
{
gHwndBeingDestroyed = (mHackDestroyWnd ? mHackDestroyWnd : mWnd);
WinDestroyWindow( gHwndBeingDestroyed);
gHwndBeingDestroyed = NULLHANDLE;
HWND hwndBeingDestroyed = mFrameWnd ? mFrameWnd : mWnd;
gIsDestroyingAny = PR_TRUE;
#ifdef DEBUG_FOCUS
printf("[%x] Destroy (%d)\n", this, mWindowIdentifier);
#endif
if (hwndBeingDestroyed == WinQueryFocus(HWND_DESKTOP)) {
WinSetFocus(HWND_DESKTOP, WinQueryWindow(hwndBeingDestroyed, QW_PARENT));
}
WinDestroyWindow(hwndBeingDestroyed);
gIsDestroyingAny = PR_FALSE;
}
}
return NS_OK;
@ -1350,8 +1369,10 @@ NS_METHOD nsWindow::SetFocus(PRBool aRaise)
mOS2Toolkit->CallMethod(&info);
}
else
if (mWnd &&
(!gHwndBeingDestroyed || !WinIsChild(mWnd, gHwndBeingDestroyed))) {
if (mWnd) {
#ifdef DEBUG_FOCUS
printf("[%x] SetFocus (%d)\n", this, mWindowIdentifier);
#endif
WinSetFocus( HWND_DESKTOP, mWnd);
}
return NS_OK;
@ -2093,6 +2114,7 @@ void nsWindow::ConstrainZLevel(HWND *aAfter) {
PRBool nsWindow::ProcessMessage( ULONG msg, MPARAM mp1, MPARAM mp2, MRESULT &rc)
{
PRBool result = PR_FALSE; // call the default window procedure
PRBool isMozWindowTakingFocus = PR_TRUE;
switch (msg) {
#if 0
@ -2294,48 +2316,75 @@ PRBool nsWindow::ProcessMessage( ULONG msg, MPARAM mp1, MPARAM mp2, MRESULT &rc)
result = OnScroll( msg, mp1, mp2);
break;
case WM_FOCUSCHANGED:
/* Make a test to see if we are in the process of closing, deleting
* or destroying this nsWindow. If we are, then we've already
* gotten rid of our nsDocShell->mScriptGlobal. To handle focus
* events when there is no mScriptGlobal is apparently a bad thing.
*/
if(!(mWindowState & nsWindowState_eClosing))
{
PRBool isMozWindowTakingFocus = PR_TRUE;
if( SHORT1FROMMP( mp2 ) || mWnd == WinQueryFocus(HWND_DESKTOP) )
{
result = DispatchFocus( NS_GOTFOCUS, isMozWindowTakingFocus );
// Only sending an Activate event when we get a WM_ACTIVATE message
// isn't good enough; need to do this every time we gain focus.
if( !gJustGotActivate )
{
gJustGotActivate = PR_TRUE;
if ( WinIsChild( mWnd, HWNDFROMMP(mp1)) && mNextID == 1)
result = DispatchFocus( NS_PLUGIN_ACTIVATE, isMozWindowTakingFocus );
else
result = DispatchFocus( NS_ACTIVATE, isMozWindowTakingFocus );
gJustGotActivate = PR_FALSE;
}
}
else
{
char className[19];
::WinQueryClassName((HWND)mp1, 19, className);
if (strcmp(className, WindowClass()) != 0 &&
strcmp(className, WC_SCROLLBAR_STRING) != 0)
isMozWindowTakingFocus = PR_FALSE;
if( gJustGotDeactivate )
{
gJustGotDeactivate = PR_FALSE;
result = DispatchFocus( NS_DEACTIVATE, isMozWindowTakingFocus );
}
result = DispatchFocus( NS_LOSTFOCUS, isMozWindowTakingFocus );
}
case WM_ACTIVATE:
#ifdef DEBUG_FOCUS
printf("[%x] WM_ACTIVATE (%d)\n", this, mWindowIdentifier);
#endif
if (mp1) {
/* The window is being activated */
gJustGotActivate = PR_TRUE;
#ifdef DEBUG_FOCUS
printf("[%x] NS_GOTFOCUS (%d)\n", this, mWindowIdentifier);
#endif
result = DispatchFocus(NS_GOTFOCUS, isMozWindowTakingFocus);
} else {
/* The window is being deactivated */
gJustGotDeactivate = PR_TRUE;
}
break;
case WM_FOCUSCHANGED:
#ifdef DEBUG_FOCUS
printf("[%x] WM_FOCUSCHANGED (%d)\n", this, mWindowIdentifier);
#endif
if (SHORT1FROMMP(mp2)) {
/* We are receiving focus */
if (!gIsDestroyingAny) {
#ifdef DEBUG_FOCUS
printf("[%x] NS_GOTFOCUS (%d)\n", this, mWindowIdentifier);
#endif
result = DispatchFocus(NS_GOTFOCUS, isMozWindowTakingFocus);
if (gJustGotActivate) {
gJustGotActivate = PR_FALSE;
#ifdef DEBUG_FOCUS
printf("[%x] NS_ACTIVATE (%d)\n", this, mWindowIdentifier);
#endif
result = DispatchFocus(NS_ACTIVATE, isMozWindowTakingFocus);
}
if ( WinIsChild( mWnd, HWNDFROMMP(mp1)) && mNextID == 1) {
#ifdef DEBUG_FOCUS
printf("[%x] NS_PLUGIN_ACTIVATE (%d)\n", this, mWindowIdentifier);
#endif
result = DispatchFocus(NS_PLUGIN_ACTIVATE, isMozWindowTakingFocus);
WinSetFocus(HWND_DESKTOP, mWnd);
}
} else {
nsToolkit *toolkit = NS_STATIC_CAST(nsToolkit *, mToolkit);
WinPostMsg(toolkit->GetDispatchWindow(), WM_FOCUSCHANGED, mp1, mp2);
}
} else {
/* We are losing focus */
char className[19];
::WinQueryClassName((HWND)mp1, 19, className);
if (strcmp(className, WindowClass()) != 0 &&
strcmp(className, WC_SCROLLBAR_STRING) != 0) {
isMozWindowTakingFocus = PR_FALSE;
}
if (gJustGotDeactivate) {
gJustGotDeactivate = PR_FALSE;
#ifdef DEBUG_FOCUS
printf("[%x] NS_DEACTIVATE (%d)\n", this, mWindowIdentifier);
#endif
result = DispatchFocus(NS_DEACTIVATE, isMozWindowTakingFocus);
}
#ifdef DEBUG_FOCUS
printf("[%x] NS_LOSTFOCUS (%d)\n", this, mWindowIdentifier);
#endif
result = DispatchFocus(NS_LOSTFOCUS, isMozWindowTakingFocus);
}
break;
case WM_WINDOWPOSCHANGED:
result = OnReposition( (PSWP) mp1);
break;
@ -2494,9 +2543,6 @@ void nsWindow::OnDestroy()
// kill font
delete mFont;
// release menubar
// NS_IF_RELEASE(mMenuBar);
// dispatching of the event may cause the reference count to drop to 0
// and result in this object being deleted. To avoid that, add a
// reference and then release it after dispatching the event.

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

@ -41,7 +41,7 @@
#include "nsToolkit.h"
#include "nsSwitchToUIThread.h"
class nsIMenuBar;
//#define DEBUG_FOCUS
// Base widget class.
// This is abstract. Controls (labels, radio buttons, listboxen) derive
@ -99,8 +99,6 @@ class nsWindow : public nsBaseWidget,
virtual nsIWidget *GetParent();
NS_IMETHOD SetSizeMode(PRInt32 aMode);
NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar) { return NS_ERROR_FAILURE; }
NS_IMETHOD ShowMenuBar(PRBool aShow) { return NS_ERROR_FAILURE; }
// Physical properties
NS_IMETHOD Show( PRBool bState);
@ -143,6 +141,8 @@ class nsWindow : public nsBaseWidget,
NS_IMETHOD SetCursor( nsCursor aCursor);
NS_IMETHOD HideWindowChrome(PRBool aShouldHide);
NS_IMETHOD SetTitle( const nsString& aTitle);
NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar) { return NS_ERROR_FAILURE; }
NS_IMETHOD ShowMenuBar(PRBool aShow) { return NS_ERROR_FAILURE; }
NS_IMETHOD Invalidate( PRBool aIsSynchronous);
NS_IMETHOD Invalidate( const nsRect & aRect, PRBool aIsSynchronous);
NS_IMETHOD InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous);
@ -229,6 +229,7 @@ protected:
// PM data members
HWND mWnd; // window handle
HWND mFrameWnd; // frame window handle
PFNWP mPrevWndProc; // previous window procedure
nsWindow *mParent; // parent widget
ULONG mNextID; // next child window id
@ -294,6 +295,9 @@ protected:
};
friend MRESULT EXPENTRY fnwpNSWindow( HWND, ULONG, MPARAM, MPARAM);
friend MRESULT EXPENTRY fnwpFrame( HWND, ULONG, MPARAM, MPARAM);
#ifdef DEBUG_FOCUS
int mWindowIdentifier;
#endif
};
#define PM2NS_PARENT NS2PM_PARENT