lock_layout_manager.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_WM_LOCK_LAYOUT_MANAGER_H_
  5. #define ASH_WM_LOCK_LAYOUT_MANAGER_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/keyboard/ui/keyboard_ui_controller.h"
  8. #include "ash/public/cpp/keyboard/keyboard_controller_observer.h"
  9. #include "ash/shelf/shelf.h"
  10. #include "ash/shelf/shelf_observer.h"
  11. #include "ash/wm/wm_default_layout_manager.h"
  12. #include "base/scoped_observation.h"
  13. #include "ui/aura/window_observer.h"
  14. #include "ui/gfx/geometry/rect.h"
  15. namespace ash {
  16. class WindowState;
  17. class WMEvent;
  18. // LockLayoutManager is used for the windows created in LockScreenContainer.
  19. // For Chrome OS this includes out-of-box/login/lock/multi-profile login use
  20. // cases. LockScreenContainer does not use default work area definition.
  21. // By default work area is defined as display area minus shelf, and minus
  22. // virtual keyboard bounds.
  23. // For windows in LockScreenContainer work area is display area minus virtual
  24. // keyboard bounds (only if keyboard overscroll is disabled). If keyboard
  25. // overscroll is enabled then work area always equals to display area size since
  26. // virtual keyboard changes inner workspace of each WebContents.
  27. // For all windows in LockScreenContainer default WindowState is replaced
  28. // with LockWindowState.
  29. class ASH_EXPORT LockLayoutManager : public WmDefaultLayoutManager,
  30. public aura::WindowObserver,
  31. public ShelfObserver,
  32. public KeyboardControllerObserver {
  33. public:
  34. LockLayoutManager(aura::Window* window, Shelf* shelf);
  35. LockLayoutManager(const LockLayoutManager&) = delete;
  36. LockLayoutManager& operator=(const LockLayoutManager&) = delete;
  37. ~LockLayoutManager() override;
  38. // Overridden from WmDefaultLayoutManager:
  39. void OnWindowResized() override;
  40. void OnWindowAddedToLayout(aura::Window* child) override;
  41. void OnWillRemoveWindowFromLayout(aura::Window* child) override;
  42. void OnWindowRemovedFromLayout(aura::Window* child) override;
  43. void OnChildWindowVisibilityChanged(aura::Window* child,
  44. bool visible) override;
  45. void SetChildBounds(aura::Window* child,
  46. const gfx::Rect& requested_bounds) override;
  47. // Overriden from aura::WindowObserver:
  48. void OnWindowDestroying(aura::Window* window) override;
  49. void OnWindowBoundsChanged(aura::Window* window,
  50. const gfx::Rect& old_bounds,
  51. const gfx::Rect& new_bounds,
  52. ui::PropertyChangeReason reason) override;
  53. // ShelfObserver:
  54. void WillChangeVisibilityState(ShelfVisibilityState visibility) override;
  55. // KeyboardControllerObserver overrides:
  56. void OnKeyboardOccludedBoundsChanged(const gfx::Rect& new_bounds) override;
  57. protected:
  58. // Adjusts the bounds of all managed windows when the display area changes.
  59. // This happens when the display size, work area insets has changed.
  60. void AdjustWindowsForWorkAreaChange(const WMEvent* event);
  61. aura::Window* window() { return window_; }
  62. aura::Window* root_window() { return root_window_; }
  63. private:
  64. aura::Window* window_;
  65. aura::Window* root_window_;
  66. base::ScopedObservation<Shelf, ShelfObserver> shelf_observation_{this};
  67. };
  68. } // namespace ash
  69. #endif // ASH_WM_LOCK_LAYOUT_MANAGER_H_