Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/desktop_host_win.h" | 5 #include "ui/aura/desktop_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/desktop.h" | 12 #include "ui/aura/desktop.h" |
| 13 #include "ui/aura/event.h" | 13 #include "ui/aura/event.h" |
| 14 #include "ui/base/ime/mock_input_method.h" | |
| 14 | 15 |
| 15 using std::max; | 16 using std::max; |
| 16 using std::min; | 17 using std::min; |
| 17 | 18 |
| 18 namespace aura { | 19 namespace aura { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 const wchar_t* GetCursorId(gfx::NativeCursor native_cursor) { | 23 const wchar_t* GetCursorId(gfx::NativeCursor native_cursor) { |
| 23 switch (native_cursor) { | 24 switch (native_cursor) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 } | 108 } |
| 108 | 109 |
| 109 // static | 110 // static |
| 110 gfx::Size DesktopHost::GetNativeScreenSize() { | 111 gfx::Size DesktopHost::GetNativeScreenSize() { |
| 111 return gfx::Size(GetSystemMetrics(SM_CXSCREEN), | 112 return gfx::Size(GetSystemMetrics(SM_CXSCREEN), |
| 112 GetSystemMetrics(SM_CYSCREEN)); | 113 GetSystemMetrics(SM_CYSCREEN)); |
| 113 } | 114 } |
| 114 | 115 |
| 115 DesktopHostWin::DesktopHostWin(const gfx::Rect& bounds) | 116 DesktopHostWin::DesktopHostWin(const gfx::Rect& bounds) |
| 116 : desktop_(NULL), | 117 : desktop_(NULL), |
| 118 // TODO(yusukes): implement and use ui::InputMethodWin. | |
| 119 ALLOW_THIS_IN_INITIALIZER_LIST( | |
| 120 input_method_(new ui::MockInputMethod(this))), | |
| 117 fullscreen_(false), | 121 fullscreen_(false), |
| 118 saved_window_style_(0), | 122 saved_window_style_(0), |
| 119 saved_window_ex_style_(0) { | 123 saved_window_ex_style_(0) { |
| 120 Init(NULL, bounds); | 124 Init(NULL, bounds); |
| 121 SetWindowText(hwnd(), L"aura::Desktop!"); | 125 SetWindowText(hwnd(), L"aura::Desktop!"); |
| 126 input_method_->Init(hwnd()); | |
| 122 } | 127 } |
| 123 | 128 |
| 124 DesktopHostWin::~DesktopHostWin() { | 129 DesktopHostWin::~DesktopHostWin() { |
| 125 DestroyWindow(hwnd()); | 130 DestroyWindow(hwnd()); |
| 126 } | 131 } |
| 127 | 132 |
| 128 bool DesktopHostWin::Dispatch(const MSG& msg) { | 133 bool DesktopHostWin::Dispatch(const MSG& msg) { |
| 129 TranslateMessage(&msg); | 134 TranslateMessage(&msg); |
| 130 DispatchMessage(&msg); | 135 DispatchMessage(&msg); |
| 131 return true; | 136 return true; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 } | 243 } |
| 239 | 244 |
| 240 void DesktopHostWin::OnClose() { | 245 void DesktopHostWin::OnClose() { |
| 241 // TODO: this obviously shouldn't be here. | 246 // TODO: this obviously shouldn't be here. |
| 242 MessageLoopForUI::current()->Quit(); | 247 MessageLoopForUI::current()->Quit(); |
| 243 } | 248 } |
| 244 | 249 |
| 245 LRESULT DesktopHostWin::OnKeyEvent(UINT message, | 250 LRESULT DesktopHostWin::OnKeyEvent(UINT message, |
| 246 WPARAM w_param, | 251 WPARAM w_param, |
| 247 LPARAM l_param) { | 252 LPARAM l_param) { |
| 253 // TODO(yusukes): Support input method. | |
| 248 MSG msg = { hwnd(), message, w_param, l_param }; | 254 MSG msg = { hwnd(), message, w_param, l_param }; |
| 249 KeyEvent keyev(msg, message == WM_CHAR); | 255 KeyEvent keyev(msg, message == WM_CHAR); |
| 250 SetMsgHandled(desktop_->DispatchKeyEvent(&keyev)); | 256 SetMsgHandled(desktop_->DispatchKeyEvent(&keyev)); |
| 251 return 0; | 257 return 0; |
| 252 } | 258 } |
| 253 | 259 |
| 254 LRESULT DesktopHostWin::OnMouseRange(UINT message, | 260 LRESULT DesktopHostWin::OnMouseRange(UINT message, |
| 255 WPARAM w_param, | 261 WPARAM w_param, |
| 256 LPARAM l_param) { | 262 LPARAM l_param) { |
| 257 MSG msg = { hwnd(), message, w_param, l_param, 0, | 263 MSG msg = { hwnd(), message, w_param, l_param, 0, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 269 ValidateRect(hwnd(), NULL); | 275 ValidateRect(hwnd(), NULL); |
| 270 } | 276 } |
| 271 | 277 |
| 272 void DesktopHostWin::OnSize(UINT param, const CSize& size) { | 278 void DesktopHostWin::OnSize(UINT param, const CSize& size) { |
| 273 // Minimizing resizes the window to 0x0 which causes our layout to go all | 279 // Minimizing resizes the window to 0x0 which causes our layout to go all |
| 274 // screwy, so we just ignore it. | 280 // screwy, so we just ignore it. |
| 275 if (param != SIZE_MINIMIZED) | 281 if (param != SIZE_MINIMIZED) |
| 276 desktop_->OnHostResized(gfx::Size(size.cx, size.cy)); | 282 desktop_->OnHostResized(gfx::Size(size.cx, size.cy)); |
| 277 } | 283 } |
| 278 | 284 |
| 285 void DesktopHostWin::SetInputMethod(ui::InputMethod* input_method) { | |
|
sky
2011/12/01 17:01:09
Order doesn't match header.
Yusuke Sato
2011/12/02 02:18:31
Done.
| |
| 286 input_method_.reset(input_method); | |
| 287 } | |
| 288 | |
| 289 ui::InputMethod* DesktopHostWin::GetInputMethod() const { | |
| 290 return input_method_.get(); | |
| 291 } | |
| 292 | |
| 293 void DesktopHostWin::DispatchKeyEventPostIME(const base::NativeEvent& event) { | |
| 294 // TODO(yusukes): Support input method. | |
| 295 NOTIMPLEMENTED(); | |
| 296 } | |
| 297 | |
| 298 void DesktopHostWin::DispatchFabricatedKeyEventPostIME( | |
| 299 ui::EventType type, ui::KeyboardCode key_code, int flags) { | |
| 300 // TODO(yusukes): Support input method. | |
| 301 NOTIMPLEMENTED(); | |
| 302 } | |
| 303 | |
| 279 } // namespace aura | 304 } // namespace aura |
| OLD | NEW |