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.h" | 5 #include "ui/events/platform/x11/x11_event_source.h" |
6 | 6 |
7 #include <glib.h> | 7 #include <glib.h> |
8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 | 9 |
10 namespace ui { | 10 namespace ui { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 }; | 48 }; |
49 | 49 |
50 class X11EventSourceGlib : public X11EventSource { | 50 class X11EventSourceGlib : public X11EventSource { |
51 public: | 51 public: |
52 explicit X11EventSourceGlib(XDisplay* display) | 52 explicit X11EventSourceGlib(XDisplay* display) |
53 : X11EventSource(display), | 53 : X11EventSource(display), |
54 x_source_(NULL) { | 54 x_source_(NULL) { |
55 InitXSource(ConnectionNumber(display)); | 55 InitXSource(ConnectionNumber(display)); |
56 } | 56 } |
57 | 57 |
58 virtual ~X11EventSourceGlib() { | 58 ~X11EventSourceGlib() override { |
59 g_source_destroy(x_source_); | 59 g_source_destroy(x_source_); |
60 g_source_unref(x_source_); | 60 g_source_unref(x_source_); |
61 } | 61 } |
62 | 62 |
63 private: | 63 private: |
64 void InitXSource(int fd) { | 64 void InitXSource(int fd) { |
65 CHECK(!x_source_); | 65 CHECK(!x_source_); |
66 CHECK(display()) << "Unable to get connection to X server"; | 66 CHECK(display()) << "Unable to get connection to X server"; |
67 | 67 |
68 x_poll_.reset(new GPollFD()); | 68 x_poll_.reset(new GPollFD()); |
(...skipping 23 matching lines...) Expand all Loading... |
92 }; | 92 }; |
93 | 93 |
94 } // namespace | 94 } // namespace |
95 | 95 |
96 scoped_ptr<PlatformEventSource> PlatformEventSource::CreateDefault() { | 96 scoped_ptr<PlatformEventSource> PlatformEventSource::CreateDefault() { |
97 return scoped_ptr<PlatformEventSource>( | 97 return scoped_ptr<PlatformEventSource>( |
98 new X11EventSourceGlib(gfx::GetXDisplay())); | 98 new X11EventSourceGlib(gfx::GetXDisplay())); |
99 } | 99 } |
100 | 100 |
101 } // namespace ui | 101 } // namespace ui |
OLD | NEW |