OLD | NEW |
---|---|
(Empty) | |
1 // 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 | |
5 #include "ui/views/widget/desktop_aura/desktop_screen_wayland.h" | |
6 | |
7 #include "ui/aura/window.h" | |
8 #include "ui/display/display.h" | |
9 #include "ui/display/screen.h" | |
10 #include "ui/ozone/platform/wayland/wayland_display.h" | |
11 #include "ui/views/widget/desktop_aura/desktop_screen.h" | |
12 | |
13 namespace views { | |
14 | |
15 //////////////////////////////////////////////////////////////////////////////// | |
16 // DesktopScreenWayland, public: | |
17 DesktopScreenWayland::DesktopScreenWayland() | |
18 : display::Screen(), | |
19 displays_(), | |
tonikitoo
2016/06/06 15:29:59
Is this needed?
joone
2016/06/06 18:22:22
It needs to initialize the vector.
| |
20 isOutputSizeInitialized(false) { | |
21 | |
22 ui::WaylandDisplay::GetInstance()->SetDesktopScreenDelegate(this); | |
23 // Set a dummy display::Display to provide a display::Display to | |
24 // initialize CC. | |
25 SetGeometry(0, gfx::Rect(0, 0, 0, 0)); | |
tonikitoo
2016/06/06 15:29:59
Question: Is this call here temporarily for the re
joone
2016/06/06 18:22:22
Yes, it allows us to avoid the initial crash.
| |
26 } | |
27 | |
28 DesktopScreenWayland::~DesktopScreenWayland() { | |
29 } | |
30 | |
31 void DesktopScreenWayland::SetGeometry(int32_t name, | |
32 const gfx::Rect& geometry) { | |
33 display::Display* matching = nullptr; | |
34 for (std::vector<display::Display>::iterator it = displays_.begin(); | |
35 it != displays_.end(); ++it) { | |
36 if (name == it->id()) | |
37 matching = &*it; | |
38 } | |
39 | |
40 std::vector<display::Display> old_displays = displays_; | |
41 if (!isOutputSizeInitialized) { | |
42 // Remove the dummy display::Display. | |
43 displays_.clear(); | |
44 isOutputSizeInitialized = true; | |
45 } | |
46 | |
47 if (!matching) | |
48 displays_.push_back(display::Display(name, geometry)); | |
49 else | |
50 matching->set_bounds(geometry); | |
51 | |
52 change_notifier_.NotifyDisplaysChanged(old_displays, displays_); | |
53 } | |
54 | |
55 // Overridden from display::Screen: | |
56 gfx::Point DesktopScreenWayland::GetCursorScreenPoint() { | |
57 return gfx::Point(); | |
58 } | |
59 | |
60 bool DesktopScreenWayland::IsWindowUnderCursor(gfx::NativeWindow window) { | |
61 return true; | |
62 } | |
63 | |
64 gfx::NativeWindow DesktopScreenWayland::GetWindowAtScreenPoint( | |
65 const gfx::Point& point) { | |
66 return nullptr; | |
67 } | |
68 | |
69 int DesktopScreenWayland::GetNumDisplays() const { | |
70 return displays_.size(); | |
71 } | |
72 | |
73 std::vector<display::Display> DesktopScreenWayland::GetAllDisplays() const { | |
74 return displays_; | |
75 } | |
76 | |
77 display::Display DesktopScreenWayland::GetDisplayNearestWindow( | |
78 gfx::NativeView window) const { | |
79 return GetPrimaryDisplay(); | |
80 } | |
81 | |
82 display::Display DesktopScreenWayland::GetDisplayNearestPoint( | |
83 const gfx::Point& point) const { | |
84 return GetPrimaryDisplay(); | |
85 } | |
86 | |
87 display::Display DesktopScreenWayland::GetDisplayMatching( | |
88 const gfx::Rect& match_rect) const { | |
89 return GetPrimaryDisplay(); | |
90 } | |
91 | |
92 display::Display DesktopScreenWayland::GetPrimaryDisplay() const { | |
93 DCHECK(!displays_.empty()); | |
94 return displays_.front(); | |
95 } | |
96 | |
97 void DesktopScreenWayland::AddObserver(display::DisplayObserver* observer) { | |
98 change_notifier_.AddObserver(observer); | |
99 } | |
100 | |
101 void DesktopScreenWayland::RemoveObserver(display::DisplayObserver* observer) { | |
102 change_notifier_.RemoveObserver(observer); | |
103 } | |
104 | |
105 void DesktopScreenWayland::OnOutputSizeChanged(int32_t name, | |
106 unsigned width, unsigned height) { | |
107 SetGeometry(name, gfx::Rect(0, 0, width, height)); | |
108 } | |
109 | |
110 } // namespace views | |
OLD | NEW |