lock_window_state.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_WINDOW_STATE_H_
  5. #define ASH_WM_LOCK_WINDOW_STATE_H_
  6. #include "ash/wm/window_state.h"
  7. namespace ash {
  8. // The LockWindowState implementation which reduces all possible window
  9. // states to maximized (or normal if can't be maximized)/minimized/full-screen
  10. // and is applied only on lock (login) window container and window containers
  11. // associated with apps handling lock screen tray actions.
  12. // LockWindowState implements Ash behavior without state machine.
  13. class LockWindowState : public WindowState::State {
  14. public:
  15. // The |window|'s state object will be modified to use this new window mode
  16. // state handler.
  17. // |exclude_shelf| - if set, the maximized window size will be
  18. // restricted to work area defined by ash shelf, rather than taking only
  19. // virtual keyboard window into consideration when calculating the window
  20. // size.
  21. LockWindowState(aura::Window* window, bool exclude_shelf);
  22. LockWindowState(const LockWindowState&) = delete;
  23. LockWindowState& operator=(const LockWindowState&) = delete;
  24. ~LockWindowState() override;
  25. // WindowState::State overrides:
  26. void OnWMEvent(WindowState* window_state, const WMEvent* event) override;
  27. chromeos::WindowStateType GetType() const override;
  28. void AttachState(WindowState* window_state,
  29. WindowState::State* previous_state) override;
  30. void DetachState(WindowState* window_state) override;
  31. // Creates new LockWindowState instance and attaches it to |window|.
  32. static WindowState* SetLockWindowState(aura::Window* window);
  33. static WindowState* SetLockWindowStateWithShelfExcluded(aura::Window* window);
  34. private:
  35. // Updates the window to |new_state_type| and resulting bounds:
  36. // Either full screen, maximized centered or minimized. If the state does not
  37. // change, only the bounds will be changed.
  38. void UpdateWindow(WindowState* window_state,
  39. chromeos::WindowStateType new_state_type);
  40. // Depending on the capabilities of the window we either return
  41. // |WindowStateType::kMaximized| or |WindowStateType::kNormal|.
  42. chromeos::WindowStateType GetMaximizedOrCenteredWindowType(
  43. WindowState* window_state);
  44. // Returns boudns to be used for the provided window.
  45. gfx::Rect GetWindowBounds(aura::Window* window);
  46. // Updates the bounds taking virtual keyboard bounds into consideration.
  47. void UpdateBounds(WindowState* window_state);
  48. // The current state type. Due to the nature of this state, this can only be
  49. // WM_STATE_TYPE{NORMAL, MINIMIZED, MAXIMIZED}.
  50. chromeos::WindowStateType current_state_type_;
  51. // Restrict window size to the work area defined by the shelf - i.e. window
  52. // bounds exclude system shelf bounds.
  53. bool exclude_shelf_ = false;
  54. };
  55. } // namespace ash
  56. #endif // ASH_WM_LOCK_WINDOW_STATE_H_