Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1038)

Side by Side Diff: ash/display/multi_display_manager.h

Issue 11363124: Move DisplayManager and DisplayChangeObserverX11 from aura to ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix rebase Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/display/display_manager_unittest.cc ('k') | ash/display/multi_display_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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_MULTI_DISPLAY_MANAGER_H_
6 #define ASH_DISPLAY_MULTI_DISPLAY_MANAGER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "ash/ash_export.h"
12 #include "base/compiler_specific.h"
13 #include "base/gtest_prod_util.h"
14 #include "ui/aura/display_manager.h"
15 #include "ui/aura/root_window_observer.h"
16 #include "ui/aura/window.h"
17
18 namespace gfx {
19 class Display;
20 class Insets;
21 class Rect;
22 }
23
24 namespace ash {
25 class AcceleratorControllerTest;
26 namespace test {
27 class MultiDisplayManagerTestApi;
28 class SystemGestureEventFilterTest;
29 }
30 namespace internal {
31
32 // MultiDisplayManager maintains the current display configurations,
33 // and notifies observers when configuration changes.
34 // This is exported for unittest.
35 //
36 // TODO(oshima): gfx::Screen needs to return translated coordinates
37 // if the root window is translated. crbug.com/119268.
38 class ASH_EXPORT MultiDisplayManager : public aura::DisplayManager,
39 public aura::RootWindowObserver {
40 public:
41 MultiDisplayManager();
42 virtual ~MultiDisplayManager();
43
44 // Used to emulate display change when run in a desktop environment instead
45 // of on a device.
46 static void CycleDisplay();
47 static void ToggleDisplayScale();
48
49 // When set to true, the MultiMonitorManager calls OnDisplayBoundsChanged
50 // even if the display's bounds didn't change. Used to swap primary
51 // display.
52 void set_force_bounds_changed(bool force_bounds_changed) {
53 force_bounds_changed_ = force_bounds_changed;
54 }
55
56 // True if the given |display| is currently connected.
57 bool IsActiveDisplay(const gfx::Display& display) const;
58
59 // True if there is an internal display.
60 bool HasInternalDisplay() const;
61
62 bool IsInternalDisplayId(int64 id) const;
63
64 bool UpdateWorkAreaOfDisplayNearestWindow(const aura::Window* window,
65 const gfx::Insets& insets);
66
67 // Returns display for given |id|;
68 const gfx::Display& GetDisplayForId(int64 id) const;
69
70 // Finds the display that contains |point| in screeen coordinates.
71 // Returns invalid display if there is no display that can satisfy
72 // the condition.
73 const gfx::Display& FindDisplayContainingPoint(
74 const gfx::Point& point_in_screen) const;
75
76 // Registers the overscan insets for the display of the specified ID. Note
77 // that the insets size should be specified in DIP size. It also triggers the
78 // display's bounds change.
79 void SetOverscanInsets(int64 display_id, const gfx::Insets& insets_in_dip);
80
81 // Returns the current overscan insets for the specified |display_id|.
82 // Returns an empty insets (0, 0, 0, 0) if no insets are specified for
83 // the display.
84 gfx::Insets GetOverscanInsets(int64 display_id) const;
85
86 // DisplayManager overrides:
87 virtual void OnNativeDisplaysChanged(
88 const std::vector<gfx::Display>& displays) OVERRIDE;
89 virtual aura::RootWindow* CreateRootWindowForDisplay(
90 const gfx::Display& display) OVERRIDE;
91 virtual gfx::Display* GetDisplayAt(size_t index) OVERRIDE;
92
93 virtual size_t GetNumDisplays() const OVERRIDE;
94 virtual const gfx::Display& GetDisplayNearestPoint(
95 const gfx::Point& point) const OVERRIDE;
96 virtual const gfx::Display& GetDisplayNearestWindow(
97 const aura::Window* window) const OVERRIDE;
98 virtual const gfx::Display& GetDisplayMatching(
99 const gfx::Rect& match_rect)const OVERRIDE;
100 virtual std::string GetDisplayNameFor(const gfx::Display& display) OVERRIDE;
101
102 // RootWindowObserver overrides:
103 virtual void OnRootWindowResized(const aura::RootWindow* root,
104 const gfx::Size& new_size) OVERRIDE;
105
106 private:
107 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, ConvertPoint);
108 FRIEND_TEST_ALL_PREFIXES(MultiDisplayManagerTest, TestNativeDisplaysChanged);
109 FRIEND_TEST_ALL_PREFIXES(MultiDisplayManagerTest,
110 NativeDisplaysChangedAfterPrimaryChange);
111 friend class ash::AcceleratorControllerTest;
112 friend class test::MultiDisplayManagerTestApi;
113 friend class MultiDisplayManagerTest;
114 friend class test::SystemGestureEventFilterTest;
115
116 typedef std::vector<gfx::Display> DisplayList;
117
118 void Init();
119 void CycleDisplayImpl();
120 void ScaleDisplayImpl();
121
122 gfx::Display& FindDisplayForRootWindow(const aura::RootWindow* root);
123 gfx::Display& FindDisplayForId(int64 id);
124
125 // Refer to |aura::DisplayManager::CreateDisplayFromSpec| API for
126 // the format of |spec|.
127 void AddDisplayFromSpec(const std::string& spec);
128
129 // Set the 1st display as an internal display and returns the display Id for
130 // the internal display.
131 int64 SetFirstDisplayAsInternalDisplayForTest();
132
133 // Checks if the mouse pointer is on one of displays, and moves to
134 // the center of the nearest display if it's outside of all displays.
135 void EnsurePointerInDisplays();
136
137 // Updates |display_names_| by calling platform-dependent functions.
138 void RefreshDisplayNames();
139
140 // Update the display's id in the |display_list| to match the ones
141 // stored in this display manager's |displays_|. This is used to
142 // emulate display change behavior during the test byn creating the
143 // display list with the same display ids but with different bounds
144 void SetDisplayIdsForTest(DisplayList* display_list) const;
145
146 DisplayList displays_;
147
148 int64 internal_display_id_;
149
150 // An internal display cache used when the internal display is disconnectd.
151 scoped_ptr<gfx::Display> internal_display_;
152
153 bool force_bounds_changed_;
154
155 // The mapping from the display ID to its overscan insets.
156 std::map<int64, gfx::Insets> overscan_mapping_;
157
158 // The cached display's name for the display ID.
159 std::map<int64, std::string> display_names_;
160
161 DISALLOW_COPY_AND_ASSIGN(MultiDisplayManager);
162 };
163
164 extern const aura::WindowProperty<int64>* const kDisplayIdKey;
165
166 } // namespace internal
167 } // namespace ash
168
169 #endif // ASH_DISPLAY_MULTI_DISPLAY_MANAGER_H_
OLDNEW
« no previous file with comments | « ash/display/display_manager_unittest.cc ('k') | ash/display/multi_display_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698