From 233cc095be779b66ce00f93df95ec0052d3fe96a Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Tue, 13 May 2014 15:26:01 -0700 Subject: [PATCH 01/13] Fixes several aero and dark shell issues --- appshell/cef_buffered_dc.h | 100 ++++++++++++++++++++++ appshell/cef_dark_aero_window.cpp | 53 ++---------- appshell/cef_dark_aero_window.h | 12 ++- appshell/cef_dark_window.cpp | 135 ++++++++++++++---------------- appshell/cef_dark_window.h | 15 +++- appshell/cef_main_window.cpp | 5 +- appshell/cef_window.cpp | 22 +++-- 7 files changed, 203 insertions(+), 139 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..f5ffd9b9c --- /dev/null +++ b/appshell/cef_buffered_dc.h @@ -0,0 +1,100 @@ +#pragma once +/* + * Copyright (c) 2013 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() + { + ::BitBlt(mWindowDC, 0, 0, mWidth, mHeight, mDcMem, 0, 0, SRCCOPY); + + ::SelectObject(mDcMem, mBmOld); + ::DeleteObject(mBitmap); + ::DeleteDC(mDcMem); + + if (mReleaseDcOnDestroy) { + mWnd->ReleaseDC(mWindowDC); + mReleaseDcOnDestroy = true; + } + } + +private: + cef_buffered_dc() + { + } + + cef_buffered_dc(const cef_buffered_dc&) + { + } + +protected: + void CommonInit() + { + if (mWindowDC == NULL) { + mWindowDC = mWnd->GetDC(); + } + + RECT rectWindow; + mWnd->GetWindowRect(&rectWindow); + mWidth = ::RectWidth(rectWindow); + mHeight = ::RectHeight(rectWindow); + + mDcMem = ::CreateCompatibleDC(mWindowDC); + mBitmap = ::CreateCompatibleBitmap(mWindowDC, mWidth, mHeight); + mBmOld = ::SelectObject(mDcMem, mBitmap); + } + + 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..9432cc835 100644 --- a/appshell/cef_dark_aero_window.cpp +++ b/appshell/cef_dark_aero_window.cpp @@ -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,13 +395,6 @@ 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); -} // The Aero version doesn't send us WM_DRAWITEM messages // to draw the item when hovering so we have to do that @@ -675,7 +630,7 @@ LRESULT cef_dark_aero_window::WindowProc(UINT message, WPARAM wParam, LPARAM lPa switch(message) { case WM_ACTIVATE: if (mReady) { - UpdateMenuBar(); + UpdateNonClientArea(); } break; case WM_NCMOUSELEAVE: @@ -742,6 +697,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..92a7b3db0 100644 --- a/appshell/cef_dark_aero_window.h +++ b/appshell/cef_dark_aero_window.h @@ -83,18 +83,16 @@ 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 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..a1b7a595b 100644 --- a/appshell/cef_dark_window.cpp +++ b/appshell/cef_dark_window.cpp @@ -100,12 +100,15 @@ cef_dark_window::cef_dark_window() : mPressedSysMinimizeButton(0), mPressedSysMaximizeButton(0), mWindowIcon(0), - mBackgroundBrush(0), - mFrameOutlinePen(0), + mBackgroundActiveBrush(0), + mBackgroundInactiveBrush(0), + mFrameOutlineActivePen(0), + mFrameOutlineInactivePen(0), mCaptionFont(0), mMenuFont(0), mHighlightBrush(0), - mHoverBrush(0) + mHoverBrush(0), + 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,8 +598,8 @@ void cef_dark_window::EnforceMenuBackground() ::GetMenuInfo(mbi.hMenu, &mi); - if (mi.hbrBack != mBackgroundBrush) { - mi.hbrBack = mBackgroundBrush; + if (mi.hbrBack != mBackgroundActiveBrush) { + mi.hbrBack = mBackgroundActiveBrush; ::SetMenuInfo(mbi.hMenu, &mi); } } @@ -622,11 +631,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 +638,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 +677,15 @@ void cef_dark_window::DoPaintNonClientArea(HDC hdc) { EnforceMenuBackground(); - HDC hdcOrig = hdc; - RECT rectWindow; - GetWindowRect(&rectWindow); - - int Width = ::RectWidth(rectWindow); - int Height = ::RectHeight(rectWindow); + cef_buffered_dc dc(this, hdc); - 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); + InitDeviceContext(dc); + InitDeviceContext(dc.GetWindowDC()); + DoDrawFrame(dc); + DoDrawSystemMenuIcon(dc); + DoDrawTitlebarText(dc); + DoDrawSystemIcons(dc); + DoDrawMenuBar(dc); } // Special case for derived classes to implement @@ -922,7 +913,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 +1195,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..7125d3947 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(157, 159, 160) +#define CEF_COLOR_FRAME_OUTLINE_ACTIVE RGB(42, 44, 45) +#define CEF_COLOR_FRAME_OUTLINE_INACTIVE RGB(125, 128, 129) #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..10f75c470 100644 --- a/appshell/cef_main_window.cpp +++ b/appshell/cef_main_window.cpp @@ -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_window.cpp b/appshell/cef_window.cpp index a3585eded..6e3f6f37f 100644 --- a/appshell/cef_window.cpp +++ b/appshell/cef_window.cpp @@ -20,6 +20,8 @@ * DEALINGS IN THE SOFTWARE. */ #include "cef_window.h" +#undef NDEBUG +#include // Externals extern HINSTANCE hInst; @@ -35,11 +37,11 @@ struct HookData { } void Reset() { - mOldHook = NULL; + mhHook = NULL; mWindow = NULL; } - HHOOK mOldHook; + HHOOK mhHook; cef_window* mWindow; } gHookData; @@ -61,11 +63,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 +76,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 +87,22 @@ 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() { + BOOL result = ::UnhookWindowsHookEx(gHookData.mhHook); + if (!result) { + DWORD dwError = ::GetLastError(); + } gHookData.Reset(); + } // Window Proc which receives messages from subclassed windows From 029e24cac6f2b1edd46fc20ba8e53a5654bc66e6 Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Thu, 15 May 2014 10:22:58 -0700 Subject: [PATCH 02/13] fix lost change --- appshell/cef_buffered_dc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appshell/cef_buffered_dc.h b/appshell/cef_buffered_dc.h index f5ffd9b9c..60fe18b0a 100644 --- a/appshell/cef_buffered_dc.h +++ b/appshell/cef_buffered_dc.h @@ -59,7 +59,6 @@ class cef_buffered_dc if (mReleaseDcOnDestroy) { mWnd->ReleaseDC(mWindowDC); - mReleaseDcOnDestroy = true; } } @@ -77,6 +76,7 @@ class cef_buffered_dc { if (mWindowDC == NULL) { mWindowDC = mWnd->GetDC(); + mReleaseDcOnDestroy = true; } RECT rectWindow; From 705c896218efa0c772e96f848062af115b7be2d0 Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Thu, 15 May 2014 10:26:19 -0700 Subject: [PATCH 03/13] remove unused code --- appshell/cef_window.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/appshell/cef_window.cpp b/appshell/cef_window.cpp index 6e3f6f37f..41db38be0 100644 --- a/appshell/cef_window.cpp +++ b/appshell/cef_window.cpp @@ -20,8 +20,6 @@ * DEALINGS IN THE SOFTWARE. */ #include "cef_window.h" -#undef NDEBUG -#include // Externals extern HINSTANCE hInst; @@ -97,10 +95,7 @@ static void _HookWindowCreate(cef_window* window) // Disabled Hooking static void _UnHookWindowCreate() { - BOOL result = ::UnhookWindowsHookEx(gHookData.mhHook); - if (!result) { - DWORD dwError = ::GetLastError(); - } + ::UnhookWindowsHookEx(gHookData.mhHook); gHookData.Reset(); } From fdb166cf61dbb41227cbb575833cb2b363629e76 Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Thu, 15 May 2014 17:52:37 -0700 Subject: [PATCH 04/13] rtc: minor nits and color change from @larz0 --- appshell/cef_buffered_dc.h | 49 +++++++++++++++++++------------- appshell/cef_dark_window.cpp | 55 ++++++++++++++++++++---------------- appshell/cef_dark_window.h | 2 +- appshell_paths.gypi | 21 +++++++------- 4 files changed, 72 insertions(+), 55 deletions(-) diff --git a/appshell/cef_buffered_dc.h b/appshell/cef_buffered_dc.h index 60fe18b0a..367d23aae 100644 --- a/appshell/cef_buffered_dc.h +++ b/appshell/cef_buffered_dc.h @@ -1,6 +1,6 @@ #pragma once /* - * Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. + * 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"), @@ -51,15 +51,7 @@ class cef_buffered_dc ~cef_buffered_dc() { - ::BitBlt(mWindowDC, 0, 0, mWidth, mHeight, mDcMem, 0, 0, SRCCOPY); - - ::SelectObject(mDcMem, mBmOld); - ::DeleteObject(mBitmap); - ::DeleteDC(mDcMem); - - if (mReleaseDcOnDestroy) { - mWnd->ReleaseDC(mWindowDC); - } + Destroy(); } private: @@ -74,19 +66,36 @@ class cef_buffered_dc protected: void CommonInit() { - if (mWindowDC == NULL) { - mWindowDC = mWnd->GetDC(); - mReleaseDcOnDestroy = true; + 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); } + } - RECT rectWindow; - mWnd->GetWindowRect(&rectWindow); - mWidth = ::RectWidth(rectWindow); - mHeight = ::RectHeight(rectWindow); + void Destroy() + { + if (mWnd) { + ::BitBlt(mWindowDC, 0, 0, mWidth, mHeight, mDcMem, 0, 0, SRCCOPY); - mDcMem = ::CreateCompatibleDC(mWindowDC); - mBitmap = ::CreateCompatibleBitmap(mWindowDC, mWidth, mHeight); - mBmOld = ::SelectObject(mDcMem, mBitmap); + ::SelectObject(mDcMem, mBmOld); + ::DeleteObject(mBitmap); + ::DeleteDC(mDcMem); + + if (mReleaseDcOnDestroy) { + mWnd->ReleaseDC(mWindowDC); + } + } } cef_window* mWnd; diff --git a/appshell/cef_dark_window.cpp b/appshell/cef_dark_window.cpp index a1b7a595b..785792f81 100644 --- a/appshell/cef_dark_window.cpp +++ b/appshell/cef_dark_window.cpp @@ -87,27 +87,27 @@ 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), - mBackgroundActiveBrush(0), - mBackgroundInactiveBrush(0), - mFrameOutlineActivePen(0), - mFrameOutlineInactivePen(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)); @@ -598,9 +598,16 @@ void cef_dark_window::EnforceMenuBackground() ::GetMenuInfo(mbi.hMenu, &mi); - if (mi.hbrBack != mBackgroundActiveBrush) { - mi.hbrBack = mBackgroundActiveBrush; - ::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); + } } } diff --git a/appshell/cef_dark_window.h b/appshell/cef_dark_window.h index 7125d3947..aa754e5c6 100644 --- a/appshell/cef_dark_window.h +++ b/appshell/cef_dark_window.h @@ -31,7 +31,7 @@ namespace Gdiplus // Color Constants #define CEF_COLOR_BACKGROUND_ACTIVE RGB(60, 63, 65) -#define CEF_COLOR_BACKGROUND_INACTIVE RGB(157, 159, 160) +#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(125, 128, 129) #define CEF_COLOR_NORMALTEXT RGB(215, 216, 217) 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', From 5974f773dc76f0c9a17c1da53cc51d57dfb78870 Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Fri, 16 May 2014 09:28:42 -0700 Subject: [PATCH 05/13] change tx border per @larz0 --- appshell/cef_dark_window.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appshell/cef_dark_window.h b/appshell/cef_dark_window.h index aa754e5c6..0e3945964 100644 --- a/appshell/cef_dark_window.h +++ b/appshell/cef_dark_window.h @@ -33,7 +33,7 @@ namespace Gdiplus #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(125, 128, 129) +#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) From 4977cc7e93f43910337f93c7096053d86bc5c45c Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Fri, 16 May 2014 09:58:33 -0700 Subject: [PATCH 06/13] rtc --- appshell/cef_buffered_dc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appshell/cef_buffered_dc.h b/appshell/cef_buffered_dc.h index 367d23aae..b7835ae07 100644 --- a/appshell/cef_buffered_dc.h +++ b/appshell/cef_buffered_dc.h @@ -59,7 +59,7 @@ class cef_buffered_dc { } - cef_buffered_dc(const cef_buffered_dc&) + cef_buffered_dc(const cef_buffered_dc& other) { } From f049399adb5b7e2568f13967875e3730950ebd9a Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Fri, 16 May 2014 14:35:12 -0700 Subject: [PATCH 07/13] test code for @bchintx --- appshell/cef_dark_aero_window.cpp | 7 +++++-- appshell/cef_dark_window.cpp | 7 +++++++ appshell/cef_window.h | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/appshell/cef_dark_aero_window.cpp b/appshell/cef_dark_aero_window.cpp index 9432cc835..f33ff961c 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; @@ -596,10 +596,13 @@ 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) { + char szBuffer[256]; + ::sprintf (szBuffer, "Window Message %04x\n", message); + ::OutputDebugStringA(szBuffer); + bool callDefWindowProc = true; switch (message) diff --git a/appshell/cef_dark_window.cpp b/appshell/cef_dark_window.cpp index 785792f81..26556f340 100644 --- a/appshell/cef_dark_window.cpp +++ b/appshell/cef_dark_window.cpp @@ -626,6 +626,11 @@ void cef_dark_window::InitDeviceContext(HDC hdc) // that the background has already been drawn using DoDrawFrame void cef_dark_window::DoDrawMenuBar(HDC hdc) { + // Put a breakpoint here and, If you hit this breakpoint and see a white line under the menubar + // then you need to look in the output window and copy all of the Window Messages since the last + // "Done Drawing Menu Bar" message and send them to jsbooher@adobe for analysis + ::OutputDebugStringA("Drawing Menu Bar\n"); + HMENU menu = GetMenu(); int items = ::GetMenuItemCount(menu); @@ -676,6 +681,8 @@ void cef_dark_window::DoDrawMenuBar(HDC hdc) HandleDrawItem(&dis); } } + + ::OutputDebugStringA("Done Drawing Menu Bar\n"); } // Paints the entire non-client area. 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); } From 9542f5cbe39872822d6303a651396a0ee091c9c0 Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Fri, 16 May 2014 17:41:12 -0700 Subject: [PATCH 08/13] experimental fixes for windows 7 --- appshell/cef_dark_aero_window.cpp | 14 +++++++++++--- appshell/cef_dark_aero_window.h | 10 +++++++++- appshell/cef_dark_window.cpp | 4 ++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/appshell/cef_dark_aero_window.cpp b/appshell/cef_dark_aero_window.cpp index f33ff961c..315caf617 100644 --- a/appshell/cef_dark_aero_window.cpp +++ b/appshell/cef_dark_aero_window.cpp @@ -395,6 +395,11 @@ void cef_dark_aero_window::DrawMenuBar(HDC hdc) } } +void cef_dark_aero_window::UpdateMenuBar() +{ + cef_buffered_dc dc(this); + DrawMenuBar(dc); +} // The Aero version doesn't send us WM_DRAWITEM messages // to draw the item when hovering so we have to do that @@ -599,15 +604,17 @@ LRESULT cef_dark_aero_window::DwpCustomFrameProc(UINT message, WPARAM wParam, LP // 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) { - char szBuffer[256]; + /* char szBuffer[256]; ::sprintf (szBuffer, "Window Message %04x\n", message); ::OutputDebugStringA(szBuffer); - + */ bool callDefWindowProc = true; switch (message) { - + case WM_UAHDRAWMENU: + UpdateMenuBar(); + return 0L; case WM_MEASUREITEM: if (HandleMeasureItem((LPMEASUREITEMSTRUCT)lParam)) return 0L; @@ -631,6 +638,7 @@ 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) { UpdateNonClientArea(); diff --git a/appshell/cef_dark_aero_window.h b/appshell/cef_dark_aero_window.h index 92a7b3db0..d6bff5386 100644 --- a/appshell/cef_dark_aero_window.h +++ b/appshell/cef_dark_aero_window.h @@ -23,7 +23,14 @@ #include "cef_dark_window.h" #include -#define CDW_UPDATEMENU WM_USER+1004 +// These are undocument 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); @@ -87,6 +94,7 @@ class cef_dark_aero_window : public cef_dark_window virtual void HiliteMenuItemAt(LPPOINT pt); virtual void UpdateNonClientArea(); + virtual void UpdateMenuBar(); virtual void InitDeviceContext(HDC hdc); diff --git a/appshell/cef_dark_window.cpp b/appshell/cef_dark_window.cpp index 26556f340..c165165b8 100644 --- a/appshell/cef_dark_window.cpp +++ b/appshell/cef_dark_window.cpp @@ -629,7 +629,7 @@ void cef_dark_window::DoDrawMenuBar(HDC hdc) // Put a breakpoint here and, If you hit this breakpoint and see a white line under the menubar // then you need to look in the output window and copy all of the Window Messages since the last // "Done Drawing Menu Bar" message and send them to jsbooher@adobe for analysis - ::OutputDebugStringA("Drawing Menu Bar\n"); + // ::OutputDebugStringA("Drawing Menu Bar\n"); HMENU menu = GetMenu(); int items = ::GetMenuItemCount(menu); @@ -682,7 +682,7 @@ void cef_dark_window::DoDrawMenuBar(HDC hdc) } } - ::OutputDebugStringA("Done Drawing Menu Bar\n"); + //::OutputDebugStringA("Done Drawing Menu Bar\n"); } // Paints the entire non-client area. From 9ea05fc85c4a69ec61fef2fe08757bed4a8fd63c Mon Sep 17 00:00:00 2001 From: JeffryBooher Date: Mon, 19 May 2014 09:27:30 -0700 Subject: [PATCH 09/13] remove debug code/fix white line --- appshell/cef_dark_aero_window.cpp | 7 +------ appshell/cef_dark_aero_window.h | 3 +-- appshell/cef_dark_window.cpp | 7 ------- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/appshell/cef_dark_aero_window.cpp b/appshell/cef_dark_aero_window.cpp index 315caf617..db7e86063 100644 --- a/appshell/cef_dark_aero_window.cpp +++ b/appshell/cef_dark_aero_window.cpp @@ -604,16 +604,11 @@ LRESULT cef_dark_aero_window::DwpCustomFrameProc(UINT message, WPARAM wParam, LP // 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) { - /* char szBuffer[256]; - ::sprintf (szBuffer, "Window Message %04x\n", message); - ::OutputDebugStringA(szBuffer); - */ bool callDefWindowProc = true; switch (message) { - case WM_UAHDRAWMENU: - UpdateMenuBar(); + case WM_NCPAINT: return 0L; case WM_MEASUREITEM: if (HandleMeasureItem((LPMEASUREITEMSTRUCT)lParam)) diff --git a/appshell/cef_dark_aero_window.h b/appshell/cef_dark_aero_window.h index d6bff5386..e2a2215a8 100644 --- a/appshell/cef_dark_aero_window.h +++ b/appshell/cef_dark_aero_window.h @@ -23,7 +23,7 @@ #include "cef_dark_window.h" #include -// These are undocument Aero messages +// Undocumented Aero Messages #define WM_UAHDESTROYWINDOW 0x0090 #define WM_UAHDRAWMENU 0x0091 #define WM_UAHDRAWMENUITEM 0x0092 @@ -31,7 +31,6 @@ #define WM_UAHMEASUREMENUITEM 0x0094 #define WM_UAHNCPAINTMENUPOPUP 0x0095 - // prototypes for DWM function pointers typedef HRESULT (STDAPICALLTYPE *PFNDWMEFICA)(HWND hWnd, __in const MARGINS* pMarInset); typedef BOOL (STDAPICALLTYPE *PFNDWMDWP)(__in HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, __out LRESULT *plResult); diff --git a/appshell/cef_dark_window.cpp b/appshell/cef_dark_window.cpp index c165165b8..785792f81 100644 --- a/appshell/cef_dark_window.cpp +++ b/appshell/cef_dark_window.cpp @@ -626,11 +626,6 @@ void cef_dark_window::InitDeviceContext(HDC hdc) // that the background has already been drawn using DoDrawFrame void cef_dark_window::DoDrawMenuBar(HDC hdc) { - // Put a breakpoint here and, If you hit this breakpoint and see a white line under the menubar - // then you need to look in the output window and copy all of the Window Messages since the last - // "Done Drawing Menu Bar" message and send them to jsbooher@adobe for analysis - // ::OutputDebugStringA("Drawing Menu Bar\n"); - HMENU menu = GetMenu(); int items = ::GetMenuItemCount(menu); @@ -681,8 +676,6 @@ void cef_dark_window::DoDrawMenuBar(HDC hdc) HandleDrawItem(&dis); } } - - //::OutputDebugStringA("Done Drawing Menu Bar\n"); } // Paints the entire non-client area. From eedf57152f1aa726c22e6d07dd36e76d5c324c8c Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Mon, 19 May 2014 13:43:21 -0700 Subject: [PATCH 10/13] revert change to override WM_NCPAINT --- appshell/cef_dark_aero_window.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/appshell/cef_dark_aero_window.cpp b/appshell/cef_dark_aero_window.cpp index db7e86063..5b669797c 100644 --- a/appshell/cef_dark_aero_window.cpp +++ b/appshell/cef_dark_aero_window.cpp @@ -608,8 +608,6 @@ LRESULT cef_dark_aero_window::WindowProc(UINT message, WPARAM wParam, LPARAM lPa switch (message) { - case WM_NCPAINT: - return 0L; case WM_MEASUREITEM: if (HandleMeasureItem((LPMEASUREITEMSTRUCT)lParam)) return 0L; From 22f9f553e5506416b2f27295a5aad7eafefe5645 Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Mon, 19 May 2014 14:22:52 -0700 Subject: [PATCH 11/13] Optimize Drawing and fix white line --- appshell/cef_dark_aero_window.cpp | 2 +- appshell/cef_main_window.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/appshell/cef_dark_aero_window.cpp b/appshell/cef_dark_aero_window.cpp index 5b669797c..31d90e247 100644 --- a/appshell/cef_dark_aero_window.cpp +++ b/appshell/cef_dark_aero_window.cpp @@ -546,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; } diff --git a/appshell/cef_main_window.cpp b/appshell/cef_main_window.cpp index 10f75c470..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)); From bada0eea3ac6b9bc4701d9929d25bfcd873b10cd Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Mon, 19 May 2014 14:55:34 -0700 Subject: [PATCH 12/13] Optimize Drawing and fix white line on popup windows --- appshell/cef_main_window.cpp | 2 +- appshell/cef_popup_window.cpp | 7 +++++++ appshell/cef_popup_window.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/appshell/cef_main_window.cpp b/appshell/cef_main_window.cpp index 4388074fd..5d3fd129d 100644 --- a/appshell/cef_main_window.cpp +++ b/appshell/cef_main_window.cpp @@ -69,7 +69,7 @@ ATOM cef_main_window::RegisterWndClass() wcex.hInstance = ::hInst; wcex.hIcon = ::LoadIcon(hInst, MAKEINTRESOURCE(IDI_CEFCLIENT)); wcex.hCursor = ::LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.hbrBackground = (HBRUSH)::CreateSolidBrush(CEF_COLOR_BACKGROUND_ACTIVE); wcex.lpszMenuName = MAKEINTRESOURCE(menuId); wcex.lpszClassName = ::kWindowClassname; wcex.hIconSm = ::LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); diff --git a/appshell/cef_popup_window.cpp b/appshell/cef_popup_window.cpp index 7aed3d645..8418d015a 100644 --- a/appshell/cef_popup_window.cpp +++ b/appshell/cef_popup_window.cpp @@ -95,6 +95,12 @@ void cef_popup_window::InitSystemIcon() } } +void cef_popup_window::SetClassStyles() +{ + SetClassLong(mWnd, GCL_STYLE, CS_SAVEBITS); + SetClassLong(mWnd, GCL_HBRBACKGROUND, (LONG)::CreateSolidBrush(CEF_COLOR_BACKGROUND_ACTIVE)); +} + // Subclasses the HWND and initializes the dark drawing code bool cef_popup_window::SubclassWindow(HWND wnd) { @@ -108,6 +114,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(); From c957c704887ee82226f549b416c653a751f25831 Mon Sep 17 00:00:00 2001 From: Jeff Booher Date: Mon, 19 May 2014 15:11:03 -0700 Subject: [PATCH 13/13] revert background brush --- appshell/cef_main_window.cpp | 2 +- appshell/cef_popup_window.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/appshell/cef_main_window.cpp b/appshell/cef_main_window.cpp index 5d3fd129d..4388074fd 100644 --- a/appshell/cef_main_window.cpp +++ b/appshell/cef_main_window.cpp @@ -69,7 +69,7 @@ ATOM cef_main_window::RegisterWndClass() wcex.hInstance = ::hInst; wcex.hIcon = ::LoadIcon(hInst, MAKEINTRESOURCE(IDI_CEFCLIENT)); wcex.hCursor = ::LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)::CreateSolidBrush(CEF_COLOR_BACKGROUND_ACTIVE); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = MAKEINTRESOURCE(menuId); wcex.lpszClassName = ::kWindowClassname; wcex.hIconSm = ::LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); diff --git a/appshell/cef_popup_window.cpp b/appshell/cef_popup_window.cpp index 8418d015a..7165958f6 100644 --- a/appshell/cef_popup_window.cpp +++ b/appshell/cef_popup_window.cpp @@ -98,7 +98,6 @@ void cef_popup_window::InitSystemIcon() void cef_popup_window::SetClassStyles() { SetClassLong(mWnd, GCL_STYLE, CS_SAVEBITS); - SetClassLong(mWnd, GCL_HBRBACKGROUND, (LONG)::CreateSolidBrush(CEF_COLOR_BACKGROUND_ACTIVE)); } // Subclasses the HWND and initializes the dark drawing code