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

Side by Side Diff: ui/wayland/wayland_message_pump.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_message_pump.h ('k') | ui/wayland/wayland_screen.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_message_pump.h"
6
7 #include <wayland-client.h>
8
9 #include "ui/wayland/wayland_display.h"
10
11 namespace ui {
12
13 WaylandMessagePump::WaylandMessagePump(WaylandDisplay* display)
14 : display_(display) {
15 static GSourceFuncs kSourceHandlers = {
16 WaylandMessagePump::SourcePrepare,
17 WaylandMessagePump::SourceCheck,
18 WaylandMessagePump::SourceDispatch,
19 NULL
20 };
21
22 source_ = static_cast<WorkSource*>(
23 g_source_new(&kSourceHandlers, sizeof(WorkSource)));
24 source_->pump = this;
25 pfd_.fd = wl_display_get_fd(display_->display(),
26 WaylandMessagePump::SourceUpdate,
27 source_);
28 pfd_.events = G_IO_IN | G_IO_ERR;
29 g_source_add_poll(source_, &pfd_);
30 g_source_attach(source_, NULL);
31 }
32
33 WaylandMessagePump::~WaylandMessagePump() {
34 g_source_destroy(source_);
35 g_source_unref(source_);
36 }
37
38 int WaylandMessagePump::HandlePrepare() {
39 while (mask_ & WL_DISPLAY_WRITABLE)
40 wl_display_iterate(display_->display(), WL_DISPLAY_WRITABLE);
41
42 return -1;
43 }
44
45 bool WaylandMessagePump::HandleCheck() {
46 return pfd_.revents;
47 }
48
49 void WaylandMessagePump::HandleDispatch() {
50 wl_display_iterate(display_->display(), WL_DISPLAY_READABLE);
51 }
52
53 // static
54 gboolean WaylandMessagePump::SourcePrepare(GSource* source, gint* timeout) {
55 *timeout = static_cast<WorkSource*>(source)->pump->HandlePrepare();
56 return FALSE;
57 }
58
59 // static
60 gboolean WaylandMessagePump::SourceCheck(GSource* source) {
61 return static_cast<WorkSource*>(source)->pump->HandleCheck();
62 }
63
64 // static
65 gboolean WaylandMessagePump::SourceDispatch(GSource* source,
66 GSourceFunc callback,
67 gpointer data) {
68 static_cast<WorkSource*>(source)->pump->HandleDispatch();
69 return TRUE;
70 }
71
72 // static
73 int WaylandMessagePump::SourceUpdate(uint32_t mask, void* data) {
74 static_cast<WorkSource*>(data)->pump->mask_ = mask;
75 return 0;
76 }
77
78 } // namespace ui
OLDNEW
« no previous file with comments | « ui/wayland/wayland_message_pump.h ('k') | ui/wayland/wayland_screen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698