blob: ae1f25acc79693fadff154ce2b769a4513e4173b [file] [log] [blame]
msw5e048a72016-09-07 18:55:301// Copyright 2016 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
msw5e048a72016-09-07 18:55:305#include "ui/display/screen_base.h"
6
7#include "ui/display/display_finder.h"
8
9namespace display {
10
riajiangbcbb8c42016-11-07 17:57:4111ScreenBase::ScreenBase() {}
msw5e048a72016-09-07 18:55:3012
riajiangbcbb8c42016-11-07 17:57:4113ScreenBase::~ScreenBase() {}
msw5e048a72016-09-07 18:55:3014
15gfx::Point ScreenBase::GetCursorScreenPoint() {
Daniel Bratellff541192017-11-02 14:22:2816 NOTIMPLEMENTED_LOG_ONCE();
msw5e048a72016-09-07 18:55:3017 return gfx::Point();
18}
19
20bool ScreenBase::IsWindowUnderCursor(gfx::NativeWindow window) {
Daniel Bratellff541192017-11-02 14:22:2821 NOTIMPLEMENTED_LOG_ONCE();
msw5e048a72016-09-07 18:55:3022 return false;
23}
24
25gfx::NativeWindow ScreenBase::GetWindowAtScreenPoint(const gfx::Point& point) {
Daniel Bratellff541192017-11-02 14:22:2826 NOTIMPLEMENTED_LOG_ONCE();
msw5e048a72016-09-07 18:55:3027 return nullptr;
28}
29
kylechar9825bba2016-11-02 14:10:1630Display ScreenBase::GetPrimaryDisplay() const {
31 auto iter = display_list_.GetPrimaryDisplayIterator();
32 if (iter == display_list_.displays().end())
33 return Display(); // Invalid display since we have no primary display.
34 return *iter;
msw5e048a72016-09-07 18:55:3035}
36
jinsukkim2dd85f32017-03-17 01:54:2837Display ScreenBase::GetDisplayNearestWindow(gfx::NativeWindow window) const {
riajiange5d57c42016-12-17 04:42:0538 // TODO(riajiang): Implement this for multi-displays either here or in
39 // ScreenMus.
Daniel Bratellff541192017-11-02 14:22:2840 NOTIMPLEMENTED_LOG_ONCE();
kylechar9825bba2016-11-02 14:10:1641 return GetPrimaryDisplay();
msw5e048a72016-09-07 18:55:3042}
43
kylechar9825bba2016-11-02 14:10:1644Display ScreenBase::GetDisplayNearestPoint(const gfx::Point& point) const {
45 return *FindDisplayNearestPoint(display_list_.displays(), point);
msw5e048a72016-09-07 18:55:3046}
47
48int ScreenBase::GetNumDisplays() const {
49 return static_cast<int>(display_list_.displays().size());
50}
51
riajiang107f22dd2016-11-18 18:38:1152const std::vector<Display>& ScreenBase::GetAllDisplays() const {
msw5e048a72016-09-07 18:55:3053 return display_list_.displays();
54}
55
kylechar9825bba2016-11-02 14:10:1656Display ScreenBase::GetDisplayMatching(const gfx::Rect& match_rect) const {
skycdafce62017-03-06 19:22:3357 if (match_rect.IsEmpty())
58 return GetDisplayNearestPoint(match_rect.origin());
59
kylechar9825bba2016-11-02 14:10:1660 const Display* match =
61 FindDisplayWithBiggestIntersection(display_list_.displays(), match_rect);
msw5e048a72016-09-07 18:55:3062 return match ? *match : GetPrimaryDisplay();
63}
64
kylechar9825bba2016-11-02 14:10:1665void ScreenBase::AddObserver(DisplayObserver* observer) {
msw5e048a72016-09-07 18:55:3066 display_list_.AddObserver(observer);
67}
68
kylechar9825bba2016-11-02 14:10:1669void ScreenBase::RemoveObserver(DisplayObserver* observer) {
msw5e048a72016-09-07 18:55:3070 display_list_.RemoveObserver(observer);
71}
72
riajiangbcbb8c42016-11-07 17:57:4173void ScreenBase::ProcessDisplayChanged(const Display& changed_display,
74 bool is_primary) {
75 if (display_list_.FindDisplayById(changed_display.id()) ==
76 display_list_.displays().end()) {
77 display_list_.AddDisplay(changed_display,
78 is_primary ? DisplayList::Type::PRIMARY
79 : DisplayList::Type::NOT_PRIMARY);
80 return;
81 }
82 display_list_.UpdateDisplay(
83 changed_display,
84 is_primary ? DisplayList::Type::PRIMARY : DisplayList::Type::NOT_PRIMARY);
85}
86
msw5e048a72016-09-07 18:55:3087} // namespace display