| 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 |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "ui/aura/client/capture_client.h" | 12 #include "ui/aura/client/capture_client.h" |
| 13 #include "ui/aura/env.h" | 13 #include "ui/aura/env.h" |
| 14 #include "ui/aura/root_window.h" | 14 #include "ui/aura/root_window.h" |
| 15 #include "ui/base/cursor/cursor_loader_win.h" |
| 15 #include "ui/base/events/event.h" | 16 #include "ui/base/events/event.h" |
| 16 #include "ui/base/view_prop.h" | 17 #include "ui/base/view_prop.h" |
| 17 | 18 |
| 18 using std::max; | 19 using std::max; |
| 19 using std::min; | 20 using std::min; |
| 20 | 21 |
| 21 namespace aura { | 22 namespace aura { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 const char* kRootWindowHostWinKey = "__AURA_ROOT_WINDOW_HOST_WIN__"; | 26 const char* kRootWindowHostWinKey = "__AURA_ROOT_WINDOW_HOST_WIN__"; |
| 26 | 27 |
| 27 // TODO(mazda): Move the cursor code to ui/base/cursor/cursor_loader_win.{cc,h}. | |
| 28 const wchar_t* GetCursorId(gfx::NativeCursor native_cursor) { | |
| 29 switch (native_cursor.native_type()) { | |
| 30 case ui::kCursorNull: | |
| 31 return IDC_ARROW; | |
| 32 case ui::kCursorPointer: | |
| 33 return IDC_ARROW; | |
| 34 case ui::kCursorCross: | |
| 35 return IDC_CROSS; | |
| 36 case ui::kCursorHand: | |
| 37 return IDC_HAND; | |
| 38 case ui::kCursorIBeam: | |
| 39 return IDC_IBEAM; | |
| 40 case ui::kCursorWait: | |
| 41 return IDC_WAIT; | |
| 42 case ui::kCursorHelp: | |
| 43 return IDC_HELP; | |
| 44 case ui::kCursorEastResize: | |
| 45 return IDC_SIZEWE; | |
| 46 case ui::kCursorNorthResize: | |
| 47 return IDC_SIZENS; | |
| 48 case ui::kCursorNorthEastResize: | |
| 49 return IDC_SIZENESW; | |
| 50 case ui::kCursorNorthWestResize: | |
| 51 return IDC_SIZENWSE; | |
| 52 case ui::kCursorSouthResize: | |
| 53 return IDC_SIZENS; | |
| 54 case ui::kCursorSouthEastResize: | |
| 55 return IDC_SIZENWSE; | |
| 56 case ui::kCursorSouthWestResize: | |
| 57 return IDC_SIZENESW; | |
| 58 case ui::kCursorWestResize: | |
| 59 return IDC_SIZEWE; | |
| 60 case ui::kCursorNorthSouthResize: | |
| 61 return IDC_SIZENS; | |
| 62 case ui::kCursorEastWestResize: | |
| 63 return IDC_SIZEWE; | |
| 64 case ui::kCursorNorthEastSouthWestResize: | |
| 65 return IDC_SIZENESW; | |
| 66 case ui::kCursorNorthWestSouthEastResize: | |
| 67 return IDC_SIZENWSE; | |
| 68 case ui::kCursorMove: | |
| 69 return IDC_SIZEALL; | |
| 70 case ui::kCursorProgress: | |
| 71 return IDC_APPSTARTING; | |
| 72 case ui::kCursorNoDrop: | |
| 73 return IDC_NO; | |
| 74 case ui::kCursorNotAllowed: | |
| 75 return IDC_NO; | |
| 76 case ui::kCursorColumnResize: | |
| 77 case ui::kCursorRowResize: | |
| 78 case ui::kCursorMiddlePanning: | |
| 79 case ui::kCursorEastPanning: | |
| 80 case ui::kCursorNorthPanning: | |
| 81 case ui::kCursorNorthEastPanning: | |
| 82 case ui::kCursorNorthWestPanning: | |
| 83 case ui::kCursorSouthPanning: | |
| 84 case ui::kCursorSouthEastPanning: | |
| 85 case ui::kCursorSouthWestPanning: | |
| 86 case ui::kCursorWestPanning: | |
| 87 case ui::kCursorVerticalText: | |
| 88 case ui::kCursorCell: | |
| 89 case ui::kCursorContextMenu: | |
| 90 case ui::kCursorAlias: | |
| 91 case ui::kCursorCopy: | |
| 92 case ui::kCursorNone: | |
| 93 case ui::kCursorZoomIn: | |
| 94 case ui::kCursorZoomOut: | |
| 95 case ui::kCursorGrab: | |
| 96 case ui::kCursorGrabbing: | |
| 97 case ui::kCursorCustom: | |
| 98 // TODO(jamescook): Should we use WebKit glue resources for these? | |
| 99 // Or migrate those resources to someplace ui/aura can share? | |
| 100 NOTIMPLEMENTED(); | |
| 101 return IDC_ARROW; | |
| 102 default: | |
| 103 NOTREACHED(); | |
| 104 return IDC_ARROW; | |
| 105 } | |
| 106 } | |
| 107 | |
| 108 } // namespace | 28 } // namespace |
| 109 | 29 |
| 110 // static | 30 // static |
| 111 RootWindowHost* RootWindowHost::Create(RootWindowHostDelegate* delegate, | 31 RootWindowHost* RootWindowHost::Create(RootWindowHostDelegate* delegate, |
| 112 const gfx::Rect& bounds) { | 32 const gfx::Rect& bounds) { |
| 113 return new RootWindowHostWin(delegate, bounds); | 33 return new RootWindowHostWin(delegate, bounds); |
| 114 } | 34 } |
| 115 | 35 |
| 116 // static | 36 // static |
| 117 RootWindowHost* RootWindowHost::GetForAcceleratedWidget( | 37 RootWindowHost* RootWindowHost::GetForAcceleratedWidget( |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 RECT r; | 145 RECT r; |
| 226 GetClientRect(hwnd(), &r); | 146 GetClientRect(hwnd(), &r); |
| 227 return gfx::Point(r.left, r.top); | 147 return gfx::Point(r.left, r.top); |
| 228 } | 148 } |
| 229 | 149 |
| 230 | 150 |
| 231 void RootWindowHostWin::SetCursor(gfx::NativeCursor native_cursor) { | 151 void RootWindowHostWin::SetCursor(gfx::NativeCursor native_cursor) { |
| 232 // Custom web cursors are handled directly. | 152 // Custom web cursors are handled directly. |
| 233 if (native_cursor == ui::kCursorCustom) | 153 if (native_cursor == ui::kCursorCustom) |
| 234 return; | 154 return; |
| 235 const wchar_t* cursor_id = GetCursorId(native_cursor); | 155 |
| 236 // TODO(jamescook): Support for non-system cursors will require finding | 156 ui::CursorLoaderWin cursor_loader; |
| 237 // the appropriate module to pass to LoadCursor(). | 157 cursor_loader.SetPlatformCursor(&native_cursor); |
| 238 ::SetCursor(LoadCursor(NULL, cursor_id)); | 158 ::SetCursor(native_cursor.platform()); |
| 239 } | 159 } |
| 240 | 160 |
| 241 void RootWindowHostWin::SetCapture() { | 161 void RootWindowHostWin::SetCapture() { |
| 242 if (!has_capture_) { | 162 if (!has_capture_) { |
| 243 has_capture_ = true; | 163 has_capture_ = true; |
| 244 ::SetCapture(hwnd()); | 164 ::SetCapture(hwnd()); |
| 245 } | 165 } |
| 246 } | 166 } |
| 247 | 167 |
| 248 void RootWindowHostWin::ReleaseCapture() { | 168 void RootWindowHostWin::ReleaseCapture() { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 } | 272 } |
| 353 | 273 |
| 354 void RootWindowHostWin::OnSize(UINT param, const CSize& size) { | 274 void RootWindowHostWin::OnSize(UINT param, const CSize& size) { |
| 355 // Minimizing resizes the window to 0x0 which causes our layout to go all | 275 // Minimizing resizes the window to 0x0 which causes our layout to go all |
| 356 // screwy, so we just ignore it. | 276 // screwy, so we just ignore it. |
| 357 if (param != SIZE_MINIMIZED) | 277 if (param != SIZE_MINIMIZED) |
| 358 delegate_->OnHostResized(gfx::Size(size.cx, size.cy)); | 278 delegate_->OnHostResized(gfx::Size(size.cx, size.cy)); |
| 359 } | 279 } |
| 360 | 280 |
| 361 } // namespace aura | 281 } // namespace aura |
| OLD | NEW |