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

Side by Side Diff: ui/wayland/wayland_display.cc

Issue 10009024: Remove WAYLAND port (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/wayland/wayland_display.h ('k') | ui/wayland/wayland_input_device.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 "ui/wayland/wayland_display.h"
6
7 #include <string.h>
8 #include <wayland-client.h>
9
10 #include "ui/wayland/wayland_buffer.h"
11 #include "ui/wayland/wayland_input_device.h"
12 #include "ui/wayland/wayland_screen.h"
13 #include "ui/wayland/wayland_window.h"
14
15 namespace ui {
16
17 // static
18 WaylandDisplay* WaylandDisplay::Connect(char* name) {
19 WaylandDisplay* display = new WaylandDisplay(name);
20 if (!display->display_) {
21 delete display;
22 return NULL;
23 }
24
25 wl_display_set_user_data(display->display_, display);
26 // Register the display initialization handler and iterate over the initial
27 // connection events sent by the server. This is required since the display
28 // will send registration events needed to initialize everything else. This
29 // will create the compositor, etc.., which are required in creating
30 // a drawing context.
31 wl_display_add_global_listener(display->display_,
32 WaylandDisplay::DisplayHandleGlobal,
33 display);
34 wl_display_iterate(display->display_, WL_DISPLAY_READABLE);
35
36 return display;
37 }
38
39 // static
40 WaylandDisplay* WaylandDisplay::GetDisplay(wl_display* display) {
41 return static_cast<WaylandDisplay*>(wl_display_get_user_data(display));
42 }
43
44 WaylandDisplay::WaylandDisplay(char* name) : display_(NULL),
45 compositor_(NULL),
46 shell_(NULL),
47 shm_(NULL) {
48 display_ = wl_display_connect(name);
49 }
50
51 WaylandDisplay::~WaylandDisplay() {
52 if (display_)
53 wl_display_destroy(display_);
54 if (compositor_)
55 wl_compositor_destroy(compositor_);
56 if (shell_)
57 wl_shell_destroy(shell_);
58 if (shm_)
59 wl_shm_destroy(shm_);
60 for (std::list<WaylandInputDevice*>::iterator i = input_list_.begin();
61 i != input_list_.end(); ++i) {
62 delete *i;
63 }
64 for (std::list<WaylandScreen*>::iterator i = screen_list_.begin();
65 i != screen_list_.end(); ++i) {
66 delete *i;
67 }
68 }
69
70 wl_surface* WaylandDisplay::CreateSurface() {
71 return wl_compositor_create_surface(compositor_);
72 }
73
74 void WaylandDisplay::SetCursor(WaylandBuffer* buffer,
75 int32_t x, int32_t y) {
76 // Currently there is no way of knowing which input device should have the
77 // buffer attached, so we just attach to every input device.
78 for (std::list<WaylandInputDevice*>::iterator i = input_list_.begin();
79 i != input_list_.end(); ++i) {
80 (*i)->Attach(buffer->buffer(), x, y);
81 }
82 }
83
84 std::list<WaylandScreen*> WaylandDisplay::GetScreenList() const {
85 return screen_list_;
86 }
87
88 // static
89 void WaylandDisplay::DisplayHandleGlobal(wl_display* display,
90 uint32_t id,
91 const char* interface,
92 uint32_t version,
93 void* data) {
94 WaylandDisplay* disp = static_cast<WaylandDisplay*>(data);
95
96 static const wl_shell_listener kShellListener = {
97 WaylandDisplay::ShellHandleConfigure,
98 };
99
100 if (strcmp(interface, "wl_compositor") == 0) {
101 disp->compositor_ = static_cast<wl_compositor*>(
102 wl_display_bind(display, id, &wl_compositor_interface));
103 } else if (strcmp(interface, "wl_output") == 0) {
104 WaylandScreen* screen = new WaylandScreen(disp, id);
105 disp->screen_list_.push_back(screen);
106 } else if (strcmp(interface, "wl_input_device") == 0) {
107 WaylandInputDevice *input_device = new WaylandInputDevice(display, id);
108 disp->input_list_.push_back(input_device);
109 } else if (strcmp(interface, "wl_shell") == 0) {
110 disp->shell_ = static_cast<wl_shell*>(
111 wl_display_bind(display, id, &wl_shell_interface));
112 wl_shell_add_listener(disp->shell_, &kShellListener, disp);
113 } else if (strcmp(interface, "wl_shm") == 0) {
114 disp->shm_ = static_cast<wl_shm*>(
115 wl_display_bind(display, id, &wl_shm_interface));
116 }
117 }
118
119 // static
120 void WaylandDisplay::ShellHandleConfigure(void* data,
121 wl_shell* shell,
122 uint32_t time,
123 uint32_t edges,
124 wl_surface* surface,
125 int32_t width,
126 int32_t height) {
127 WaylandWindow* window = static_cast<WaylandWindow*>(
128 wl_surface_get_user_data(surface));
129 window->Configure(time, edges, 0, 0, width, height);
130 }
131
132 } // namespace ui
OLDNEW
« no previous file with comments | « ui/wayland/wayland_display.h ('k') | ui/wayland/wayland_input_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698