OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/events/platform/x11/x11_event_source_glib.h" | 5 #include "ui/events/platform/x11/x11_event_source_glib.h" |
6 | 6 |
| 7 #include <X11/Xlib.h> |
7 #include <glib.h> | 8 #include <glib.h> |
8 #include <X11/Xlib.h> | 9 |
| 10 #include "base/memory/ptr_util.h" |
9 | 11 |
10 namespace ui { | 12 namespace ui { |
11 | 13 |
12 namespace { | 14 namespace { |
13 | 15 |
14 struct GLibX11Source : public GSource { | 16 struct GLibX11Source : public GSource { |
15 // Note: The GLibX11Source is created and destroyed by GLib. So its | 17 // Note: The GLibX11Source is created and destroyed by GLib. So its |
16 // constructor/destructor may or may not get called. | 18 // constructor/destructor may or may not get called. |
17 XDisplay* display; | 19 XDisplay* display; |
18 GPollFD* poll_fd; | 20 GPollFD* poll_fd; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 glib_x_source->poll_fd = x_poll_.get(); | 88 glib_x_source->poll_fd = x_poll_.get(); |
87 | 89 |
88 x_source_ = glib_x_source; | 90 x_source_ = glib_x_source; |
89 g_source_add_poll(x_source_, x_poll_.get()); | 91 g_source_add_poll(x_source_, x_poll_.get()); |
90 g_source_set_can_recurse(x_source_, TRUE); | 92 g_source_set_can_recurse(x_source_, TRUE); |
91 g_source_set_callback(x_source_, NULL, &event_source_, NULL); | 93 g_source_set_callback(x_source_, NULL, &event_source_, NULL); |
92 g_source_attach(x_source_, g_main_context_default()); | 94 g_source_attach(x_source_, g_main_context_default()); |
93 } | 95 } |
94 | 96 |
95 // static | 97 // static |
96 scoped_ptr<PlatformEventSource> PlatformEventSource::CreateDefault() { | 98 std::unique_ptr<PlatformEventSource> PlatformEventSource::CreateDefault() { |
97 return make_scoped_ptr(new X11EventSourceGlib(gfx::GetXDisplay())); | 99 return base::WrapUnique(new X11EventSourceGlib(gfx::GetXDisplay())); |
98 } | 100 } |
99 | 101 |
100 } // namespace ui | 102 } // namespace ui |
OLD | NEW |