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

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

Issue 582143004: Introduce "Preferred" accelerators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
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/accelerators/accelerator_delegate.h" 5 #include "ash/accelerators/accelerator_delegate.h"
6 6
7 #include "ash/accelerators/accelerator_controller.h" 7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/wm/window_state.h" 9 #include "ash/wm/window_state.h"
10 #include "ui/base/accelerators/accelerator.h" 10 #include "ui/base/accelerators/accelerator.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 const ui::KeyEvent& event, 52 const ui::KeyEvent& event,
53 const ui::Accelerator& accelerator) { 53 const ui::Accelerator& accelerator) {
54 aura::Window* target = static_cast<aura::Window*>(event.target()); 54 aura::Window* target = static_cast<aura::Window*>(event.target());
55 DCHECK(target); 55 DCHECK(target);
56 56
57 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 57 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
58 if (std::find(root_windows.begin(), root_windows.end(), target) != 58 if (std::find(root_windows.begin(), root_windows.end(), target) !=
59 root_windows.end()) 59 root_windows.end())
60 return true; 60 return true;
61 61
62 // A full screen window should be able to handle all key events including the 62 aura::Window* top_level = ::wm::GetToplevelWindow(target);
63 Shell* shell = Shell::GetInstance();
64
65 // Reserved accelerators (such as Power button) always have a prority.
66 if (shell->accelerator_controller()->IsReserved(accelerator))
67 return true;
68
69 // A full screen window has a right to handle all key events including the
63 // reserved ones. 70 // reserved ones.
64 aura::Window* top_level = ::wm::GetToplevelWindow(target);
65
66 if (top_level && wm::GetWindowState(top_level)->IsFullscreen()) { 71 if (top_level && wm::GetWindowState(top_level)->IsFullscreen()) {
67 // TODO(yusukes): On Chrome OS, only browser and flash windows can be full 72 // On ChromeOS, fullscreen windows are either browser or apps, which
68 // screen. Launching an app in "open full-screen" mode is not supported yet. 73 // send key events to a web content first, then will process keys
69 // That makes the IsWindowFullscreen() check above almost meaningless 74 // if the web content didn't consume them.
70 // because a browser and flash window do handle Ash accelerators anyway
71 // before they're passed to a page or flash content.
72 return false; 75 return false;
73 } 76 }
74 77
75 if (Shell::GetInstance()->GetAppListTargetVisibility()) 78 // Handle preferred accelerators (such as ALT-TAB) before sending
79 // to the target.
80 if (shell->accelerator_controller()->IsPreferred(accelerator))
76 return true; 81 return true;
77 82
78 // Unless |target| is in the full screen state, handle reserved accelerators 83 return shell->GetAppListTargetVisibility();
79 // such as Alt+Tab now.
80 return Shell::GetInstance()->accelerator_controller()->IsReservedAccelerator(
81 accelerator);
82 } 84 }
83 85
84 } // namespace ash 86 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698