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.
5 #ifndef ASH_DISPLAY_DISPLAY_UTIL_H_
6 #define ASH_DISPLAY_DISPLAY_UTIL_H_
12 #include "ash/ash_export.h"
13 #include "ash/display/display_layout.h"
23 class AshWindowTreeHost
;
27 // Creates the display mode list for internal display
28 // based on |native_mode|.
29 ASH_EXPORT
std::vector
<DisplayMode
> CreateInternalDisplayModeList(
30 const DisplayMode
& native_mode
);
32 // Creates the display mode list for unified display
33 // based on |native_mode| and |scales|.
34 ASH_EXPORT
std::vector
<DisplayMode
> CreateUnifiedDisplayModeList(
35 const DisplayMode
& native_mode
,
36 const std::set
<std::pair
<float, float>>& dsf_scale_list
);
38 // Gets the display mode for |resolution|. Returns false if no display
39 // mode matches the resolution, or the display is an internal display.
40 ASH_EXPORT
bool GetDisplayModeForResolution(const DisplayInfo
& info
,
41 const gfx::Size
& resolution
,
44 // Gets the display mode for the next valid UI scale. Returns false
45 // if the display is not an internal display.
46 ASH_EXPORT
bool GetDisplayModeForNextUIScale(const DisplayInfo
& info
,
50 // Gets the display mode for the next valid resolution. Returns false
51 // if the display is an internal display.
52 ASH_EXPORT
bool GetDisplayModeForNextResolution(const DisplayInfo
& info
,
56 // Sets the UI scale for the |display_id|. Returns false if the
57 // display_id is not an internal display.
58 ASH_EXPORT
bool SetDisplayUIScale(int64 display_id
, float scale
);
60 // Tests if the |info| has display mode that matches |ui_scale|.
61 bool HasDisplayModeForUIScale(const DisplayInfo
& info
, float ui_scale
);
63 // Computes the bounds that defines the bounds between two displays
64 // based on the layout |position|.
65 void ComputeBoundary(const gfx::Display
& primary_display
,
66 const gfx::Display
& secondary_display
,
67 DisplayLayout::Position position
,
68 gfx::Rect
* primary_edge_in_screen
,
69 gfx::Rect
* secondary_edge_in_screen
);
71 // Creates edge bounds from |bounds_in_screen| that fits the edge
72 // of the native window for |ash_host|.
73 ASH_EXPORT
gfx::Rect
GetNativeEdgeBounds(AshWindowTreeHost
* ash_host
,
74 const gfx::Rect
& bounds_in_screen
);
76 // Moves the cursor to the point inside the |ash_host| that is closest to
77 // the point_in_screen, which may be outside of the root window.
78 // |update_last_loation_now| is used for the test to update the mouse
79 // location synchronously.
80 void MoveCursorTo(AshWindowTreeHost
* ash_host
,
81 const gfx::Point
& point_in_screen
,
82 bool update_last_location_now
);
84 // Returns the index in the displays whose bounds contains |point_in_screen|.
85 // Returns -1 if no such display exist.
86 ASH_EXPORT
int FindDisplayIndexContainingPoint(
87 const std::vector
<gfx::Display
>& displays
,
88 const gfx::Point
& point_in_screen
);
90 // Creates the DisplayIdPair where ids are sorted using |CompareDisplayIds|
92 ASH_EXPORT DisplayIdPair
CreateDisplayIdPair(int64 id1
, int64 id2
);
94 // Returns true if one of following conditinos is met.
95 // 1) id1 is internal.
96 // 2) output index of id1 < output index of id2 and id2 isn't internal.
97 ASH_EXPORT
bool CompareDisplayIds(int64 id1
, int64 id2
);
101 #endif // ASH_DISPLAY_DISPLAY_UTIL_H_