| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/base/user_input_monitor.h" | 5 #include "media/base/user_input_monitor.h" |
| 6 | 6 |
| 7 #include <sys/select.h> | 7 #include <sys/select.h> |
| 8 #include <unistd.h> | 8 #include <unistd.h> |
| 9 #define XK_MISCELLANY | 9 #define XK_MISCELLANY |
| 10 #include <X11/keysymdef.h> | 10 #include <X11/keysymdef.h> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 19 #include "base/message_loop/message_pump_libevent.h" | 19 #include "base/message_loop/message_pump_libevent.h" |
| 20 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
| 21 #include "base/synchronization/lock.h" | 21 #include "base/synchronization/lock.h" |
| 22 #include "media/base/keyboard_event_counter.h" | 22 #include "media/base/keyboard_event_counter.h" |
| 23 #include "third_party/skia/include/core/SkPoint.h" | 23 #include "third_party/skia/include/core/SkPoint.h" |
| 24 #include "ui/events/keycodes/keyboard_code_conversion_x.h" | 24 #include "ui/events/keycodes/keyboard_code_conversion_x.h" |
| 25 #include "ui/gfx/x/x11_types.h" |
| 25 | 26 |
| 26 // These includes need to be later than dictated by the style guide due to | 27 // These includes need to be later than dictated by the style guide due to |
| 27 // Xlib header pollution, specifically the min, max, and Status macros. | 28 // Xlib header pollution, specifically the min, max, and Status macros. |
| 28 #include <X11/XKBlib.h> | 29 #include <X11/XKBlib.h> |
| 29 #include <X11/Xlibint.h> | 30 #include <X11/Xlibint.h> |
| 30 #include <X11/extensions/record.h> | 31 #include <X11/extensions/record.h> |
| 31 | 32 |
| 32 namespace media { | 33 namespace media { |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 141 |
| 141 if (type == KEYBOARD_EVENT) | 142 if (type == KEYBOARD_EVENT) |
| 142 counter_.Reset(); | 143 counter_.Reset(); |
| 143 | 144 |
| 144 // TODO(jamiewalch): We should pass the display in. At that point, since | 145 // TODO(jamiewalch): We should pass the display in. At that point, since |
| 145 // XRecord needs a private connection to the X Server for its data channel | 146 // XRecord needs a private connection to the X Server for its data channel |
| 146 // and both channels are used from a separate thread, we'll need to duplicate | 147 // and both channels are used from a separate thread, we'll need to duplicate |
| 147 // them with something like the following: | 148 // them with something like the following: |
| 148 // XOpenDisplay(DisplayString(display)); | 149 // XOpenDisplay(DisplayString(display)); |
| 149 if (!x_control_display_) | 150 if (!x_control_display_) |
| 150 x_control_display_ = XOpenDisplay(NULL); | 151 x_control_display_ = gfx::OpenNewXDisplay(); |
| 151 | 152 |
| 152 if (!x_record_display_) | 153 if (!x_record_display_) |
| 153 x_record_display_ = XOpenDisplay(NULL); | 154 x_record_display_ = gfx::OpenNewXDisplay(); |
| 154 | 155 |
| 155 if (!x_control_display_ || !x_record_display_) { | 156 if (!x_control_display_ || !x_record_display_) { |
| 156 LOG(ERROR) << "Couldn't open X display"; | 157 LOG(ERROR) << "Couldn't open X display"; |
| 157 StopMonitor(type); | 158 StopMonitor(type); |
| 158 return; | 159 return; |
| 159 } | 160 } |
| 160 | 161 |
| 161 int xr_opcode, xr_event, xr_error; | 162 int xr_opcode, xr_event, xr_error; |
| 162 if (!XQueryExtension( | 163 if (!XQueryExtension( |
| 163 x_control_display_, "RECORD", &xr_opcode, &xr_event, &xr_error)) { | 164 x_control_display_, "RECORD", &xr_opcode, &xr_event, &xr_error)) { |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 } // namespace | 374 } // namespace |
| 374 | 375 |
| 375 scoped_ptr<UserInputMonitor> UserInputMonitor::Create( | 376 scoped_ptr<UserInputMonitor> UserInputMonitor::Create( |
| 376 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 377 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
| 377 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { | 378 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { |
| 378 return scoped_ptr<UserInputMonitor>( | 379 return scoped_ptr<UserInputMonitor>( |
| 379 new UserInputMonitorLinux(io_task_runner)); | 380 new UserInputMonitorLinux(io_task_runner)); |
| 380 } | 381 } |
| 381 | 382 |
| 382 } // namespace media | 383 } // namespace media |
| OLD | NEW |