#include "ash/wm/status_area_layout_manager.h"
#include "ash/wm/system_background_controller.h"
#include "ash/wm/system_modal_container_layout_manager.h"
+#include "ash/wm/virtual_keyboard_container_layout_manager.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ui/wm/public/window_types.h"
#if defined(OS_CHROMEOS)
-#include "ash/system/tray_accessibility.h"
+#include "ash/ash_touch_exploration_manager_chromeos.h"
#include "ash/wm/boot_splash_screen_chromeos.h"
#include "ui/chromeos/touch_exploration_controller.h"
#endif
class EmptyWindowDelegate : public aura::WindowDelegate {
public:
EmptyWindowDelegate() {}
- virtual ~EmptyWindowDelegate() {}
+ ~EmptyWindowDelegate() override {}
// aura::WindowDelegate overrides:
- virtual gfx::Size GetMinimumSize() const OVERRIDE {
- return gfx::Size();
- }
- virtual gfx::Size GetMaximumSize() const OVERRIDE {
- return gfx::Size();
- }
- virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) OVERRIDE {
- }
- virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE {
+ gfx::Size GetMinimumSize() const override { return gfx::Size(); }
+ gfx::Size GetMaximumSize() const override { return gfx::Size(); }
+ void OnBoundsChanged(const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) override {}
+ gfx::NativeCursor GetCursor(const gfx::Point& point) override {
return gfx::kNullCursor;
}
- virtual int GetNonClientComponent(
- const gfx::Point& point) const OVERRIDE {
+ int GetNonClientComponent(const gfx::Point& point) const override {
return HTNOWHERE;
}
- virtual bool ShouldDescendIntoChildForEventHandling(
+ bool ShouldDescendIntoChildForEventHandling(
aura::Window* child,
- const gfx::Point& location) OVERRIDE {
- return false;
- }
- virtual bool CanFocus() OVERRIDE {
- return false;
- }
- virtual void OnCaptureLost() OVERRIDE {
- }
- virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
- }
- virtual void OnDeviceScaleFactorChanged(
- float device_scale_factor) OVERRIDE {
- }
- virtual void OnWindowDestroying(aura::Window* window) OVERRIDE {}
- virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE {
- delete this;
- }
- virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE {
- }
- virtual bool HasHitTestMask() const OVERRIDE {
+ const gfx::Point& location) override {
return false;
}
- virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE {}
+ bool CanFocus() override { return false; }
+ void OnCaptureLost() override {}
+ void OnPaint(gfx::Canvas* canvas) override {}
+ void OnDeviceScaleFactorChanged(float device_scale_factor) override {}
+ void OnWindowDestroying(aura::Window* window) override {}
+ void OnWindowDestroyed(aura::Window* window) override { delete this; }
+ void OnWindowTargetVisibilityChanged(bool visible) override {}
+ bool HasHitTestMask() const override { return false; }
+ void GetHitTestMask(gfx::Path* mask) const override {}
private:
DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate);
};
-#if defined(OS_CHROMEOS)
-// Responsible for initializing TouchExplorationController when spoken
-// feedback is on.
-class CrosAccessibilityObserver : public AccessibilityObserver {
- public:
- explicit CrosAccessibilityObserver(
- RootWindowController* root_window_controller)
- : root_window_controller_(root_window_controller) {
- Shell::GetInstance()->system_tray_notifier()->
- AddAccessibilityObserver(this);
- UpdateTouchExplorationState();
- }
-
- virtual ~CrosAccessibilityObserver() {
- SystemTrayNotifier* system_tray_notifier =
- Shell::GetInstance()->system_tray_notifier();
- if (system_tray_notifier)
- system_tray_notifier->RemoveAccessibilityObserver(this);
- }
-
- private:
- void UpdateTouchExplorationState() {
- AccessibilityDelegate* delegate =
- Shell::GetInstance()->accessibility_delegate();
- bool enabled = delegate->IsSpokenFeedbackEnabled();
-
- if (enabled && !touch_exploration_controller_.get()) {
- touch_exploration_controller_.reset(
- new ui::TouchExplorationController(
- root_window_controller_->GetRootWindow()));
- } else if (!enabled) {
- touch_exploration_controller_.reset();
- }
- }
-
- // Overridden from AccessibilityObserver.
- virtual void OnAccessibilityModeChanged(
- AccessibilityNotificationVisibility notify) OVERRIDE {
- UpdateTouchExplorationState();
- }
-
- scoped_ptr<ui::TouchExplorationController> touch_exploration_controller_;
- RootWindowController* root_window_controller_;
-
- DISALLOW_COPY_AND_ASSIGN(CrosAccessibilityObserver);
-};
-#endif // OS_CHROMEOS
-
} // namespace
void RootWindowController::CreateForPrimaryDisplay(AshWindowTreeHost* host) {
controller->Init(RootWindowController::SECONDARY, false /* first run */);
}
-void RootWindowController::CreateForVirtualKeyboardDisplay(
- AshWindowTreeHost* host) {
- RootWindowController* controller = new RootWindowController(host);
- controller->Init(RootWindowController::VIRTUAL_KEYBOARD,
- false /* first run */);
-}
-
// static
RootWindowController* RootWindowController::ForShelf(
const aura::Window* window) {
+ CHECK(Shell::HasInstance());
return GetRootWindowController(window->GetRootWindow());
}
// static
RootWindowController* RootWindowController::ForWindow(
const aura::Window* window) {
+ CHECK(Shell::HasInstance());
return GetRootWindowController(window->GetRootWindow());
}
// static
RootWindowController* RootWindowController::ForTargetRootWindow() {
+ CHECK(Shell::HasInstance());
return GetRootWindowController(Shell::GetTargetRootWindow());
}
shell->RemoveShellObserver(this);
#if defined(OS_CHROMEOS)
- if (cros_accessibility_observer_) {
- cros_accessibility_observer_.reset();
+ if (touch_exploration_manager_) {
+ touch_exploration_manager_.reset();
}
#endif
void RootWindowController::HandleInitialDesktopBackgroundAnimationStarted() {
#if defined(OS_CHROMEOS)
- if (CommandLine::ForCurrentProcess()->HasSwitch(
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAshAnimateFromBootSplashScreen) &&
boot_splash_screen_.get()) {
// Make the splash screen fade out so it doesn't obscure the desktop
if (!wallpaper_controller_.get())
return;
- views::MenuRunner menu_runner(menu_model.get());
+ views::MenuRunner menu_runner(menu_model.get(),
+ views::MenuRunner::CONTEXT_MENU);
if (menu_runner.RunMenuAt(wallpaper_controller_->widget(),
NULL,
gfx::Rect(location_in_screen, gfx::Size()),
views::MENU_ANCHOR_TOPLEFT,
- source_type,
- views::MenuRunner::CONTEXT_MENU) ==
- views::MenuRunner::MENU_DELETED) {
+ source_type) == views::MenuRunner::MENU_DELETED) {
return;
}
return;
}
DCHECK(keyboard_controller);
- if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) {
- keyboard_controller->AddObserver(shelf()->shelf_layout_manager());
- keyboard_controller->AddObserver(panel_layout_manager_);
- keyboard_controller->AddObserver(docked_layout_manager_);
- keyboard_controller->AddObserver(workspace_controller_->layout_manager());
- Shell::GetInstance()->delegate()->VirtualKeyboardActivated(true);
- }
- aura::Window* parent = GetContainer(
- kShellWindowId_VirtualKeyboardParentContainer);
+ keyboard_controller->AddObserver(shelf()->shelf_layout_manager());
+ keyboard_controller->AddObserver(panel_layout_manager_);
+ keyboard_controller->AddObserver(docked_layout_manager_);
+ keyboard_controller->AddObserver(workspace_controller_->layout_manager());
+ Shell::GetInstance()->delegate()->VirtualKeyboardActivated(true);
+ aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer);
DCHECK(parent);
aura::Window* keyboard_container =
keyboard_controller->GetContainerWindow();
aura::Window* keyboard_container =
keyboard_controller->GetContainerWindow();
if (keyboard_container->GetRootWindow() == GetRootWindow()) {
- aura::Window* parent = GetContainer(
- kShellWindowId_VirtualKeyboardParentContainer);
+ aura::Window* parent =
+ GetContainer(kShellWindowId_ImeWindowParentContainer);
DCHECK(parent);
parent->RemoveChild(keyboard_container);
- if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) {
- // Virtual keyboard may be deactivated while still showing, notify all
- // observers that keyboard bounds changed to 0 before remove them.
- keyboard_controller->NotifyKeyboardBoundsChanging(gfx::Rect());
- keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager());
- keyboard_controller->RemoveObserver(panel_layout_manager_);
- keyboard_controller->RemoveObserver(docked_layout_manager_);
- keyboard_controller->RemoveObserver(
- workspace_controller_->layout_manager());
- Shell::GetInstance()->delegate()->VirtualKeyboardActivated(false);
- }
+ // Virtual keyboard may be deactivated while still showing, notify all
+ // observers that keyboard bounds changed to 0 before remove them.
+ keyboard_controller->NotifyKeyboardBoundsChanging(gfx::Rect());
+ keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager());
+ keyboard_controller->RemoveObserver(panel_layout_manager_);
+ keyboard_controller->RemoveObserver(docked_layout_manager_);
+ keyboard_controller->RemoveObserver(
+ workspace_controller_->layout_manager());
+ Shell::GetInstance()->delegate()->VirtualKeyboardActivated(false);
}
}
bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) {
- aura::Window* parent = GetContainer(
- kShellWindowId_VirtualKeyboardParentContainer);
+ aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer);
return parent ? parent->Contains(window) : false;
}
ash_host_->AsWindowTreeHost()->SetCursor(ui::kCursorPointer);
CreateContainersInRootWindow(root_window);
- if (root_window_type == VIRTUAL_KEYBOARD) {
- aura::Window* virtual_keyboard_parent_container = GetContainer(
- kShellWindowId_VirtualKeyboardParentContainer);
- virtual_keyboard_parent_container->SetBounds(root_window->bounds());
- shell->InitKeyboard();
- return;
- }
-
CreateSystemBackground(first_run_after_boot);
InitLayoutManagers();
if (root_window_type == PRIMARY) {
root_window_layout()->OnWindowResized();
- if (!keyboard::IsKeyboardUsabilityExperimentEnabled())
- shell->InitKeyboard();
+ shell->InitKeyboard();
} else {
root_window_layout()->OnWindowResized();
ash_host_->AsWindowTreeHost()->Show();
}
#if defined(OS_CHROMEOS)
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kAshEnableTouchExplorationMode)) {
- cros_accessibility_observer_.reset(new CrosAccessibilityObserver(this));
+ if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAshDisableTouchExplorationMode)) {
+ touch_exploration_manager_.reset(new AshTouchExplorationManager(this));
}
#endif
}
new DockedWindowLayoutManager(docked_container, workspace_controller());
docked_container->SetLayoutManager(docked_layout_manager_);
+ // Installs SnapLayoutManager to containers who set the
+ // |kSnapsChildrenToPhysicalPixelBoundary| property.
+ wm::InstallSnapLayoutManagerToContainers(root_window);
+
// Create Panel layout manager
aura::Window* panel_container = GetContainer(kShellWindowId_PanelContainer);
panel_layout_manager_ = new PanelLayoutManager(panel_container);
}
void RootWindowController::InitTouchHuds() {
- CommandLine* command_line = CommandLine::ForCurrentProcess();
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kAshTouchHud))
set_touch_hud_debug(new TouchHudDebug(GetRootWindow()));
if (Shell::GetInstance()->is_touch_hud_projection_enabled())
// Make a copy of the system's boot splash screen so we can composite it
// onscreen until the desktop background is ready.
if (is_first_run_after_boot &&
- (CommandLine::ForCurrentProcess()->HasSwitch(
+ (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAshCopyHostBackgroundAtBoot) ||
- CommandLine::ForCurrentProcess()->HasSwitch(
+ base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAshAnimateFromBootSplashScreen)))
boot_splash_screen_.reset(new BootSplashScreen(GetHost()));
#endif
"DefaultContainer",
non_lock_screen_containers);
::wm::SetChildWindowVisibilityChangesAnimated(default_container);
+ wm::SetSnapsChildrenToPhysicalPixelBoundary(default_container);
SetUsesScreenCoordinates(default_container);
SetUsesEasyResizeTargeter(default_container);
"AlwaysOnTopContainer",
non_lock_screen_containers);
::wm::SetChildWindowVisibilityChangesAnimated(always_on_top_container);
+ wm::SetSnapsChildrenToPhysicalPixelBoundary(always_on_top_container);
SetUsesScreenCoordinates(always_on_top_container);
aura::Window* docked_container = CreateContainer(
"DockedContainer",
non_lock_screen_containers);
::wm::SetChildWindowVisibilityChangesAnimated(docked_container);
+ wm::SetSnapsChildrenToPhysicalPixelBoundary(docked_container);
SetUsesScreenCoordinates(docked_container);
SetUsesEasyResizeTargeter(docked_container);
CreateContainer(kShellWindowId_ShelfContainer,
"ShelfContainer",
non_lock_screen_containers);
+ wm::SetSnapsChildrenToPhysicalPixelBoundary(shelf_container);
SetUsesScreenCoordinates(shelf_container);
DescendantShouldStayInSameRootWindow(shelf_container);
kShellWindowId_PanelContainer,
"PanelContainer",
non_lock_screen_containers);
+ wm::SetSnapsChildrenToPhysicalPixelBoundary(panel_container);
SetUsesScreenCoordinates(panel_container);
aura::Window* shelf_bubble_container =
CreateContainer(kShellWindowId_ShelfBubbleContainer,
"ShelfBubbleContainer",
non_lock_screen_containers);
+ wm::SetSnapsChildrenToPhysicalPixelBoundary(shelf_bubble_container);
SetUsesScreenCoordinates(shelf_bubble_container);
DescendantShouldStayInSameRootWindow(shelf_bubble_container);
CreateContainer(kShellWindowId_AppListContainer,
"AppListContainer",
non_lock_screen_containers);
+ wm::SetSnapsChildrenToPhysicalPixelBoundary(app_list_container);
SetUsesScreenCoordinates(app_list_container);
aura::Window* modal_container = CreateContainer(
kShellWindowId_SystemModalContainer,
"SystemModalContainer",
non_lock_screen_containers);
+ wm::SetSnapsChildrenToPhysicalPixelBoundary(modal_container);
modal_container->SetLayoutManager(
new SystemModalContainerLayoutManager(modal_container));
::wm::SetChildWindowVisibilityChangesAnimated(modal_container);
kShellWindowId_LockScreenContainer,
"LockScreenContainer",
lock_screen_containers);
- if (CommandLine::ForCurrentProcess()->HasSwitch(
+ wm::SetSnapsChildrenToPhysicalPixelBoundary(lock_container);
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAshDisableLockLayoutManager)) {
lock_container->SetLayoutManager(
new WorkspaceLayoutManager(lock_container));
kShellWindowId_LockSystemModalContainer,
"LockSystemModalContainer",
lock_screen_containers);
+ wm::SetSnapsChildrenToPhysicalPixelBoundary(lock_modal_container);
lock_modal_container->SetLayoutManager(
new SystemModalContainerLayoutManager(lock_modal_container));
::wm::SetChildWindowVisibilityChangesAnimated(lock_modal_container);
CreateContainer(kShellWindowId_StatusContainer,
"StatusContainer",
lock_screen_related_containers);
+ wm::SetSnapsChildrenToPhysicalPixelBoundary(status_container);
SetUsesScreenCoordinates(status_container);
DescendantShouldStayInSameRootWindow(status_container);
"SettingBubbleContainer",
lock_screen_related_containers);
::wm::SetChildWindowVisibilityChangesAnimated(settings_bubble_container);
+ wm::SetSnapsChildrenToPhysicalPixelBoundary(settings_bubble_container);
SetUsesScreenCoordinates(settings_bubble_container);
DescendantShouldStayInSameRootWindow(settings_bubble_container);
+ aura::Window* virtual_keyboard_parent_container =
+ CreateContainer(kShellWindowId_ImeWindowParentContainer,
+ "VirtualKeyboardParentContainer",
+ lock_screen_related_containers);
+ wm::SetSnapsChildrenToPhysicalPixelBoundary(
+ virtual_keyboard_parent_container);
+ virtual_keyboard_parent_container->SetLayoutManager(
+ new VirtualKeyboardContainerLayoutManager(
+ virtual_keyboard_parent_container));
+ SetUsesScreenCoordinates(virtual_keyboard_parent_container);
+
aura::Window* menu_container = CreateContainer(
kShellWindowId_MenuContainer,
"MenuContainer",
lock_screen_related_containers);
::wm::SetChildWindowVisibilityChangesAnimated(menu_container);
+ wm::SetSnapsChildrenToPhysicalPixelBoundary(menu_container);
SetUsesScreenCoordinates(menu_container);
aura::Window* drag_drop_container = CreateContainer(
"DragImageAndTooltipContainer",
lock_screen_related_containers);
::wm::SetChildWindowVisibilityChangesAnimated(drag_drop_container);
+ wm::SetSnapsChildrenToPhysicalPixelBoundary(drag_drop_container);
SetUsesScreenCoordinates(drag_drop_container);
aura::Window* overlay_container = CreateContainer(
kShellWindowId_OverlayContainer,
"OverlayContainer",
lock_screen_related_containers);
+ wm::SetSnapsChildrenToPhysicalPixelBoundary(overlay_container);
SetUsesScreenCoordinates(overlay_container);
- aura::Window* virtual_keyboard_parent_container = CreateContainer(
- kShellWindowId_VirtualKeyboardParentContainer,
- "VirtualKeyboardParentContainer",
- root_window);
- SetUsesScreenCoordinates(virtual_keyboard_parent_container);
-
#if defined(OS_CHROMEOS)
aura::Window* mouse_cursor_container = CreateContainer(
kShellWindowId_MouseCursorContainer,