15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <set> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/ash_export.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ash/shell_observer.h" 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/wm/window_state_observer.h" 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ash/wm/wm_types.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h" 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/compiler_specific.h" 16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/aura/layout_manager.h" 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/aura/window_observer.h" 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/rect.h" 2046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles)#include "ui/keyboard/keyboard_controller_observer.h" 21effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "ui/wm/public/activation_change_observer.h" 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace aura { 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class RootWindow; 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Window; 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ui { 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Layer; 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ash { 33c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochclass ShelfLayoutManager; 34c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdochclass WorkspaceLayoutManagerDelegate; 35c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace wm { 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class WindowState; 38a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class WMEvent; 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 41a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles)// LayoutManager used on the window created for a workspace. 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class ASH_EXPORT WorkspaceLayoutManager 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) : public aura::LayoutManager, 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public aura::WindowObserver, 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public aura::client::ActivationChangeObserver, 4646d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) public keyboard::KeyboardControllerObserver, 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public ShellObserver, 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public wm::WindowStateObserver { 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 50a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) explicit WorkspaceLayoutManager(aura::Window* window); 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~WorkspaceLayoutManager(); 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 53c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch void SetShelf(ShelfLayoutManager* shelf); 54a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 55a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // A delegate which can be set to add a backdrop behind the top most visible 56a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // window. With the call the ownership of the delegate will be transferred to 57a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // the WorkspaceLayoutManager. 58a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) void SetMaximizeBackdropDelegate( 59a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_ptr<WorkspaceLayoutManagerDelegate> delegate); 60a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 61558790d6acca3451cf3a6b497803a5f07d0bec58Ben Murdoch // Overridden from aura::LayoutManager: 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnWindowResized() OVERRIDE {} 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE; 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE; 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE; 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnChildWindowVisibilityChanged(aura::Window* child, 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool visibile) OVERRIDE; 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetChildBounds(aura::Window* child, 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect& requested_bounds) OVERRIDE; 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ash::ShellObserver overrides: 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnDisplayWorkAreaInsetsChanged() OVERRIDE; 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overriden from WindowObserver: 75a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual void OnWindowHierarchyChanged( 76a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const WindowObserver::HierarchyChangeParams& params) OVERRIDE; 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnWindowPropertyChanged(aura::Window* window, 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const void* key, 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) intptr_t old) OVERRIDE; 80a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) virtual void OnWindowStackingChanged(aura::Window* window) OVERRIDE; 815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; 825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void OnWindowBoundsChanged(aura::Window* window, 835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const gfx::Rect& old_bounds, 845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const gfx::Rect& new_bounds) OVERRIDE; 855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // aura::client::ActivationChangeObserver overrides: 875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void OnWindowActivated(aura::Window* gained_active, 885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) aura::Window* lost_active) OVERRIDE; 8958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) 9046d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) // keyboard::KeyboardControllerObserver overrides: 9146d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) virtual void OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) OVERRIDE; 9246d4c2bc3267f3f028f39e7e311b0f89aba2e4fdTorne (Richard Coles) 934e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) // WindowStateObserver overrides: 94a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual void OnPostWindowStateTypeChange( 95a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) wm::WindowState* window_state, 96a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) wm::WindowStateType old_type) OVERRIDE; 974e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) typedef std::set<aura::Window*> WindowSet; 1005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 101a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Adjusts the bounds of all managed windows when the display area changes. 102a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // This happens when the display size, work area insets has changed. 103a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // If this is called for a display size change (i.e. |event| 104a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // is DISPLAY_RESIZED), the non-maximized/non-fullscreen 1055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // windows are readjusted to make sure the window is completely within the 1065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // display region. Otherwise, it makes sure at least some parts of the window 1075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // is on display. 108a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) void AdjustAllWindowsBoundsForWorkAreaChange(const wm::WMEvent* event); 109bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 110a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Updates the visibility state of the shelf. 111a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void UpdateShelfVisibility(); 112a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 113a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Updates the fullscreen state of the workspace and notifies Shell if it 114a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // has changed. 115a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void UpdateFullscreenState(); 116a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) 117a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Updates the bounds of the window for a stte type change from 1185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // |old_show_type|. 119a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) void UpdateBoundsFromStateType(wm::WindowState* window_state, 120a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) wm::WindowStateType old_state_type); 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 12268043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) // If |window_state| is maximized or fullscreen the bounds of the 12368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) // window are set and true is returned. Does nothing otherwise. 12468043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) bool SetMaximizedOrFullscreenBounds(wm::WindowState* window_state); 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 126a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // Animates the window bounds to |bounds|. 127a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void SetChildBoundsAnimated(aura::Window* child, const gfx::Rect& bounds); 128a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 129c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch ShelfLayoutManager* shelf_; 130a36e5920737c6adbddd3e43b760e5de8431db6e0Torne (Richard Coles) aura::Window* window_; 1315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) aura::Window* root_window_; 1325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Set of windows we're listening to. 1345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) WindowSet windows_; 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // The work area in the coordinates of |window_|. 1378bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) gfx::Rect work_area_in_parent_; 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 139a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) // True if this workspace is currently in fullscreen mode. 140a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) bool is_fullscreen_; 141a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 142a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // A window which covers the full container and which gets inserted behind the 143a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // topmost visible window. 144a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_ptr<WorkspaceLayoutManagerDelegate> backdrop_delegate_; 145a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManager); 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace ash 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // ASH_WM_WORKSPACE_WORKSPACE_LAYOUT_MANAGER_H_ 152