| 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 11 matching lines...) Expand all Loading... |
| 22 #include "base/win/scoped_gdi_object.h" | 22 #include "base/win/scoped_gdi_object.h" |
| 23 #include "base/win/windows_version.h" | 23 #include "base/win/windows_version.h" |
| 24 #include "ui/base/touch/touch_enabled.h" | 24 #include "ui/base/touch/touch_enabled.h" |
| 25 #include "ui/base/view_prop.h" | 25 #include "ui/base/view_prop.h" |
| 26 #include "ui/base/win/internal_constants.h" | 26 #include "ui/base/win/internal_constants.h" |
| 27 #include "ui/base/win/lock_state.h" | 27 #include "ui/base/win/lock_state.h" |
| 28 #include "ui/base/win/mouse_wheel_util.h" | 28 #include "ui/base/win/mouse_wheel_util.h" |
| 29 #include "ui/base/win/shell.h" | 29 #include "ui/base/win/shell.h" |
| 30 #include "ui/base/win/touch_input.h" | 30 #include "ui/base/win/touch_input.h" |
| 31 #include "ui/display/win/dpi.h" | 31 #include "ui/display/win/dpi.h" |
| 32 #include "ui/display/win/screen_win.h" |
| 32 #include "ui/events/event.h" | 33 #include "ui/events/event.h" |
| 33 #include "ui/events/event_utils.h" | 34 #include "ui/events/event_utils.h" |
| 34 #include "ui/events/keycodes/keyboard_code_conversion_win.h" | 35 #include "ui/events/keycodes/keyboard_code_conversion_win.h" |
| 35 #include "ui/events/win/system_event_state_lookup.h" | 36 #include "ui/events/win/system_event_state_lookup.h" |
| 36 #include "ui/gfx/canvas.h" | 37 #include "ui/gfx/canvas.h" |
| 37 #include "ui/gfx/geometry/insets.h" | 38 #include "ui/gfx/geometry/insets.h" |
| 38 #include "ui/gfx/icon_util.h" | 39 #include "ui/gfx/icon_util.h" |
| 39 #include "ui/gfx/path.h" | 40 #include "ui/gfx/path.h" |
| 40 #include "ui/gfx/path_win.h" | 41 #include "ui/gfx/path_win.h" |
| 41 #include "ui/gfx/win/direct_manipulation.h" | 42 #include "ui/gfx/win/direct_manipulation.h" |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 | 316 |
| 316 HWNDMessageHandler::HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate) | 317 HWNDMessageHandler::HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate) |
| 317 : msg_handled_(FALSE), | 318 : msg_handled_(FALSE), |
| 318 delegate_(delegate), | 319 delegate_(delegate), |
| 319 fullscreen_handler_(new FullscreenHandler), | 320 fullscreen_handler_(new FullscreenHandler), |
| 320 waiting_for_close_now_(false), | 321 waiting_for_close_now_(false), |
| 321 use_system_default_icon_(false), | 322 use_system_default_icon_(false), |
| 322 restored_enabled_(false), | 323 restored_enabled_(false), |
| 323 current_cursor_(NULL), | 324 current_cursor_(NULL), |
| 324 previous_cursor_(NULL), | 325 previous_cursor_(NULL), |
| 326 dpi_(0), |
| 325 active_mouse_tracking_flags_(0), | 327 active_mouse_tracking_flags_(0), |
| 326 is_right_mouse_pressed_on_caption_(false), | 328 is_right_mouse_pressed_on_caption_(false), |
| 327 lock_updates_count_(0), | 329 lock_updates_count_(0), |
| 328 ignore_window_pos_changes_(false), | 330 ignore_window_pos_changes_(false), |
| 329 last_monitor_(NULL), | 331 last_monitor_(NULL), |
| 330 is_first_nccalc_(true), | 332 is_first_nccalc_(true), |
| 331 menu_depth_(0), | 333 menu_depth_(0), |
| 332 id_generator_(0), | 334 id_generator_(0), |
| 333 needs_scroll_styles_(false), | 335 needs_scroll_styles_(false), |
| 334 in_size_loop_(false), | 336 in_size_loop_(false), |
| (...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1360 // receive a size notification when its initial bounds are specified at window | 1362 // receive a size notification when its initial bounds are specified at window |
| 1361 // creation time. | 1363 // creation time. |
| 1362 ClientAreaSizeChanged(); | 1364 ClientAreaSizeChanged(); |
| 1363 | 1365 |
| 1364 delegate_->HandleCreate(); | 1366 delegate_->HandleCreate(); |
| 1365 | 1367 |
| 1366 windows_session_change_observer_.reset(new WindowsSessionChangeObserver( | 1368 windows_session_change_observer_.reset(new WindowsSessionChangeObserver( |
| 1367 base::Bind(&HWNDMessageHandler::OnSessionChange, | 1369 base::Bind(&HWNDMessageHandler::OnSessionChange, |
| 1368 base::Unretained(this)))); | 1370 base::Unretained(this)))); |
| 1369 | 1371 |
| 1372 float scale_factor = display::win::ScreenWin::GetScaleFactorForHWND(hwnd()); |
| 1373 dpi_ = display::win::GetDPIFromScalingFactor(scale_factor); |
| 1374 |
| 1370 // TODO(beng): move more of NWW::OnCreate here. | 1375 // TODO(beng): move more of NWW::OnCreate here. |
| 1371 return 0; | 1376 return 0; |
| 1372 } | 1377 } |
| 1373 | 1378 |
| 1374 void HWNDMessageHandler::OnDestroy() { | 1379 void HWNDMessageHandler::OnDestroy() { |
| 1375 windows_session_change_observer_.reset(nullptr); | 1380 windows_session_change_observer_.reset(nullptr); |
| 1376 delegate_->HandleDestroying(); | 1381 delegate_->HandleDestroying(); |
| 1377 // If the window going away is a fullscreen window then remove its references | 1382 // If the window going away is a fullscreen window then remove its references |
| 1378 // from the full screen window map. | 1383 // from the full screen window map. |
| 1379 for (auto iter = fullscreen_monitor_map_.Get().begin(); | 1384 for (auto iter = fullscreen_monitor_map_.Get().begin(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1405 FrameTypeChanged(); | 1410 FrameTypeChanged(); |
| 1406 return 0; | 1411 return 0; |
| 1407 } | 1412 } |
| 1408 | 1413 |
| 1409 LRESULT HWNDMessageHandler::OnDpiChanged(UINT msg, | 1414 LRESULT HWNDMessageHandler::OnDpiChanged(UINT msg, |
| 1410 WPARAM w_param, | 1415 WPARAM w_param, |
| 1411 LPARAM l_param) { | 1416 LPARAM l_param) { |
| 1412 if (LOWORD(w_param) != HIWORD(w_param)) | 1417 if (LOWORD(w_param) != HIWORD(w_param)) |
| 1413 NOTIMPLEMENTED() << "Received non-square scaling factors"; | 1418 NOTIMPLEMENTED() << "Received non-square scaling factors"; |
| 1414 | 1419 |
| 1420 // The first WM_DPICHANGED originates from EnableChildWindowDpiMessage during |
| 1421 // initialization. We don't want to propagate this as the client is already |
| 1422 // set at the current scale factor and may cause the window to display too |
| 1423 // soon. See http://crbug.com/625076. |
| 1424 int dpi = LOWORD(w_param); |
| 1425 if (dpi_ == dpi) |
| 1426 return 0; |
| 1427 |
| 1428 dpi_ = dpi; |
| 1415 SetBoundsInternal(gfx::Rect(*reinterpret_cast<RECT*>(l_param)), false); | 1429 SetBoundsInternal(gfx::Rect(*reinterpret_cast<RECT*>(l_param)), false); |
| 1416 delegate_->HandleWindowScaleFactorChanged( | 1430 delegate_->HandleWindowScaleFactorChanged( |
| 1417 display::win::GetScalingFactorFromDPI(LOWORD(w_param))); | 1431 display::win::GetScalingFactorFromDPI(dpi_)); |
| 1418 return 0; | 1432 return 0; |
| 1419 } | 1433 } |
| 1420 | 1434 |
| 1421 void HWNDMessageHandler::OnEnterMenuLoop(BOOL from_track_popup_menu) { | 1435 void HWNDMessageHandler::OnEnterMenuLoop(BOOL from_track_popup_menu) { |
| 1422 if (menu_depth_++ == 0) | 1436 if (menu_depth_++ == 0) |
| 1423 delegate_->HandleMenuLoop(true); | 1437 delegate_->HandleMenuLoop(true); |
| 1424 } | 1438 } |
| 1425 | 1439 |
| 1426 void HWNDMessageHandler::OnEnterSizeMove() { | 1440 void HWNDMessageHandler::OnEnterSizeMove() { |
| 1427 // Please refer to the comments in the OnSize function about the scrollbar | 1441 // Please refer to the comments in the OnSize function about the scrollbar |
| (...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2758 MONITORINFO monitor_info = {sizeof(monitor_info)}; | 2772 MONITORINFO monitor_info = {sizeof(monitor_info)}; |
| 2759 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY), | 2773 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY), |
| 2760 &monitor_info); | 2774 &monitor_info); |
| 2761 gfx::Rect shrunk_rect(monitor_info.rcMonitor); | 2775 gfx::Rect shrunk_rect(monitor_info.rcMonitor); |
| 2762 shrunk_rect.set_height(shrunk_rect.height() - 1); | 2776 shrunk_rect.set_height(shrunk_rect.height() - 1); |
| 2763 background_fullscreen_hack_ = true; | 2777 background_fullscreen_hack_ = true; |
| 2764 SetBoundsInternal(shrunk_rect, false); | 2778 SetBoundsInternal(shrunk_rect, false); |
| 2765 } | 2779 } |
| 2766 | 2780 |
| 2767 } // namespace views | 2781 } // namespace views |
| OLD | NEW |