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

Side by Side Diff: ash/accelerators/accelerator_dispatcher_win.cc

Issue 9958152: Consolidate win/x dispatchers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync, addressed comments Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/accelerators/accelerator_dispatcher.h"
6
7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/shell.h"
9 #include "ui/aura/env.h"
10 #include "ui/aura/event.h"
11 #include "ui/aura/root_window.h"
12 #include "ui/base/accelerators/accelerator.h"
13 #include "ui/base/events.h"
14
15 namespace ash {
16
17 namespace {
18
19 const int kModifierMask = (ui::EF_SHIFT_DOWN |
20 ui::EF_CONTROL_DOWN |
21 ui::EF_ALT_DOWN);
22 } // namespace
23
24 bool AcceleratorDispatcher::Dispatch(const MSG& msg) {
25 // TODO(oshima): Consolidate win and linux. http://crbug.com/116282
26 if (!associated_window_)
27 return false;
28 if (!ui::IsNoopEvent(msg) && !associated_window_->CanReceiveEvents())
29 return aura::Env::GetInstance()->GetDispatcher()->Dispatch(msg);
30
31 if (msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN ||
32 msg.message == WM_KEYUP || msg.message == WM_SYSKEYUP) {
33 ash::AcceleratorController* accelerator_controller =
34 ash::Shell::GetInstance()->accelerator_controller();
35 if (accelerator_controller) {
36 ui::Accelerator accelerator(ui::KeyboardCodeFromNative(msg),
37 ui::EventFlagsFromNative(msg) & kModifierMask);
38 if (msg.message == WM_KEYUP || msg.message == WM_SYSKEYUP)
39 accelerator.set_type(ui::ET_KEY_RELEASED);
40 if (accelerator_controller->Process(accelerator))
41 return true;
42 accelerator.set_type(aura::TranslatedKeyEvent(msg, false).type());
43 if (accelerator_controller->Process(accelerator))
44 return true;
45 }
46 }
47
48 return nested_dispatcher_->Dispatch(msg);
49 }
50
51 } // namespace ash
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_dispatcher_linux.cc ('k') | ash/accelerators/nested_dispatcher_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698