Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: ui/views/widget/hwnd_message_handler.cc

Issue 10828395: Move more message handlers from NativeWidgetWin to HWNDMessageHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/widget/hwnd_message_handler.h ('k') | ui/views/widget/native_widget_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/hwnd_message_handler.cc
===================================================================
--- ui/views/widget/hwnd_message_handler.cc (revision 152375)
+++ ui/views/widget/hwnd_message_handler.cc (working copy)
@@ -280,6 +280,13 @@
reinterpret_cast<LPARAM>(text));
}
+void HWNDMessageHandler::OnSize(UINT param, const CSize& size) {
+ RedrawWindow(hwnd(), NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN);
+ // ResetWindowRegion is going to trigger WM_NCPAINT. By doing it after we've
+ // invoked OnSize we ensure the RootView has been laid out.
+ ResetWindowRegion(false);
+}
+
void HWNDMessageHandler::OnThemeChanged() {
ui::NativeThemeWin::instance()->CloseHandles();
}
@@ -290,6 +297,48 @@
SetMsgHandled(FALSE);
}
+void HWNDMessageHandler::ResetWindowRegion(bool force) {
+ // A native frame uses the native window region, and we don't want to mess
+ // with it.
+ if (!delegate_->IsUsingCustomFrame() || !delegate_->IsWidgetWindow()) {
+ if (force)
+ SetWindowRgn(hwnd(), NULL, TRUE);
+ return;
+ }
+
+ // Changing the window region is going to force a paint. Only change the
+ // window region if the region really differs.
+ HRGN current_rgn = CreateRectRgn(0, 0, 0, 0);
+ int current_rgn_result = GetWindowRgn(hwnd(), current_rgn);
+
+ CRect window_rect;
+ GetWindowRect(hwnd(), &window_rect);
+ HRGN new_region;
+ if (delegate_->AsNativeWidgetWin()->IsMaximized()) {
+ HMONITOR monitor = MonitorFromWindow(hwnd(), MONITOR_DEFAULTTONEAREST);
+ MONITORINFO mi;
+ mi.cbSize = sizeof mi;
+ GetMonitorInfo(monitor, &mi);
+ CRect work_rect = mi.rcWork;
+ work_rect.OffsetRect(-window_rect.left, -window_rect.top);
+ new_region = CreateRectRgnIndirect(&work_rect);
+ } else {
+ gfx::Path window_mask;
+ delegate_->GetWindowMask(
+ gfx::Size(window_rect.Width(), window_rect.Height()), &window_mask);
+ new_region = window_mask.CreateNativeRegion();
+ }
+
+ if (current_rgn_result == ERROR || !EqualRgn(current_rgn, new_region)) {
+ // SetWindowRgn takes ownership of the HRGN created by CreateNativeRegion.
+ SetWindowRgn(hwnd(), new_region, TRUE);
+ } else {
+ DeleteObject(new_region);
+ }
+
+ DeleteObject(current_rgn);
+}
+
////////////////////////////////////////////////////////////////////////////////
// HWNDMessageHandler, private:
« no previous file with comments | « ui/views/widget/hwnd_message_handler.h ('k') | ui/views/widget/native_widget_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698