#ifndef ASH_DISPLAY_EXTENDED_MOUSE_WARP_CONTROLLER_H_
#define ASH_DISPLAY_EXTENDED_MOUSE_WARP_CONTROLLER_H_
#include "ash/display/mouse_warp_controller.h"
#include "base/memory/raw_ptr.h"
#include <memory>
#include <vector>
#include "base/gtest_prod_util.h"
#include "ui/gfx/geometry/rect.h"
namespace aura {
class Window;
}
namespace display {
class Display;
}
namespace gfx {
class Point;
}
namespace ash {
class SharedDisplayEdgeIndicator;
class ASH_EXPORT ExtendedMouseWarpController : public MouseWarpController {
public:
explicit ExtendedMouseWarpController(aura::Window* drag_source);
ExtendedMouseWarpController(const ExtendedMouseWarpController&) = delete;
ExtendedMouseWarpController& operator=(const ExtendedMouseWarpController&) =
delete;
~ExtendedMouseWarpController() override;
bool WarpMouseCursor(ui::MouseEvent* event) override;
void SetEnabled(bool enable) override;
private:
friend class AshTestBase;
friend class ExtendedMouseWarpControllerTest;
FRIEND_TEST_ALL_PREFIXES(ExtendedMouseWarpControllerTest,
IndicatorBoundsTestThreeDisplays);
FRIEND_TEST_ALL_PREFIXES(ExtendedMouseWarpControllerTest,
IndicatorBoundsTestThreeDisplaysWithLayout);
FRIEND_TEST_ALL_PREFIXES(ExtendedMouseWarpControllerTest,
IndicatorBoundsTestThreeDisplaysWithLayout2);
class ASH_EXPORT WarpRegion {
public:
WarpRegion(int64_t a_display_id,
int64_t b_display_id,
const gfx::Rect& a_indicator_bounds,
const gfx::Rect& b_indicator_bounds);
WarpRegion(const WarpRegion&) = delete;
WarpRegion& operator=(const WarpRegion&) = delete;
~WarpRegion();
const gfx::Rect& a_indicator_bounds() { return a_indicator_bounds_; }
const gfx::Rect& b_indicator_bounds() { return b_indicator_bounds_; }
const gfx::Rect& GetIndicatorBoundsForTest(int64_t id) const;
const gfx::Rect& GetIndicatorNativeBoundsForTest(int64_t id) const;
private:
friend class ExtendedMouseWarpController;
int64_t a_display_id_;
int64_t b_display_id_;
gfx::Rect a_edge_bounds_in_native_;
gfx::Rect b_edge_bounds_in_native_;
gfx::Rect a_indicator_bounds_;
gfx::Rect b_indicator_bounds_;
std::unique_ptr<SharedDisplayEdgeIndicator> shared_display_edge_indicator_;
};
void AddWarpRegion(std::unique_ptr<WarpRegion> region, bool has_drag_source);
bool WarpMouseCursorInNativeCoords(const gfx::Point& point_in_native,
const gfx::Point& point_in_screen,
bool update_mouse_location_now);
std::unique_ptr<WarpRegion> CreateWarpRegion(const display::Display& a,
const display::Display& b,
int64_t drag_source_dispay_id);
void allow_non_native_event_for_test() { allow_non_native_event_ = true; }
raw_ptr<aura::Window> drag_source_root_;
bool enabled_;
bool allow_non_native_event_;
std::vector<std::unique_ptr<WarpRegion>> warp_regions_;
};
}
#endif