summaryrefslogtreecommitdiffstats
path: root/win8
diff options
context:
space:
mode:
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_;