Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / ash / display / screen_ash.h
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
5 #ifndef ASH_DISPLAY_SCREEN_ASH_H_
6 #define ASH_DISPLAY_SCREEN_ASH_H_
7
8 #include "ash/ash_export.h"
9 #include "base/compiler_specific.h"
10 #include "base/observer_list.h"
11 #include "ui/gfx/screen.h"
12
13 namespace gfx {
14 class Rect;
15 }
16
17 namespace ash {
18 namespace  internal {
19 class DisplayManager;
20 }
21
22 // Aura implementation of gfx::Screen. Implemented here to avoid circular
23 // dependencies.
24 class ASH_EXPORT ScreenAsh : public gfx::Screen {
25  public:
26   ScreenAsh();
27   virtual ~ScreenAsh();
28
29   // Finds the display that contains |point| in screeen coordinates.
30   // Returns invalid display if there is no display that can satisfy
31   // the condition.
32   static gfx::Display FindDisplayContainingPoint(const gfx::Point& point);
33
34   // Returns the bounds for maximized windows in parent coordinates.
35   // Maximized windows trigger auto-hiding the shelf.
36   static gfx::Rect GetMaximizedWindowBoundsInParent(aura::Window* window);
37
38   // Returns the display bounds in parent coordinates.
39   static gfx::Rect GetDisplayBoundsInParent(aura::Window* window);
40
41   // Returns the display's work area bounds in parent coordinates.
42   static gfx::Rect GetDisplayWorkAreaBoundsInParent(aura::Window* window);
43
44   // Converts |rect| from |window|'s coordinates to the virtual screen
45   // coordinates.
46   static gfx::Rect ConvertRectToScreen(aura::Window* window,
47                                        const gfx::Rect& rect);
48
49   // Converts |rect| from virtual screen coordinates to the |window|'s
50   // coordinates.
51   static gfx::Rect ConvertRectFromScreen(aura::Window* window,
52                                          const gfx::Rect& rect);
53
54   // Returns a gfx::Display object for secondary display. Returns
55   // invalid display if there is no secondary display connected.
56   static const gfx::Display& GetSecondaryDisplay();
57
58   // Returns a gfx::Display object for the specified id.  Returns
59   // invalid display if no such display is connected.
60   static const gfx::Display& GetDisplayForId(int64 display_id);
61
62   // gfx::Screen overrides:
63   virtual bool IsDIPEnabled() OVERRIDE;
64   virtual gfx::Point GetCursorScreenPoint() OVERRIDE;
65   virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE;
66   virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point)
67       OVERRIDE;
68   virtual int GetNumDisplays() const OVERRIDE;
69   virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE;
70   virtual gfx::Display GetDisplayNearestWindow(
71       gfx::NativeView view) const OVERRIDE;
72   virtual gfx::Display GetDisplayNearestPoint(
73       const gfx::Point& point) const OVERRIDE;
74   virtual gfx::Display GetDisplayMatching(
75       const gfx::Rect& match_rect) const OVERRIDE;
76   virtual gfx::Display GetPrimaryDisplay() const OVERRIDE;
77   virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE;
78   virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE;
79
80  private:
81   friend class internal::DisplayManager;
82
83   // Notifies observers of display configuration changes.
84   void NotifyBoundsChanged(const gfx::Display& display);
85   void NotifyDisplayAdded(const gfx::Display& display);
86   void NotifyDisplayRemoved(const gfx::Display& display);
87
88   // Creates a screen that can be used during shutdown.
89   // It simply has a copy of the displays.
90   gfx::Screen* CloneForShutdown();
91
92   ObserverList<gfx::DisplayObserver> observers_;
93
94   DISALLOW_COPY_AND_ASSIGN(ScreenAsh);
95 };
96
97 }  // namespace ash
98
99 #endif  // ASH_DISPLAY_SCREEN_ASH_H_