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

Side by Side Diff: ash/wm/maximize_mode/maximize_mode_event_blocker.cc

Issue 251193005: Enabled volume buttons when TouchView is active (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merged changes with trunk Created 6 years, 7 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 | « ash/wm/maximize_mode/maximize_mode_controller_unittest.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ash/wm/maximize_mode/maximize_mode_event_blocker.h" 5 #include "ash/wm/maximize_mode/maximize_mode_event_blocker.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "ui/aura/client/cursor_client.h" 9 #include "ui/aura/client/cursor_client.h"
10 #include "ui/events/event_targeter.h" 10 #include "ui/events/event_targeter.h"
11 #include "ui/events/keycodes/keyboard_codes.h"
11 12
12 namespace ash { 13 namespace ash {
13 14
14 namespace { 15 namespace {
15 16
16 // Event targeter to prevent delivery of mouse and touchpad events while 17 // Event targeter to prevent delivery of mouse and touchpad events while
17 // maximize mode is active. Other events such as touch are passed on to the 18 // maximize mode is active. Other events such as touch are passed on to the
18 // default targeter. 19 // default targeter.
19 // TODO(flackr): This should only stop events from the internal keyboard and 20 // TODO(flackr): This should only stop events from the internal keyboard and
20 // touchpad. 21 // touchpad.
(...skipping 26 matching lines...) Expand all
47 } 48 }
48 49
49 void BlockKeyboardAndTouchpadTargeter::SetDefaultTargeter( 50 void BlockKeyboardAndTouchpadTargeter::SetDefaultTargeter(
50 ui::EventTargeter* default_targeter) { 51 ui::EventTargeter* default_targeter) {
51 default_targeter_ = default_targeter; 52 default_targeter_ = default_targeter;
52 } 53 }
53 54
54 ui::EventTarget* BlockKeyboardAndTouchpadTargeter::FindTargetForEvent( 55 ui::EventTarget* BlockKeyboardAndTouchpadTargeter::FindTargetForEvent(
55 ui::EventTarget* root, 56 ui::EventTarget* root,
56 ui::Event* event) { 57 ui::Event* event) {
57 if (event->HasNativeEvent() && (event->IsMouseEvent() || event->IsKeyEvent())) 58 if (event->HasNativeEvent()) {
58 return NULL; 59 if (event->IsMouseEvent())
60 return NULL;
61 if (event->IsKeyEvent()) {
62 // TODO(bruthig): Fix this to block rewritten volume keys
63 // (i.e. F9 and F10) from the device's keyboard. https://crbug.com/368669
64 ui::KeyEvent* key_event = static_cast<ui::KeyEvent*>(event);
65 if (key_event->key_code() != ui::VKEY_VOLUME_DOWN &&
66 key_event->key_code() != ui::VKEY_VOLUME_UP) {
67 return NULL;
68 }
69 }
70 }
59 return default_targeter_->FindTargetForEvent(root, event); 71 return default_targeter_->FindTargetForEvent(root, event);
60 } 72 }
61 73
62 } // namespace 74 } // namespace
63 75
64 MaximizeModeEventBlocker::MaximizeModeEventBlocker() { 76 MaximizeModeEventBlocker::MaximizeModeEventBlocker() {
65 Shell::GetInstance()->AddShellObserver(this); 77 Shell::GetInstance()->AddShellObserver(this);
66 78
67 // Hide the cursor as mouse events will be blocked. 79 // Hide the cursor as mouse events will be blocked.
68 aura::client::CursorClient* cursor_client_ = 80 aura::client::CursorClient* cursor_client_ =
(...skipping 22 matching lines...) Expand all
91 aura::Window* root_window) { 103 aura::Window* root_window) {
92 BlockKeyboardAndTouchpadTargeter* targeter = 104 BlockKeyboardAndTouchpadTargeter* targeter =
93 new BlockKeyboardAndTouchpadTargeter(); 105 new BlockKeyboardAndTouchpadTargeter();
94 aura::ScopedWindowTargeter* scoped_targeter = new aura::ScopedWindowTargeter( 106 aura::ScopedWindowTargeter* scoped_targeter = new aura::ScopedWindowTargeter(
95 root_window, scoped_ptr<ui::EventTargeter>(targeter)); 107 root_window, scoped_ptr<ui::EventTargeter>(targeter));
96 targeter->SetDefaultTargeter(scoped_targeter->old_targeter()); 108 targeter->SetDefaultTargeter(scoped_targeter->old_targeter());
97 targeters_.push_back(scoped_targeter); 109 targeters_.push_back(scoped_targeter);
98 } 110 }
99 111
100 } // namespace ash 112 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/maximize_mode/maximize_mode_controller_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698