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

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: (09.28.2016)Rebase on master Created 4 years, 3 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..556dd206fef1758564125e53fc697231bd8f5f58
--- /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/ozone/public/ozone_platform.h"
+#include "ui/views/widget/desktop_aura/desktop_screen.h"
+
+namespace views {
+
+////////////////////////////////////////////////////////////////////////////////
+// DesktopScreenWayland, public:
+DesktopScreenWayland::DesktopScreenWayland()
+ : display::Screen(),
+ displays_() {
+ // Add a dummy Display.
+ // Without this, content_shell crashes in WindowTreeHost::InitCompositor()
+ // whiling calling GetDeviceScaleFactorFromDisplay() because the wl_output
+ // messages arrives later from Wayland Server.
+ displays_.push_back(display::Display(0, gfx::Rect(0, 0, 800, 600)));
+ ui::OzonePlatform::GetInstance()->SetScreenOutputObserver(this);
+}
+
+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) {
+ // Remove the dummy Display.
+ if (GetPrimaryDisplay().id() == 0 && displays_.size() == 1)
+ displays_.clear();
+
+ 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_);
+}
+
+} // namespace views
« 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