Skip to content
This repository was archived by the owner on Sep 2, 2021. It is now read-only.

Commit 48323ec

Browse files
committed
Merge pull request #347 from adobe/jeff/fix-5252
Restored secondary windows need repainting
2 parents 058f2ef + ceed162 commit 48323ec

File tree

4 files changed

+61
-48
lines changed

4 files changed

+61
-48
lines changed

appshell/cef_host_window.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,45 @@ BOOL cef_host_window::DoCommand(UINT commandId, CefRefPtr<CommandCallback> callb
9090
return DoCommand(commandString, callback);
9191
}
9292

93+
// WM_SIZE handler
94+
BOOL cef_host_window::HandleSize(BOOL bMinimize)
95+
{
96+
#ifdef DARK_UI
97+
// We turn off redraw during activation to minimized flicker
98+
// which causes problems on some versions of Windows. If the app
99+
// was minimized and was re-activated, it will restore and the client area isn't
100+
// drawn so redraw the client area now or it will be hollow in the middle...
101+
if (GetProp(L"WasMinimized")) {
102+
DoRepaintClientArea();
103+
}
104+
SetProp(L"WasMinimized", (HANDLE)bMinimize);
105+
#endif
106+
107+
return FALSE;
108+
}
109+
110+
void cef_host_window::DoRepaintClientArea()
111+
{
112+
CefWindowHandle hwnd = SafeGetCefBrowserHwnd();
113+
if (!hwnd)
114+
return;
115+
116+
RECT rect;
117+
GetClientRect(&rect);
118+
119+
::RedrawWindow(hwnd, &rect, NULL, RDW_ERASE|RDW_INTERNALPAINT|RDW_INVALIDATE|RDW_ERASENOW|RDW_UPDATENOW|RDW_ALLCHILDREN);
120+
}
121+
122+
93123
// Window Proc dispatches window messages
94124
LRESULT cef_host_window::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
95125
{
96126
switch (message)
97127
{
128+
case WM_SIZE:
129+
if (HandleSize(wParam == SIZE_MINIMIZED))
130+
return 0L;
131+
break;
98132
case WM_INITMENUPOPUP:
99133
if (HandleInitMenuPopup((HMENU)wParam))
100134
return 0L;

appshell/cef_host_window.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,15 @@ class cef_host_window : public cef_host_window_base
5151

5252
// Message Handlers
5353
BOOL HandleInitMenuPopup(HMENU hMenuPopup);
54+
BOOL HandleSize(BOOL bMinimize);
5455

5556
// Command Implementation
5657
BOOL DoCommand(UINT commandId, CefRefPtr<CommandCallback> callback = 0);
5758
BOOL DoCommand(const CefString& commandString, CefRefPtr<CommandCallback> callback = 0);
5859

60+
// Implementation
61+
virtual void DoRepaintClientArea();
62+
5963
// Helper to get a command string from command id
6064
CefString GetCommandString(UINT commandId);
6165
};

appshell/cef_main_window.cpp

Lines changed: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -265,52 +265,6 @@ BOOL cef_main_window::HandleExitCommand()
265265
return TRUE;
266266
}
267267

268-
// WM_SIZE handler
269-
BOOL cef_main_window::HandleSize(BOOL bMinimize)
270-
{
271-
// Minimizing the window to 0x0 which causes our layout to go all
272-
// screwy, so we just ignore it.
273-
CefWindowHandle hwnd = SafeGetCefBrowserHwnd();
274-
if (!hwnd)
275-
return FALSE;
276-
277-
RECT rect;
278-
GetClientRect(&rect);
279-
280-
if (!bMinimize)
281-
{
282-
HDWP hdwp = ::BeginDeferWindowPos(1);
283-
hdwp = ::DeferWindowPos(hdwp, hwnd, NULL, rect.left, rect.top, ::RectWidth(rect), ::RectHeight(rect), SWP_NOZORDER);
284-
::EndDeferWindowPos(hdwp);
285-
}
286-
287-
#ifdef DARK_UI
288-
// We turn off redraw during activation to minimized flicker
289-
// which causes problems on some versions of Windows. If the app
290-
// was minimized and was re-activated, it will restore and the client area isn't
291-
// drawn so redraw the client area now or it will be hollow in the middle...
292-
if (GetProp(L"WasMinimized")) {
293-
DoRepaintClientArea();
294-
}
295-
SetProp(L"WasMinimized", (HANDLE)bMinimize);
296-
#endif
297-
298-
return FALSE;
299-
}
300-
301-
void cef_main_window::DoRepaintClientArea()
302-
{
303-
CefWindowHandle hwnd = SafeGetCefBrowserHwnd();
304-
if (!hwnd)
305-
return;
306-
307-
RECT rect;
308-
GetClientRect(&rect);
309-
310-
::RedrawWindow(hwnd, &rect, NULL, RDW_ERASE|RDW_INTERNALPAINT|RDW_INVALIDATE|RDW_ERASENOW|RDW_UPDATENOW|RDW_ALLCHILDREN);
311-
}
312-
313-
314268
// WM_COMMAND handler
315269
BOOL cef_main_window::HandleCommand(UINT commandId)
316270
{
@@ -459,6 +413,28 @@ HWND cef_main_window::FindFirstTopLevelInstance()
459413
return hFirstInstanceWnd;
460414
}
461415

416+
// WM_SIZE handler
417+
BOOL cef_main_window::HandleSize(BOOL bMinimize)
418+
{
419+
CefWindowHandle hwnd = SafeGetCefBrowserHwnd();
420+
if (!hwnd)
421+
return FALSE;
422+
423+
RECT rect;
424+
GetClientRect(&rect);
425+
426+
// Minimizing the window to 0x0 which causes our layout to go all
427+
// screwy, so we just ignore it.
428+
if (!bMinimize)
429+
{
430+
HDWP hdwp = ::BeginDeferWindowPos(1);
431+
hdwp = ::DeferWindowPos(hdwp, hwnd, NULL, rect.left, rect.top, ::RectWidth(rect), ::RectHeight(rect), SWP_NOZORDER);
432+
::EndDeferWindowPos(hdwp);
433+
}
434+
435+
return FALSE;
436+
}
437+
462438
// WindowProc -- Dispatches and routes window messages
463439
LRESULT cef_main_window::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
464440
{

appshell/cef_main_window.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,18 @@ class cef_main_window : public cef_host_window
5454
BOOL HandleSetFocus(HWND hLosingFocus);
5555
BOOL HandleDestroy();
5656
BOOL HandleClose();
57-
BOOL HandleSize(BOOL bMinimize);
5857
BOOL HandleInitMenuPopup(HMENU hMenuPopup);
5958
BOOL HandleCommand(UINT commandId);
6059
BOOL HandleExitCommand();
6160
BOOL HandlePaint();
6261
BOOL HandleGetMinMaxInfo(LPMINMAXINFO mmi);
6362
BOOL HandleCopyData(HWND, PCOPYDATASTRUCT lpCopyData);
63+
BOOL HandleSize(BOOL bMinimize);
6464

6565
// Implementation
6666
virtual void PostNcDestroy();
6767
virtual void GetCefBrowserRect(RECT& rect);
6868
virtual const CefRefPtr<CefBrowser> GetBrowser();
69-
virtual void DoRepaintClientArea();
7069

7170
// Find helper
7271
static BOOL CALLBACK FindSuitableBracketsInstanceHelper(HWND hwnd, LPARAM lParam);

0 commit comments

Comments
 (0)