Windows: Set browser window size to 0x0 when minimized to reduce resource usage (issue #1369).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1820 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
df2242aff2
commit
6308a7e03b
|
@ -589,13 +589,15 @@ LRESULT CALLBACK CefBrowserHostImpl::WndProc(HWND hwnd, UINT message,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
// Minimizing resizes the window to 0x0 which causes our layout to go all
|
if (browser && browser->window_widget_) {
|
||||||
// screwy, so we just ignore it.
|
// Pass window resize events to the HWND for the DesktopNativeWidgetAura
|
||||||
if (wParam != SIZE_MINIMIZED && browser && browser->window_widget_) {
|
// root window. Passing size 0x0 (wParam == SIZE_MINIMIZED, for example)
|
||||||
// Resize the Widget window to the full size of the browser window.
|
// will cause the widget to be hidden which reduces resource usage.
|
||||||
RECT rc;
|
RECT rc;
|
||||||
GetClientRect(hwnd, &rc);
|
GetClientRect(hwnd, &rc);
|
||||||
browser->window_widget_->SetSize(gfx::Size(rc.right, rc.bottom));
|
SetWindowPos(HWNDForWidget(browser->window_widget_), NULL,
|
||||||
|
rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
|
||||||
|
SWP_NOZORDER);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -596,26 +596,33 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_SIZE:
|
case WM_SIZE: {
|
||||||
if (!g_handler.get())
|
if (!g_handler.get())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Mark the off-screen browser as hidden when the frame window is
|
// For off-screen browsers when the frame window is minimized set the
|
||||||
// minimized to reduce resource usage.
|
// browser as hidden to reduce resource usage.
|
||||||
if (AppIsOffScreenRenderingEnabled()) {
|
const bool offscreen = AppIsOffScreenRenderingEnabled();
|
||||||
|
if (offscreen) {
|
||||||
CefRefPtr<OSRWindow> osr_window =
|
CefRefPtr<OSRWindow> osr_window =
|
||||||
static_cast<OSRWindow*>(g_handler->GetOSRHandler().get());
|
static_cast<OSRWindow*>(g_handler->GetOSRHandler().get());
|
||||||
if (osr_window)
|
if (osr_window)
|
||||||
osr_window->WasHidden(wParam == SIZE_MINIMIZED);
|
osr_window->WasHidden(wParam == SIZE_MINIMIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't resize the window if minimizing because the resulting size of 0x0
|
if (g_handler->GetBrowser()) {
|
||||||
// causes the layout to go all screwy.
|
|
||||||
if (wParam != SIZE_MINIMIZED && g_handler->GetBrowser()) {
|
|
||||||
// Retrieve the window handle (parent window with off-screen rendering).
|
// Retrieve the window handle (parent window with off-screen rendering).
|
||||||
CefWindowHandle hwnd =
|
CefWindowHandle hwnd =
|
||||||
g_handler->GetBrowser()->GetHost()->GetWindowHandle();
|
g_handler->GetBrowser()->GetHost()->GetWindowHandle();
|
||||||
if (hwnd) {
|
if (hwnd) {
|
||||||
|
if (wParam == SIZE_MINIMIZED) {
|
||||||
|
// For windowed browsers when the frame window is minimized set the
|
||||||
|
// browser window size to 0x0 to reduce resource usage.
|
||||||
|
if (!offscreen) {
|
||||||
|
SetWindowPos(hwnd, NULL,
|
||||||
|
0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// Resize the window and address bar to match the new frame size.
|
// Resize the window and address bar to match the new frame size.
|
||||||
RECT rect;
|
RECT rect;
|
||||||
GetClientRect(hWnd, &rect);
|
GetClientRect(hWnd, &rect);
|
||||||
|
@ -627,12 +634,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||||
hdwp = DeferWindowPos(hdwp, editWnd, NULL, urloffset,
|
hdwp = DeferWindowPos(hdwp, editWnd, NULL, urloffset,
|
||||||
0, rect.right - urloffset, URLBAR_HEIGHT, SWP_NOZORDER);
|
0, rect.right - urloffset, URLBAR_HEIGHT, SWP_NOZORDER);
|
||||||
hdwp = DeferWindowPos(hdwp, hwnd, NULL,
|
hdwp = DeferWindowPos(hdwp, hwnd, NULL,
|
||||||
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
|
rect.left, rect.top, rect.right - rect.left,
|
||||||
SWP_NOZORDER);
|
rect.bottom - rect.top, SWP_NOZORDER);
|
||||||
EndDeferWindowPos(hdwp);
|
EndDeferWindowPos(hdwp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
case WM_ERASEBKGND:
|
case WM_ERASEBKGND:
|
||||||
if (g_handler.get() && g_handler->GetBrowser()) {
|
if (g_handler.get() && g_handler->GetBrowser()) {
|
||||||
|
|
Loading…
Reference in New Issue