| 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 <shellapi.h> | 8 #include <shellapi.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 // If we're in fullscreen mode, we've changed the normal bounds to the monitor | 490 // If we're in fullscreen mode, we've changed the normal bounds to the monitor |
| 491 // rect, so return the saved bounds instead. | 491 // rect, so return the saved bounds instead. |
| 492 if (fullscreen_handler_->fullscreen()) | 492 if (fullscreen_handler_->fullscreen()) |
| 493 return fullscreen_handler_->GetRestoreBounds(); | 493 return fullscreen_handler_->GetRestoreBounds(); |
| 494 | 494 |
| 495 gfx::Rect bounds; | 495 gfx::Rect bounds; |
| 496 GetWindowPlacement(&bounds, NULL); | 496 GetWindowPlacement(&bounds, NULL); |
| 497 return bounds; | 497 return bounds; |
| 498 } | 498 } |
| 499 | 499 |
| 500 gfx::Rect HWNDMessageHandler::GetClientAreaBounds() const { |
| 501 if (IsMinimized()) |
| 502 return gfx::Rect(); |
| 503 if (delegate_->WidgetSizeIsClientSize()) |
| 504 return GetClientAreaBoundsInScreen(); |
| 505 return GetWindowBoundsInScreen(); |
| 506 } |
| 507 |
| 500 void HWNDMessageHandler::GetWindowPlacement( | 508 void HWNDMessageHandler::GetWindowPlacement( |
| 501 gfx::Rect* bounds, | 509 gfx::Rect* bounds, |
| 502 ui::WindowShowState* show_state) const { | 510 ui::WindowShowState* show_state) const { |
| 503 WINDOWPLACEMENT wp; | 511 WINDOWPLACEMENT wp; |
| 504 wp.length = sizeof(wp); | 512 wp.length = sizeof(wp); |
| 505 const bool succeeded = !!::GetWindowPlacement(hwnd(), &wp); | 513 const bool succeeded = !!::GetWindowPlacement(hwnd(), &wp); |
| 506 DCHECK(succeeded); | 514 DCHECK(succeeded); |
| 507 | 515 |
| 508 if (bounds != NULL) { | 516 if (bounds != NULL) { |
| 509 if (wp.showCmd == SW_SHOWNORMAL) { | 517 if (wp.showCmd == SW_SHOWNORMAL) { |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 tme.hwndTrack = hwnd(); | 1072 tme.hwndTrack = hwnd(); |
| 1065 tme.dwHoverTime = 0; | 1073 tme.dwHoverTime = 0; |
| 1066 TrackMouseEvent(&tme); | 1074 TrackMouseEvent(&tme); |
| 1067 } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { | 1075 } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { |
| 1068 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); | 1076 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); |
| 1069 TrackMouseEvents(mouse_tracking_flags); | 1077 TrackMouseEvents(mouse_tracking_flags); |
| 1070 } | 1078 } |
| 1071 } | 1079 } |
| 1072 | 1080 |
| 1073 void HWNDMessageHandler::ClientAreaSizeChanged() { | 1081 void HWNDMessageHandler::ClientAreaSizeChanged() { |
| 1074 RECT r = {0, 0, 0, 0}; | 1082 gfx::Size s = GetClientAreaBounds().size(); |
| 1075 // In case of minimized window GetWindowRect can return normally unexpected | |
| 1076 // coordinates. | |
| 1077 if (!IsMinimized()) { | |
| 1078 if (delegate_->WidgetSizeIsClientSize()) | |
| 1079 GetClientRect(hwnd(), &r); | |
| 1080 else | |
| 1081 GetWindowRect(hwnd(), &r); | |
| 1082 } | |
| 1083 gfx::Size s(std::max(0, static_cast<int>(r.right - r.left)), | |
| 1084 std::max(0, static_cast<int>(r.bottom - r.top))); | |
| 1085 delegate_->HandleClientSizeChanged(s); | 1083 delegate_->HandleClientSizeChanged(s); |
| 1086 if (use_layered_buffer_) | 1084 if (use_layered_buffer_) |
| 1087 layered_window_contents_.reset(new gfx::Canvas(s, 1.0f, false)); | 1085 layered_window_contents_.reset(new gfx::Canvas(s, 1.0f, false)); |
| 1088 } | 1086 } |
| 1089 | 1087 |
| 1090 bool HWNDMessageHandler::GetClientAreaInsets(gfx::Insets* insets) const { | 1088 bool HWNDMessageHandler::GetClientAreaInsets(gfx::Insets* insets) const { |
| 1091 if (delegate_->GetClientAreaInsets(insets)) | 1089 if (delegate_->GetClientAreaInsets(insets)) |
| 1092 return true; | 1090 return true; |
| 1093 DCHECK(insets->empty()); | 1091 DCHECK(insets->empty()); |
| 1094 | 1092 |
| (...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2315 SetMsgHandled(FALSE); | 2313 SetMsgHandled(FALSE); |
| 2316 } | 2314 } |
| 2317 | 2315 |
| 2318 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { | 2316 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { |
| 2319 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); | 2317 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); |
| 2320 for (size_t i = 0; i < touch_events.size() && ref; ++i) | 2318 for (size_t i = 0; i < touch_events.size() && ref; ++i) |
| 2321 delegate_->HandleTouchEvent(touch_events[i]); | 2319 delegate_->HandleTouchEvent(touch_events[i]); |
| 2322 } | 2320 } |
| 2323 | 2321 |
| 2324 } // namespace views | 2322 } // namespace views |
| OLD | NEW |