Index: components/exo/wayland/server.cc |
diff --git a/components/exo/wayland/server.cc b/components/exo/wayland/server.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..05312107e7432c6d921f128974c4f2fb77c671d5 |
--- /dev/null |
+++ b/components/exo/wayland/server.cc |
@@ -0,0 +1,74 @@ |
+// Copyright 2015 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 "components/exo/wayland/server.h" |
+ |
+#include <wayland-server-core.h> |
+#include <wayland-server-protocol-core.h> |
+ |
+#include <algorithm> |
+ |
+#include "base/bind.h" |
+#include "base/cancelable_callback.h" |
+#include "base/strings/utf_string_conversions.h" |
+#include "cc/base/region.h" |
+#include "components/exo/buffer.h" |
+#include "components/exo/display.h" |
+#include "components/exo/shared_memory.h" |
+#include "components/exo/shell_surface.h" |
+#include "components/exo/surface.h" |
+ |
+namespace exo { |
+namespace wayland { |
+namespace { |
+ |
+#include "components/exo/wayland/wayland_bindings.h" |
piman
2015/11/18 04:31:51
This is surprising to say the least to include fro
reveman
2015/11/18 06:48:36
Right, this include stuff comes from an attempt to
piman
2015/11/18 17:35:12
Yep, SG, thanks.
|
+ |
+} // namespace |
+ |
+//////////////////////////////////////////////////////////////////////////////// |
+// Server, public: |
+ |
+Server::Server(Display* display) |
+ : display_(display), wl_display_(wl_display_create()) { |
+ wl_global_create(wl_display_.get(), &wl_compositor_interface, |
+ compositor_version, display_, bind_compositor); |
+ wl_global_create(wl_display_.get(), &wl_shm_interface, 1, display_, bind_shm); |
+ wl_global_create(wl_display_.get(), &wl_shell_interface, 1, display_, |
+ bind_shell); |
+} |
+ |
+Server::~Server() {} |
+ |
+// static |
+scoped_ptr<Server> Server::Create(Display* display) { |
+ scoped_ptr<Server> server(new Server(display)); |
+ int rv = wl_display_add_socket(server->wl_display_.get(), nullptr); |
+ DCHECK_EQ(rv, 0) << "wl_display_add_socket failed: " << rv; |
+ return server; |
+} |
+ |
+bool Server::AddSocket(const std::string name) { |
+ DCHECK(!name.empty()); |
+ return !wl_display_add_socket(wl_display_.get(), name.c_str()); |
+} |
+ |
+int Server::GetFileDescriptor() const { |
+ wl_event_loop* event_loop = wl_display_get_event_loop(wl_display_.get()); |
+ DCHECK(event_loop); |
+ return wl_event_loop_get_fd(event_loop); |
+} |
+ |
+void Server::Dispatch(base::TimeDelta timeout) { |
+ wl_event_loop* event_loop = wl_display_get_event_loop(wl_display_.get()); |
+ DCHECK(event_loop); |
+ wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); |
+} |
+ |
+void Server::Flush() { |
+ wl_display_flush_clients(wl_display_.get()); |
+} |
+ |
+} // namespace wayland |
+} // namespace exo |