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

Side by Side Diff: ash/display/screen_ash.cc

Issue 2361283002: Add GetDisplayWithDisplayId to display::Screen. (Closed)
Patch Set: test Created 4 years, 3 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/display/screen_ash.h" 5 #include "ash/display/screen_ash.h"
6 6
7 #include "ash/aura/wm_window_aura.h" 7 #include "ash/aura/wm_window_aura.h"
8 #include "ash/common/shelf/shelf_widget.h" 8 #include "ash/common/shelf/shelf_widget.h"
9 #include "ash/common/wm/root_window_finder.h" 9 #include "ash/common/wm/root_window_finder.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 30 matching lines...) Expand all
41 // display::Screen overrides: 41 // display::Screen overrides:
42 gfx::Point GetCursorScreenPoint() override { return gfx::Point(); } 42 gfx::Point GetCursorScreenPoint() override { return gfx::Point(); }
43 bool IsWindowUnderCursor(gfx::NativeWindow window) override { return false; } 43 bool IsWindowUnderCursor(gfx::NativeWindow window) override { return false; }
44 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override { 44 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override {
45 return NULL; 45 return NULL;
46 } 46 }
47 int GetNumDisplays() const override { return display_list_.size(); } 47 int GetNumDisplays() const override { return display_list_.size(); }
48 std::vector<display::Display> GetAllDisplays() const override { 48 std::vector<display::Display> GetAllDisplays() const override {
49 return display_list_; 49 return display_list_;
50 } 50 }
51 bool GetDisplayWithDisplayId(int64_t display_id,
52 display::Display* display) const override {
53 for (display::Display display_in_list : display_list_) {
sadrul 2016/09/23 19:51:12 const&
riajiang 2016/10/05 14:54:11 Done.
54 if (display_in_list.id() == display_id) {
55 *display = display_in_list;
56 return true;
57 }
58 }
59 return false;
60 }
51 display::Display GetDisplayNearestWindow( 61 display::Display GetDisplayNearestWindow(
52 gfx::NativeView view) const override { 62 gfx::NativeView view) const override {
53 return primary_display_; 63 return primary_display_;
54 } 64 }
55 display::Display GetDisplayNearestPoint( 65 display::Display GetDisplayNearestPoint(
56 const gfx::Point& point) const override { 66 const gfx::Point& point) const override {
57 return *display::FindDisplayNearestPoint(display_list_, point); 67 return *display::FindDisplayNearestPoint(display_list_, point);
58 } 68 }
59 display::Display GetDisplayMatching( 69 display::Display GetDisplayMatching(
60 const gfx::Rect& match_rect) const override { 70 const gfx::Rect& match_rect) const override {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 117 }
108 118
109 int ScreenAsh::GetNumDisplays() const { 119 int ScreenAsh::GetNumDisplays() const {
110 return GetDisplayManager()->GetNumDisplays(); 120 return GetDisplayManager()->GetNumDisplays();
111 } 121 }
112 122
113 std::vector<display::Display> ScreenAsh::GetAllDisplays() const { 123 std::vector<display::Display> ScreenAsh::GetAllDisplays() const {
114 return GetDisplayManager()->active_display_list(); 124 return GetDisplayManager()->active_display_list();
115 } 125 }
116 126
127 bool ScreenAsh::GetDisplayWithDisplayId(int64_t display_id,
128 display::Display* display) const {
129 for (display::Display display_in_list : GetAllDisplays()) {
sadrul 2016/09/23 19:51:12 GetAllDisplays() makes a copy of the list. It'd be
riajiang 2016/10/05 14:54:11 I see. Done.
130 if (display_in_list.id() == display_id) {
131 *display = display_in_list;
132 return true;
133 }
134 }
135 return false;
136 }
137
117 display::Display ScreenAsh::GetDisplayNearestWindow( 138 display::Display ScreenAsh::GetDisplayNearestWindow(
118 gfx::NativeView window) const { 139 gfx::NativeView window) const {
119 if (!window) 140 if (!window)
120 return GetPrimaryDisplay(); 141 return GetPrimaryDisplay();
121 const aura::Window* root_window = window->GetRootWindow(); 142 const aura::Window* root_window = window->GetRootWindow();
122 if (!root_window) 143 if (!root_window)
123 return GetPrimaryDisplay(); 144 return GetPrimaryDisplay();
124 const RootWindowSettings* rws = GetRootWindowSettings(root_window); 145 const RootWindowSettings* rws = GetRootWindowSettings(root_window);
125 int64_t id = rws->display_id; 146 int64_t id = rws->display_id;
126 // if id is |kInvaildDisplayID|, it's being deleted. 147 // if id is |kInvaildDisplayID|, it's being deleted.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 209 }
189 210
190 // static 211 // static
191 void ScreenAsh::CreateScreenForShutdown() { 212 void ScreenAsh::CreateScreenForShutdown() {
192 delete screen_for_shutdown; 213 delete screen_for_shutdown;
193 screen_for_shutdown = new ScreenForShutdown(display::Screen::GetScreen()); 214 screen_for_shutdown = new ScreenForShutdown(display::Screen::GetScreen());
194 display::Screen::SetScreenInstance(screen_for_shutdown); 215 display::Screen::SetScreenInstance(screen_for_shutdown);
195 } 216 }
196 217
197 } // namespace ash 218 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698