| 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/aura/window_tree_host_win.h" | 5 #include "ui/aura/window_tree_host_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "ui/aura/client/cursor_client.h" | 12 #include "ui/aura/client/cursor_client.h" |
| 13 #include "ui/aura/window_event_dispatcher.h" | 13 #include "ui/aura/window_event_dispatcher.h" |
| 14 #include "ui/base/cursor/cursor_loader_win.h" | 14 #include "ui/base/cursor/cursor_loader_win.h" |
| 15 #include "ui/base/view_prop.h" | 15 #include "ui/base/view_prop.h" |
| 16 #include "ui/compositor/compositor.h" | |
| 17 #include "ui/events/event.h" | 16 #include "ui/events/event.h" |
| 18 #include "ui/gfx/display.h" | 17 #include "ui/gfx/display.h" |
| 19 #include "ui/gfx/insets.h" | 18 #include "ui/gfx/insets.h" |
| 20 #include "ui/gfx/screen.h" | 19 #include "ui/gfx/screen.h" |
| 21 | 20 |
| 22 using std::max; | 21 using std::max; |
| 23 using std::min; | 22 using std::min; |
| 24 | 23 |
| 25 namespace aura { | 24 namespace aura { |
| 26 namespace { | 25 namespace { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 NULL, | 127 NULL, |
| 129 window_rect.left, | 128 window_rect.left, |
| 130 window_rect.top, | 129 window_rect.top, |
| 131 window_rect.right - window_rect.left, | 130 window_rect.right - window_rect.left, |
| 132 window_rect.bottom - window_rect.top, | 131 window_rect.bottom - window_rect.top, |
| 133 SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOREPOSITION); | 132 SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOREPOSITION); |
| 134 | 133 |
| 135 // Explicity call OnHostResized when the scale has changed because | 134 // Explicity call OnHostResized when the scale has changed because |
| 136 // the window size may not have changed. | 135 // the window size may not have changed. |
| 137 float current_scale = compositor()->device_scale_factor(); | 136 float current_scale = compositor()->device_scale_factor(); |
| 138 float new_scale = gfx::Screen::GetScreenFor(window())-> | 137 float new_scale = gfx::Screen::GetScreenFor( |
| 139 GetDisplayNearestWindow(window()).device_scale_factor(); | 138 delegate_->AsDispatcher()->window())->GetDisplayNearestWindow( |
| 139 delegate_->AsDispatcher()->window()).device_scale_factor(); |
| 140 if (current_scale != new_scale) | 140 if (current_scale != new_scale) |
| 141 OnHostResized(bounds.size()); | 141 OnHostResized(bounds.size()); |
| 142 } | 142 } |
| 143 | 143 |
| 144 gfx::Insets WindowTreeHostWin::GetInsets() const { | 144 gfx::Insets WindowTreeHostWin::GetInsets() const { |
| 145 return gfx::Insets(); | 145 return gfx::Insets(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void WindowTreeHostWin::SetInsets(const gfx::Insets& insets) { | 148 void WindowTreeHostWin::SetInsets(const gfx::Insets& insets) { |
| 149 } | 149 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 void WindowTreeHostWin::OnDeviceScaleFactorChanged( | 223 void WindowTreeHostWin::OnDeviceScaleFactorChanged( |
| 224 float device_scale_factor) { | 224 float device_scale_factor) { |
| 225 NOTIMPLEMENTED(); | 225 NOTIMPLEMENTED(); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void WindowTreeHostWin::PrepareForShutdown() { | 228 void WindowTreeHostWin::PrepareForShutdown() { |
| 229 NOTIMPLEMENTED(); | 229 NOTIMPLEMENTED(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 ui::EventProcessor* WindowTreeHostWin::GetEventProcessor() { | 232 ui::EventProcessor* WindowTreeHostWin::GetEventProcessor() { |
| 233 return dispatcher(); | 233 return delegate_->GetEventProcessor(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void WindowTreeHostWin::OnClose() { | 236 void WindowTreeHostWin::OnClose() { |
| 237 // TODO: this obviously shouldn't be here. | 237 // TODO: this obviously shouldn't be here. |
| 238 base::MessageLoopForUI::current()->Quit(); | 238 base::MessageLoopForUI::current()->Quit(); |
| 239 } | 239 } |
| 240 | 240 |
| 241 LRESULT WindowTreeHostWin::OnKeyEvent(UINT message, | 241 LRESULT WindowTreeHostWin::OnKeyEvent(UINT message, |
| 242 WPARAM w_param, | 242 WPARAM w_param, |
| 243 LPARAM l_param) { | 243 LPARAM l_param) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 261 } | 261 } |
| 262 SetMsgHandled(handled); | 262 SetMsgHandled(handled); |
| 263 return 0; | 263 return 0; |
| 264 } | 264 } |
| 265 | 265 |
| 266 LRESULT WindowTreeHostWin::OnCaptureChanged(UINT message, | 266 LRESULT WindowTreeHostWin::OnCaptureChanged(UINT message, |
| 267 WPARAM w_param, | 267 WPARAM w_param, |
| 268 LPARAM l_param) { | 268 LPARAM l_param) { |
| 269 if (has_capture_) { | 269 if (has_capture_) { |
| 270 has_capture_ = false; | 270 has_capture_ = false; |
| 271 OnHostLostWindowCapture(); | 271 delegate_->OnHostLostWindowCapture(); |
| 272 } | 272 } |
| 273 return 0; | 273 return 0; |
| 274 } | 274 } |
| 275 | 275 |
| 276 LRESULT WindowTreeHostWin::OnNCActivate(UINT message, | 276 LRESULT WindowTreeHostWin::OnNCActivate(UINT message, |
| 277 WPARAM w_param, | 277 WPARAM w_param, |
| 278 LPARAM l_param) { | 278 LPARAM l_param) { |
| 279 if (!!w_param) | 279 if (!!w_param) |
| 280 OnHostActivated(); | 280 delegate_->OnHostActivated(); |
| 281 return DefWindowProc(hwnd(), message, w_param, l_param); | 281 return DefWindowProc(hwnd(), message, w_param, l_param); |
| 282 } | 282 } |
| 283 | 283 |
| 284 void WindowTreeHostWin::OnMove(const gfx::Point& point) { | 284 void WindowTreeHostWin::OnMove(const gfx::Point& point) { |
| 285 OnHostMoved(point); | 285 OnHostMoved(point); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void WindowTreeHostWin::OnPaint(HDC dc) { | 288 void WindowTreeHostWin::OnPaint(HDC dc) { |
| 289 gfx::Rect damage_rect; | 289 gfx::Rect damage_rect; |
| 290 RECT update_rect = {0}; | 290 RECT update_rect = {0}; |
| 291 if (GetUpdateRect(hwnd(), &update_rect, FALSE)) | 291 if (GetUpdateRect(hwnd(), &update_rect, FALSE)) |
| 292 damage_rect = gfx::Rect(update_rect); | 292 damage_rect = gfx::Rect(update_rect); |
| 293 compositor()->ScheduleRedrawRect(damage_rect); | 293 compositor()->ScheduleRedrawRect(damage_rect); |
| 294 ValidateRect(hwnd(), NULL); | 294 ValidateRect(hwnd(), NULL); |
| 295 } | 295 } |
| 296 | 296 |
| 297 void WindowTreeHostWin::OnSize(UINT param, const gfx::Size& size) { | 297 void WindowTreeHostWin::OnSize(UINT param, const gfx::Size& size) { |
| 298 // Minimizing resizes the window to 0x0 which causes our layout to go all | 298 // Minimizing resizes the window to 0x0 which causes our layout to go all |
| 299 // screwy, so we just ignore it. | 299 // screwy, so we just ignore it. |
| 300 if (param != SIZE_MINIMIZED) | 300 if (delegate_ && param != SIZE_MINIMIZED) |
| 301 OnHostResized(size); | 301 OnHostResized(size); |
| 302 } | 302 } |
| 303 | 303 |
| 304 namespace test { | 304 namespace test { |
| 305 | 305 |
| 306 // static | 306 // static |
| 307 void SetUsePopupAsRootWindowForTest(bool use) { | 307 void SetUsePopupAsRootWindowForTest(bool use) { |
| 308 use_popup_as_root_window_for_test = use; | 308 use_popup_as_root_window_for_test = use; |
| 309 } | 309 } |
| 310 | 310 |
| 311 } // namespace test | 311 } // namespace test |
| 312 | 312 |
| 313 } // namespace aura | 313 } // namespace aura |
| OLD | NEW |