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

Restored secondary windows need repainting #347

Merged
merged 2 commits into from
Oct 3, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions appshell/cef_host_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,45 @@ BOOL cef_host_window::DoCommand(UINT commandId, CefRefPtr<CommandCallback> callb
return DoCommand(commandString, callback);
}

// WM_SIZE handler
BOOL cef_host_window::HandleSize(BOOL bMinimize)
{
#ifdef DARK_UI
// We turn off redraw during activation to minimized flicker
// which causes problems on some versions of Windows. If the app
// was minimized and was re-activated, it will restore and the client area isn't
// drawn so redraw the client area now or it will be hollow in the middle...
if (GetProp(L"WasMinimized")) {
DoRepaintClientArea();
}
SetProp(L"WasMinimized", (HANDLE)bMinimize);
#endif

return FALSE;
}

void cef_host_window::DoRepaintClientArea()
{
CefWindowHandle hwnd = SafeGetCefBrowserHwnd();
if (!hwnd)
return;

RECT rect;
GetClientRect(&rect);

::RedrawWindow(hwnd, &rect, NULL, RDW_ERASE|RDW_INTERNALPAINT|RDW_INVALIDATE|RDW_ERASENOW|RDW_UPDATENOW|RDW_ALLCHILDREN);
}


// Window Proc dispatches window messages
LRESULT cef_host_window::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_SIZE:
if (HandleSize(wParam == SIZE_MINIMIZED))
return 0L;
break;
case WM_INITMENUPOPUP:
if (HandleInitMenuPopup((HMENU)wParam))
return 0L;
Expand Down
4 changes: 4 additions & 0 deletions appshell/cef_host_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ class cef_host_window : public cef_host_window_base

// Message Handlers
BOOL HandleInitMenuPopup(HMENU hMenuPopup);
BOOL HandleSize(BOOL bMinimize);

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

// Implementation
virtual void DoRepaintClientArea();

// Helper to get a command string from command id
CefString GetCommandString(UINT commandId);
};
68 changes: 22 additions & 46 deletions appshell/cef_main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,52 +265,6 @@ BOOL cef_main_window::HandleExitCommand()
return TRUE;
}

// WM_SIZE handler
BOOL cef_main_window::HandleSize(BOOL bMinimize)
{
// Minimizing the window to 0x0 which causes our layout to go all
// screwy, so we just ignore it.
CefWindowHandle hwnd = SafeGetCefBrowserHwnd();
if (!hwnd)
return FALSE;

RECT rect;
GetClientRect(&rect);

if (!bMinimize)
{
HDWP hdwp = ::BeginDeferWindowPos(1);
hdwp = ::DeferWindowPos(hdwp, hwnd, NULL, rect.left, rect.top, ::RectWidth(rect), ::RectHeight(rect), SWP_NOZORDER);
::EndDeferWindowPos(hdwp);
}

#ifdef DARK_UI
// We turn off redraw during activation to minimized flicker
// which causes problems on some versions of Windows. If the app
// was minimized and was re-activated, it will restore and the client area isn't
// drawn so redraw the client area now or it will be hollow in the middle...
if (GetProp(L"WasMinimized")) {
DoRepaintClientArea();
}
SetProp(L"WasMinimized", (HANDLE)bMinimize);
#endif

return FALSE;
}

void cef_main_window::DoRepaintClientArea()
{
CefWindowHandle hwnd = SafeGetCefBrowserHwnd();
if (!hwnd)
return;

RECT rect;
GetClientRect(&rect);

::RedrawWindow(hwnd, &rect, NULL, RDW_ERASE|RDW_INTERNALPAINT|RDW_INVALIDATE|RDW_ERASENOW|RDW_UPDATENOW|RDW_ALLCHILDREN);
}


// WM_COMMAND handler
BOOL cef_main_window::HandleCommand(UINT commandId)
{
Expand Down Expand Up @@ -459,6 +413,28 @@ HWND cef_main_window::FindFirstTopLevelInstance()
return hFirstInstanceWnd;
}

// WM_SIZE handler
BOOL cef_main_window::HandleSize(BOOL bMinimize)
{
// Minimizing the window to 0x0 which causes our layout to go all
// screwy, so we just ignore it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should be right above the line if (!bMinimize).

CefWindowHandle hwnd = SafeGetCefBrowserHwnd();
if (!hwnd)
return FALSE;

RECT rect;
GetClientRect(&rect);

if (!bMinimize)
{
HDWP hdwp = ::BeginDeferWindowPos(1);
hdwp = ::DeferWindowPos(hdwp, hwnd, NULL, rect.left, rect.top, ::RectWidth(rect), ::RectHeight(rect), SWP_NOZORDER);
::EndDeferWindowPos(hdwp);
}

return FALSE;
}

// WindowProc -- Dispatches and routes window messages
LRESULT cef_main_window::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
Expand Down
3 changes: 1 addition & 2 deletions appshell/cef_main_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,18 @@ class cef_main_window : public cef_host_window
BOOL HandleSetFocus(HWND hLosingFocus);
BOOL HandleDestroy();
BOOL HandleClose();
BOOL HandleSize(BOOL bMinimize);
BOOL HandleInitMenuPopup(HMENU hMenuPopup);
BOOL HandleCommand(UINT commandId);
BOOL HandleExitCommand();
BOOL HandlePaint();
BOOL HandleGetMinMaxInfo(LPMINMAXINFO mmi);
BOOL HandleCopyData(HWND, PCOPYDATASTRUCT lpCopyData);
BOOL HandleSize(BOOL bMinimize);

// Implementation
virtual void PostNcDestroy();
virtual void GetCefBrowserRect(RECT& rect);
virtual const CefRefPtr<CefBrowser> GetBrowser();
virtual void DoRepaintClientArea();

// Find helper
static BOOL CALLBACK FindSuitableBracketsInstanceHelper(HWND hwnd, LPARAM lParam);
Expand Down