| OLD | NEW |
| 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/win/hwnd_message_handler.h" | 5 #include "ui/views/win/hwnd_message_handler.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 #include <oleacc.h> | 8 #include <oleacc.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #include <tchar.h> | 10 #include <tchar.h> |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 HWNDMessageHandler::HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate) | 322 HWNDMessageHandler::HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate) |
| 323 : msg_handled_(FALSE), | 323 : msg_handled_(FALSE), |
| 324 delegate_(delegate), | 324 delegate_(delegate), |
| 325 fullscreen_handler_(new FullscreenHandler), | 325 fullscreen_handler_(new FullscreenHandler), |
| 326 waiting_for_close_now_(false), | 326 waiting_for_close_now_(false), |
| 327 use_system_default_icon_(false), | 327 use_system_default_icon_(false), |
| 328 restored_enabled_(false), | 328 restored_enabled_(false), |
| 329 current_cursor_(NULL), | 329 current_cursor_(NULL), |
| 330 previous_cursor_(NULL), | 330 previous_cursor_(NULL), |
| 331 dpi_(0), | 331 dpi_(0), |
| 332 called_enable_non_client_dpi_scaling_(false), |
| 332 active_mouse_tracking_flags_(0), | 333 active_mouse_tracking_flags_(0), |
| 333 is_right_mouse_pressed_on_caption_(false), | 334 is_right_mouse_pressed_on_caption_(false), |
| 334 lock_updates_count_(0), | 335 lock_updates_count_(0), |
| 335 ignore_window_pos_changes_(false), | 336 ignore_window_pos_changes_(false), |
| 336 last_monitor_(NULL), | 337 last_monitor_(NULL), |
| 337 is_first_nccalc_(true), | 338 is_first_nccalc_(true), |
| 338 menu_depth_(0), | 339 menu_depth_(0), |
| 339 id_generator_(0), | 340 id_generator_(0), |
| 340 in_size_loop_(false), | 341 in_size_loop_(false), |
| 341 touch_down_contexts_(0), | 342 touch_down_contexts_(0), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 355 } | 356 } |
| 356 | 357 |
| 357 void HWNDMessageHandler::Init(HWND parent, const gfx::Rect& bounds) { | 358 void HWNDMessageHandler::Init(HWND parent, const gfx::Rect& bounds) { |
| 358 TRACE_EVENT0("views", "HWNDMessageHandler::Init"); | 359 TRACE_EVENT0("views", "HWNDMessageHandler::Init"); |
| 359 GetMonitorAndRects(bounds.ToRECT(), &last_monitor_, &last_monitor_rect_, | 360 GetMonitorAndRects(bounds.ToRECT(), &last_monitor_, &last_monitor_rect_, |
| 360 &last_work_area_); | 361 &last_work_area_); |
| 361 | 362 |
| 362 // Create the window. | 363 // Create the window. |
| 363 WindowImpl::Init(parent, bounds); | 364 WindowImpl::Init(parent, bounds); |
| 364 | 365 |
| 365 if (delegate_->HasFrame() && base::win::IsProcessPerMonitorDpiAware()) { | 366 if (!called_enable_non_client_dpi_scaling_ && |
| 367 delegate_->HasFrame() && |
| 368 base::win::IsProcessPerMonitorDpiAware()) { |
| 366 static auto enable_child_window_dpi_message_func = []() { | 369 static auto enable_child_window_dpi_message_func = []() { |
| 367 // Derived signature; not available in headers. | 370 // Derived signature; not available in headers. |
| 368 // This call gets Windows to scale the non-client area when WM_DPICHANGED | 371 // This call gets Windows to scale the non-client area when WM_DPICHANGED |
| 369 // is fired. | 372 // is fired. |
| 370 using EnableChildWindowDpiMessagePtr = LRESULT (WINAPI*)(HWND, BOOL); | 373 using EnableChildWindowDpiMessagePtr = LRESULT (WINAPI*)(HWND, BOOL); |
| 371 return reinterpret_cast<EnableChildWindowDpiMessagePtr>( | 374 return reinterpret_cast<EnableChildWindowDpiMessagePtr>( |
| 372 GetProcAddress(GetModuleHandle(L"user32.dll"), | 375 GetProcAddress(GetModuleHandle(L"user32.dll"), |
| 373 "EnableChildWindowDpiMessage")); | 376 "EnableChildWindowDpiMessage")); |
| 374 }(); | 377 }(); |
| 375 if (enable_child_window_dpi_message_func) | 378 if (enable_child_window_dpi_message_func) |
| (...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1788 // pixels in the (now wrong) location, and thus makes actions like resizing a | 1791 // pixels in the (now wrong) location, and thus makes actions like resizing a |
| 1789 // window from the left edge look slightly less broken. | 1792 // window from the left edge look slightly less broken. |
| 1790 // We special case when left or top insets are 0, since these conditions | 1793 // We special case when left or top insets are 0, since these conditions |
| 1791 // actually require another repaint to correct the layout after glass gets | 1794 // actually require another repaint to correct the layout after glass gets |
| 1792 // turned on and off. | 1795 // turned on and off. |
| 1793 if (insets.left() == 0 || insets.top() == 0) | 1796 if (insets.left() == 0 || insets.top() == 0) |
| 1794 return 0; | 1797 return 0; |
| 1795 return mode ? WVR_REDRAW : 0; | 1798 return mode ? WVR_REDRAW : 0; |
| 1796 } | 1799 } |
| 1797 | 1800 |
| 1801 LRESULT HWNDMessageHandler::OnNCCreate(LPCREATESTRUCT lpCreateStruct) { |
| 1802 SetMsgHandled(FALSE); |
| 1803 if (delegate_->HasFrame() && base::win::IsProcessPerMonitorDpiAware()) { |
| 1804 static auto enable_non_client_dpi_scaling_func = []() { |
| 1805 // Signature only available in the 10.0.14393.0 API. As of this writing, |
| 1806 // Chrome built against 10.0.10586.0. |
| 1807 using EnableNonClientDpiScalingPtr = LRESULT (WINAPI*)(HWND); |
| 1808 return reinterpret_cast<EnableNonClientDpiScalingPtr>( |
| 1809 GetProcAddress(GetModuleHandle(L"user32.dll"), |
| 1810 "EnableNonClientDpiScaling")); |
| 1811 }(); |
| 1812 called_enable_non_client_dpi_scaling_ = |
| 1813 !!(enable_non_client_dpi_scaling_func && |
| 1814 enable_non_client_dpi_scaling_func(hwnd())); |
| 1815 } |
| 1816 return FALSE; |
| 1817 } |
| 1818 |
| 1798 LRESULT HWNDMessageHandler::OnNCHitTest(const gfx::Point& point) { | 1819 LRESULT HWNDMessageHandler::OnNCHitTest(const gfx::Point& point) { |
| 1799 if (!delegate_->HasNonClientView()) { | 1820 if (!delegate_->HasNonClientView()) { |
| 1800 SetMsgHandled(FALSE); | 1821 SetMsgHandled(FALSE); |
| 1801 return 0; | 1822 return 0; |
| 1802 } | 1823 } |
| 1803 | 1824 |
| 1804 // Some views may overlap the non client area of the window. | 1825 // Some views may overlap the non client area of the window. |
| 1805 // This means that we should look for these views before handing the | 1826 // This means that we should look for these views before handing the |
| 1806 // hittest message off to DWM or DefWindowProc. | 1827 // hittest message off to DWM or DefWindowProc. |
| 1807 // If the hittest returned from the search for a view returns HTCLIENT | 1828 // If the hittest returned from the search for a view returns HTCLIENT |
| (...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2755 MONITORINFO monitor_info = {sizeof(monitor_info)}; | 2776 MONITORINFO monitor_info = {sizeof(monitor_info)}; |
| 2756 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY), | 2777 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY), |
| 2757 &monitor_info); | 2778 &monitor_info); |
| 2758 gfx::Rect shrunk_rect(monitor_info.rcMonitor); | 2779 gfx::Rect shrunk_rect(monitor_info.rcMonitor); |
| 2759 shrunk_rect.set_height(shrunk_rect.height() - 1); | 2780 shrunk_rect.set_height(shrunk_rect.height() - 1); |
| 2760 background_fullscreen_hack_ = true; | 2781 background_fullscreen_hack_ = true; |
| 2761 SetBoundsInternal(shrunk_rect, false); | 2782 SetBoundsInternal(shrunk_rect, false); |
| 2762 } | 2783 } |
| 2763 | 2784 |
| 2764 } // namespace views | 2785 } // namespace views |
| OLD | NEW |