summaryrefslogtreecommitdiff
path: root/chromium/ui/display/screen_base.cc
blob: 03d89f0a4ec6195a44158eda4298d63d407daaf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/display/screen_base.h"

#include "ui/display/display_finder.h"

namespace display {

ScreenBase::ScreenBase() {}

ScreenBase::~ScreenBase() {}

gfx::Point ScreenBase::GetCursorScreenPoint() {
  NOTIMPLEMENTED_LOG_ONCE();
  return gfx::Point();
}

bool ScreenBase::IsWindowUnderCursor(gfx::NativeWindow window) {
  NOTIMPLEMENTED_LOG_ONCE();
  return false;
}

gfx::NativeWindow ScreenBase::GetWindowAtScreenPoint(const gfx::Point& point) {
  NOTIMPLEMENTED_LOG_ONCE();
  return nullptr;
}

gfx::NativeWindow ScreenBase::GetLocalProcessWindowAtPoint(
    const gfx::Point& screen_point,
    const std::set<gfx::NativeWindow>& ignore) {
  NOTIMPLEMENTED_LOG_ONCE();
  return nullptr;
}

Display ScreenBase::GetPrimaryDisplay() const {
  auto iter = display_list_.GetPrimaryDisplayIterator();
  if (iter == display_list_.displays().end())
    return Display::GetDefaultDisplay();
  return *iter;
}

Display ScreenBase::GetDisplayNearestWindow(gfx::NativeWindow window) const {
  NOTIMPLEMENTED_LOG_ONCE();
  return GetPrimaryDisplay();
}

Display ScreenBase::GetDisplayNearestPoint(const gfx::Point& point) const {
  return *FindDisplayNearestPoint(display_list_.displays(), point);
}

int ScreenBase::GetNumDisplays() const {
  return static_cast<int>(display_list_.displays().size());
}

const std::vector<Display>& ScreenBase::GetAllDisplays() const {
  return display_list_.displays();
}

Display ScreenBase::GetDisplayMatching(const gfx::Rect& match_rect) const {
  if (match_rect.IsEmpty())
    return GetDisplayNearestPoint(match_rect.origin());

  const Display* match =
      FindDisplayWithBiggestIntersection(display_list_.displays(), match_rect);
  return match ? *match : GetPrimaryDisplay();
}

void ScreenBase::AddObserver(DisplayObserver* observer) {
  display_list_.AddObserver(observer);
}

void ScreenBase::RemoveObserver(DisplayObserver* observer) {
  display_list_.RemoveObserver(observer);
}

void ScreenBase::SetPanelRotationForTesting(int64_t display_id,
                                            Display::Rotation rotation) {
  Display display = *display_list_.FindDisplayById(display_id);
  display.set_panel_rotation(rotation);
  ProcessDisplayChanged(display, true);
}

void ScreenBase::ProcessDisplayChanged(const Display& changed_display,
                                       bool is_primary) {
  if (display_list_.FindDisplayById(changed_display.id()) ==
      display_list_.displays().end()) {
    display_list_.AddDisplay(changed_display,
                             is_primary ? DisplayList::Type::PRIMARY
                                        : DisplayList::Type::NOT_PRIMARY);
    return;
  }
  display_list_.UpdateDisplay(
      changed_display,
      is_primary ? DisplayList::Type::PRIMARY : DisplayList::Type::NOT_PRIMARY);
}

}  // namespace display