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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_screen_wayland.cc

Issue 2027943002: [WIP] Make content_shell run under Wayland Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on tonikitoo's CL (included) Created 4 years, 6 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
(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_() {
20 }
21
22 DesktopScreenWayland::~DesktopScreenWayland() {
23 }
24
25 // Overridden from display::Screen:
26 gfx::Point DesktopScreenWayland::GetCursorScreenPoint() {
27 return gfx::Point();
28 }
29
30 bool DesktopScreenWayland::IsWindowUnderCursor(gfx::NativeWindow window) {
31 return true;
32 }
33
34 gfx::NativeWindow DesktopScreenWayland::GetWindowAtScreenPoint(
35 const gfx::Point& point) {
36 return nullptr;
37 }
38
39 int DesktopScreenWayland::GetNumDisplays() const {
40 return displays_.size();
41 }
42
43 std::vector<display::Display> DesktopScreenWayland::GetAllDisplays() const {
44 return displays_;
45 }
46
47 display::Display DesktopScreenWayland::GetDisplayNearestWindow(
48 gfx::NativeView window) const {
49 return GetPrimaryDisplay();
50 }
51
52 display::Display DesktopScreenWayland::GetDisplayNearestPoint(
53 const gfx::Point& point) const {
54 return GetPrimaryDisplay();
55 }
56
57 display::Display DesktopScreenWayland::GetDisplayMatching(
58 const gfx::Rect& match_rect) const {
59 return GetPrimaryDisplay();
60 }
61
62 display::Display DesktopScreenWayland::GetPrimaryDisplay() const {
63 DCHECK(!displays_.empty());
64 return displays_.front();
65 }
66
67 void DesktopScreenWayland::AddObserver(display::DisplayObserver* observer) {
68 change_notifier_.AddObserver(observer);
69 }
70
71 void DesktopScreenWayland::RemoveObserver(display::DisplayObserver* observer) {
72 change_notifier_.RemoveObserver(observer);
73 }
74
75 void DesktopScreenWayland::OnOutputGeometryChanged(int32_t name,
76 const gfx::Rect& rect) {
77
78 display::Display* matching = nullptr;
79 for (std::vector<display::Display>::iterator it = displays_.begin();
80 it != displays_.end(); ++it) {
81 if (name == it->id())
82 matching = &*it;
83 }
84
85 std::vector<display::Display> old_displays = displays_;
86
87 if (!matching)
88 displays_.push_back(display::Display(name, rect));
89 else
90 matching->set_bounds(rect);
91
92 change_notifier_.NotifyDisplaysChanged(old_displays, displays_);
93 }
94
95 void DesktopScreenWayland::WaitForScreenSizeAvailable() {
96 base::RunLoop run_loop;
97 ui::WaylandDisplay::GetInstance()->SetOutputCompleteClosure(
98 run_loop.QuitClosure());
99 run_loop.Run();
100 }
101
102 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698