From d48f8a07e991ff355e3acdaa7cb7a95d98cf1584 Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Tue, 13 May 2014 15:26:01 -0700 Subject: [PATCH] Fixes various Aero drawing issues --- appshell/cef_buffered_dc.h | 109 ++++++++++++++++++ appshell/cef_dark_aero_window.cpp | 59 ++-------- appshell/cef_dark_aero_window.h | 21 ++-- appshell/cef_dark_window.cpp | 176 +++++++++++++++--------------- appshell/cef_dark_window.h | 15 ++- appshell/cef_main_window.cpp | 7 +- appshell/cef_popup_window.cpp | 6 + appshell/cef_popup_window.h | 1 + appshell/cef_window.cpp | 17 +-- appshell/cef_window.h | 3 + appshell_paths.gypi | 21 ++-- 11 files changed, 266 insertions(+), 169 deletions(-) create mode 100644 appshell/cef_buffered_dc.h diff --git a/appshell/cef_buffered_dc.h b/appshell/cef_buffered_dc.h new file mode 100644 index 000000000..b7835ae07 --- /dev/null +++ b/appshell/cef_buffered_dc.h @@ -0,0 +1,109 @@ +#pragma once +/* + * Copyright (c) 2014 Adobe Systems Incorporated. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include "cef_window.h" + + +class cef_buffered_dc +{ +public: + cef_buffered_dc(cef_window* window, HDC hdc = NULL) + : mWnd(window) + , mWindowDC(hdc) + , mDcMem(NULL) + , mBitmap(NULL) + , mBmOld(NULL) + , mWidth(0) + , mHeight(0) + , mReleaseDcOnDestroy(false) + { + CommonInit(); + } + + operator HDC() + { + return mDcMem; + } + + HDC GetWindowDC() + { + return mWindowDC; + } + + ~cef_buffered_dc() + { + Destroy(); + } + +private: + cef_buffered_dc() + { + } + + cef_buffered_dc(const cef_buffered_dc& other) + { + } + +protected: + void CommonInit() + { + if (mWnd) { + if (mWindowDC == NULL) { + mWindowDC = mWnd->GetDC(); + mReleaseDcOnDestroy = true; + } + + RECT rectWindow; + mWnd->GetWindowRect(&rectWindow); + mWidth = ::RectWidth(rectWindow); + mHeight = ::RectHeight(rectWindow); + + mDcMem = ::CreateCompatibleDC(mWindowDC); + mBitmap = ::CreateCompatibleBitmap(mWindowDC, mWidth, mHeight); + mBmOld = ::SelectObject(mDcMem, mBitmap); + } + } + + void Destroy() + { + if (mWnd) { + ::BitBlt(mWindowDC, 0, 0, mWidth, mHeight, mDcMem, 0, 0, SRCCOPY); + + ::SelectObject(mDcMem, mBmOld); + ::DeleteObject(mBitmap); + ::DeleteDC(mDcMem); + + if (mReleaseDcOnDestroy) { + mWnd->ReleaseDC(mWindowDC); + } + } + } + + cef_window* mWnd; + HDC mWindowDC; + HDC mDcMem; + HBITMAP mBitmap; + HGDIOBJ mBmOld; + int mWidth; + int mHeight; + bool mReleaseDcOnDestroy; +}; \ No newline at end of file diff --git a/appshell/cef_dark_aero_window.cpp b/appshell/cef_dark_aero_window.cpp index 87e76807d..31d90e247 100644 --- a/appshell/cef_dark_aero_window.cpp +++ b/appshell/cef_dark_aero_window.cpp @@ -20,7 +20,7 @@ * DEALINGS IN THE SOFTWARE. */ #include "cef_dark_aero_window.h" - +#include // Constants static const int kWindowFrameSize = 8; static const int kSystemIconZoomFactorCX = kWindowFrameSize + 2; @@ -318,44 +318,6 @@ void cef_dark_aero_window::InitDeviceContext(HDC hdc) } } -// Redraws the non-client area -void cef_dark_aero_window::DoPaintNonClientArea(HDC hdc) -{ - if (CanUseAeroGlass()) { - EnforceMenuBackground(); - - HDC hdcOrig = hdc; - RECT rectWindow; - GetWindowRect(&rectWindow); - - int Width = ::RectWidth(rectWindow); - int Height = ::RectHeight(rectWindow); - - HDC dcMem = ::CreateCompatibleDC(hdc); - HBITMAP bm = ::CreateCompatibleBitmap(hdc, Width, Height); - HGDIOBJ bmOld = ::SelectObject(dcMem, bm); - - hdc = dcMem; - - InitDeviceContext(hdc); - InitDeviceContext(hdcOrig); - - DoDrawFrame(hdc); - DoDrawSystemMenuIcon(hdc); - DoDrawTitlebarText(hdc); - DoDrawSystemIcons(hdc); - DoDrawMenuBar(hdc); - - ::BitBlt(hdcOrig, 0, 0, Width, Height, dcMem, 0, 0, SRCCOPY); - - ::SelectObject(dcMem, bmOld); - ::DeleteObject(bm); - ::DeleteDC(dcMem); - } else { - cef_dark_window::DoPaintNonClientArea(hdc); - } -} - // Force Drawing the non-client area. // Normally WM_NCPAINT is used but there are times when you // need to force drawing the entire non-client area when @@ -397,7 +359,7 @@ void cef_dark_aero_window::ComputeMenuBarRect(RECT& rect) const ComputeWindowCaptionRect(rectCaption); GetRealClientRect(&rectClient); - rect.top = rectCaption.bottom + 1; + rect.top = ::GetSystemMetrics(SM_CYFRAME) + mNcMetrics.iCaptionHeight + 1; rect.bottom = rectClient.top - 1; rect.left = rectClient.left; @@ -433,12 +395,10 @@ void cef_dark_aero_window::DrawMenuBar(HDC hdc) } } -// Redraws the menu bar void cef_dark_aero_window::UpdateMenuBar() { - HDC hdc = GetWindowDC(); - DrawMenuBar(hdc); - ReleaseDC(hdc); + cef_buffered_dc dc(this); + DrawMenuBar(dc); } // The Aero version doesn't send us WM_DRAWITEM messages @@ -586,7 +546,7 @@ BOOL cef_dark_aero_window::HandleNcCalcSize(BOOL calcValidRects, NCCALCSIZE_PARA pncsp->rgrc[0].right = pncsp->rgrc[0].right - 0; pncsp->rgrc[0].bottom = pncsp->rgrc[0].bottom - 0; - *lr = 0; + *lr = IsZoomed() ? WVR_REDRAW : 0; return TRUE; } @@ -641,7 +601,6 @@ LRESULT cef_dark_aero_window::DwpCustomFrameProc(UINT message, WPARAM wParam, LP return lr; } - // WindowProc handles dispatching of messages and routing back to the base class or to Windows LRESULT cef_dark_aero_window::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { @@ -649,7 +608,6 @@ LRESULT cef_dark_aero_window::WindowProc(UINT message, WPARAM wParam, LPARAM lPa switch (message) { - case WM_MEASUREITEM: if (HandleMeasureItem((LPMEASUREITEMSTRUCT)lParam)) return 0L; @@ -673,9 +631,10 @@ LRESULT cef_dark_aero_window::WindowProc(UINT message, WPARAM wParam, LPARAM lPa LRESULT lr = DwpCustomFrameProc(message, wParam, lParam, &callDefWindowProc); switch(message) { + case WM_NCACTIVATE: case WM_ACTIVATE: if (mReady) { - UpdateMenuBar(); + UpdateNonClientArea(); } break; case WM_NCMOUSELEAVE: @@ -742,6 +701,10 @@ LRESULT cef_dark_aero_window::WindowProc(UINT message, WPARAM wParam, LPARAM lPa case WM_EXITMENULOOP: mMenuActiveIndex = -1; break; + case WM_ACTIVATEAPP: + mIsActive = (BOOL)wParam; + UpdateNonClientArea(); + break; } return lr; diff --git a/appshell/cef_dark_aero_window.h b/appshell/cef_dark_aero_window.h index aa818740d..e2a2215a8 100644 --- a/appshell/cef_dark_aero_window.h +++ b/appshell/cef_dark_aero_window.h @@ -23,7 +23,13 @@ #include "cef_dark_window.h" #include -#define CDW_UPDATEMENU WM_USER+1004 +// Undocumented Aero Messages +#define WM_UAHDESTROYWINDOW 0x0090 +#define WM_UAHDRAWMENU 0x0091 +#define WM_UAHDRAWMENUITEM 0x0092 +#define WM_UAHINITMENU 0x0093 +#define WM_UAHMEASUREMENUITEM 0x0094 +#define WM_UAHNCPAINTMENUPOPUP 0x0095 // prototypes for DWM function pointers typedef HRESULT (STDAPICALLTYPE *PFNDWMEFICA)(HWND hWnd, __in const MARGINS* pMarInset); @@ -83,18 +89,17 @@ class cef_dark_aero_window : public cef_dark_window void PostHandleNcLeftButtonUp(UINT uHitTest, LPPOINT pt); - void DrawMenuBar(HDC hdc); - void UpdateMenuBar(); - void HiliteMenuItemAt(LPPOINT pt); + virtual void DrawMenuBar(HDC hdc); + virtual void HiliteMenuItemAt(LPPOINT pt); virtual void UpdateNonClientArea(); + virtual void UpdateMenuBar(); virtual void InitDeviceContext(HDC hdc); - virtual void DoPaintNonClientArea(HDC hdc); - void ComputeMenuBarRect(RECT& rect) const; - void ComputeWindowCaptionRect(RECT& rect) const; - void ComputeWindowIconRect(RECT& rect) const; + virtual void ComputeMenuBarRect(RECT& rect) const; + virtual void ComputeWindowCaptionRect(RECT& rect) const; + virtual void ComputeWindowIconRect(RECT& rect) const; LRESULT DwpCustomFrameProc(UINT message, WPARAM wParam, LPARAM lParam, bool* pfCallDefWindowProc); diff --git a/appshell/cef_dark_window.cpp b/appshell/cef_dark_window.cpp index 4a0a77cd2..785792f81 100644 --- a/appshell/cef_dark_window.cpp +++ b/appshell/cef_dark_window.cpp @@ -87,25 +87,28 @@ namespace ResourceImage * cef_dark_window */ cef_dark_window::cef_dark_window() : - mSysCloseButton(0), - mSysRestoreButton(0), - mSysMinimizeButton(0), - mSysMaximizeButton(0), - mHoverSysCloseButton(0), - mHoverSysRestoreButton(0), - mHoverSysMinimizeButton(0), - mHoverSysMaximizeButton(0), - mPressedSysCloseButton(0), - mPressedSysRestoreButton(0), - mPressedSysMinimizeButton(0), - mPressedSysMaximizeButton(0), - mWindowIcon(0), - mBackgroundBrush(0), - mFrameOutlinePen(0), - mCaptionFont(0), - mMenuFont(0), - mHighlightBrush(0), - mHoverBrush(0) + mSysCloseButton(NULL), + mSysRestoreButton(NULL), + mSysMinimizeButton(NULL), + mSysMaximizeButton(NULL), + mHoverSysCloseButton(NULL), + mHoverSysRestoreButton(NULL), + mHoverSysMinimizeButton(NULL), + mHoverSysMaximizeButton(NULL), + mPressedSysCloseButton(NULL), + mPressedSysRestoreButton(NULL), + mPressedSysMinimizeButton(NULL), + mPressedSysMaximizeButton(NULL), + mWindowIcon(NULL), + mBackgroundActiveBrush(NULL), + mBackgroundInactiveBrush(NULL), + mFrameOutlineActivePen(NULL), + mFrameOutlineInactivePen(NULL), + mCaptionFont(NULL), + mMenuFont(NULL), + mHighlightBrush(NULL), + mHoverBrush(NULL), + mIsActive(TRUE) { ::ZeroMemory(&mNcMetrics, sizeof(mNcMetrics)); } @@ -148,13 +151,14 @@ void cef_dark_window::InitDrawingResources() Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); } LoadSysButtonImages(); + // Create Brushes and Pens - if (mBackgroundBrush == NULL) { - mBackgroundBrush = ::CreateSolidBrush(CEF_COLOR_BACKGROUND); + if (mBackgroundActiveBrush == NULL) { + mBackgroundActiveBrush = ::CreateSolidBrush(CEF_COLOR_BACKGROUND_ACTIVE); } - if (mBackgroundBrush == NULL) { - mBackgroundBrush = ::CreateSolidBrush(CEF_COLOR_BACKGROUND); + if (mBackgroundInactiveBrush == NULL) { + mBackgroundInactiveBrush = ::CreateSolidBrush(CEF_COLOR_BACKGROUND_INACTIVE); } if (mHighlightBrush == NULL) { mHighlightBrush = ::CreateSolidBrush(CEF_COLOR_MENU_HILITE_BACKGROUND); @@ -162,8 +166,11 @@ void cef_dark_window::InitDrawingResources() if (mHoverBrush == NULL) { mHoverBrush = ::CreateSolidBrush(CEF_COLOR_MENU_HOVER_BACKGROUND); } - if (mFrameOutlinePen == NULL) { - mFrameOutlinePen = ::CreatePen(PS_SOLID, 1, CEF_COLOR_FRAME_OUTLINE); + if (mFrameOutlineActivePen == NULL) { + mFrameOutlineActivePen = ::CreatePen(PS_SOLID, 1, CEF_COLOR_FRAME_OUTLINE_ACTIVE); + } + if (mFrameOutlineInactivePen == NULL) { + mFrameOutlineInactivePen = ::CreatePen(PS_SOLID, 1, CEF_COLOR_FRAME_OUTLINE_INACTIVE); } } @@ -258,12 +265,14 @@ BOOL cef_dark_window::HandleNcDestroy() delete mPressedSysMinimizeButton; delete mPressedSysMaximizeButton; - ::DeleteObject(mBackgroundBrush); + ::DeleteObject(mBackgroundActiveBrush); + ::DeleteObject(mBackgroundInactiveBrush); ::DeleteObject(mCaptionFont); ::DeleteObject(mMenuFont); ::DeleteObject(mHighlightBrush); ::DeleteObject(mHoverBrush); - ::DeleteObject(mFrameOutlinePen); + ::DeleteObject(mFrameOutlineActivePen); + ::DeleteObject(mFrameOutlineInactivePen); return cef_window::HandleNcDestroy(); } @@ -429,9 +438,9 @@ void cef_dark_window::DoDrawFrame(HDC hdc) rectFrame.right = ::RectWidth(rectWindow); // Paint the entire thing with the background brush - ::FillRect(hdc, &rectFrame, mBackgroundBrush); + ::FillRect(hdc, &rectFrame, (mIsActive) ? mBackgroundActiveBrush : mBackgroundInactiveBrush); - HGDIOBJ oldPen = ::SelectObject(hdc, mFrameOutlinePen); + HGDIOBJ oldPen = (mIsActive) ? ::SelectObject(hdc, mFrameOutlineActivePen) : ::SelectObject(hdc, mFrameOutlineInactivePen); HGDIOBJ oldbRush = ::SelectObject(hdc, ::GetStockObject(NULL_BRUSH)); // Now draw a PX tuxedo border around the edge @@ -589,9 +598,16 @@ void cef_dark_window::EnforceMenuBackground() ::GetMenuInfo(mbi.hMenu, &mi); - if (mi.hbrBack != mBackgroundBrush) { - mi.hbrBack = mBackgroundBrush; - ::SetMenuInfo(mbi.hMenu, &mi); + if (mIsActive) { + if (mi.hbrBack != mBackgroundActiveBrush) { + mi.hbrBack = mBackgroundActiveBrush; + ::SetMenuInfo(mbi.hMenu, &mi); + } + } else { + if (mi.hbrBack != mBackgroundInactiveBrush) { + mi.hbrBack = mBackgroundInactiveBrush; + ::SetMenuInfo(mbi.hMenu, &mi); + } } } @@ -622,11 +638,6 @@ void cef_dark_window::DoDrawMenuBar(HDC hdc) mmi.cbSize = sizeof (mmi); mmi.fMask = MIIM_STATE|MIIM_ID; ::GetMenuItemInfo (menu, i, TRUE, &mmi); - - // Drawitem only works on ID - MEASUREITEMSTRUCT mis = {0}; - mis.CtlType = ODT_MENU; - mis.itemID = mmi.wID; RECT itemRect; ::SetRectEmpty(&itemRect); @@ -634,31 +645,35 @@ void cef_dark_window::DoDrawMenuBar(HDC hdc) if (::GetMenuItemRect(mWnd, menu, (UINT)i, &itemRect)) { ScreenToNonClient(&itemRect); - // Check to make sure it's actually in the - // the correct location (fixes aero drawing issue) - POINT pt = {itemRect.left, itemRect.top}; - if (!CanUseAeroGlass() || ::PtInRect(&menuBarRect, pt)) { - - // Draw the menu item - DRAWITEMSTRUCT dis = {0}; - dis.CtlType = ODT_MENU; - dis.itemID = mmi.wID; - dis.hwndItem = (HWND)menu; - dis.itemAction = ODA_DRAWENTIRE; - dis.hDC = hdc; - ::CopyRect(&dis.rcItem, &itemRect); - - if (mmi.fState & MFS_HILITE) { - dis.itemState |= ODS_SELECTED; - } - if (mmi.fState & MFS_GRAYED) { - dis.itemState |= ODS_GRAYED; - } - - dis.itemState |= ODS_NOACCEL; - - HandleDrawItem(&dis); + POINT ptTopLeftItem = {itemRect.left, itemRect.top}; + + if (CanUseAeroGlass() && !::PtInRect(&menuBarRect, ptTopLeftItem)) { + // Check to make sure it's actually in the + // the correct location (fixes aero drawing issue) + int itemHeight = ::RectHeight(itemRect); + itemRect.top = menuBarRect.top; + itemRect.bottom = itemRect.top + itemHeight; } + + // Draw the menu item + DRAWITEMSTRUCT dis = {0}; + dis.CtlType = ODT_MENU; + dis.itemID = mmi.wID; + dis.hwndItem = (HWND)menu; + dis.itemAction = ODA_DRAWENTIRE; + dis.hDC = hdc; + ::CopyRect(&dis.rcItem, &itemRect); + + if (mmi.fState & MFS_HILITE) { + dis.itemState |= ODS_SELECTED; + } + if (mmi.fState & MFS_GRAYED) { + dis.itemState |= ODS_GRAYED; + } + + dis.itemState |= ODS_NOACCEL; + + HandleDrawItem(&dis); } } } @@ -669,32 +684,15 @@ void cef_dark_window::DoPaintNonClientArea(HDC hdc) { EnforceMenuBackground(); - HDC hdcOrig = hdc; - RECT rectWindow; - GetWindowRect(&rectWindow); - - int Width = ::RectWidth(rectWindow); - int Height = ::RectHeight(rectWindow); - - HDC dcMem = ::CreateCompatibleDC(hdc); - HBITMAP bm = ::CreateCompatibleBitmap(hdc, Width, Height); - HGDIOBJ bmOld = ::SelectObject(dcMem, bm); - - hdc = dcMem; + cef_buffered_dc dc(this, hdc); - InitDeviceContext(hdc); - InitDeviceContext(hdcOrig); - DoDrawFrame(hdc); - DoDrawSystemMenuIcon(hdc); - DoDrawTitlebarText(hdc); - DoDrawSystemIcons(hdc); - DoDrawMenuBar(hdc); - - ::BitBlt(hdcOrig, 0, 0, Width, Height, dcMem, 0, 0, SRCCOPY); - - ::SelectObject(dcMem, bmOld); - ::DeleteObject(bm); - ::DeleteDC(dcMem); + InitDeviceContext(dc); + InitDeviceContext(dc.GetWindowDC()); + DoDrawFrame(dc); + DoDrawSystemMenuIcon(dc); + DoDrawTitlebarText(dc); + DoDrawSystemIcons(dc); + DoDrawMenuBar(dc); } // Special case for derived classes to implement @@ -922,7 +920,7 @@ BOOL cef_dark_window::HandleDrawItem(LPDRAWITEMSTRUCT lpDIS) if (lpDIS->itemState & ODS_SELECTED || lpDIS->itemState & ODS_HOTLIGHT) { ::FillRect(lpDIS->hDC, &rectBG, mHoverBrush); } else { - ::FillRect(lpDIS->hDC, &rectBG, mBackgroundBrush); + ::FillRect(lpDIS->hDC, &rectBG, (mIsActive) ? mBackgroundActiveBrush : mBackgroundInactiveBrush); } if (lpDIS->itemState & ODS_GRAYED) { @@ -1204,6 +1202,10 @@ LRESULT cef_dark_window::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) } } break; + case WM_ACTIVATEAPP: + mIsActive = (BOOL)wParam; + UpdateNonClientArea(); + break; } return lr; } diff --git a/appshell/cef_dark_window.h b/appshell/cef_dark_window.h index b7901f19b..0e3945964 100644 --- a/appshell/cef_dark_window.h +++ b/appshell/cef_dark_window.h @@ -21,6 +21,7 @@ * DEALINGS IN THE SOFTWARE. */ #include "cef_window.h" +#include "cef_buffered_dc.h" // Placeholder namespace Gdiplus @@ -29,8 +30,10 @@ namespace Gdiplus }; // Color Constants -#define CEF_COLOR_BACKGROUND RGB(60, 63, 65) -#define CEF_COLOR_FRAME_OUTLINE RGB(42, 44, 45) +#define CEF_COLOR_BACKGROUND_ACTIVE RGB(60, 63, 65) +#define CEF_COLOR_BACKGROUND_INACTIVE RGB(68, 71, 73) +#define CEF_COLOR_FRAME_OUTLINE_ACTIVE RGB(42, 44, 45) +#define CEF_COLOR_FRAME_OUTLINE_INACTIVE RGB(60, 63, 65) #define CEF_COLOR_NORMALTEXT RGB(215, 216, 217) #define CEF_COLOR_MENU_HILITE_BACKGROUND RGB(247, 247, 247) #define CEF_COLOR_MENU_HOVER_BACKGROUND RGB(45, 46, 48) @@ -154,14 +157,18 @@ class cef_dark_window : public cef_window Gdiplus::Image* mPressedSysMinimizeButton; Gdiplus::Image* mPressedSysMaximizeButton; + BOOL mIsActive; + HFONT mCaptionFont; - HBRUSH mBackgroundBrush; + HBRUSH mBackgroundActiveBrush; + HBRUSH mBackgroundInactiveBrush; HICON mWindowIcon; HFONT mMenuFont; HBRUSH mHighlightBrush; HBRUSH mHoverBrush; - HPEN mFrameOutlinePen; + HPEN mFrameOutlineActivePen; + HPEN mFrameOutlineInactivePen; // Metrics and State Data NONCLIENTMETRICS mNcMetrics; diff --git a/appshell/cef_main_window.cpp b/appshell/cef_main_window.cpp index 929280d6b..4388074fd 100644 --- a/appshell/cef_main_window.cpp +++ b/appshell/cef_main_window.cpp @@ -64,7 +64,7 @@ ATOM cef_main_window::RegisterWndClass() ::ZeroMemory (&wcex, sizeof (wcex)); wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.style = CS_SAVEBITS; wcex.lpfnWndProc = ::DefWindowProc; wcex.hInstance = ::hInst; wcex.hIcon = ::LoadIcon(hInst, MAKEINTRESOURCE(IDI_CEFCLIENT)); @@ -182,9 +182,6 @@ BOOL cef_main_window::HandleCreate() // WM_ERASEBKGND handler BOOL cef_main_window::HandleEraseBackground(HDC hdc) { -#if defined(DARK_AERO_GLASS) && defined (DARK_UI) - DrawMenuBar(hdc); -#endif return (SafeGetCefBrowserHwnd() != NULL); } @@ -208,7 +205,7 @@ BOOL cef_main_window::HandlePaint() HDC hdc = BeginPaint(&ps); #if defined(DARK_AERO_GLASS) && defined (DARK_UI) - DoPaintClientArea(hdc); + DoPaintNonClientArea(hdc); #endif EndPaint(&ps); diff --git a/appshell/cef_popup_window.cpp b/appshell/cef_popup_window.cpp index 7aed3d645..7165958f6 100644 --- a/appshell/cef_popup_window.cpp +++ b/appshell/cef_popup_window.cpp @@ -95,6 +95,11 @@ void cef_popup_window::InitSystemIcon() } } +void cef_popup_window::SetClassStyles() +{ + SetClassLong(mWnd, GCL_STYLE, CS_SAVEBITS); +} + // Subclasses the HWND and initializes the dark drawing code bool cef_popup_window::SubclassWindow(HWND wnd) { @@ -108,6 +113,7 @@ bool cef_popup_window::SubclassWindow(HWND wnd) ::MoveWindow(hwndBrowser, rectBrowser.left, rectBrowser.top, ::RectWidth(rectBrowser), ::RectHeight(rectBrowser), FALSE); } + SetClassStyles(); InitSystemIcon(); GetBrowser()->GetHost()->SetFocus(true); return true; diff --git a/appshell/cef_popup_window.h b/appshell/cef_popup_window.h index 0e6662ca8..915fdb9a7 100644 --- a/appshell/cef_popup_window.h +++ b/appshell/cef_popup_window.h @@ -43,6 +43,7 @@ class cef_popup_window : public cef_host_window // Initialization void InitSystemIcon(); + void SetClassStyles(); // Implementation virtual void PostNcDestroy(); diff --git a/appshell/cef_window.cpp b/appshell/cef_window.cpp index a3585eded..41db38be0 100644 --- a/appshell/cef_window.cpp +++ b/appshell/cef_window.cpp @@ -35,11 +35,11 @@ struct HookData { } void Reset() { - mOldHook = NULL; + mhHook = NULL; mWindow = NULL; } - HHOOK mOldHook; + HHOOK mhHook; cef_window* mWindow; } gHookData; @@ -61,11 +61,11 @@ cef_window::~cef_window(void) static LRESULT CALLBACK _HookProc(int code, WPARAM wParam, LPARAM lParam) { if (code != HCBT_CREATEWND) - return CallNextHookEx(gHookData.mOldHook, code, wParam, lParam); + return CallNextHookEx(gHookData.mhHook, code, wParam, lParam); LPCREATESTRUCT lpcs = ((LPCBT_CREATEWND)lParam)->lpcs; - HHOOK nextHook = gHookData.mOldHook; + HHOOK nextHook = gHookData.mhHook; if (lpcs->lpCreateParams && lpcs->lpCreateParams == (LPVOID)gHookData.mWindow) { @@ -74,7 +74,8 @@ static LRESULT CALLBACK _HookProc(int code, WPARAM wParam, LPARAM lParam) // Rest the hook data here since we've already hooked this window // this allows for other windows to be created in the WM_CREATE handlers // of subclassed windows - gHookData.Reset(); + gHookData.mWindow = 0; + } return CallNextHookEx(nextHook, code, wParam, lParam); @@ -84,17 +85,19 @@ static LRESULT CALLBACK _HookProc(int code, WPARAM wParam, LPARAM lParam) static void _HookWindowCreate(cef_window* window) { // can only hook one creation at a time - if (gHookData.mOldHook || gHookData.mWindow) + if (gHookData.mhHook || gHookData.mWindow) return; - gHookData.mOldHook = ::SetWindowsHookEx(WH_CBT, _HookProc, NULL, ::GetCurrentThreadId()); + gHookData.mhHook = ::SetWindowsHookEx(WH_CBT, _HookProc, NULL, ::GetCurrentThreadId()); gHookData.mWindow = window; } // Disabled Hooking static void _UnHookWindowCreate() { + ::UnhookWindowsHookEx(gHookData.mhHook); gHookData.Reset(); + } // Window Proc which receives messages from subclassed windows diff --git a/appshell/cef_window.h b/appshell/cef_window.h index 247925dae..2f45353ca 100644 --- a/appshell/cef_window.h +++ b/appshell/cef_window.h @@ -162,6 +162,9 @@ class cef_window BOOL IsIconic() const { return ::IsIconic(mWnd); } + BOOL IsWindowVisible() const + { return ::IsWindowVisible(mWnd); } + void SetStyle(DWORD dwStyle) { SetWindowLong(GWL_STYLE, dwStyle); } diff --git a/appshell_paths.gypi b/appshell_paths.gypi index 092b688c1..753b06239 100755 --- a/appshell_paths.gypi +++ b/appshell_paths.gypi @@ -116,8 +116,9 @@ 'appshell/resource.h', 'appshell/res/appshell.ico', 'appshell/resource_util_win.cpp', - 'appshell/cef_dark_aero_window.cpp', - 'appshell/cef_dark_aero_window.h', + 'appshell/cef_buffered_dc.h', + 'appshell/cef_dark_aero_window.cpp', + 'appshell/cef_dark_aero_window.h', 'appshell/cef_dark_window.cpp', 'appshell/cef_dark_window.h', 'appshell/cef_host_window.cpp', @@ -258,14 +259,14 @@ 'appshell/mac/window-zoom-inactive@2x.png', 'appshell/mac/window-zoom-pressed.png', 'appshell/mac/window-zoom-pressed@2x.png', - 'appshell/mac/window-fullscreen-pressed.png', - 'appshell/mac/window-fullscreen-pressed@2x.png', - 'appshell/mac/window-fullscreen-hover.png', - 'appshell/mac/window-fullscreen-hover@2x.png', - 'appshell/mac/window-fullscreen-active.png', - 'appshell/mac/window-fullscreen-active@2x.png', - 'appshell/mac/window-fullscreen-inactive.png', - 'appshell/mac/window-fullscreen-inactive@2x.png', + 'appshell/mac/window-fullscreen-pressed.png', + 'appshell/mac/window-fullscreen-pressed@2x.png', + 'appshell/mac/window-fullscreen-hover.png', + 'appshell/mac/window-fullscreen-hover@2x.png', + 'appshell/mac/window-fullscreen-active.png', + 'appshell/mac/window-fullscreen-active@2x.png', + 'appshell/mac/window-fullscreen-inactive.png', + 'appshell/mac/window-fullscreen-inactive@2x.png', ], 'appshell_bundle_resources_linux': [ 'Resources/locales',