| 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/root_window_host_win.h" | 5 #include "ui/aura/root_window_host_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 namespace aura { | 22 namespace aura { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 const char* kRootWindowHostWinKey = "__AURA_ROOT_WINDOW_HOST_WIN__"; | 26 const char* kRootWindowHostWinKey = "__AURA_ROOT_WINDOW_HOST_WIN__"; |
| 27 | 27 |
| 28 } // namespace | 28 } // namespace |
| 29 | 29 |
| 30 // static | 30 // static |
| 31 RootWindowHost* RootWindowHost::Create(RootWindowHostDelegate* delegate, | 31 RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) { |
| 32 const gfx::Rect& bounds) { | 32 return new RootWindowHostWin(bounds); |
| 33 return new RootWindowHostWin(delegate, bounds); | |
| 34 } | 33 } |
| 35 | 34 |
| 36 // static | 35 // static |
| 37 RootWindowHost* RootWindowHost::GetForAcceleratedWidget( | 36 RootWindowHost* RootWindowHost::GetForAcceleratedWidget( |
| 38 gfx::AcceleratedWidget accelerated_widget) { | 37 gfx::AcceleratedWidget accelerated_widget) { |
| 39 return reinterpret_cast<RootWindowHost*>( | 38 return reinterpret_cast<RootWindowHost*>( |
| 40 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostWinKey)); | 39 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostWinKey)); |
| 41 } | 40 } |
| 42 | 41 |
| 43 // static | 42 // static |
| 44 gfx::Size RootWindowHost::GetNativeScreenSize() { | 43 gfx::Size RootWindowHost::GetNativeScreenSize() { |
| 45 return gfx::Size(GetSystemMetrics(SM_CXSCREEN), | 44 return gfx::Size(GetSystemMetrics(SM_CXSCREEN), |
| 46 GetSystemMetrics(SM_CYSCREEN)); | 45 GetSystemMetrics(SM_CYSCREEN)); |
| 47 } | 46 } |
| 48 | 47 |
| 49 RootWindowHostWin::RootWindowHostWin(RootWindowHostDelegate* delegate, | 48 RootWindowHostWin::RootWindowHostWin(const gfx::Rect& bounds) |
| 50 const gfx::Rect& bounds) | 49 : delegate_(NULL), |
| 51 : delegate_(delegate), | |
| 52 fullscreen_(false), | 50 fullscreen_(false), |
| 53 has_capture_(false), | 51 has_capture_(false), |
| 54 saved_window_style_(0), | 52 saved_window_style_(0), |
| 55 saved_window_ex_style_(0) { | 53 saved_window_ex_style_(0) { |
| 56 Init(NULL, bounds); | 54 Init(NULL, bounds); |
| 57 SetWindowText(hwnd(), L"aura::RootWindow!"); | 55 SetWindowText(hwnd(), L"aura::RootWindow!"); |
| 58 prop_.reset(new ui::ViewProp(hwnd(), kRootWindowHostWinKey, this)); | 56 prop_.reset(new ui::ViewProp(hwnd(), kRootWindowHostWinKey, this)); |
| 59 } | 57 } |
| 60 | 58 |
| 61 RootWindowHostWin::~RootWindowHostWin() { | 59 RootWindowHostWin::~RootWindowHostWin() { |
| 62 DestroyWindow(hwnd()); | 60 DestroyWindow(hwnd()); |
| 63 } | 61 } |
| 64 | 62 |
| 63 void RootWindowHostWin::SetDelegate(RootWindowHostDelegate* delegate) { |
| 64 delegate_ = delegate; |
| 65 } |
| 66 |
| 65 RootWindow* RootWindowHostWin::GetRootWindow() { | 67 RootWindow* RootWindowHostWin::GetRootWindow() { |
| 66 return delegate_->AsRootWindow(); | 68 return delegate_->AsRootWindow(); |
| 67 } | 69 } |
| 68 | 70 |
| 69 gfx::AcceleratedWidget RootWindowHostWin::GetAcceleratedWidget() { | 71 gfx::AcceleratedWidget RootWindowHostWin::GetAcceleratedWidget() { |
| 70 return hwnd(); | 72 return hwnd(); |
| 71 } | 73 } |
| 72 | 74 |
| 73 void RootWindowHostWin::Show() { | 75 void RootWindowHostWin::Show() { |
| 74 ShowWindow(hwnd(), SW_SHOWNORMAL); | 76 ShowWindow(hwnd(), SW_SHOWNORMAL); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 } | 274 } |
| 273 | 275 |
| 274 void RootWindowHostWin::OnSize(UINT param, const CSize& size) { | 276 void RootWindowHostWin::OnSize(UINT param, const CSize& size) { |
| 275 // Minimizing resizes the window to 0x0 which causes our layout to go all | 277 // Minimizing resizes the window to 0x0 which causes our layout to go all |
| 276 // screwy, so we just ignore it. | 278 // screwy, so we just ignore it. |
| 277 if (param != SIZE_MINIMIZED) | 279 if (param != SIZE_MINIMIZED) |
| 278 delegate_->OnHostResized(gfx::Size(size.cx, size.cy)); | 280 delegate_->OnHostResized(gfx::Size(size.cx, size.cy)); |
| 279 } | 281 } |
| 280 | 282 |
| 281 } // namespace aura | 283 } // namespace aura |
| OLD | NEW |