mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 601603. Part 3 - Retrieve necessary system metrics to measure size and position of caption buttons. r=jmathies
This commit is contained in:
parent
0ccddd02da
commit
b0d4103811
@ -1917,6 +1917,19 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame*
|
||||
*aIsOverridable = PR_FALSE;
|
||||
return NS_OK;
|
||||
|
||||
case NS_THEME_WINDOW_BUTTON_BOX:
|
||||
case NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED:
|
||||
QueryForButtonData(aFrame);
|
||||
aResult->width = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cx;
|
||||
aResult->height = nsUXThemeData::sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cy
|
||||
- GetSystemMetrics(SM_CYFRAME);
|
||||
if (aWidgetType == NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED) {
|
||||
aResult->width += 1;
|
||||
aResult->height -= 2;
|
||||
}
|
||||
*aIsOverridable = PR_FALSE;
|
||||
return NS_OK;
|
||||
|
||||
case NS_THEME_WINDOW_FRAME_LEFT:
|
||||
case NS_THEME_WINDOW_FRAME_RIGHT:
|
||||
case NS_THEME_WINDOW_FRAME_BOTTOM:
|
||||
|
@ -72,7 +72,7 @@ PRPackedBool
|
||||
nsUXThemeData::sHaveCompositor = PR_FALSE;
|
||||
|
||||
PRBool nsUXThemeData::sTitlebarInfoPopulated = PR_FALSE;
|
||||
SIZE nsUXThemeData::sCommandButtons[3];
|
||||
SIZE nsUXThemeData::sCommandButtons[4];
|
||||
|
||||
nsUXThemeData::OpenThemeDataPtr nsUXThemeData::openTheme = NULL;
|
||||
nsUXThemeData::CloseThemeDataPtr nsUXThemeData::closeTheme = NULL;
|
||||
@ -265,6 +265,8 @@ nsUXThemeData::InitTitlebarInfo()
|
||||
sCommandButtons[0].cy = GetSystemMetrics(SM_CYSIZE);
|
||||
sCommandButtons[1].cx = sCommandButtons[2].cx = sCommandButtons[0].cx;
|
||||
sCommandButtons[1].cy = sCommandButtons[2].cy = sCommandButtons[0].cy;
|
||||
sCommandButtons[3].cx = sCommandButtons[0].cx * 3;
|
||||
sCommandButtons[3].cy = sCommandButtons[0].cy;
|
||||
|
||||
// Use system metrics for pre-vista
|
||||
if (nsWindow::GetWindowsVersion() < VISTA_VERSION)
|
||||
@ -278,9 +280,18 @@ nsUXThemeData::UpdateTitlebarInfo(HWND aWnd)
|
||||
if (sTitlebarInfoPopulated || !aWnd)
|
||||
return;
|
||||
|
||||
// Compositor enabled, we won't use these.
|
||||
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
||||
if (nsUXThemeData::CheckForCompositor()) {
|
||||
RECT captionButtons;
|
||||
if (FAILED(nsUXThemeData::dwmGetWindowAttributePtr(aWnd,
|
||||
DWMWA_CAPTION_BUTTON_BOUNDS,
|
||||
&captionButtons,
|
||||
sizeof(captionButtons)))) {
|
||||
NS_WARNING("DWMWA_CAPTION_BUTTON_BOUNDS query failed to find usable metrics.");
|
||||
return;
|
||||
}
|
||||
sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cx = captionButtons.right - captionButtons.left - 3;
|
||||
sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cy = (captionButtons.bottom - captionButtons.top) - 1;
|
||||
sTitlebarInfoPopulated = PR_TRUE;
|
||||
return;
|
||||
}
|
||||
|
@ -108,9 +108,10 @@ enum WindowsThemeColor {
|
||||
WINTHEMECOLOR_METALLIC = 3
|
||||
};
|
||||
|
||||
#define CMDBUTTONIDX_MINIMIZE 0
|
||||
#define CMDBUTTONIDX_RESTORE 1
|
||||
#define CMDBUTTONIDX_CLOSE 2
|
||||
#define CMDBUTTONIDX_MINIMIZE 0
|
||||
#define CMDBUTTONIDX_RESTORE 1
|
||||
#define CMDBUTTONIDX_CLOSE 2
|
||||
#define CMDBUTTONIDX_BUTTONBOX 3
|
||||
|
||||
class nsUXThemeData {
|
||||
static HMODULE sThemeDLL;
|
||||
@ -131,7 +132,7 @@ public:
|
||||
static PRPackedBool sIsVistaOrLater;
|
||||
static PRPackedBool sHaveCompositor;
|
||||
static PRBool sTitlebarInfoPopulated;
|
||||
static SIZE sCommandButtons[3];
|
||||
static SIZE sCommandButtons[4];
|
||||
static nsILookAndFeel::WindowsThemeIdentifier sThemeId;
|
||||
static PRBool sIsDefaultWindowsTheme;
|
||||
|
||||
|
@ -2457,7 +2457,8 @@ void nsWindow::UpdatePossiblyTransparentRegion(const nsIntRegion &aDirtyRegion,
|
||||
|
||||
// The minimum glass height must be the caption buttons height,
|
||||
// otherwise the buttons are drawn incorrectly.
|
||||
margins.cyTopHeight = PR_MAX(largest.y, mCaptionButtons.height);
|
||||
margins.cyTopHeight = PR_MAX(largest.y,
|
||||
nsUXThemeData::sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cy);
|
||||
}
|
||||
|
||||
// Only update glass area if there are changes
|
||||
@ -2504,65 +2505,6 @@ void nsWindow::UpdateGlass()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
||||
void nsWindow::UpdateCaptionButtonsClippingRect()
|
||||
{
|
||||
NS_ASSERTION(mWnd, "UpdateCaptionButtonsClippingRect called with invalid mWnd.");
|
||||
|
||||
RECT captionButtons;
|
||||
mCaptionButtonsRoundedRegion.SetEmpty();
|
||||
mCaptionButtons.Empty();
|
||||
|
||||
if (!mCustomNonClient ||
|
||||
mSizeMode == nsSizeMode_Fullscreen ||
|
||||
mSizeMode == nsSizeMode_Minimized ||
|
||||
!nsUXThemeData::CheckForCompositor() ||
|
||||
FAILED(nsUXThemeData::dwmGetWindowAttributePtr(mWnd,
|
||||
DWMWA_CAPTION_BUTTON_BOUNDS,
|
||||
&captionButtons,
|
||||
sizeof(captionButtons)))) {
|
||||
return;
|
||||
}
|
||||
|
||||
mCaptionButtons = nsWindowGfx::ToIntRect(captionButtons);
|
||||
|
||||
// Adjustments to reported area
|
||||
PRInt32 leftMargin = (mNonClientMargins.left == -1) ? mHorResizeMargin : mNonClientMargins.left;
|
||||
|
||||
// "leftMargin - 1" represents the resizer border and an
|
||||
// one pixel adjustment to hide the semi-transparent highlight.
|
||||
// The extra width is already excluded when the window is maximized.
|
||||
mCaptionButtons.x -= leftMargin - 1;
|
||||
|
||||
if (mSizeMode != nsSizeMode_Maximized) {
|
||||
mCaptionButtons.width += leftMargin - 1;
|
||||
mCaptionButtons.height -= mVertResizeMargin + 1;
|
||||
} else {
|
||||
// Adjustments to the buttons' shift from the edge of the screen,
|
||||
// plus some apparently transparent drop shadow below them.
|
||||
mCaptionButtons.width -= 2;
|
||||
mCaptionButtons.height -= 3;
|
||||
}
|
||||
|
||||
// Create a rounded region by shrinking the 2 bottommost pixel rows from
|
||||
// the rect by 1 and 2 pixels.
|
||||
// mCaptionButtons: mCaptionButtonsRoundedRegion:
|
||||
// +-----------+ +-----------+
|
||||
// | | | |
|
||||
// | | | |
|
||||
// +-----------+ +-------+
|
||||
nsIntRect round1(mCaptionButtons.x, mCaptionButtons.y,
|
||||
mCaptionButtons.width, mCaptionButtons.height - 2);
|
||||
nsIntRect round2(mCaptionButtons.x + 1, mCaptionButtons.YMost() - 2,
|
||||
mCaptionButtons.width - 2, 1);
|
||||
nsIntRect round3(mCaptionButtons.x + 2, mCaptionButtons.YMost() - 1,
|
||||
mCaptionButtons.width - 4, 1);
|
||||
mCaptionButtonsRoundedRegion.Or(mCaptionButtonsRoundedRegion, round1);
|
||||
mCaptionButtonsRoundedRegion.Or(mCaptionButtonsRoundedRegion, round2);
|
||||
mCaptionButtonsRoundedRegion.Or(mCaptionButtonsRoundedRegion, round3);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* SECTION: nsIWidget::HideWindowChrome
|
||||
@ -7141,10 +7083,6 @@ PRBool nsWindow::OnResize(nsIntRect &aWindowRect)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
||||
UpdateCaptionButtonsClippingRect();
|
||||
#endif
|
||||
|
||||
// call the event callback
|
||||
if (mEventCallback) {
|
||||
nsSizeEvent event(PR_TRUE, NS_SIZE, this);
|
||||
|
@ -455,9 +455,6 @@ protected:
|
||||
static STDMETHODIMP_(LRESULT) LresultFromObject(REFIID riid, WPARAM wParam, LPUNKNOWN pAcc);
|
||||
#endif // ACCESSIBILITY
|
||||
void ClearCachedResources();
|
||||
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
||||
void UpdateCaptionButtonsClippingRect();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIWidget> mParent;
|
||||
@ -511,13 +508,6 @@ protected:
|
||||
// Margins set by the owner
|
||||
nsIntMargin mNonClientMargins;
|
||||
|
||||
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN
|
||||
// Represents the area taken by the caption buttons
|
||||
// on dwm-enabled systems
|
||||
nsIntRect mCaptionButtons;
|
||||
nsIntRegion mCaptionButtonsRoundedRegion;
|
||||
#endif
|
||||
|
||||
// Indicates custom frames are enabled
|
||||
PRPackedBool mCustomNonClient;
|
||||
// Cached copy of L&F's resize border
|
||||
|
Loading…
Reference in New Issue
Block a user