summaryrefslogtreecommitdiffstats
path: root/win8
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-01 20:59:52 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-01 20:59:52 +0000
commit4404c0783d68fca1bcea77a780789ca6a720d15f (patch)
treef607e45638748014391770f7936c96bb66cd024e /win8
parentf522800ade9624102400dbe3b338213b67b8a1fe (diff)
downloadchromium_src-4404c0783d68fca1bcea77a780789ca6a720d15f.zip
chromium_src-4404c0783d68fca1bcea77a780789ca6a720d15f.tar.gz
chromium_src-4404c0783d68fca1bcea77a780789ca6a720d15f.tar.bz2
Ensure that keyboard input works in Chrome AURA on Windows 8 in metro. cpu: please review everything,
sky: Please review the changes to ui and chrome\browser. We need to send character events to the RenderViewHost class in addition to the KeyDown/Keyup events for this to work. To achieve this we register the character received event on the Windows 8 CoreWindow class and send the character info via a new IPC message MetroViewerHostMsg_Character. The chrome side handling for this message is performed in the MockInputMethod::DispatchFabricatedKeyEvent function where we dispatch the message to the focused TextInputClient. While working on this I also noticed that we were not sending the event flags like shift/alt/Ctrl, etc to Chrome from the Metro code. Added support for that. This ensures that we are able to select text in the edit fields on the page and the omnibox, etc. The above changes will most likely not work with IME's. Will look into that in a subsequent change. BUG=158637 R=cpu,sky Review URL: https://codereview.chromium.org/11348053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165496 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'win8')
-rw-r--r--win8/metro_driver/chrome_app_view_ash.cc52
-rw-r--r--win8/metro_driver/chrome_app_view_ash.h3
2 files changed, 52 insertions, 3 deletions
diff --git a/win8/metro_driver/chrome_app_view_ash.cc b/win8/metro_driver/chrome_app_view_ash.cc
index 4cde83a..9d9d809 100644
--- a/win8/metro_driver/chrome_app_view_ash.cc
+++ b/win8/metro_driver/chrome_app_view_ash.cc
@@ -9,11 +9,13 @@
#include "base/bind.h"
#include "base/message_loop.h"
-#include "base/win/metro.h"
#include "base/threading/thread.h"
+#include "base/win/metro.h"
+#include "base/win/win_util.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_proxy.h"
#include "ipc/ipc_sender.h"
+#include "ui/base/events/event_constants.h"
#include "ui/metro_viewer/metro_viewer_messages.h"
#include "win8/metro_driver/metro_driver.h"
#include "win8/metro_driver/winrt_utils.h"
@@ -30,6 +32,10 @@ typedef winfoundtn::ITypedEventHandler<
winui::Core::CoreWindow*,
winui::Core::KeyEventArgs*> KeyEventHandler;
+typedef winfoundtn::ITypedEventHandler<
+ winui::Core::CoreWindow*,
+ winui::Core::CharacterReceivedEventArgs*> CharEventHandler;
+
// This function is exported by chrome.exe.
typedef int (__cdecl *BreakpadExceptionHandler)(EXCEPTION_POINTERS* info);
@@ -125,6 +131,18 @@ void RunMessageLoop(winui::Core::ICoreDispatcher* dispatcher) {
MessageLoop::current()->Quit();
}
+// Helper to return the state of the shift/control/alt keys.
+uint32 GetKeyboardEventFlags() {
+ uint32 flags = 0;
+ if (base::win::IsShiftPressed())
+ flags |= ui::EF_SHIFT_DOWN;
+ if (base::win::IsCtrlPressed())
+ flags |= ui::EF_CONTROL_DOWN;
+ if (base::win::IsAltPressed())
+ flags |= ui::EF_ALT_DOWN;
+ return flags;
+}
+
} // namespace
ChromeAppViewAsh::ChromeAppViewAsh()
@@ -182,6 +200,11 @@ ChromeAppViewAsh::SetWindow(winui::Core::ICoreWindow* window) {
&keyup_token_);
CheckHR(hr);
+ hr = window_->add_CharacterReceived(mswr::Callback<CharEventHandler>(
+ this, &ChromeAppViewAsh::OnCharacterReceived).Get(),
+ &character_received_token_);
+ CheckHR(hr);
+
// By initializing the direct 3D swap chain with the corewindow
// we can now directly blit to it from the browser process.
direct3d_helper_.Initialize(window);
@@ -331,7 +354,8 @@ HRESULT ChromeAppViewAsh::OnKeyDown(winui::Core::ICoreWindow* sender,
ui_channel_->Send(new MetroViewerHostMsg_KeyDown(virtual_key,
status.RepeatCount,
- status.ScanCode));
+ status.ScanCode,
+ GetKeyboardEventFlags()));
return S_OK;
}
@@ -348,10 +372,32 @@ HRESULT ChromeAppViewAsh::OnKeyUp(winui::Core::ICoreWindow* sender,
ui_channel_->Send(new MetroViewerHostMsg_KeyUp(virtual_key,
status.RepeatCount,
- status.ScanCode));
+ status.ScanCode,
+ GetKeyboardEventFlags()));
return S_OK;
}
+HRESULT ChromeAppViewAsh::OnCharacterReceived(
+ winui::Core::ICoreWindow* sender,
+ winui::Core::ICharacterReceivedEventArgs* args) {
+ unsigned int char_code = 0;
+ HRESULT hr = args->get_KeyCode(&char_code);
+ if (FAILED(hr))
+ return hr;
+
+ winui::Core::CorePhysicalKeyStatus status;
+ hr = args->get_KeyStatus(&status);
+ if (FAILED(hr))
+ return hr;
+
+ ui_channel_->Send(new MetroViewerHostMsg_Character(char_code,
+ status.RepeatCount,
+ status.ScanCode,
+ GetKeyboardEventFlags()));
+ return S_OK;
+}
+
+
///////////////////////////////////////////////////////////////////////////////
ChromeAppViewFactory::ChromeAppViewFactory(
diff --git a/win8/metro_driver/chrome_app_view_ash.h b/win8/metro_driver/chrome_app_view_ash.h
index 2379b51..7730bcb 100644
--- a/win8/metro_driver/chrome_app_view_ash.h
+++ b/win8/metro_driver/chrome_app_view_ash.h
@@ -50,6 +50,8 @@ class ChromeAppViewAsh
HRESULT OnKeyUp(winui::Core::ICoreWindow* sender,
winui::Core::IKeyEventArgs* args);
+ HRESULT OnCharacterReceived(winui::Core::ICoreWindow* sender,
+ winui::Core::ICharacterReceivedEventArgs* args);
mswr::ComPtr<winui::Core::ICoreWindow> window_;
mswr::ComPtr<winapp::Core::ICoreApplicationView> view_;
@@ -59,6 +61,7 @@ class ChromeAppViewAsh
EventRegistrationToken pointerreleased_token_;
EventRegistrationToken keydown_token_;
EventRegistrationToken keyup_token_;
+ EventRegistrationToken character_received_token_;
metro_driver::Direct3DHelper direct3d_helper_;