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

Unified Diff: views/focus/accelerator_handler_win.cc

Issue 6487002: Add a new constructor to KeyEvent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: views/focus/accelerator_handler_win.cc
===================================================================
--- views/focus/accelerator_handler_win.cc (revision 74437)
+++ views/focus/accelerator_handler_win.cc (working copy)
@@ -11,10 +11,39 @@
namespace views {
+namespace {
+
+// Since AcceleratorHandler's Dispatch method is called regardless of the level
+// of MessageLoop nesting, we maintain a stack of MSGs so that code run from
+// each loop gets the correct MSG. This scoping class handles pushing and
+// popping before and after calls to DispatchMessage().
+class ScopedCurrentMessage {
+ public:
+ ScopedCurrentMessage(const MSG& msg, std::vector<MSG>* msg_stack)
+ : msg_stack_(msg_stack) {
+ msg_stack_->push_back(msg);
+ }
+ ~ScopedCurrentMessage() {
+ msg_stack_->pop_back();
+ }
+
+ private:
+ std::vector<MSG>* msg_stack_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedCurrentMessage);
+};
+
+} // namespace
+
+// static
+std::vector<MSG> AcceleratorHandler::current_messages_;
+
AcceleratorHandler::AcceleratorHandler() {
}
bool AcceleratorHandler::Dispatch(const MSG& msg) {
+ ScopedCurrentMessage current_message(msg, &current_messages_);
+
bool process_message = true;
if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST) {
@@ -24,11 +53,7 @@
switch (msg.message) {
case WM_KEYDOWN:
case WM_SYSKEYDOWN: {
- KeyEvent event(ui::ET_KEY_PRESSED,
- ui::KeyboardCodeForWindowsKeyCode(msg.wParam),
- KeyEvent::GetKeyStateFlags(),
- msg.lParam & 0xFFFF,
- (msg.lParam & 0xFFFF0000) >> 16);
+ KeyEvent event(msg);
process_message = focus_manager->OnKeyEvent(event);
if (!process_message) {
// Record that this key is pressed so we can remember not to

Powered by Google App Engine
This is Rietveld 408576698