From 52cfea1ccce19c424168a56843a98253bd505645 Mon Sep 17 00:00:00 2001 From: mustaq Date: Wed, 21 Jan 2015 12:34:04 -0800 Subject: Unified touch_device_aurax11 and touch_device_ozone. This change was suggested in http://crrev.com/806693008 BUG=443667 Review URL: https://codereview.chromium.org/815983003 Cr-Commit-Position: refs/heads/master@{#312430} --- ui/base/BUILD.gn | 6 +-- ui/base/touch/touch_device_aurax11.cc | 69 ----------------------------------- ui/base/touch/touch_device_linux.cc | 69 +++++++++++++++++++++++++++++++++++ ui/base/touch/touch_device_ozone.cc | 64 -------------------------------- ui/base/ui_base.gyp | 16 +++++--- 5 files changed, 82 insertions(+), 142 deletions(-) delete mode 100644 ui/base/touch/touch_device_aurax11.cc create mode 100644 ui/base/touch/touch_device_linux.cc delete mode 100644 ui/base/touch/touch_device_ozone.cc (limited to 'ui') diff --git a/ui/base/BUILD.gn b/ui/base/BUILD.gn index a2633c9..fb1402b 100644 --- a/ui/base/BUILD.gn +++ b/ui/base/BUILD.gn @@ -286,10 +286,8 @@ component("base") { sources += [ "touch/touch_device_win.cc" ] } else if (is_android) { sources += [ "touch/touch_device_android.cc" ] - } else if (use_ozone) { - sources += [ "touch/touch_device_ozone.cc" ] - } else if (use_aura && use_x11) { - sources += [ "touch/touch_device_aurax11.cc" ] + } else if (is_linux) { + sources += [ "touch/touch_device_linux.cc" ] } else { # Empty implementation for all other cases. sources += [ "touch/touch_device.cc" ] diff --git a/ui/base/touch/touch_device_aurax11.cc b/ui/base/touch/touch_device_aurax11.cc deleted file mode 100644 index 723fb0a..0000000 --- a/ui/base/touch/touch_device_aurax11.cc +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2013 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 "ui/base/touch/touch_device.h" - -#include "base/logging.h" -#include "ui/events/devices/device_data_manager.h" - -namespace ui { - -bool IsTouchDevicePresent() { - return ui::DeviceDataManager::GetInstance()->touchscreen_devices().size() > 0; -} - -int MaxTouchPoints() { - int max_touch = -1; - const std::vector& touchscreen_devices = - ui::DeviceDataManager::GetInstance()->touchscreen_devices(); - for (const ui::TouchscreenDevice& device : touchscreen_devices) { - if (device.touch_points > max_touch) - max_touch = device.touch_points; - } - return max_touch; -} - -// TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/440503 -int GetAvailablePointerTypes() { - // Assume a mouse is there - int available_pointer_types = POINTER_TYPE_FINE; - if (IsTouchDevicePresent()) - available_pointer_types |= POINTER_TYPE_COARSE; - - DCHECK(available_pointer_types); - return available_pointer_types; -} - -PointerType GetPrimaryPointerType() { - int available_pointer_types = GetAvailablePointerTypes(); - if (available_pointer_types & POINTER_TYPE_FINE) - return POINTER_TYPE_FINE; - if (available_pointer_types & POINTER_TYPE_COARSE) - return POINTER_TYPE_COARSE; - DCHECK_EQ(available_pointer_types, POINTER_TYPE_NONE); - return POINTER_TYPE_NONE; -} - -// TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/440503 -int GetAvailableHoverTypes() { - // Assume a mouse is there - int available_hover_types = HOVER_TYPE_HOVER; - if (IsTouchDevicePresent()) - available_hover_types |= HOVER_TYPE_ON_DEMAND; - - DCHECK(available_hover_types); - return available_hover_types; -} - -HoverType GetPrimaryHoverType() { - int available_hover_types = GetAvailableHoverTypes(); - if (available_hover_types & HOVER_TYPE_HOVER) - return HOVER_TYPE_HOVER; - if (available_hover_types & HOVER_TYPE_ON_DEMAND) - return HOVER_TYPE_ON_DEMAND; - DCHECK_EQ(available_hover_types, HOVER_TYPE_NONE); - return HOVER_TYPE_NONE; -} - -} // namespace ui diff --git a/ui/base/touch/touch_device_linux.cc b/ui/base/touch/touch_device_linux.cc new file mode 100644 index 0000000..e0e7948 --- /dev/null +++ b/ui/base/touch/touch_device_linux.cc @@ -0,0 +1,69 @@ +// Copyright (c) 2013 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 "ui/base/touch/touch_device.h" + +#include "base/logging.h" +#include "ui/events/devices/device_data_manager.h" + +namespace ui { + +bool IsTouchDevicePresent() { + return ui::DeviceDataManager::GetInstance()->touchscreen_devices().size() > 0; +} + +int MaxTouchPoints() { + int max_touch = 0; + const std::vector& touchscreen_devices = + ui::DeviceDataManager::GetInstance()->touchscreen_devices(); + for (const ui::TouchscreenDevice& device : touchscreen_devices) { + if (device.touch_points > max_touch) + max_touch = device.touch_points; + } + return max_touch; +} + +// TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/440503 +int GetAvailablePointerTypes() { + // Assume a mouse is there + int available_pointer_types = POINTER_TYPE_FINE; + if (IsTouchDevicePresent()) + available_pointer_types |= POINTER_TYPE_COARSE; + + DCHECK(available_pointer_types); + return available_pointer_types; +} + +PointerType GetPrimaryPointerType() { + int available_pointer_types = GetAvailablePointerTypes(); + if (available_pointer_types & POINTER_TYPE_FINE) + return POINTER_TYPE_FINE; + if (available_pointer_types & POINTER_TYPE_COARSE) + return POINTER_TYPE_COARSE; + DCHECK_EQ(available_pointer_types, POINTER_TYPE_NONE); + return POINTER_TYPE_NONE; +} + +// TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/440503 +int GetAvailableHoverTypes() { + // Assume a mouse is there + int available_hover_types = HOVER_TYPE_HOVER; + if (IsTouchDevicePresent()) + available_hover_types |= HOVER_TYPE_ON_DEMAND; + + DCHECK(available_hover_types); + return available_hover_types; +} + +HoverType GetPrimaryHoverType() { + int available_hover_types = GetAvailableHoverTypes(); + if (available_hover_types & HOVER_TYPE_HOVER) + return HOVER_TYPE_HOVER; + if (available_hover_types & HOVER_TYPE_ON_DEMAND) + return HOVER_TYPE_ON_DEMAND; + DCHECK_EQ(available_hover_types, HOVER_TYPE_NONE); + return HOVER_TYPE_NONE; +} + +} // namespace ui diff --git a/ui/base/touch/touch_device_ozone.cc b/ui/base/touch/touch_device_ozone.cc deleted file mode 100644 index 6698891..0000000 --- a/ui/base/touch/touch_device_ozone.cc +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2013 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 "ui/base/touch/touch_device.h" - -#include "base/logging.h" -#include "ui/events/devices/device_data_manager.h" - -namespace ui { - -bool IsTouchDevicePresent() { - // TODO(sadrul@chromium.org): Support evdev hotplugging. - return ui::DeviceDataManager::GetInstance()->touchscreen_devices().size() > 0; -} - -int MaxTouchPoints() { - // Hard-code this to 11 until we have a real implementation. - return 11; -} - -// TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/440503 -int GetAvailablePointerTypes() { - // Assume a mouse is there - int available_pointer_types = POINTER_TYPE_FINE; - if (IsTouchDevicePresent()) - available_pointer_types |= POINTER_TYPE_COARSE; - - DCHECK(available_pointer_types); - return available_pointer_types; -} - -PointerType GetPrimaryPointerType() { - int available_pointer_types = GetAvailablePointerTypes(); - if (available_pointer_types & POINTER_TYPE_FINE) - return POINTER_TYPE_FINE; - if (available_pointer_types & POINTER_TYPE_COARSE) - return POINTER_TYPE_COARSE; - DCHECK_EQ(available_pointer_types, POINTER_TYPE_NONE); - return POINTER_TYPE_NONE; -} - -// TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/440503 -int GetAvailableHoverTypes() { - // Assume a mouse is there - int available_hover_types = HOVER_TYPE_HOVER; - if (IsTouchDevicePresent()) - available_hover_types |= HOVER_TYPE_ON_DEMAND; - - DCHECK(available_hover_types); - return available_hover_types; -} - -HoverType GetPrimaryHoverType() { - int available_hover_types = GetAvailableHoverTypes(); - if (available_hover_types & HOVER_TYPE_HOVER) - return HOVER_TYPE_HOVER; - if (available_hover_types & HOVER_TYPE_ON_DEMAND) - return HOVER_TYPE_ON_DEMAND; - DCHECK_EQ(available_hover_types, HOVER_TYPE_NONE); - return HOVER_TYPE_NONE; -} - -} // namespace ui diff --git a/ui/base/ui_base.gyp b/ui/base/ui_base.gyp index f8f4eef..7891a1b 100644 --- a/ui/base/ui_base.gyp +++ b/ui/base/ui_base.gyp @@ -362,8 +362,7 @@ 'touch/touch_device.cc', 'touch/touch_device.h', 'touch/touch_device_android.cc', - 'touch/touch_device_aurax11.cc', - 'touch/touch_device_ozone.cc', + 'touch/touch_device_linux.cc', 'touch/touch_device_win.cc', 'touch/touch_editing_controller.cc', 'touch/touch_editing_controller.h', @@ -540,13 +539,20 @@ ['chromeos==1 or (use_aura==1 and OS=="linux" and use_x11==0)', { 'sources!': [ 'dragdrop/os_exchange_data_provider_aurax11.cc', - 'touch/touch_device.cc', ], }, { 'sources!': [ 'dragdrop/os_exchange_data_provider_aura.cc', 'dragdrop/os_exchange_data_provider_aura.h', - 'touch/touch_device_aurax11.cc', + ], + }], + ['OS=="linux"', { + 'sources!': [ + 'touch/touch_device.cc', + ], + }, { + 'sources!': [ + 'touch/touch_device_linux.cc', ], }], ['OS=="win"', { @@ -583,7 +589,7 @@ '-loleacc.lib', ], }, - },{ # OS!="win" + }, { # OS!="win" 'conditions': [ ['use_aura==0', { 'sources!': [ -- cgit v1.1