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

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: (09.28.2016)Rebase on master Created 4 years, 2 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/ozone/public/ozone_platform.h"
9 #include "ui/views/widget/desktop_aura/desktop_screen.h"
10
11 namespace views {
12
13 ////////////////////////////////////////////////////////////////////////////////
14 // DesktopScreenWayland, public:
15 DesktopScreenWayland::DesktopScreenWayland()
16 : display::Screen(),
17 displays_() {
18 // Add a dummy Display.
19 // Without this, content_shell crashes in WindowTreeHost::InitCompositor()
20 // whiling calling GetDeviceScaleFactorFromDisplay() because the wl_output
21 // messages arrives later from Wayland Server.
22 displays_.push_back(display::Display(0, gfx::Rect(0, 0, 800, 600)));
23 ui::OzonePlatform::GetInstance()->SetScreenOutputObserver(this);
24 }
25
26 DesktopScreenWayland::~DesktopScreenWayland() {
27 }
28
29 // Overridden from display::Screen:
30 gfx::Point DesktopScreenWayland::GetCursorScreenPoint() {
31 return gfx::Point();
32 }
33
34 bool DesktopScreenWayland::IsWindowUnderCursor(gfx::NativeWindow window) {
35 return true;
36 }
37
38 gfx::NativeWindow DesktopScreenWayland::GetWindowAtScreenPoint(
39 const gfx::Point& point) {
40 return nullptr;
41 }
42
43 int DesktopScreenWayland::GetNumDisplays() const {
44 return displays_.size();
45 }
46
47 std::vector<display::Display> DesktopScreenWayland::GetAllDisplays() const {
48 return displays_;
49 }
50
51 display::Display DesktopScreenWayland::GetDisplayNearestWindow(
52 gfx::NativeView window) const {
53 return GetPrimaryDisplay();
54 }
55
56 display::Display DesktopScreenWayland::GetDisplayNearestPoint(
57 const gfx::Point& point) const {
58 return GetPrimaryDisplay();
59 }
60
61 display::Display DesktopScreenWayland::GetDisplayMatching(
62 const gfx::Rect& match_rect) const {
63 return GetPrimaryDisplay();
64 }
65
66 display::Display DesktopScreenWayland::GetPrimaryDisplay() const {
67 DCHECK(!displays_.empty());
68 return displays_.front();
69 }
70
71 void DesktopScreenWayland::AddObserver(display::DisplayObserver* observer) {
72 change_notifier_.AddObserver(observer);
73 }
74
75 void DesktopScreenWayland::RemoveObserver(display::DisplayObserver* observer) {
76 change_notifier_.RemoveObserver(observer);
77 }
78
79 void DesktopScreenWayland::OnOutputGeometryChanged(int32_t name,
80 const gfx::Rect& rect) {
81 // Remove the dummy Display.
82 if (GetPrimaryDisplay().id() == 0 && displays_.size() == 1)
83 displays_.clear();
84
85 display::Display* matching = nullptr;
86 for (std::vector<display::Display>::iterator it = displays_.begin();
87 it != displays_.end(); ++it) {
88 if (name == it->id())
89 matching = &*it;
90 }
91
92 std::vector<display::Display> old_displays = displays_;
93
94 if (!matching)
95 displays_.push_back(display::Display(name, rect));
96 else
97 matching->set_bounds(rect);
98
99 change_notifier_.NotifyDisplaysChanged(old_displays, displays_);
100 }
101
102 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_screen_wayland.h ('k') | ui/views/widget/desktop_aura/desktop_window_tree_host_wayland.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698