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: remoting/host/input_injector_x11.cc

Issue 810133003: replace NULL->nullptr in src/remoting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/host/input_injector.h" 5 #include "remoting/host/input_injector.h"
6 6
7 #include <X11/extensions/XInput.h> 7 #include <X11/extensions/XInput.h>
8 #include <X11/extensions/XTest.h> 8 #include <X11/extensions/XTest.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 #include <X11/XKBlib.h> 10 #include <X11/XKBlib.h>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 Mod3Mask, 49 Mod3Mask,
50 Mod4Mask, 50 Mod4Mask,
51 ShiftMask | Mod2Mask, 51 ShiftMask | Mod2Mask,
52 ShiftMask | Mod3Mask, 52 ShiftMask | Mod3Mask,
53 ShiftMask | Mod4Mask, 53 ShiftMask | Mod4Mask,
54 }; 54 };
55 55
56 // TODO(sergeyu): Is there a better way to find modifiers state? 56 // TODO(sergeyu): Is there a better way to find modifiers state?
57 for (size_t i = 0; i < arraysize(kModifiersToTry); ++i) { 57 for (size_t i = 0; i < arraysize(kModifiersToTry); ++i) {
58 unsigned long key_sym_with_mods; 58 unsigned long key_sym_with_mods;
59 if (XkbLookupKeySym( 59 if (XkbLookupKeySym(display, *keycode, kModifiersToTry[i], nullptr,
60 display, *keycode, kModifiersToTry[i], NULL, &key_sym_with_mods) && 60 &key_sym_with_mods) &&
61 key_sym_with_mods == key_sym) { 61 key_sym_with_mods == key_sym) {
62 *modifiers = kModifiersToTry[i]; 62 *modifiers = kModifiersToTry[i];
63 return true; 63 return true;
64 } 64 }
65 } 65 }
66 66
67 return false; 67 return false;
68 } 68 }
69 69
70 // Finds a keycode and set of modifiers that generate character with the 70 // Finds a keycode and set of modifiers that generate character with the
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 scoped_ptr<protocol::ClipboardStub> client_clipboard) { 223 scoped_ptr<protocol::ClipboardStub> client_clipboard) {
224 core_->Start(client_clipboard.Pass()); 224 core_->Start(client_clipboard.Pass());
225 } 225 }
226 226
227 InputInjectorX11::Core::Core( 227 InputInjectorX11::Core::Core(
228 scoped_refptr<base::SingleThreadTaskRunner> task_runner) 228 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
229 : task_runner_(task_runner), 229 : task_runner_(task_runner),
230 latest_mouse_position_(-1, -1), 230 latest_mouse_position_(-1, -1),
231 wheel_ticks_x_(0.0f), 231 wheel_ticks_x_(0.0f),
232 wheel_ticks_y_(0.0f), 232 wheel_ticks_y_(0.0f),
233 display_(XOpenDisplay(NULL)), 233 display_(XOpenDisplay(nullptr)),
234 root_window_(BadValue), 234 root_window_(BadValue),
235 saved_auto_repeat_enabled_(false) { 235 saved_auto_repeat_enabled_(false) {
236 } 236 }
237 237
238 bool InputInjectorX11::Core::Init() { 238 bool InputInjectorX11::Core::Init() {
239 CHECK(display_); 239 CHECK(display_);
240 240
241 if (!task_runner_->BelongsToCurrentThread()) 241 if (!task_runner_->BelongsToCurrentThread())
242 task_runner_->PostTask(FROM_HERE, base::Bind(&Core::InitClipboard, this)); 242 task_runner_->PostTask(FROM_HERE, base::Bind(&Core::InitClipboard, this));
243 243
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 XFlush(display_); 493 XFlush(display_);
494 } 494 }
495 495
496 void InputInjectorX11::Core::InitMouseButtonMap() { 496 void InputInjectorX11::Core::InitMouseButtonMap() {
497 // TODO(rmsousa): Run this on global/device mapping change events. 497 // TODO(rmsousa): Run this on global/device mapping change events.
498 498
499 // Do not touch global pointer mapping, since this may affect the local user. 499 // Do not touch global pointer mapping, since this may affect the local user.
500 // Instead, try to work around it by reversing the mapping. 500 // Instead, try to work around it by reversing the mapping.
501 // Note that if a user has a global mapping that completely disables a button 501 // Note that if a user has a global mapping that completely disables a button
502 // (by assigning 0 to it), we won't be able to inject it. 502 // (by assigning 0 to it), we won't be able to inject it.
503 int num_buttons = XGetPointerMapping(display_, NULL, 0); 503 int num_buttons = XGetPointerMapping(display_, nullptr, 0);
504 scoped_ptr<unsigned char[]> pointer_mapping(new unsigned char[num_buttons]); 504 scoped_ptr<unsigned char[]> pointer_mapping(new unsigned char[num_buttons]);
505 num_buttons = XGetPointerMapping(display_, pointer_mapping.get(), 505 num_buttons = XGetPointerMapping(display_, pointer_mapping.get(),
506 num_buttons); 506 num_buttons);
507 for (int i = 0; i < kNumPointerButtons; i++) { 507 for (int i = 0; i < kNumPointerButtons; i++) {
508 pointer_button_map_[i] = -1; 508 pointer_button_map_[i] = -1;
509 } 509 }
510 for (int i = 0; i < num_buttons; i++) { 510 for (int i = 0; i < num_buttons; i++) {
511 // Reverse the mapping. 511 // Reverse the mapping.
512 if (pointer_mapping[i] > 0 && pointer_mapping[i] <= kNumPointerButtons) 512 if (pointer_mapping[i] > 0 && pointer_mapping[i] <= kNumPointerButtons)
513 pointer_button_map_[pointer_mapping[i] - 1] = i + 1; 513 pointer_button_map_[pointer_mapping[i] - 1] = i + 1;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 HOST_LOG << "Cannot find XTest device."; 549 HOST_LOG << "Cannot find XTest device.";
550 return; 550 return;
551 } 551 }
552 552
553 XDevice* device = XOpenDevice(display_, device_id); 553 XDevice* device = XOpenDevice(display_, device_id);
554 if (!device) { 554 if (!device) {
555 LOG(ERROR) << "Cannot open XTest device."; 555 LOG(ERROR) << "Cannot open XTest device.";
556 return; 556 return;
557 } 557 }
558 558
559 int num_device_buttons = XGetDeviceButtonMapping(display_, device, NULL, 0); 559 int num_device_buttons =
560 XGetDeviceButtonMapping(display_, device, nullptr, 0);
560 scoped_ptr<unsigned char[]> button_mapping(new unsigned char[num_buttons]); 561 scoped_ptr<unsigned char[]> button_mapping(new unsigned char[num_buttons]);
561 for (int i = 0; i < num_device_buttons; i++) { 562 for (int i = 0; i < num_device_buttons; i++) {
562 button_mapping[i] = i + 1; 563 button_mapping[i] = i + 1;
563 } 564 }
564 error = XSetDeviceButtonMapping(display_, device, button_mapping.get(), 565 error = XSetDeviceButtonMapping(display_, device, button_mapping.get(),
565 num_device_buttons); 566 num_device_buttons);
566 if (error != Success) 567 if (error != Success)
567 LOG(ERROR) << "Failed to set XTest device button mapping: " << error; 568 LOG(ERROR) << "Failed to set XTest device button mapping: " << error;
568 569
569 XCloseDevice(display_, device); 570 XCloseDevice(display_, device);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 627 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
627 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { 628 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
628 scoped_ptr<InputInjectorX11> injector( 629 scoped_ptr<InputInjectorX11> injector(
629 new InputInjectorX11(main_task_runner)); 630 new InputInjectorX11(main_task_runner));
630 if (!injector->Init()) 631 if (!injector->Init())
631 return nullptr; 632 return nullptr;
632 return injector.Pass(); 633 return injector.Pass();
633 } 634 }
634 635
635 } // namespace remoting 636 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/input_injector_mac.cc ('k') | remoting/host/installer/mac/uninstaller/remoting_uninstaller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698