Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/exo/wayland/server.h" | |
| 6 | |
| 7 #include <wayland-server-core.h> | |
| 8 #include <wayland-server-protocol-core.h> | |
| 9 | |
| 10 #include <algorithm> | |
| 11 | |
| 12 #include "base/bind.h" | |
| 13 #include "base/cancelable_callback.h" | |
| 14 #include "base/strings/utf_string_conversions.h" | |
| 15 #include "cc/base/region.h" | |
| 16 #include "components/exo/buffer.h" | |
| 17 #include "components/exo/display.h" | |
| 18 #include "components/exo/shared_memory.h" | |
| 19 #include "components/exo/shell_surface.h" | |
| 20 #include "components/exo/surface.h" | |
| 21 | |
| 22 namespace exo { | |
| 23 namespace wayland { | |
| 24 namespace { | |
| 25 | |
| 26 #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.
| |
| 27 | |
| 28 } // namespace | |
| 29 | |
| 30 //////////////////////////////////////////////////////////////////////////////// | |
| 31 // Server, public: | |
| 32 | |
| 33 Server::Server(Display* display) | |
| 34 : display_(display), wl_display_(wl_display_create()) { | |
| 35 wl_global_create(wl_display_.get(), &wl_compositor_interface, | |
| 36 compositor_version, display_, bind_compositor); | |
| 37 wl_global_create(wl_display_.get(), &wl_shm_interface, 1, display_, bind_shm); | |
| 38 wl_global_create(wl_display_.get(), &wl_shell_interface, 1, display_, | |
| 39 bind_shell); | |
| 40 } | |
| 41 | |
| 42 Server::~Server() {} | |
| 43 | |
| 44 // static | |
| 45 scoped_ptr<Server> Server::Create(Display* display) { | |
| 46 scoped_ptr<Server> server(new Server(display)); | |
| 47 int rv = wl_display_add_socket(server->wl_display_.get(), nullptr); | |
| 48 DCHECK_EQ(rv, 0) << "wl_display_add_socket failed: " << rv; | |
| 49 return server; | |
| 50 } | |
| 51 | |
| 52 bool Server::AddSocket(const std::string name) { | |
| 53 DCHECK(!name.empty()); | |
| 54 return !wl_display_add_socket(wl_display_.get(), name.c_str()); | |
| 55 } | |
| 56 | |
| 57 int Server::GetFileDescriptor() const { | |
| 58 wl_event_loop* event_loop = wl_display_get_event_loop(wl_display_.get()); | |
| 59 DCHECK(event_loop); | |
| 60 return wl_event_loop_get_fd(event_loop); | |
| 61 } | |
| 62 | |
| 63 void Server::Dispatch(base::TimeDelta timeout) { | |
| 64 wl_event_loop* event_loop = wl_display_get_event_loop(wl_display_.get()); | |
| 65 DCHECK(event_loop); | |
| 66 wl_event_loop_dispatch(event_loop, timeout.InMilliseconds()); | |
| 67 } | |
| 68 | |
| 69 void Server::Flush() { | |
| 70 wl_display_flush_clients(wl_display_.get()); | |
| 71 } | |
| 72 | |
| 73 } // namespace wayland | |
| 74 } // namespace exo | |
| OLD | NEW |