| 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 "stdafx.h" | 5 #include "stdafx.h" |
| 6 #include <corewindow.h> | 6 #include <corewindow.h> |
| 7 #include <shobjidl.h> | 7 #include <shobjidl.h> |
| 8 #include <stdint.h> |
| 8 | 9 |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" |
| 10 #include "ui/gfx/geometry/safe_integer_conversions.h" | 12 #include "ui/gfx/geometry/safe_integer_conversions.h" |
| 11 #include "ui/gfx/win/msg_util.h" | 13 #include "ui/gfx/win/msg_util.h" |
| 12 | 14 |
| 13 #pragma comment(lib, "shell32.lib") | 15 #pragma comment(lib, "shell32.lib") |
| 14 | 16 |
| 15 EXTERN_C IMAGE_DOS_HEADER __ImageBase; | 17 EXTERN_C IMAGE_DOS_HEADER __ImageBase; |
| 16 // Even though we only create a single window, we need to keep this | 18 // Even though we only create a single window, we need to keep this |
| 17 // count because of the hidden window used by the UI message loop of | 19 // count because of the hidden window used by the UI message loop of |
| 18 // the metro viewer. | 20 // the metro viewer. |
| 19 int g_window_count = 0; | 21 int g_window_count = 0; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } | 152 } |
| 151 | 153 |
| 152 HRESULT STDMETHODCALLTYPE get_Position(winfoundtn::Point* position) override { | 154 HRESULT STDMETHODCALLTYPE get_Position(winfoundtn::Point* position) override { |
| 153 static float scale = GetModernUIScale(); | 155 static float scale = GetModernUIScale(); |
| 154 // Scale down the points here as they are scaled up on the other side. | 156 // Scale down the points here as they are scaled up on the other side. |
| 155 position->X = gfx::ToRoundedInt(CR_GET_X_LPARAM(msg_.lParam) / scale); | 157 position->X = gfx::ToRoundedInt(CR_GET_X_LPARAM(msg_.lParam) / scale); |
| 156 position->Y = gfx::ToRoundedInt(CR_GET_Y_LPARAM(msg_.lParam) / scale); | 158 position->Y = gfx::ToRoundedInt(CR_GET_Y_LPARAM(msg_.lParam) / scale); |
| 157 return S_OK; | 159 return S_OK; |
| 158 } | 160 } |
| 159 | 161 |
| 160 HRESULT STDMETHODCALLTYPE get_PointerId(uint32* pointer_id) override { | 162 HRESULT STDMETHODCALLTYPE get_PointerId(uint32_t* pointer_id) override { |
| 161 // TODO(ananta) | 163 // TODO(ananta) |
| 162 // Implement this properly. | 164 // Implement this properly. |
| 163 *pointer_id = 1; | 165 *pointer_id = 1; |
| 164 return S_OK; | 166 return S_OK; |
| 165 } | 167 } |
| 166 | 168 |
| 167 HRESULT STDMETHODCALLTYPE get_Timestamp(uint64* timestamp) override { | 169 HRESULT STDMETHODCALLTYPE get_Timestamp(uint64_t* timestamp) override { |
| 168 *timestamp = msg_.time; | 170 *timestamp = msg_.time; |
| 169 return S_OK; | 171 return S_OK; |
| 170 } | 172 } |
| 171 | 173 |
| 172 HRESULT STDMETHODCALLTYPE | 174 HRESULT STDMETHODCALLTYPE |
| 173 get_Properties(winui::Input::IPointerPointProperties** properties) override { | 175 get_Properties(winui::Input::IPointerPointProperties** properties) override { |
| 174 return QueryInterface(winui::Input::IID_IPointerPointProperties, | 176 return QueryInterface(winui::Input::IID_IPointerPointProperties, |
| 175 reinterpret_cast<void**>(properties)); | 177 reinterpret_cast<void**>(properties)); |
| 176 } | 178 } |
| 177 | 179 |
| 178 HRESULT STDMETHODCALLTYPE | 180 HRESULT STDMETHODCALLTYPE |
| 179 get_RawPosition(winfoundtn::Point* position) override { | 181 get_RawPosition(winfoundtn::Point* position) override { |
| 180 return E_NOTIMPL; | 182 return E_NOTIMPL; |
| 181 } | 183 } |
| 182 | 184 |
| 183 HRESULT STDMETHODCALLTYPE get_FrameId(uint32* frame_id) override { | 185 HRESULT STDMETHODCALLTYPE get_FrameId(uint32_t* frame_id) override { |
| 184 return E_NOTIMPL; | 186 return E_NOTIMPL; |
| 185 } | 187 } |
| 186 | 188 |
| 187 HRESULT STDMETHODCALLTYPE get_IsInContact(boolean* in_contact) override { | 189 HRESULT STDMETHODCALLTYPE get_IsInContact(boolean* in_contact) override { |
| 188 return E_NOTIMPL; | 190 return E_NOTIMPL; |
| 189 } | 191 } |
| 190 | 192 |
| 191 // IPointerPointProperties implementation. | 193 // IPointerPointProperties implementation. |
| 192 HRESULT STDMETHODCALLTYPE | 194 HRESULT STDMETHODCALLTYPE |
| 193 get_PointerUpdateKind(winui::Input::PointerUpdateKind* update_kind) override { | 195 get_PointerUpdateKind(winui::Input::PointerUpdateKind* update_kind) override { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 HRESULT STDMETHODCALLTYPE | 307 HRESULT STDMETHODCALLTYPE |
| 306 get_IsXButton1Pressed(boolean* is_xbutton1_pressed) override { | 308 get_IsXButton1Pressed(boolean* is_xbutton1_pressed) override { |
| 307 return E_NOTIMPL; | 309 return E_NOTIMPL; |
| 308 } | 310 } |
| 309 | 311 |
| 310 HRESULT STDMETHODCALLTYPE | 312 HRESULT STDMETHODCALLTYPE |
| 311 get_IsXButton2Pressed(boolean* is_xbutton2_pressed) override { | 313 get_IsXButton2Pressed(boolean* is_xbutton2_pressed) override { |
| 312 return E_NOTIMPL; | 314 return E_NOTIMPL; |
| 313 } | 315 } |
| 314 | 316 |
| 315 HRESULT STDMETHODCALLTYPE | 317 HRESULT STDMETHODCALLTYPE HasUsage(uint32_t usage_page, |
| 316 HasUsage(uint32 usage_page, uint32 usage_id, boolean* has_usage) override { | 318 uint32_t usage_id, |
| 319 boolean* has_usage) override { |
| 317 return E_NOTIMPL; | 320 return E_NOTIMPL; |
| 318 } | 321 } |
| 319 | 322 |
| 320 HRESULT STDMETHODCALLTYPE GetUsageValue(uint32 usage_page, | 323 HRESULT STDMETHODCALLTYPE GetUsageValue(uint32_t usage_page, |
| 321 uint32 usage_id, | 324 uint32_t usage_id, |
| 322 int32* usage_value) override { | 325 int32_t* usage_value) override { |
| 323 return E_NOTIMPL; | 326 return E_NOTIMPL; |
| 324 } | 327 } |
| 325 | 328 |
| 326 // IPointerDevice implementation. | 329 // IPointerDevice implementation. |
| 327 HRESULT STDMETHODCALLTYPE get_PointerDeviceType( | 330 HRESULT STDMETHODCALLTYPE get_PointerDeviceType( |
| 328 windevs::Input::PointerDeviceType* device_type) override { | 331 windevs::Input::PointerDeviceType* device_type) override { |
| 329 if (msg_.message == WM_TOUCH) { | 332 if (msg_.message == WM_TOUCH) { |
| 330 *device_type = windevs::Input::PointerDeviceType_Touch; | 333 *device_type = windevs::Input::PointerDeviceType_Touch; |
| 331 } else { | 334 } else { |
| 332 *device_type = windevs::Input::PointerDeviceType_Mouse; | 335 *device_type = windevs::Input::PointerDeviceType_Mouse; |
| 333 } | 336 } |
| 334 return S_OK; | 337 return S_OK; |
| 335 } | 338 } |
| 336 | 339 |
| 337 HRESULT STDMETHODCALLTYPE get_IsIntegrated(boolean* is_integrated) override { | 340 HRESULT STDMETHODCALLTYPE get_IsIntegrated(boolean* is_integrated) override { |
| 338 return E_NOTIMPL; | 341 return E_NOTIMPL; |
| 339 } | 342 } |
| 340 | 343 |
| 341 HRESULT STDMETHODCALLTYPE get_MaxContacts(uint32* contacts) override { | 344 HRESULT STDMETHODCALLTYPE get_MaxContacts(uint32_t* contacts) override { |
| 342 return E_NOTIMPL; | 345 return E_NOTIMPL; |
| 343 } | 346 } |
| 344 | 347 |
| 345 HRESULT STDMETHODCALLTYPE | 348 HRESULT STDMETHODCALLTYPE |
| 346 get_PhysicalDeviceRect(winfoundtn::Rect* rect) override { | 349 get_PhysicalDeviceRect(winfoundtn::Rect* rect) override { |
| 347 return E_NOTIMPL; | 350 return E_NOTIMPL; |
| 348 } | 351 } |
| 349 | 352 |
| 350 HRESULT STDMETHODCALLTYPE get_ScreenRect(winfoundtn::Rect* rect) override { | 353 HRESULT STDMETHODCALLTYPE get_ScreenRect(winfoundtn::Rect* rect) override { |
| 351 return E_NOTIMPL; | 354 return E_NOTIMPL; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 key_status->RepeatCount = msg_.lParam & 0x0000FFFF; | 389 key_status->RepeatCount = msg_.lParam & 0x0000FFFF; |
| 387 key_status->ScanCode = (msg_.lParam >> 16) & 0x00FF; | 390 key_status->ScanCode = (msg_.lParam >> 16) & 0x00FF; |
| 388 key_status->IsExtendedKey = (msg_.lParam & (1 << 24)); | 391 key_status->IsExtendedKey = (msg_.lParam & (1 << 24)); |
| 389 key_status->IsMenuKeyDown = (msg_.lParam & (1 << 29)); | 392 key_status->IsMenuKeyDown = (msg_.lParam & (1 << 29)); |
| 390 key_status->WasKeyDown = (msg_.lParam & (1 << 30)); | 393 key_status->WasKeyDown = (msg_.lParam & (1 << 30)); |
| 391 key_status->IsKeyReleased = (msg_.lParam & (1 << 31)); | 394 key_status->IsKeyReleased = (msg_.lParam & (1 << 31)); |
| 392 return S_OK; | 395 return S_OK; |
| 393 } | 396 } |
| 394 | 397 |
| 395 // ICharacterReceivedEventArgs implementation. | 398 // ICharacterReceivedEventArgs implementation. |
| 396 HRESULT STDMETHODCALLTYPE get_KeyCode(uint32* key_code) override { | 399 HRESULT STDMETHODCALLTYPE get_KeyCode(uint32_t* key_code) override { |
| 397 *key_code = msg_.wParam; | 400 *key_code = msg_.wParam; |
| 398 return S_OK; | 401 return S_OK; |
| 399 } | 402 } |
| 400 | 403 |
| 401 // IAcceleratorKeyEventArgs implementation. | 404 // IAcceleratorKeyEventArgs implementation. |
| 402 HRESULT STDMETHODCALLTYPE | 405 HRESULT STDMETHODCALLTYPE |
| 403 get_EventType(winui::Core::CoreAcceleratorKeyEventType* event_type) override { | 406 get_EventType(winui::Core::CoreAcceleratorKeyEventType* event_type) override { |
| 404 if (msg_.message == WM_SYSKEYDOWN) { | 407 if (msg_.message == WM_SYSKEYDOWN) { |
| 405 *event_type = winui::Core::CoreAcceleratorKeyEventType_SystemKeyDown; | 408 *event_type = winui::Core::CoreAcceleratorKeyEventType_SystemKeyDown; |
| 406 } else if (msg_.message == WM_SYSKEYUP) { | 409 } else if (msg_.message == WM_SYSKEYUP) { |
| (...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 }; | 1220 }; |
| 1218 | 1221 |
| 1219 | 1222 |
| 1220 mswr::ComPtr<winapp::Core::ICoreApplication> InitWindows7() { | 1223 mswr::ComPtr<winapp::Core::ICoreApplication> InitWindows7() { |
| 1221 HRESULT hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); | 1224 HRESULT hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); |
| 1222 if (FAILED(hr)) | 1225 if (FAILED(hr)) |
| 1223 CHECK(false); | 1226 CHECK(false); |
| 1224 return mswr::Make<CoreApplicationWin7Emulation>(); | 1227 return mswr::Make<CoreApplicationWin7Emulation>(); |
| 1225 } | 1228 } |
| 1226 | 1229 |
| OLD | NEW |