Chromium Code Reviews| 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..0234efa60f01ba61303b8db9108ac79cb97b56d7 |
| --- /dev/null |
| +++ b/ui/views/widget/desktop_aura/desktop_screen_wayland.cc |
| @@ -0,0 +1,110 @@ |
| +// 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_(), |
|
tonikitoo
2016/06/06 15:29:59
Is this needed?
joone
2016/06/06 18:22:22
It needs to initialize the vector.
|
| + isOutputSizeInitialized(false) { |
| + |
| + ui::WaylandDisplay::GetInstance()->SetDesktopScreenDelegate(this); |
| + // Set a dummy display::Display to provide a display::Display to |
| + // initialize CC. |
| + 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.
|
| +} |
| + |
| +DesktopScreenWayland::~DesktopScreenWayland() { |
| +} |
| + |
| +void DesktopScreenWayland::SetGeometry(int32_t name, |
| + const gfx::Rect& geometry) { |
| + 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 (!isOutputSizeInitialized) { |
| + // Remove the dummy display::Display. |
| + displays_.clear(); |
| + isOutputSizeInitialized = true; |
| + } |
| + |
| + if (!matching) |
| + displays_.push_back(display::Display(name, geometry)); |
| + else |
| + matching->set_bounds(geometry); |
| + |
| + change_notifier_.NotifyDisplaysChanged(old_displays, displays_); |
| +} |
| + |
| +// 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::OnOutputSizeChanged(int32_t name, |
| + unsigned width, unsigned height) { |
| + SetGeometry(name, gfx::Rect(0, 0, width, height)); |
| +} |
| + |
| +} // namespace views |