| OLD | NEW |
| 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/display/display_manager.h" | 7 #include "ash/display/display_manager.h" |
| 8 #include "ash/display/window_tree_host_manager.h" | 8 #include "ash/display/window_tree_host_manager.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/root_window_settings.h" | 10 #include "ash/root_window_settings.h" |
| 11 #include "ash/shelf/shelf_layout_manager.h" | 11 #include "ash/shelf/shelf_layout_manager.h" |
| 12 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ash/wm/aura/wm_window_aura.h" | 14 #include "ash/wm/aura/wm_window_aura.h" |
| 15 #include "ash/wm/common/root_window_finder.h" | 15 #include "ash/wm/common/root_window_finder.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "ui/aura/client/screen_position_client.h" | 17 #include "ui/aura/client/screen_position_client.h" |
| 18 #include "ui/aura/env.h" | 18 #include "ui/aura/env.h" |
| 19 #include "ui/aura/window_event_dispatcher.h" | 19 #include "ui/aura/window_event_dispatcher.h" |
| 20 #include "ui/display/display.h" | 20 #include "ui/display/display.h" |
| 21 #include "ui/display/display_finder.h" |
| 21 #include "ui/display/screen.h" | 22 #include "ui/display/screen.h" |
| 22 #include "ui/gfx/display_finder.h" | |
| 23 | 23 |
| 24 namespace ash { | 24 namespace ash { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 DisplayManager* GetDisplayManager() { | 28 DisplayManager* GetDisplayManager() { |
| 29 return Shell::GetInstance()->display_manager(); | 29 return Shell::GetInstance()->display_manager(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 class ScreenForShutdown : public display::Screen { | 32 class ScreenForShutdown : public display::Screen { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 45 int GetNumDisplays() const override { return display_list_.size(); } | 45 int GetNumDisplays() const override { return display_list_.size(); } |
| 46 std::vector<display::Display> GetAllDisplays() const override { | 46 std::vector<display::Display> GetAllDisplays() const override { |
| 47 return display_list_; | 47 return display_list_; |
| 48 } | 48 } |
| 49 display::Display GetDisplayNearestWindow( | 49 display::Display GetDisplayNearestWindow( |
| 50 gfx::NativeView view) const override { | 50 gfx::NativeView view) const override { |
| 51 return primary_display_; | 51 return primary_display_; |
| 52 } | 52 } |
| 53 display::Display GetDisplayNearestPoint( | 53 display::Display GetDisplayNearestPoint( |
| 54 const gfx::Point& point) const override { | 54 const gfx::Point& point) const override { |
| 55 return *gfx::FindDisplayNearestPoint(display_list_, point); | 55 return *display::FindDisplayNearestPoint(display_list_, point); |
| 56 } | 56 } |
| 57 display::Display GetDisplayMatching( | 57 display::Display GetDisplayMatching( |
| 58 const gfx::Rect& match_rect) const override { | 58 const gfx::Rect& match_rect) const override { |
| 59 const display::Display* matching = | 59 const display::Display* matching = |
| 60 gfx::FindDisplayWithBiggestIntersection(display_list_, match_rect); | 60 display::FindDisplayWithBiggestIntersection(display_list_, match_rect); |
| 61 // Fallback to the primary display if there is no matching display. | 61 // Fallback to the primary display if there is no matching display. |
| 62 return matching ? *matching : GetPrimaryDisplay(); | 62 return matching ? *matching : GetPrimaryDisplay(); |
| 63 } | 63 } |
| 64 display::Display GetPrimaryDisplay() const override { | 64 display::Display GetPrimaryDisplay() const override { |
| 65 return primary_display_; | 65 return primary_display_; |
| 66 } | 66 } |
| 67 void AddObserver(display::DisplayObserver* observer) override { | 67 void AddObserver(display::DisplayObserver* observer) override { |
| 68 NOTREACHED() << "Observer should not be added during shutdown"; | 68 NOTREACHED() << "Observer should not be added during shutdown"; |
| 69 } | 69 } |
| 70 void RemoveObserver(display::DisplayObserver* observer) override {} | 70 void RemoveObserver(display::DisplayObserver* observer) override {} |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 display::Display ScreenAsh::GetDisplayNearestPoint( | 157 display::Display ScreenAsh::GetDisplayNearestPoint( |
| 158 const gfx::Point& point) const { | 158 const gfx::Point& point) const { |
| 159 const display::Display& display = | 159 const display::Display& display = |
| 160 GetDisplayManager()->FindDisplayContainingPoint(point); | 160 GetDisplayManager()->FindDisplayContainingPoint(point); |
| 161 if (display.is_valid()) | 161 if (display.is_valid()) |
| 162 return display; | 162 return display; |
| 163 // Fallback to the display that has the shortest Manhattan distance from | 163 // Fallback to the display that has the shortest Manhattan distance from |
| 164 // the |point|. This is correct in the only areas that matter, namely in the | 164 // the |point|. This is correct in the only areas that matter, namely in the |
| 165 // corners between the physical screens. | 165 // corners between the physical screens. |
| 166 return *gfx::FindDisplayNearestPoint( | 166 return *display::FindDisplayNearestPoint( |
| 167 GetDisplayManager()->active_display_list(), point); | 167 GetDisplayManager()->active_display_list(), point); |
| 168 } | 168 } |
| 169 | 169 |
| 170 display::Display ScreenAsh::GetDisplayMatching( | 170 display::Display ScreenAsh::GetDisplayMatching( |
| 171 const gfx::Rect& match_rect) const { | 171 const gfx::Rect& match_rect) const { |
| 172 if (match_rect.IsEmpty()) | 172 if (match_rect.IsEmpty()) |
| 173 return GetDisplayNearestPoint(match_rect.origin()); | 173 return GetDisplayNearestPoint(match_rect.origin()); |
| 174 const display::Display* matching = gfx::FindDisplayWithBiggestIntersection( | 174 const display::Display* matching = |
| 175 GetDisplayManager()->active_display_list(), match_rect); | 175 display::FindDisplayWithBiggestIntersection( |
| 176 GetDisplayManager()->active_display_list(), match_rect); |
| 176 // Fallback to the primary display if there is no matching display. | 177 // Fallback to the primary display if there is no matching display. |
| 177 return matching ? *matching : GetPrimaryDisplay(); | 178 return matching ? *matching : GetPrimaryDisplay(); |
| 178 } | 179 } |
| 179 | 180 |
| 180 display::Display ScreenAsh::GetPrimaryDisplay() const { | 181 display::Display ScreenAsh::GetPrimaryDisplay() const { |
| 181 return GetDisplayManager()->GetDisplayForId( | 182 return GetDisplayManager()->GetDisplayForId( |
| 182 WindowTreeHostManager::GetPrimaryDisplayId()); | 183 WindowTreeHostManager::GetPrimaryDisplayId()); |
| 183 } | 184 } |
| 184 | 185 |
| 185 void ScreenAsh::AddObserver(display::DisplayObserver* observer) { | 186 void ScreenAsh::AddObserver(display::DisplayObserver* observer) { |
| 186 observers_.AddObserver(observer); | 187 observers_.AddObserver(observer); |
| 187 } | 188 } |
| 188 | 189 |
| 189 void ScreenAsh::RemoveObserver(display::DisplayObserver* observer) { | 190 void ScreenAsh::RemoveObserver(display::DisplayObserver* observer) { |
| 190 observers_.RemoveObserver(observer); | 191 observers_.RemoveObserver(observer); |
| 191 } | 192 } |
| 192 | 193 |
| 193 display::Screen* ScreenAsh::CloneForShutdown() { | 194 display::Screen* ScreenAsh::CloneForShutdown() { |
| 194 return new ScreenForShutdown(this); | 195 return new ScreenForShutdown(this); |
| 195 } | 196 } |
| 196 | 197 |
| 197 } // namespace ash | 198 } // namespace ash |
| OLD | NEW |