Bug 586228 - Manage caption status for get window info calls made by the theme library. r=vlad, a=final.

This commit is contained in:
Jim Mathies 2010-11-11 20:39:05 -06:00
Родитель 05be39408b
Коммит 98801da9cb
3 изменённых файлов: 56 добавлений и 10 удалений

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

@ -176,6 +176,9 @@ protected:
} else if ((origBytes[nBytes] & 0xf0) == 0x50) {
// 1-byte PUSH/POP
nBytes++;
} else if (origBytes[nBytes] == 0x6A) {
// PUSH imm8
nBytes += 2;
} else {
//printf ("Unknown x86 instruction byte 0x%02x, aborting trampoline\n", origBytes[nBytes]);
return 0;

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

@ -158,6 +158,7 @@
#include "nsString.h"
#include "mozilla/Services.h"
#include "nsNativeThemeWin.h"
#include "nsWindowsDllInterceptor.h"
#if defined(WINCE)
#include "nsWindowCE.h"
@ -352,6 +353,9 @@ static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
#endif
// General purpose user32.dll hook object
static WindowsDllInterceptor sUser32Intercept;
/**************************************************************
**************************************************************
**
@ -1973,6 +1977,50 @@ nsWindow::ResetLayout()
Invalidate(PR_FALSE);
}
// Internally track the caption status via a window property. Required
// due to our internal handling of WM_NCACTIVATE when custom client
// margins are set.
static const PRUnichar kManageWindowInfoProperty[] = L"ManageWindowInfoProperty";
typedef BOOL (WINAPI *GetWindowInfoPtr)(HWND hwnd, PWINDOWINFO pwi);
static GetWindowInfoPtr sGetWindowInfoPtrStub = NULL;
BOOL WINAPI
GetWindowInfoHook(HWND hWnd, PWINDOWINFO pwi)
{
if (!sGetWindowInfoPtrStub) {
NS_ASSERTION(FALSE, "Something is horribly wrong in GetWindowInfoHook!");
return FALSE;
}
int windowStatus =
reinterpret_cast<int>(GetPropW(hWnd, kManageWindowInfoProperty));
// No property set, return the default data.
if (!windowStatus)
return sGetWindowInfoPtrStub(hWnd, pwi);
// Call GetWindowInfo and update dwWindowStatus with our
// internally tracked value.
BOOL result = sGetWindowInfoPtrStub(hWnd, pwi);
if (result && pwi)
pwi->dwWindowStatus = (windowStatus == 1 ? 0 : WS_ACTIVECAPTION);
return result;
}
void
nsWindow::UpdateGetWindowInfoCaptionStatus(PRBool aActiveCaption)
{
if (!mWnd)
return;
if (!sGetWindowInfoPtrStub) {
sUser32Intercept.Init("user32.dll");
if (!sUser32Intercept.AddHook("GetWindowInfo", GetWindowInfoHook,
(void**) &sGetWindowInfoPtrStub))
return;
}
// Update our internally tracked caption status
SetPropW(mWnd, kManageWindowInfoProperty,
reinterpret_cast<HANDLE>(static_cast<int>(aActiveCaption) + 1));
}
// Called when the window layout changes: full screen mode transitions,
// theme changes, and composition changes. Calculates the new non-client
// margins and fires off a frame changed event, which triggers an nc calc
@ -2075,6 +2123,7 @@ nsWindow::SetNonClientMargins(nsIntMargin &margins)
margins.right == -1 && margins.bottom == -1) {
mCustomNonClient = PR_FALSE;
mNonClientMargins = margins;
RemoveProp(mWnd, kManageWindowInfoProperty);
// Force a reflow of content based on the new client
// dimensions.
ResetLayout();
@ -4654,6 +4703,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
// going active
*aRetValue = FALSE; // ignored
result = PR_TRUE;
UpdateGetWindowInfoCaptionStatus(PR_TRUE);
// invalidate to trigger a paint
InvalidateNonClientRegion();
break;
@ -4661,6 +4711,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
// going inactive
*aRetValue = TRUE; // go ahead and deactive
result = PR_TRUE;
UpdateGetWindowInfoCaptionStatus(PR_FALSE);
// invalidate to trigger a paint
InvalidateNonClientRegion();
break;
@ -5043,20 +5094,10 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
nsMouseEvent event(PR_TRUE, NS_MOUSE_ACTIVATE, this,
nsMouseEvent::eReal);
InitEvent(event);
event.acceptActivation = PR_TRUE;
DispatchWindowEvent(&event);
#ifndef WINCE
if (event.acceptActivation)
*aRetValue = MA_ACTIVATE;
else
*aRetValue = MA_NOACTIVATE;
if (sSwitchKeyboardLayout && mLastKeyboardLayout)
ActivateKeyboardLayout(mLastKeyboardLayout, 0);
#else
*aRetValue = 0;
#endif
}
}
@ -5256,6 +5297,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
case WM_DWMCOMPOSITIONCHANGED:
UpdateNonClientMargins();
RemoveProp(mWnd, kManageWindowInfoProperty);
BroadcastMsg(mWnd, WM_DWMCOMPOSITIONCHANGED);
DispatchStandardEvent(NS_THEMECHANGED);
UpdateGlass();

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

@ -303,6 +303,7 @@ protected:
virtual void SubclassWindow(BOOL bState);
PRBool CanTakeFocus();
PRBool UpdateNonClientMargins(PRInt32 aSizeMode = -1, PRBool aReflowWindow = PR_TRUE);
void UpdateGetWindowInfoCaptionStatus(PRBool aActiveCaption);
void ResetLayout();
void InvalidateNonClientRegion();
HRGN ExcludeNonClientFromPaintRegion(HRGN aRegion);