Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: win8/metro_driver/metro_driver_win7.cc

Issue 1267483003: Combine the WM_CHAR with WM_KEY* for key event flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/base/ime/remote_input_method_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/profiler/scoped_tracker.h" 10 #include "base/profiler/scoped_tracker.h"
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 HRESULT STDMETHODCALLTYPE 456 HRESULT STDMETHODCALLTYPE
457 ProcessEvents(winui::Core::CoreProcessEventsOption options) override { 457 ProcessEvents(winui::Core::CoreProcessEventsOption options) override {
458 // We don't support the other message pump modes. So we basically enter a 458 // We don't support the other message pump modes. So we basically enter a
459 // traditional message loop that we only exit a teardown. 459 // traditional message loop that we only exit a teardown.
460 if (options != winui::Core::CoreProcessEventsOption_ProcessUntilQuit) 460 if (options != winui::Core::CoreProcessEventsOption_ProcessUntilQuit)
461 return E_FAIL; 461 return E_FAIL;
462 462
463 MSG msg = {0}; 463 MSG msg = {0};
464 while((::GetMessage(&msg, NULL, 0, 0) != 0) && g_window_count > 0) { 464 while((::GetMessage(&msg, NULL, 0, 0) != 0) && g_window_count > 0) {
465 ProcessInputMessage(msg); 465 ProcessInputMessage(msg);
466 ::TranslateMessage(&msg);
467 ::DispatchMessage(&msg); 466 ::DispatchMessage(&msg);
yukawa 2015/08/05 21:23:36 Can you leave a comment about why ::TranslateMessa
Shu Chen 2015/08/06 01:35:51 Done.
468 } 467 }
469 // TODO(cpu): figure what to do with msg.WParam which we would normally 468 // TODO(cpu): figure what to do with msg.WParam which we would normally
470 // return here. 469 // return here.
471 return S_OK; 470 return S_OK;
472 } 471 }
473 472
474 HRESULT STDMETHODCALLTYPE 473 HRESULT STDMETHODCALLTYPE
475 RunAsync(winui::Core::CoreDispatcherPriority priority, 474 RunAsync(winui::Core::CoreDispatcherPriority priority,
476 winui::Core::IDispatchedHandler* agileCallback, 475 winui::Core::IDispatchedHandler* agileCallback,
477 ABI::Windows::Foundation::IAsyncAction** asyncAction) override { 476 ABI::Windows::Foundation::IAsyncAction** asyncAction) override {
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 905
907 HRESULT STDMETHODCALLTYPE put_MessageHandled(boolean value) override { 906 HRESULT STDMETHODCALLTYPE put_MessageHandled(boolean value) override {
908 return S_OK; 907 return S_OK;
909 } 908 }
910 909
911 // InputHandler 910 // InputHandler
912 bool HandleKeyboardMessage(const MSG& msg) override { 911 bool HandleKeyboardMessage(const MSG& msg) override {
913 switch (msg.message) { 912 switch (msg.message) {
914 case WM_KEYDOWN: 913 case WM_KEYDOWN:
915 case WM_KEYUP: { 914 case WM_KEYUP: {
915 ::TranslateMessage(&msg);
916 // Peek & remove the following messages in the message queue.
917 // - WM_CHAR (0x0102)
918 // - WM_DEADCHAR (0x0103)
919 // And only process WM_CHAR message in browser.
920 MSG char_msg;
921 while (::PeekMessage(&char_msg, msg.hwnd, WM_CHAR, WM_DEADCHAR,
922 PM_REMOVE)) {
923 if (char_msg.message == WM_DEADCHAR)
924 continue;
925 mswr::ComPtr<winui::Core::ICharacterReceivedEventArgs> char_args;
926 char_args = mswr::Make<KeyEvent>(char_msg);
927 character_received_handler_->Invoke(this, char_args.Get());
928 }
916 mswr::ComPtr<winui::Core::IKeyEventArgs> event_args; 929 mswr::ComPtr<winui::Core::IKeyEventArgs> event_args;
917 event_args = mswr::Make<KeyEvent>(msg); 930 event_args = mswr::Make<KeyEvent>(msg);
918 KeyEventHandler* handler = NULL; 931 KeyEventHandler* handler = NULL;
919 if (msg.message == WM_KEYDOWN) { 932 if (msg.message == WM_KEYDOWN) {
920 handler = key_down_handler_; 933 handler = key_down_handler_;
921 } else { 934 } else {
922 handler = key_up_handler_; 935 handler = key_up_handler_;
923 } 936 }
924 handler->Invoke(this, event_args.Get()); 937 handler->Invoke(this, event_args.Get());
925 break; 938 break;
926 } 939 }
927 940
928 case WM_CHAR:
929 case WM_DEADCHAR:
930 case WM_UNICHAR: {
yukawa 2015/08/05 21:23:36 I supposed removing WM_UNICHAR support does not af
Shu Chen 2015/08/06 01:35:51 Removing WM_UNICHAR here doesn't change the existi
yukawa 2015/08/06 01:45:51 Is there any chance that unhandled WM_UNICHAR was
Shu Chen 2015/08/07 07:15:23 I've removed the WM_DEADCHAR & WM_UNICHAR here, an
931 mswr::ComPtr<winui::Core::ICharacterReceivedEventArgs> event_args;
932 event_args = mswr::Make<KeyEvent>(msg);
933 character_received_handler_->Invoke(this, event_args.Get());
934 break;
935 }
936
937 default: 941 default:
938 return false; 942 return false;
939 } 943 }
940 return true; 944 return true;
941 } 945 }
942 946
943 bool HandleMouseMessage(const MSG& msg) override { 947 bool HandleMouseMessage(const MSG& msg) override {
944 PointerEventHandler* handler = NULL; 948 PointerEventHandler* handler = NULL;
945 mswr::ComPtr<winui::Core::IPointerEventArgs> event_args; 949 mswr::ComPtr<winui::Core::IPointerEventArgs> event_args;
946 event_args = mswr::Make<MouseEvent>(msg); 950 event_args = mswr::Make<MouseEvent>(msg);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 }; 1222 };
1219 1223
1220 1224
1221 mswr::ComPtr<winapp::Core::ICoreApplication> InitWindows7() { 1225 mswr::ComPtr<winapp::Core::ICoreApplication> InitWindows7() {
1222 HRESULT hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); 1226 HRESULT hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
1223 if (FAILED(hr)) 1227 if (FAILED(hr))
1224 CHECK(false); 1228 CHECK(false);
1225 return mswr::Make<CoreApplicationWin7Emulation>(); 1229 return mswr::Make<CoreApplicationWin7Emulation>();
1226 } 1230 }
1227 1231
OLDNEW
« no previous file with comments | « ui/base/ime/remote_input_method_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698