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

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

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/extensions/XInput2.h> 7 #include <X11/extensions/XInput2.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 } // namespace 67 } // namespace
68 68
69 ScopedDisableInternalMouseAndKeyboardX11:: 69 ScopedDisableInternalMouseAndKeyboardX11::
70 ScopedDisableInternalMouseAndKeyboardX11() 70 ScopedDisableInternalMouseAndKeyboardX11()
71 : touchpad_device_id_(kDeviceIdNone), 71 : touchpad_device_id_(kDeviceIdNone),
72 keyboard_device_id_(kDeviceIdNone), 72 keyboard_device_id_(kDeviceIdNone),
73 core_keyboard_device_id_(kDeviceIdNone), 73 core_keyboard_device_id_(kDeviceIdNone),
74 last_mouse_location_(GetMouseLocationInScreen()) { 74 last_mouse_location_(GetMouseLocationInScreen()) {
75
76 ui::DeviceDataManagerX11* device_data_manager = 75 ui::DeviceDataManagerX11* device_data_manager =
77 ui::DeviceDataManagerX11::GetInstance(); 76 ui::DeviceDataManagerX11::GetInstance();
78 if (device_data_manager->IsXInput2Available()) { 77 if (device_data_manager->IsXInput2Available()) {
79 const XIDeviceList& xi_dev_list = 78 const XIDeviceList& xi_dev_list =
80 ui::DeviceListCacheX11::GetInstance()->GetXI2DeviceList( 79 ui::DeviceListCacheX11::GetInstance()->GetXI2DeviceList(
81 gfx::GetXDisplay()); 80 gfx::GetXDisplay());
82 for (int i = 0; i < xi_dev_list.count; ++i) { 81 for (int i = 0; i < xi_dev_list.count; ++i) {
83 std::string device_name(xi_dev_list[i].name); 82 std::string device_name(xi_dev_list[i].name);
84 base::TrimWhitespaceASCII(device_name, base::TRIM_TRAILING, &device_name); 83 base::TrimWhitespaceASCII(device_name, base::TRIM_TRAILING, &device_name);
85 if (device_name == kInternalTouchpadName) { 84 if (device_name == kInternalTouchpadName) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 if (keyboard_device_id_ != kDeviceIdNone) 128 if (keyboard_device_id_ != kDeviceIdNone)
130 device_data_manager->EnableDevice(keyboard_device_id_); 129 device_data_manager->EnableDevice(keyboard_device_id_);
131 if (core_keyboard_device_id_ != kDeviceIdNone) 130 if (core_keyboard_device_id_ != kDeviceIdNone)
132 device_data_manager->EnableDevice(core_keyboard_device_id_); 131 device_data_manager->EnableDevice(core_keyboard_device_id_);
133 device_data_manager->SetDisabledKeyboardAllowedKeys( 132 device_data_manager->SetDisabledKeyboardAllowedKeys(
134 std::unique_ptr<std::set<ui::KeyboardCode>>()); 133 std::unique_ptr<std::set<ui::KeyboardCode>>());
135 ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this); 134 ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this);
136 } 135 }
137 136
138 void ScopedDisableInternalMouseAndKeyboardX11::WillProcessEvent( 137 void ScopedDisableInternalMouseAndKeyboardX11::WillProcessEvent(
139 const ui::PlatformEvent& event) { 138 const ui::PlatformEvent& event) {}
140 }
141 139
142 void ScopedDisableInternalMouseAndKeyboardX11::DidProcessEvent( 140 void ScopedDisableInternalMouseAndKeyboardX11::DidProcessEvent(
143 const ui::PlatformEvent& event) { 141 const ui::PlatformEvent& event) {
144 if (event->type != GenericEvent) 142 if (event->type != GenericEvent)
145 return; 143 return;
146 XIDeviceEvent* xievent = 144 XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(event->xcookie.data);
147 static_cast<XIDeviceEvent*>(event->xcookie.data);
148 ui::DeviceDataManagerX11* device_data_manager = 145 ui::DeviceDataManagerX11* device_data_manager =
149 static_cast<ui::DeviceDataManagerX11*>( 146 static_cast<ui::DeviceDataManagerX11*>(
150 ui::DeviceDataManager::GetInstance()); 147 ui::DeviceDataManager::GetInstance());
151 if (xievent->evtype != XI_Motion || 148 if (xievent->evtype != XI_Motion ||
152 device_data_manager->IsFlingEvent(*event) || 149 device_data_manager->IsFlingEvent(*event) ||
153 device_data_manager->IsScrollEvent(*event) || 150 device_data_manager->IsScrollEvent(*event) ||
154 device_data_manager->IsCMTMetricsEvent(*event)) { 151 device_data_manager->IsCMTMetricsEvent(*event)) {
155 return; 152 return;
156 } 153 }
157 if (xievent->sourceid == touchpad_device_id_) { 154 if (xievent->sourceid == touchpad_device_id_) {
158 // The cursor will have already moved even though the move event will be 155 // The cursor will have already moved even though the move event will be
159 // blocked. Move the mouse cursor back to its last known location resulting 156 // 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. 157 // from an external mouse to prevent the internal touchpad from moving it.
161 SetMouseLocationInScreen(last_mouse_location_); 158 SetMouseLocationInScreen(last_mouse_location_);
162 } else { 159 } else {
163 // Track the last location seen from an external mouse event. 160 // Track the last location seen from an external mouse event.
164 last_mouse_location_ = GetMouseLocationInScreen(); 161 last_mouse_location_ = GetMouseLocationInScreen();
165 } 162 }
166 } 163 }
167 164
168 } // namespace ash 165 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698