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

Unified Diff: ash/wm/activation_controller.cc

Issue 9568045: Activate windows in topmost containers when a window is hidden. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add tests and address review comments. Created 8 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
« no previous file with comments | « ash/wm/activation_controller.h ('k') | ash/wm/activation_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/activation_controller.cc
diff --git a/ash/wm/activation_controller.cc b/ash/wm/activation_controller.cc
index c90846ad5a5aa24b3709d03d8936c39075a0e262..984175b7c6bc47d64e1737dac5b953262538d5ff 100644
--- a/ash/wm/activation_controller.cc
+++ b/ash/wm/activation_controller.cc
@@ -21,6 +21,23 @@ namespace ash {
namespace internal {
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[] = {
+ kShellWindowId_LockSystemModalContainer,
+ kShellWindowId_LockScreenContainer,
+ kShellWindowId_SystemModalContainer,
+ kShellWindowId_AlwaysOnTopContainer,
+ 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.
+ kShellWindowId_PanelContainer,
+ kShellWindowId_LauncherContainer,
+ kShellWindowId_StatusContainer,
+};
+
aura::Window* GetContainer(int id) {
return Shell::GetInstance()->GetContainer(id);
}
@@ -28,14 +45,11 @@ aura::Window* GetContainer(int id) {
// Returns true if children of |window| can be activated.
// These are the only containers in which windows can receive focus.
bool SupportsChildActivation(aura::Window* window) {
- return window->id() == kShellWindowId_DefaultContainer ||
- window->id() == kShellWindowId_AlwaysOnTopContainer ||
- window->id() == kShellWindowId_PanelContainer ||
- window->id() == kShellWindowId_SystemModalContainer ||
- window->id() == kShellWindowId_StatusContainer ||
- window->id() == kShellWindowId_LauncherContainer ||
- window->id() == kShellWindowId_LockScreenContainer ||
- window->id() == kShellWindowId_LockSystemModalContainer;
+ for (size_t i = 0; i < arraysize(kWindowContainerIds); i++) {
+ if (window->id() == kWindowContainerIds[i])
+ return true;
+ }
+ return false;
}
// Returns true if |window| can be activated or deactivated.
@@ -208,21 +222,42 @@ void ActivationController::ActivateNextWindow(aura::Window* window) {
aura::Window* ActivationController::GetTopmostWindowToActivate(
aura::Window* ignore) const {
- const aura::Window* container =
- default_container_for_test_ ? default_container_for_test_ :
- GetContainer(kShellWindowId_DefaultContainer);
- // When destructing an active window that is in a container destructed after
- // the default container during shell shutdown, |container| would be NULL
- // because default container is destructed at this point.
- if (container) {
- for (aura::Window::Windows::const_reverse_iterator i =
- container->children().rbegin();
- i != container->children().rend();
- ++i) {
- if (*i != ignore && CanActivateWindow(*i))
- return *i;
+ if (default_container_for_test_) {
oshima 2012/03/02 18:25:38 I know this isn't the scope of your CL, but asking
flackr 2012/03/02 18:58:40 Done.
+ return GetTopmostWindowToActivateInContainer(default_container_for_test_,
+ ignore);
+ }
+
+ size_t i = 0;
oshima 2012/03/02 18:25:38 current_container_index / active_container_index ?
flackr 2012/03/02 18:58:40 Done.
+ // If the container of the window losing focus is in the list, start from that
+ // container.
+ for (size_t j = 0; j < arraysize(kWindowContainerIds); j++) {
+ aura::Window* container = GetContainer(kWindowContainerIds[j]);
+ if (container && container->Contains(ignore)) {
+ i = j;
+ break;
}
}
+
+ // Look for windows to focus in that container and below.
+ aura::Window* window = NULL;
+ for (; !window && i < arraysize(kWindowContainerIds); i++) {
+ aura::Window* container = GetContainer(kWindowContainerIds[i]);
+ if (container)
+ window = GetTopmostWindowToActivateInContainer(container, ignore);
+ }
+ return window;
+}
+
+aura::Window* ActivationController::GetTopmostWindowToActivateInContainer(
+ aura::Window* container,
+ aura::Window* ignore) const {
+ for (aura::Window::Windows::const_reverse_iterator i =
+ container->children().rbegin();
+ i != container->children().rend();
+ ++i) {
+ if (*i != ignore && CanActivateWindow(*i))
+ return *i;
+ }
return NULL;
}
« no previous file with comments | « ash/wm/activation_controller.h ('k') | ash/wm/activation_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698