Skip to content

Commit

Permalink
Makes ash/mus use RootWindowControllerCommon
Browse files Browse the repository at this point in the history
BUG=none
TEST=covered by tests
R=jamescook@chromium.org

Review-Url: https://codereview.chromium.org/2033843003
Cr-Commit-Position: refs/heads/master@{#398066}
  • Loading branch information
sky authored and Commit bot committed Jun 6, 2016
1 parent 2b359d2 commit 8208371
Show file tree
Hide file tree
Showing 25 changed files with 220 additions and 458 deletions.
1 change: 1 addition & 0 deletions ash/ash.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
'common/shelf/wm_shelf_observer.h',
'common/shelf/wm_shelf_util.cc',
'common/shelf/wm_shelf_util.h',
'common/shell_window_ids.cc',
'common/shell_window_ids.h',
'common/wm/always_on_top_controller.cc',
'common/wm/always_on_top_controller.h',
Expand Down
4 changes: 4 additions & 0 deletions ash/aura/wm_window_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "ash/aura/aura_layout_manager_adapter.h"
#include "ash/aura/wm_root_window_controller_aura.h"
#include "ash/aura/wm_shell_aura.h"
#include "ash/common/shell_window_ids.h"
#include "ash/common/wm/window_state.h"
#include "ash/common/wm_layout_manager.h"
#include "ash/common/wm_window_observer.h"
Expand Down Expand Up @@ -44,6 +45,9 @@ namespace ash {

DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::WmWindowAura, kWmWindowKey, nullptr);

static_assert(aura::Window::kInitialId == kShellWindowId_Invalid,
"ids must match");

namespace {

// A tentative class to set the bounds on the window.
Expand Down
3 changes: 2 additions & 1 deletion ash/common/root_window_controller_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef ASH_COMMON_ROOT_WINDOW_CONTROLLER_COMMON_H_
#define ASH_COMMON_ROOT_WINDOW_CONTROLLER_COMMON_H_

#include "ash/ash_export.h"
#include "base/macros.h"

namespace ash {
Expand All @@ -18,7 +19,7 @@ class RootWindowLayoutManager;
// This will eventually become what is RootWindowController. During the
// transition it contains code used by both the aura and mus implementations.
// It should *not* contain any aura specific code.
class RootWindowControllerCommon {
class ASH_EXPORT RootWindowControllerCommon {
public:
explicit RootWindowControllerCommon(WmWindow* root);
~RootWindowControllerCommon();
Expand Down
30 changes: 30 additions & 0 deletions ash/common/shell_window_ids.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/common/shell_window_ids.h"

#include "base/macros.h"

namespace ash {

// NOTE: this list is ordered by activation order. That is, windows in
// containers appearing earlier in the list are activated before windows in
// containers appearing later in the list.
const int kActivatableShellWindowIds[] = {
kShellWindowId_OverlayContainer, kShellWindowId_LockSystemModalContainer,
kShellWindowId_SettingBubbleContainer, kShellWindowId_LockScreenContainer,
kShellWindowId_SystemModalContainer, kShellWindowId_AlwaysOnTopContainer,
kShellWindowId_AppListContainer, kShellWindowId_DefaultContainer,

// Docked, 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_DockedContainer, kShellWindowId_PanelContainer,
kShellWindowId_ShelfContainer, kShellWindowId_StatusContainer,
};

const size_t kNumActivatableShellWindowIds =
arraysize(kActivatableShellWindowIds);

} // namespace ash
16 changes: 16 additions & 0 deletions ash/common/shell_window_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@
#ifndef ASH_COMMON_SHELL_WINDOW_IDS_H_
#define ASH_COMMON_SHELL_WINDOW_IDS_H_

#include <stddef.h>

#include "ash/ash_export.h"

// Declarations of ids of special shell windows.

namespace ash {

// Used to indicate no shell window id.
const int kShellWindowId_Invalid = -1;

// A higher-level container that holds all of the containers stacked below
// kShellWindowId_LockScreenContainer. Only used by PowerButtonController for
// animating lower-level containers.
Expand All @@ -33,6 +40,7 @@ const int kShellWindowId_UnparentedControlContainer = 3;
const int kShellWindowId_DesktopBackgroundContainer = 4;

// The virtual keyboard container.
// NOTE: this is lazily created.
const int kShellWindowId_VirtualKeyboardContainer = 5;

// The container for standard top-level windows.
Expand Down Expand Up @@ -99,6 +107,14 @@ const int kShellWindowId_MouseCursorContainer = 24;
// The topmost container, used for power off animation.
const int kShellWindowId_PowerButtonAnimationContainer = 25;

const int kShellWindowId_Min = 0;
const int kShellWindowId_Max = kShellWindowId_PowerButtonAnimationContainer;

// These are the list of container ids of containers which may contain windows
// that need to be activated.
ASH_EXPORT extern const int kActivatableShellWindowIds[];
ASH_EXPORT extern const size_t kNumActivatableShellWindowIds;

} // namespace ash

#endif // ASH_COMMON_SHELL_WINDOW_IDS_H_
4 changes: 0 additions & 4 deletions ash/mus/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ source_set("lib") {
sources = [
"accelerator_registrar_impl.cc",
"accelerator_registrar_impl.h",
"background_layout.cc",
"background_layout.h",
"bridge/mus_layout_manager_adapter.cc",
"bridge/mus_layout_manager_adapter.h",
"bridge/wm_lookup_mus.cc",
Expand All @@ -32,8 +30,6 @@ source_set("lib") {
"disconnected_app_handler.h",
"drag_window_resizer.cc",
"drag_window_resizer.h",
"fill_layout.cc",
"fill_layout.h",
"frame/caption_buttons/caption_button_types.h",
"frame/caption_buttons/frame_caption_button.cc",
"frame/caption_buttons/frame_caption_button.h",
Expand Down
25 changes: 0 additions & 25 deletions ash/mus/background_layout.cc

This file was deleted.

30 changes: 0 additions & 30 deletions ash/mus/background_layout.h

This file was deleted.

5 changes: 3 additions & 2 deletions ash/mus/bridge/wm_shell_mus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,9 @@ bool WmShellMus::IsActivationParent(::mus::Window* window) {
if (!window)
return false;

for (size_t i = 0; i < kNumActivationContainers; ++i) {
if (window->local_id() == static_cast<int>(kActivationContainers[i]))
const int shell_window_id = WmWindowMus::Get(window)->GetShellWindowId();
for (size_t i = 0; i < kNumActivatableShellWindowIds; ++i) {
if (shell_window_id == kActivatableShellWindowIds[i])
return true;
}
return false;
Expand Down
3 changes: 2 additions & 1 deletion ash/mus/bridge/wm_window_mus.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <memory>

#include "ash/common/shell_window_ids.h"
#include "ash/common/wm_window.h"
#include "base/macros.h"
#include "base/observer_list.h"
Expand Down Expand Up @@ -224,7 +225,7 @@ class WmWindowMus : public WmWindow, public ::mus::WindowObserver {

// The shell window id of this window. Shell window ids are defined in
// ash/common/shell_window_ids.h.
int shell_window_id_ = -1;
int shell_window_id_ = kShellWindowId_Invalid;

std::unique_ptr<wm::WindowState> window_state_;

Expand Down
123 changes: 8 additions & 115 deletions ash/mus/container_ids.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,139 +12,32 @@ using ash::mojom::Container;
namespace ash {
namespace mus {

const Container kActivationContainers[] = {
// TODO(sky): figure out right set of containers. I suspect this should be
// all non containers.
Container::USER_PRIVATE_WINDOWS,
Container::USER_PRIVATE_ALWAYS_ON_TOP_WINDOWS,
Container::USER_PRIVATE_DOCKED_WINDOWS,
Container::USER_PRIVATE_PRESENTATION_WINDOWS,
Container::USER_PRIVATE_PANELS, Container::USER_PRIVATE_APP_LIST,
Container::USER_PRIVATE_SYSTEM_MODAL, Container::LOGIN,
// Bubble windows must be allowed to activate because some of them rely on
// deactivation to close.
Container::BUBBLES,
};

const size_t kNumActivationContainers = arraysize(kActivationContainers);

Container AshContainerToMashContainer(int ash_id) {
switch (ash_id) {
case kShellWindowId_UnparentedControlContainer:
case kShellWindowId_LockScreenContainer:
case kShellWindowId_LockSystemModalContainer:
// We should never be asked to parent windows of these types.
NOTREACHED();
return Container::USER_PRIVATE;

case kShellWindowId_DefaultContainer:
return Container::USER_PRIVATE_WINDOWS;

case kShellWindowId_AlwaysOnTopContainer:
return Container::USER_PRIVATE_ALWAYS_ON_TOP_WINDOWS;

case kShellWindowId_DockedContainer:
return Container::USER_PRIVATE_DOCKED_WINDOWS;

case kShellWindowId_ShelfContainer:
return Container::USER_PRIVATE_SHELF;

case kShellWindowId_PanelContainer:
return Container::USER_PRIVATE_PANELS;

case kShellWindowId_AppListContainer:
return Container::USER_PRIVATE_APP_LIST;

case kShellWindowId_SystemModalContainer:
return Container::USER_PRIVATE_SYSTEM_MODAL;

case kShellWindowId_MenuContainer:
return Container::MENUS;

case kShellWindowId_DragImageAndTooltipContainer:
return Container::DRAG_AND_TOOLTIPS;

default:
NOTREACHED();
}
return Container::USER_PRIVATE_WINDOWS;
}

int MashContainerToAshContainer(Container container) {
int MashContainerToAshShellWindowId(Container container) {
switch (container) {
case Container::ROOT:
return kUnknownAshId;

case Container::ALL_USER_BACKGROUND:
return kUnknownAshId;

case Container::USER:
return kUnknownAshId;

case Container::USER_BACKGROUND:
return kUnknownAshId;

case Container::USER_PRIVATE:
return kUnknownAshId;

case Container::USER_PRIVATE_WINDOWS:
return kShellWindowId_DefaultContainer;

case Container::USER_PRIVATE_ALWAYS_ON_TOP_WINDOWS:
return kShellWindowId_AlwaysOnTopContainer;

case Container::USER_PRIVATE_DOCKED_WINDOWS:
return kShellWindowId_DockedContainer;

case Container::USER_PRIVATE_PRESENTATION_WINDOWS:
return kUnknownAshId;
return kShellWindowId_DesktopBackgroundContainer;

case Container::USER_PRIVATE_SHELF:
return kShellWindowId_ShelfContainer;

case Container::USER_PRIVATE_PANELS:
return kShellWindowId_PanelContainer;

case Container::USER_PRIVATE_APP_LIST:
return kShellWindowId_AppListContainer;

case Container::USER_PRIVATE_SYSTEM_MODAL:
return kShellWindowId_SystemModalContainer;

case Container::LOGIN:
return kUnknownAshId;

case Container::LOGIN_WINDOWS:
return kUnknownAshId;

case Container::LOGIN_APP:
return kUnknownAshId;

case Container::LOGIN_SHELF:
return kUnknownAshId;
return kShellWindowId_LockScreenContainer;

case Container::STATUS:
return kUnknownAshId;
return kShellWindowId_StatusContainer;

case Container::BUBBLES:
return kUnknownAshId;

case Container::SYSTEM_MODAL_WINDOWS:
return kUnknownAshId;

case Container::KEYBOARD:
return kUnknownAshId;
// TODO(sky): this mapping isn't right, but BUBBLES should go away once
// http://crbug.com/616859 lands.
return kShellWindowId_SettingBubbleContainer;

case Container::MENUS:
return kShellWindowId_MenuContainer;

case Container::DRAG_AND_TOOLTIPS:
return kShellWindowId_DragImageAndTooltipContainer;

case Container::COUNT:
return kUnknownAshId;
}
return kUnknownAshId;
return kShellWindowId_Invalid;
}

} // namespace mus
Expand Down
14 changes: 2 additions & 12 deletions ash/mus/container_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,9 @@ enum class Container;
}

namespace mus {
// Id used when there is no corresponding ash container.
const int kUnknownAshId = -1;

// The set of containers that allow their children to be active.
extern const mojom::Container kActivationContainers[];

// Number of kActivationContainers.
extern const size_t kNumActivationContainers;

// Converts window ids between ash (ash/common/shell_window_ids.h) and
// mash.
mojom::Container AshContainerToMashContainer(int shell_window_id);
int MashContainerToAshContainer(mojom::Container container);
// Converts a Container to a shell window ids (ash/common/shell_window_ids.h).
int MashContainerToAshShellWindowId(mojom::Container container);

} // namespace mus
} // namespace ash
Expand Down
Loading

0 comments on commit 8208371

Please sign in to comment.