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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/widget/desktop_aura/desktop_screen_wayland.cc
diff --git a/ui/views/widget/desktop_aura/desktop_screen_wayland.cc b/ui/views/widget/desktop_aura/desktop_screen_wayland.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7df9c76b1ac3027fa1fa1c9efacc78ebc5240a07
--- /dev/null
+++ b/ui/views/widget/desktop_aura/desktop_screen_wayland.cc
@@ -0,0 +1,102 @@
+// 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/views/widget/desktop_aura/desktop_screen_wayland.h"
+
+#include "ui/aura/window.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
+#include "ui/ozone/platform/wayland/wayland_display.h"
+#include "ui/views/widget/desktop_aura/desktop_screen.h"
+
+namespace views {
+
+////////////////////////////////////////////////////////////////////////////////
+// DesktopScreenWayland, public:
+DesktopScreenWayland::DesktopScreenWayland()
+ : display::Screen(),
+ displays_() {
+}
+
+DesktopScreenWayland::~DesktopScreenWayland() {
+}
+
+// Overridden from display::Screen:
+gfx::Point DesktopScreenWayland::GetCursorScreenPoint() {
+ return gfx::Point();
+}
+
+bool DesktopScreenWayland::IsWindowUnderCursor(gfx::NativeWindow window) {
+ return true;
+}
+
+gfx::NativeWindow DesktopScreenWayland::GetWindowAtScreenPoint(
+ const gfx::Point& point) {
+ return nullptr;
+}
+
+int DesktopScreenWayland::GetNumDisplays() const {
+ return displays_.size();
+}
+
+std::vector<display::Display> DesktopScreenWayland::GetAllDisplays() const {
+ return displays_;
+}
+
+display::Display DesktopScreenWayland::GetDisplayNearestWindow(
+ gfx::NativeView window) const {
+ return GetPrimaryDisplay();
+}
+
+display::Display DesktopScreenWayland::GetDisplayNearestPoint(
+ const gfx::Point& point) const {
+ return GetPrimaryDisplay();
+}
+
+display::Display DesktopScreenWayland::GetDisplayMatching(
+ const gfx::Rect& match_rect) const {
+ return GetPrimaryDisplay();
+}
+
+display::Display DesktopScreenWayland::GetPrimaryDisplay() const {
+ DCHECK(!displays_.empty());
+ return displays_.front();
+}
+
+void DesktopScreenWayland::AddObserver(display::DisplayObserver* observer) {
+ change_notifier_.AddObserver(observer);
+}
+
+void DesktopScreenWayland::RemoveObserver(display::DisplayObserver* observer) {
+ change_notifier_.RemoveObserver(observer);
+}
+
+void DesktopScreenWayland::OnOutputGeometryChanged(int32_t name,
+ const gfx::Rect& rect) {
+
+ display::Display* matching = nullptr;
+ for (std::vector<display::Display>::iterator it = displays_.begin();
+ it != displays_.end(); ++it) {
+ if (name == it->id())
+ matching = &*it;
+ }
+
+ std::vector<display::Display> old_displays = displays_;
+
+ if (!matching)
+ displays_.push_back(display::Display(name, rect));
+ else
+ matching->set_bounds(rect);
+
+ change_notifier_.NotifyDisplaysChanged(old_displays, displays_);
+}
+
+void DesktopScreenWayland::WaitForScreenSizeAvailable() {
+ base::RunLoop run_loop;
+ ui::WaylandDisplay::GetInstance()->SetOutputCompleteClosure(
+ run_loop.QuitClosure());
+ run_loop.Run();
+}
+
+} // namespace views

Powered by Google App Engine
This is Rietveld 408576698