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 |