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

Unified Diff: ash/wm/ash_focus_rules.cc

Issue 11414304: Fleshes out the basic set of focus rules a bit more. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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
« no previous file with comments | « ash/wm/ash_focus_rules.h ('k') | ui/views/corewm/base_focus_rules.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/ash_focus_rules.cc
===================================================================
--- ash/wm/ash_focus_rules.cc (revision 170971)
+++ ash/wm/ash_focus_rules.cc (working copy)
@@ -4,11 +4,45 @@
#include "ash/wm/ash_focus_rules.h"
+#include "ash/shell.h"
+#include "ash/shell_window_ids.h"
+#include "ash/wm/window_util.h"
#include "ui/aura/window.h"
namespace ash {
namespace wm {
+namespace {
+// These are the list of container ids of containers which may contain windows
+// that need to be activated in the order that they should be activated.
+const int kWindowContainerIds[] = {
+ internal::kShellWindowId_LockSystemModalContainer,
+ internal::kShellWindowId_SettingBubbleContainer,
+ internal::kShellWindowId_LockScreenContainer,
+ internal::kShellWindowId_SystemModalContainer,
+ internal::kShellWindowId_AlwaysOnTopContainer,
+ internal::kShellWindowId_AppListContainer,
+ internal::kShellWindowId_DefaultContainer,
+
+ // Panel, launcher and status are intentionally checked after other
+ // containers even though these layers are higher. The user expects their
+ // windows to be focused before these elements.
+ internal::kShellWindowId_PanelContainer,
+ internal::kShellWindowId_LauncherContainer,
+ internal::kShellWindowId_StatusContainer,
+};
+
+bool BelongsToContainerWithEqualOrGreaterId(const aura::Window* window,
+ int container_id) {
+ for (; window; window = window->parent()) {
+ if (window->id() >= container_id)
+ return true;
+ }
+ return false;
+}
+
+} // namespace
+
////////////////////////////////////////////////////////////////////////////////
// AshFocusRules, public:
@@ -21,29 +55,45 @@
////////////////////////////////////////////////////////////////////////////////
// AshFocusRules, views::corewm::FocusRules:
-bool AshFocusRules::CanActivateWindow(aura::Window* window) {
- return window && !!window->parent();
-}
+bool AshFocusRules::SupportsChildActivation(aura::Window* window) {
+ if (window->id() == internal::kShellWindowId_WorkspaceContainer)
+ return true;
-bool AshFocusRules::CanFocusWindow(aura::Window* window) {
- aura::Window* activatable = GetActivatableWindow(window);
- return activatable->Contains(window) && window->CanFocus();
-}
+ if (window->id() != internal::kShellWindowId_DefaultContainer)
+ return false;
-aura::Window* AshFocusRules::GetActivatableWindow(aura::Window* window) {
- return window;
+ for (size_t i = 0; i < arraysize(kWindowContainerIds); i++) {
+ if (window->id() == kWindowContainerIds[i])
+ return true;
+ }
+ return false;
}
-aura::Window* AshFocusRules::GetFocusableWindow(aura::Window* window) {
- return window;
-}
+bool AshFocusRules::IsWindowConsideredVisibleForActivation(
+ aura::Window* window) {
+ if (BaseFocusRules::IsWindowConsideredVisibleForActivation(window))
+ return true;
-aura::Window* AshFocusRules::GetNextActivatableWindow(aura::Window* ignore) {
- return NULL;
+ // Minimized windows are hidden in their minimized state, but they can always
+ // be activated.
+ if (wm::IsWindowMinimized(window))
+ return true;
+
+ return window->TargetVisibility() && (window->parent()->id() ==
+ internal::kShellWindowId_WorkspaceContainer || window->parent()->id() ==
+ internal::kShellWindowId_LockScreenContainer);
}
-aura::Window* AshFocusRules::GetNextFocusableWindow(aura::Window* ignore) {
- return GetFocusableWindow(ignore->parent());
+bool AshFocusRules::CanActivateWindow(aura::Window* window) {
+ if (!BaseFocusRules::CanActivateWindow(window))
+ return false;
+
+ if (Shell::GetInstance()->IsSystemModalWindowOpen()) {
+ return BelongsToContainerWithEqualOrGreaterId(
+ window, internal::kShellWindowId_SystemModalContainer);
+ }
+
+ return true;
}
} // namespace wm
« no previous file with comments | « ash/wm/ash_focus_rules.h ('k') | ui/views/corewm/base_focus_rules.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698