| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "mojo/services/native_viewport/native_viewport.h" | 5 #include "mojo/services/native_viewport/native_viewport.h" |
| 6 | 6 |
| 7 #include "ui/events/event.h" | 7 #include "ui/events/event.h" |
| 8 #include "ui/gfx/win/msg_util.h" |
| 8 #include "ui/gfx/win/window_impl.h" | 9 #include "ui/gfx/win/window_impl.h" |
| 9 | 10 |
| 10 namespace mojo { | 11 namespace mojo { |
| 11 namespace services { | 12 namespace services { |
| 12 namespace { | 13 namespace { |
| 13 | 14 |
| 14 gfx::Rect GetWindowBoundsForClientBounds(DWORD style, DWORD ex_style, | 15 gfx::Rect GetWindowBoundsForClientBounds(DWORD style, DWORD ex_style, |
| 15 const gfx::Rect& bounds) { | 16 const gfx::Rect& bounds) { |
| 16 RECT wr; | 17 RECT wr; |
| 17 wr.left = bounds.x(); | 18 wr.left = bounds.x(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 virtual void SetCapture() OVERRIDE { | 72 virtual void SetCapture() OVERRIDE { |
| 72 DCHECK(::GetCapture() != hwnd()); | 73 DCHECK(::GetCapture() != hwnd()); |
| 73 ::SetCapture(hwnd()); | 74 ::SetCapture(hwnd()); |
| 74 } | 75 } |
| 75 | 76 |
| 76 virtual void ReleaseCapture() OVERRIDE { | 77 virtual void ReleaseCapture() OVERRIDE { |
| 77 if (::GetCapture() == hwnd()) | 78 if (::GetCapture() == hwnd()) |
| 78 ::ReleaseCapture(); | 79 ::ReleaseCapture(); |
| 79 } | 80 } |
| 80 | 81 |
| 81 BEGIN_MSG_MAP_EX(NativeViewportWin) | 82 CR_BEGIN_MSG_MAP_EX(NativeViewportWin) |
| 82 MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) | 83 CR_MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) |
| 83 | 84 |
| 84 MESSAGE_HANDLER_EX(WM_KEYDOWN, OnKeyEvent) | 85 CR_MESSAGE_HANDLER_EX(WM_KEYDOWN, OnKeyEvent) |
| 85 MESSAGE_HANDLER_EX(WM_KEYUP, OnKeyEvent) | 86 CR_MESSAGE_HANDLER_EX(WM_KEYUP, OnKeyEvent) |
| 86 MESSAGE_HANDLER_EX(WM_SYSKEYDOWN, OnKeyEvent) | 87 CR_MESSAGE_HANDLER_EX(WM_SYSKEYDOWN, OnKeyEvent) |
| 87 MESSAGE_HANDLER_EX(WM_SYSKEYUP, OnKeyEvent) | 88 CR_MESSAGE_HANDLER_EX(WM_SYSKEYUP, OnKeyEvent) |
| 88 MESSAGE_HANDLER_EX(WM_CHAR, OnKeyEvent) | 89 CR_MESSAGE_HANDLER_EX(WM_CHAR, OnKeyEvent) |
| 89 MESSAGE_HANDLER_EX(WM_SYSCHAR, OnKeyEvent) | 90 CR_MESSAGE_HANDLER_EX(WM_SYSCHAR, OnKeyEvent) |
| 90 MESSAGE_HANDLER_EX(WM_IME_CHAR, OnKeyEvent) | 91 CR_MESSAGE_HANDLER_EX(WM_IME_CHAR, OnKeyEvent) |
| 91 | 92 |
| 92 MSG_WM_CREATE(OnCreate) | 93 CR_MSG_WM_CREATE(OnCreate) |
| 93 MSG_WM_DESTROY(OnDestroy) | 94 CR_MSG_WM_DESTROY(OnDestroy) |
| 94 MSG_WM_PAINT(OnPaint) | 95 CR_MSG_WM_PAINT(OnPaint) |
| 95 MSG_WM_WINDOWPOSCHANGED(OnWindowPosChanged) | 96 CR_MSG_WM_WINDOWPOSCHANGED(OnWindowPosChanged) |
| 96 END_MSG_MAP() | 97 CR_END_MSG_MAP() |
| 97 | 98 |
| 98 LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param) { | 99 LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param) { |
| 99 MSG msg = { hwnd(), message, w_param, l_param, 0, | 100 MSG msg = { hwnd(), message, w_param, l_param, 0, |
| 100 { GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param) } }; | 101 { CR_GET_X_LPARAM(l_param), CR_GET_Y_LPARAM(l_param) } }; |
| 101 ui::MouseEvent event(msg); | 102 ui::MouseEvent event(msg); |
| 102 SetMsgHandled(delegate_->OnEvent(&event)); | 103 SetMsgHandled(delegate_->OnEvent(&event)); |
| 103 return 0; | 104 return 0; |
| 104 } | 105 } |
| 105 LRESULT OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param) { | 106 LRESULT OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param) { |
| 106 MSG msg = { hwnd(), message, w_param, l_param }; | 107 MSG msg = { hwnd(), message, w_param, l_param }; |
| 107 ui::KeyEvent event(msg, message == WM_CHAR); | 108 ui::KeyEvent event(msg, message == WM_CHAR); |
| 108 SetMsgHandled(delegate_->OnEvent(&event)); | 109 SetMsgHandled(delegate_->OnEvent(&event)); |
| 109 return 0; | 110 return 0; |
| 110 } | 111 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 144 |
| 144 // static | 145 // static |
| 145 scoped_ptr<NativeViewport> NativeViewport::Create( | 146 scoped_ptr<NativeViewport> NativeViewport::Create( |
| 146 shell::Context* context, | 147 shell::Context* context, |
| 147 NativeViewportDelegate* delegate) { | 148 NativeViewportDelegate* delegate) { |
| 148 return scoped_ptr<NativeViewport>(new NativeViewportWin(delegate)).Pass(); | 149 return scoped_ptr<NativeViewport>(new NativeViewportWin(delegate)).Pass(); |
| 149 } | 150 } |
| 150 | 151 |
| 151 } // namespace services | 152 } // namespace services |
| 152 } // namespace mojo | 153 } // namespace mojo |
| OLD | NEW |