| OLD | NEW |
| 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/internal_input_device_list_x11.h" | 5 #include "ash/wm/maximize_mode/internal_input_device_list_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 "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "ui/events/event.h" | 11 #include "ui/events/event.h" |
| 12 #include "ui/events/x/device_data_manager.h" | 12 #include "ui/events/x/device_data_manager_x11.h" |
| 13 #include "ui/events/x/device_list_cache_x.h" | 13 #include "ui/events/x/device_list_cache_x.h" |
| 14 #include "ui/gfx/x/x11_types.h" | 14 #include "ui/gfx/x/x11_types.h" |
| 15 | 15 |
| 16 namespace ash { | 16 namespace ash { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 // The name of the xinput device corresponding to the internal touchpad. | 20 // The name of the xinput device corresponding to the internal touchpad. |
| 21 const char kInternalTouchpadName[] = "Elan Touchpad"; | 21 const char kInternalTouchpadName[] = "Elan Touchpad"; |
| 22 | 22 |
| 23 // The name of the xinput device corresponding to the internal keyboard. | 23 // The name of the xinput device corresponding to the internal keyboard. |
| 24 const char kInternalKeyboardName[] = "AT Translated Set 2 keyboard"; | 24 const char kInternalKeyboardName[] = "AT Translated Set 2 keyboard"; |
| 25 | 25 |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 InternalInputDeviceListX11::InternalInputDeviceListX11() { | 28 InternalInputDeviceListX11::InternalInputDeviceListX11() { |
| 29 if (ui::DeviceDataManager::GetInstance()->IsXInput2Available()) { | 29 if (ui::DeviceDataManagerX11::GetInstance()->IsXInput2Available()) { |
| 30 XIDeviceList xi_dev_list = ui::DeviceListCacheX::GetInstance()-> | 30 XIDeviceList xi_dev_list = ui::DeviceListCacheX::GetInstance()-> |
| 31 GetXI2DeviceList(gfx::GetXDisplay()); | 31 GetXI2DeviceList(gfx::GetXDisplay()); |
| 32 for (int i = 0; i < xi_dev_list.count; ++i) { | 32 for (int i = 0; i < xi_dev_list.count; ++i) { |
| 33 std::string device_name(xi_dev_list[i].name); | 33 std::string device_name(xi_dev_list[i].name); |
| 34 base::TrimWhitespaceASCII(device_name, base::TRIM_TRAILING, &device_name); | 34 base::TrimWhitespaceASCII(device_name, base::TRIM_TRAILING, &device_name); |
| 35 if (device_name == kInternalTouchpadName || | 35 if (device_name == kInternalTouchpadName || |
| 36 device_name == kInternalKeyboardName) | 36 device_name == kInternalKeyboardName) |
| 37 internal_device_ids_.insert(xi_dev_list[i].deviceid); | 37 internal_device_ids_.insert(xi_dev_list[i].deviceid); |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 InternalInputDeviceListX11::~InternalInputDeviceListX11() { | 42 InternalInputDeviceListX11::~InternalInputDeviceListX11() { |
| 43 } | 43 } |
| 44 | 44 |
| 45 bool InternalInputDeviceListX11::IsEventFromInternalDevice( | 45 bool InternalInputDeviceListX11::IsEventFromInternalDevice( |
| 46 const ui::Event* event) { | 46 const ui::Event* event) { |
| 47 if (!event->HasNativeEvent() || | 47 if (!event->HasNativeEvent() || |
| 48 event->native_event()->type != GenericEvent) { | 48 event->native_event()->type != GenericEvent) { |
| 49 return false; | 49 return false; |
| 50 } | 50 } |
| 51 | 51 |
| 52 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>( | 52 XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>( |
| 53 event->native_event()->xcookie.data); | 53 event->native_event()->xcookie.data); |
| 54 return internal_device_ids_.find(xiev->sourceid) != | 54 return internal_device_ids_.find(xiev->sourceid) != |
| 55 internal_device_ids_.end(); | 55 internal_device_ids_.end(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 } // namespace ash | 58 } // namespace ash |
| OLD | NEW |