#ifndef ASH_WM_CLIENT_CONTROLLED_STATE_H_
#define ASH_WM_CLIENT_CONTROLLED_STATE_H_
#include <memory>
#include "ash/ash_export.h"
#include "ash/wm/base_state.h"
namespace ash {
class WMEvent;
class ASH_EXPORT ClientControlledState : public BaseState {
public:
class Delegate {
public:
virtual ~Delegate() = default;
virtual void HandleWindowStateRequest(
WindowState* window_state,
chromeos::WindowStateType requested_state) = 0;
virtual void HandleBoundsRequest(
WindowState* window_state,
chromeos::WindowStateType requested_state,
const gfx::Rect& requested_bounds_in_display,
int64_t display_id) = 0;
};
static void AdjustBoundsForMinimumWindowVisibility(
const gfx::Rect& display_bounds,
gfx::Rect* bounds);
explicit ClientControlledState(std::unique_ptr<Delegate> delegate);
ClientControlledState(const ClientControlledState&) = delete;
ClientControlledState& operator=(const ClientControlledState&) = delete;
~ClientControlledState() override;
void ResetDelegate();
void set_bounds_locally(bool set) { set_bounds_locally_ = set; }
bool set_bounds_locally() const { return set_bounds_locally_; }
void set_next_bounds_change_animation_type(
WindowState::BoundsChangeAnimationType animation_type) {
next_bounds_change_animation_type_ = animation_type;
}
void AttachState(WindowState* window_state,
WindowState::State* previous_state) override;
void DetachState(WindowState* window_state) override;
void HandleWorkspaceEvents(WindowState* window_state,
const WMEvent* event) override;
void HandleCompoundEvents(WindowState* window_state,
const WMEvent* event) override;
void HandleBoundsEvents(WindowState* window_state,
const WMEvent* event) override;
void HandleTransitionEvents(WindowState* window_state,
const WMEvent* event) override;
void OnWindowDestroying(WindowState* window_state) override;
bool EnterNextState(WindowState* window_state,
chromeos::WindowStateType next_state_type);
private:
chromeos::WindowStateType GetResolvedNextWindowStateType(
WindowState* window_state,
const WMEvent* event);
void UpdateWindowForTransitionEvents(
WindowState* window_state,
chromeos::WindowStateType next_state_type,
const WMEvent* event);
std::unique_ptr<Delegate> delegate_;
bool set_bounds_locally_ = false;
base::TimeDelta bounds_change_animation_duration_ =
WindowState::kBoundsChangeSlideDuration;
WindowState::BoundsChangeAnimationType next_bounds_change_animation_type_ =
WindowState::BoundsChangeAnimationType::kNone;
};
}
#endif