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

Side by Side Diff: remoting/host/input_injector_linux.cc

Issue 13642007: Rewrite scoped_array<T> to scoped_ptr<T[]> in remoting/, Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Manually rewrite Win files. Created 7 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 | « remoting/host/disconnect_window_win.cc ('k') | remoting/host/local_input_monitor_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/Xlib.h> 7 #include <X11/Xlib.h>
8 #include <X11/extensions/XTest.h> 8 #include <X11/extensions/XTest.h>
9 #include <X11/extensions/XInput.h> 9 #include <X11/extensions/XInput.h>
10 10
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 } 366 }
367 367
368 void InputInjectorLinux::Core::InitMouseButtonMap() { 368 void InputInjectorLinux::Core::InitMouseButtonMap() {
369 // TODO(rmsousa): Run this on global/device mapping change events. 369 // TODO(rmsousa): Run this on global/device mapping change events.
370 370
371 // Do not touch global pointer mapping, since this may affect the local user. 371 // Do not touch global pointer mapping, since this may affect the local user.
372 // Instead, try to work around it by reversing the mapping. 372 // Instead, try to work around it by reversing the mapping.
373 // Note that if a user has a global mapping that completely disables a button 373 // Note that if a user has a global mapping that completely disables a button
374 // (by assigning 0 to it), we won't be able to inject it. 374 // (by assigning 0 to it), we won't be able to inject it.
375 int num_buttons = XGetPointerMapping(display_, NULL, 0); 375 int num_buttons = XGetPointerMapping(display_, NULL, 0);
376 scoped_array<unsigned char> pointer_mapping(new unsigned char[num_buttons]); 376 scoped_ptr<unsigned char[]> pointer_mapping(new unsigned char[num_buttons]);
377 num_buttons = XGetPointerMapping(display_, pointer_mapping.get(), 377 num_buttons = XGetPointerMapping(display_, pointer_mapping.get(),
378 num_buttons); 378 num_buttons);
379 for (int i = 0; i < kNumPointerButtons; i++) { 379 for (int i = 0; i < kNumPointerButtons; i++) {
380 pointer_button_map_[i] = -1; 380 pointer_button_map_[i] = -1;
381 } 381 }
382 for (int i = 0; i < num_buttons; i++) { 382 for (int i = 0; i < num_buttons; i++) {
383 // Reverse the mapping. 383 // Reverse the mapping.
384 if (pointer_mapping[i] > 0 && pointer_mapping[i] <= kNumPointerButtons) 384 if (pointer_mapping[i] > 0 && pointer_mapping[i] <= kNumPointerButtons)
385 pointer_button_map_[pointer_mapping[i] - 1] = i + 1; 385 pointer_button_map_[pointer_mapping[i] - 1] = i + 1;
386 } 386 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 return; 422 return;
423 } 423 }
424 424
425 XDevice* device = XOpenDevice(display_, device_id); 425 XDevice* device = XOpenDevice(display_, device_id);
426 if (!device) { 426 if (!device) {
427 LOG(ERROR) << "Cannot open XTest device."; 427 LOG(ERROR) << "Cannot open XTest device.";
428 return; 428 return;
429 } 429 }
430 430
431 int num_device_buttons = XGetDeviceButtonMapping(display_, device, NULL, 0); 431 int num_device_buttons = XGetDeviceButtonMapping(display_, device, NULL, 0);
432 scoped_array<unsigned char> button_mapping(new unsigned char[num_buttons]); 432 scoped_ptr<unsigned char[]> button_mapping(new unsigned char[num_buttons]);
433 for (int i = 0; i < num_device_buttons; i++) { 433 for (int i = 0; i < num_device_buttons; i++) {
434 button_mapping[i] = i + 1; 434 button_mapping[i] = i + 1;
435 } 435 }
436 error = XSetDeviceButtonMapping(display_, device, button_mapping.get(), 436 error = XSetDeviceButtonMapping(display_, device, button_mapping.get(),
437 num_device_buttons); 437 num_device_buttons);
438 if (error != Success) 438 if (error != Success)
439 LOG(ERROR) << "Failed to set XTest device button mapping: " << error; 439 LOG(ERROR) << "Failed to set XTest device button mapping: " << error;
440 440
441 XCloseDevice(display_, device); 441 XCloseDevice(display_, device);
442 } 442 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 498 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
499 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { 499 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
500 scoped_ptr<InputInjectorLinux> injector( 500 scoped_ptr<InputInjectorLinux> injector(
501 new InputInjectorLinux(main_task_runner)); 501 new InputInjectorLinux(main_task_runner));
502 if (!injector->Init()) 502 if (!injector->Init())
503 return scoped_ptr<InputInjector>(NULL); 503 return scoped_ptr<InputInjector>(NULL);
504 return injector.PassAs<InputInjector>(); 504 return injector.PassAs<InputInjector>();
505 } 505 }
506 506
507 } // namespace remoting 507 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/disconnect_window_win.cc ('k') | remoting/host/local_input_monitor_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698