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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/hwnd_message_handler.h" 5 #include "ui/views/widget/hwnd_message_handler.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 8
9 #include "base/system_monitor/system_monitor.h" 9 #include "base/system_monitor/system_monitor.h"
10 #include "ui/gfx/path.h" 10 #include "ui/gfx/path.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 return DefWindowProcWithRedrawLock(WM_SETICON, size_type, 273 return DefWindowProcWithRedrawLock(WM_SETICON, size_type,
274 reinterpret_cast<LPARAM>(new_icon)); 274 reinterpret_cast<LPARAM>(new_icon));
275 } 275 }
276 276
277 LRESULT HWNDMessageHandler::OnSetText(const wchar_t* text) { 277 LRESULT HWNDMessageHandler::OnSetText(const wchar_t* text) {
278 // Use a ScopedRedrawLock to avoid weird non-client painting. 278 // Use a ScopedRedrawLock to avoid weird non-client painting.
279 return DefWindowProcWithRedrawLock(WM_SETTEXT, NULL, 279 return DefWindowProcWithRedrawLock(WM_SETTEXT, NULL,
280 reinterpret_cast<LPARAM>(text)); 280 reinterpret_cast<LPARAM>(text));
281 } 281 }
282 282
283 void HWNDMessageHandler::OnSize(UINT param, const CSize& size) {
284 RedrawWindow(hwnd(), NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN);
285 // ResetWindowRegion is going to trigger WM_NCPAINT. By doing it after we've
286 // invoked OnSize we ensure the RootView has been laid out.
287 ResetWindowRegion(false);
288 }
289
283 void HWNDMessageHandler::OnThemeChanged() { 290 void HWNDMessageHandler::OnThemeChanged() {
284 ui::NativeThemeWin::instance()->CloseHandles(); 291 ui::NativeThemeWin::instance()->CloseHandles();
285 } 292 }
286 293
287 void HWNDMessageHandler::OnVScroll(int scroll_type, 294 void HWNDMessageHandler::OnVScroll(int scroll_type,
288 short position, 295 short position,
289 HWND scrollbar) { 296 HWND scrollbar) {
290 SetMsgHandled(FALSE); 297 SetMsgHandled(FALSE);
291 } 298 }
292 299
300 void HWNDMessageHandler::ResetWindowRegion(bool force) {
301 // A native frame uses the native window region, and we don't want to mess
302 // with it.
303 if (!delegate_->IsUsingCustomFrame() || !delegate_->IsWidgetWindow()) {
304 if (force)
305 SetWindowRgn(hwnd(), NULL, TRUE);
306 return;
307 }
308
309 // Changing the window region is going to force a paint. Only change the
310 // window region if the region really differs.
311 HRGN current_rgn = CreateRectRgn(0, 0, 0, 0);
312 int current_rgn_result = GetWindowRgn(hwnd(), current_rgn);
313
314 CRect window_rect;
315 GetWindowRect(hwnd(), &window_rect);
316 HRGN new_region;
317 if (delegate_->AsNativeWidgetWin()->IsMaximized()) {
318 HMONITOR monitor = MonitorFromWindow(hwnd(), MONITOR_DEFAULTTONEAREST);
319 MONITORINFO mi;
320 mi.cbSize = sizeof mi;
321 GetMonitorInfo(monitor, &mi);
322 CRect work_rect = mi.rcWork;
323 work_rect.OffsetRect(-window_rect.left, -window_rect.top);
324 new_region = CreateRectRgnIndirect(&work_rect);
325 } else {
326 gfx::Path window_mask;
327 delegate_->GetWindowMask(
328 gfx::Size(window_rect.Width(), window_rect.Height()), &window_mask);
329 new_region = window_mask.CreateNativeRegion();
330 }
331
332 if (current_rgn_result == ERROR || !EqualRgn(current_rgn, new_region)) {
333 // SetWindowRgn takes ownership of the HRGN created by CreateNativeRegion.
334 SetWindowRgn(hwnd(), new_region, TRUE);
335 } else {
336 DeleteObject(new_region);
337 }
338
339 DeleteObject(current_rgn);
340 }
341
293 //////////////////////////////////////////////////////////////////////////////// 342 ////////////////////////////////////////////////////////////////////////////////
294 // HWNDMessageHandler, private: 343 // HWNDMessageHandler, private:
295 344
296 HWND HWNDMessageHandler::hwnd() { 345 HWND HWNDMessageHandler::hwnd() {
297 return delegate_->AsNativeWidgetWin()->hwnd(); 346 return delegate_->AsNativeWidgetWin()->hwnd();
298 } 347 }
299 348
300 LRESULT HWNDMessageHandler::DefWindowProcWithRedrawLock(UINT message, 349 LRESULT HWNDMessageHandler::DefWindowProcWithRedrawLock(UINT message,
301 WPARAM w_param, 350 WPARAM w_param,
302 LPARAM l_param) { 351 LPARAM l_param) {
303 return delegate_->AsNativeWidgetWin()->DefWindowProcWithRedrawLock(message, 352 return delegate_->AsNativeWidgetWin()->DefWindowProcWithRedrawLock(message,
304 w_param, 353 w_param,
305 l_param); 354 l_param);
306 } 355 }
307 356
308 void HWNDMessageHandler::SetMsgHandled(BOOL handled) { 357 void HWNDMessageHandler::SetMsgHandled(BOOL handled) {
309 delegate_->AsNativeWidgetWin()->SetMsgHandled(handled); 358 delegate_->AsNativeWidgetWin()->SetMsgHandled(handled);
310 } 359 }
311 360
312 } // namespace views 361 } // namespace views
313 362
OLDNEW
« 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