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

Unified Diff: ash/wm/maximize_mode/internal_input_device_list_x11.cc

Issue 269633005: Only block internal touchpad and allow external mice to continue working in maximize mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/maximize_mode/internal_input_device_list_x11.cc
diff --git a/ash/wm/maximize_mode/internal_input_device_list_x11.cc b/ash/wm/maximize_mode/internal_input_device_list_x11.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9a490ec6197f9f3c30f4e87003e7eb177e7de531
--- /dev/null
+++ b/ash/wm/maximize_mode/internal_input_device_list_x11.cc
@@ -0,0 +1,55 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/wm/maximize_mode/internal_input_device_list_x11.h"
+
+#include <X11/extensions/XInput2.h>
+#include <X11/Xlib.h>
+
+#include "base/strings/string_util.h"
+#include "ui/events/event.h"
+#include "ui/events/x/device_data_manager.h"
+#include "ui/events/x/device_list_cache_x.h"
+#include "ui/gfx/x/x11_types.h"
+
+namespace ash {
+
+namespace {
+
+// The name of the xinput device corresponding to the internal touchpad.
+const char kInternalTouchpadName[] = "Elan Touchpad";
+
+// The name of the xinput device corresponding to the internal keyboard.
+const char kInternalKeyboardName[] = "AT Translated Set 2 keyboard";
+
+} // namespace
+
+InternalInputDeviceListX11::InternalInputDeviceListX11() {
+ if (ui::DeviceDataManager::GetInstance()->IsXInput2Available()) {
+ XIDeviceList xi_dev_list = ui::DeviceListCacheX::GetInstance()->
+ GetXI2DeviceList(gfx::GetXDisplay());
+ for (int i = 0; i < xi_dev_list.count; ++i) {
+ std::string device_name(xi_dev_list[i].name);
+ base::TrimWhitespaceASCII(device_name, base::TRIM_TRAILING, &device_name);
+ if (device_name == kInternalTouchpadName ||
+ device_name == kInternalKeyboardName)
+ internal_device_ids_.insert(xi_dev_list[i].deviceid);
+ }
+ }
+}
+
+InternalInputDeviceListX11::~InternalInputDeviceListX11() {
+}
+
+bool InternalInputDeviceListX11::IsEventFromInternalDevice(
+ const ui::Event* event) {
+ if (!event->HasNativeEvent())
+ return false;
+ XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(
+ event->native_event()->xcookie.data);
+ return internal_device_ids_.find(xiev->sourceid) !=
+ internal_device_ids_.end();
+}
+
+} // namespace ash
« no previous file with comments | « ash/wm/maximize_mode/internal_input_device_list_x11.h ('k') | ash/wm/maximize_mode/maximize_mode_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698