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

Side by Side Diff: ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.cc

Issue 1867223004: Convert //ash from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
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 "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.h" 5 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9
10 #include <memory>
9 #include <set> 11 #include <set>
10 #include <utility> 12 #include <utility>
11 13
12 #include "ash/display/window_tree_host_manager.h" 14 #include "ash/display/window_tree_host_manager.h"
13 #include "ash/screen_util.h" 15 #include "ash/screen_util.h"
14 #include "ash/shell.h" 16 #include "ash/shell.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "ui/aura/client/cursor_client.h" 18 #include "ui/aura/client/cursor_client.h"
18 #include "ui/aura/client/screen_position_client.h" 19 #include "ui/aura/client/screen_position_client.h"
19 #include "ui/aura/env.h" 20 #include "ui/aura/env.h"
20 #include "ui/aura/window.h" 21 #include "ui/aura/window.h"
21 #include "ui/aura/window_event_dispatcher.h" 22 #include "ui/aura/window_event_dispatcher.h"
22 #include "ui/aura/window_tree_host.h" 23 #include "ui/aura/window_tree_host.h"
23 #include "ui/events/devices/input_device.h" 24 #include "ui/events/devices/input_device.h"
24 #include "ui/events/devices/keyboard_device.h" 25 #include "ui/events/devices/keyboard_device.h"
25 #include "ui/events/devices/x11/device_data_manager_x11.h" 26 #include "ui/events/devices/x11/device_data_manager_x11.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 device_data_manager->keyboard_devices()) { 102 device_data_manager->keyboard_devices()) {
102 if (device.type == ui::InputDeviceType::INPUT_DEVICE_INTERNAL) { 103 if (device.type == ui::InputDeviceType::INPUT_DEVICE_INTERNAL) {
103 keyboard_device_id_ = device.id; 104 keyboard_device_id_ = device.id;
104 device_data_manager->DisableDevice(keyboard_device_id_); 105 device_data_manager->DisableDevice(keyboard_device_id_);
105 break; 106 break;
106 } 107 }
107 } 108 }
108 } 109 }
109 // Allow the accessible keys present on the side of some devices to continue 110 // Allow the accessible keys present on the side of some devices to continue
110 // working. 111 // working.
111 scoped_ptr<std::set<ui::KeyboardCode> > excepted_keys( 112 std::unique_ptr<std::set<ui::KeyboardCode>> excepted_keys(
112 new std::set<ui::KeyboardCode>); 113 new std::set<ui::KeyboardCode>);
113 excepted_keys->insert(ui::VKEY_VOLUME_DOWN); 114 excepted_keys->insert(ui::VKEY_VOLUME_DOWN);
114 excepted_keys->insert(ui::VKEY_VOLUME_UP); 115 excepted_keys->insert(ui::VKEY_VOLUME_UP);
115 excepted_keys->insert(ui::VKEY_POWER); 116 excepted_keys->insert(ui::VKEY_POWER);
116 device_data_manager->SetDisabledKeyboardAllowedKeys(std::move(excepted_keys)); 117 device_data_manager->SetDisabledKeyboardAllowedKeys(std::move(excepted_keys));
117 ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this); 118 ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
118 } 119 }
119 120
120 ScopedDisableInternalMouseAndKeyboardX11:: 121 ScopedDisableInternalMouseAndKeyboardX11::
121 ~ScopedDisableInternalMouseAndKeyboardX11() { 122 ~ScopedDisableInternalMouseAndKeyboardX11() {
122 ui::DeviceDataManagerX11* device_data_manager = 123 ui::DeviceDataManagerX11* device_data_manager =
123 static_cast<ui::DeviceDataManagerX11*>( 124 static_cast<ui::DeviceDataManagerX11*>(
124 ui::DeviceDataManager::GetInstance()); 125 ui::DeviceDataManager::GetInstance());
125 if (touchpad_device_id_ != kDeviceIdNone) { 126 if (touchpad_device_id_ != kDeviceIdNone) {
126 device_data_manager->EnableDevice(touchpad_device_id_); 127 device_data_manager->EnableDevice(touchpad_device_id_);
127 Shell::GetInstance()->cursor_manager()->ShowCursor(); 128 Shell::GetInstance()->cursor_manager()->ShowCursor();
128 } 129 }
129 if (keyboard_device_id_ != kDeviceIdNone) 130 if (keyboard_device_id_ != kDeviceIdNone)
130 device_data_manager->EnableDevice(keyboard_device_id_); 131 device_data_manager->EnableDevice(keyboard_device_id_);
131 if (core_keyboard_device_id_ != kDeviceIdNone) 132 if (core_keyboard_device_id_ != kDeviceIdNone)
132 device_data_manager->EnableDevice(core_keyboard_device_id_); 133 device_data_manager->EnableDevice(core_keyboard_device_id_);
133 device_data_manager->SetDisabledKeyboardAllowedKeys( 134 device_data_manager->SetDisabledKeyboardAllowedKeys(
134 scoped_ptr<std::set<ui::KeyboardCode> >()); 135 std::unique_ptr<std::set<ui::KeyboardCode>>());
135 ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this); 136 ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this);
136 } 137 }
137 138
138 void ScopedDisableInternalMouseAndKeyboardX11::WillProcessEvent( 139 void ScopedDisableInternalMouseAndKeyboardX11::WillProcessEvent(
139 const ui::PlatformEvent& event) { 140 const ui::PlatformEvent& event) {
140 } 141 }
141 142
142 void ScopedDisableInternalMouseAndKeyboardX11::DidProcessEvent( 143 void ScopedDisableInternalMouseAndKeyboardX11::DidProcessEvent(
143 const ui::PlatformEvent& event) { 144 const ui::PlatformEvent& event) {
144 if (event->type != GenericEvent) 145 if (event->type != GenericEvent)
(...skipping 14 matching lines...) Expand all
159 // blocked. Move the mouse cursor back to its last known location resulting 160 // blocked. Move the mouse cursor back to its last known location resulting
160 // from an external mouse to prevent the internal touchpad from moving it. 161 // from an external mouse to prevent the internal touchpad from moving it.
161 SetMouseLocationInScreen(last_mouse_location_); 162 SetMouseLocationInScreen(last_mouse_location_);
162 } else { 163 } else {
163 // Track the last location seen from an external mouse event. 164 // Track the last location seen from an external mouse event.
164 last_mouse_location_ = GetMouseLocationInScreen(); 165 last_mouse_location_ = GetMouseLocationInScreen();
165 } 166 }
166 } 167 }
167 168
168 } // namespace ash 169 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698