chromium/ui/events/devices/x11/device_data_manager_x11.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "ui/events/devices/x11/device_data_manager_x11.h"

#include <stddef.h>

#include <algorithm>
#include <utility>

#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
#include "base/system/sys_info.h"
#include "base/version.h"
#include "build/build_config.h"
#include "ui/display/display.h"
#include "ui/events/devices/keyboard_device.h"
#include "ui/events/devices/x11/device_list_cache_x11.h"
#include "ui/events/devices/x11/touch_factory_x11.h"
#include "ui/events/devices/x11/xinput_util.h"
#include "ui/events/event_constants.h"
#include "ui/events/event_switches.h"
#include "ui/events/keycodes/keyboard_code_conversion_x.h"
#include "ui/gfx/geometry/point3_f.h"
#include "ui/gfx/x/atom_cache.h"
#include "ui/gfx/x/future.h"

// XIScrollClass was introduced in XI 2.1 so we need to define it here
// for backward-compatibility with older versions of XInput.
#if !defined(XIScrollClass)
#define XIScrollClass
#endif

// Copied from xserver-properties.h
#define AXIS_LABEL_PROP_REL_HWHEEL
#define AXIS_LABEL_PROP_REL_WHEEL

// CMT specific timings
#define AXIS_LABEL_PROP_ABS_DBL_START_TIME
#define AXIS_LABEL_PROP_ABS_DBL_END_TIME

// Ordinal values
#define AXIS_LABEL_PROP_ABS_DBL_ORDINAL_X
#define AXIS_LABEL_PROP_ABS_DBL_ORDINAL_Y

// Fling properties
#define AXIS_LABEL_PROP_ABS_DBL_FLING_VX
#define AXIS_LABEL_PROP_ABS_DBL_FLING_VY
#define AXIS_LABEL_PROP_ABS_FLING_STATE

#define AXIS_LABEL_PROP_ABS_FINGER_COUNT

// Cros metrics gesture from touchpad
#define AXIS_LABEL_PROP_ABS_METRICS_TYPE
#define AXIS_LABEL_PROP_ABS_DBL_METRICS_DATA1
#define AXIS_LABEL_PROP_ABS_DBL_METRICS_DATA2

// Touchscreen multi-touch
#define AXIS_LABEL_ABS_MT_TOUCH_MAJOR
#define AXIS_LABEL_ABS_MT_TOUCH_MINOR
#define AXIS_LABEL_ABS_MT_ORIENTATION
#define AXIS_LABEL_ABS_MT_PRESSURE
#define AXIS_LABEL_ABS_MT_POSITION_X
#define AXIS_LABEL_ABS_MT_POSITION_Y
#define AXIS_LABEL_ABS_MT_TRACKING_ID
#define AXIS_LABEL_TOUCH_TIMESTAMP

// Stylus with absolute x y pressure and tilt info
#define AXIS_LABEL_PROP_ABS_X
#define AXIS_LABEL_PROP_ABS_Y
#define AXIS_LABEL_PROP_ABS_PRESSURE
#define AXIS_LABEL_PROP_ABS_TILT_X
#define AXIS_LABEL_PROP_ABS_TILT_Y

// When you add new data types, please make sure the order here is aligned
// with the order in the DataType enum in the header file because we assume
// they are in sync when updating the device list (see UpdateDeviceList).
constexpr const char* kCachedAtoms[] =;

// Make sure the sizes of enum and |kCachedAtoms| are aligned.
static_assert;

// Constants for checking if a data type lies in the range of CMT/Touch data
// types.
const int kCMTDataTypeStart =;
const int kCMTDataTypeEnd =;
const int kTouchDataTypeStart =;
const int kTouchDataTypeEnd =;
const int kStylusDataTypeStart =;
const int kStylusDataTypeEnd =;

namespace ui {

namespace {

template <typename Iterator>
Iterator FindDeviceWithId(Iterator begin,
                          Iterator end,
                          x11::Input::DeviceId id) {}

// Disables high precision scrolling in X11
const char kDisableHighPrecisionScrolling[] =;

bool IsHighPrecisionScrollingDisabled() {}

// Identical to double_to_fp3232 from xserver's inpututils.c
x11::Input::Fp3232 DoubleToFp3232(double in) {}

// Identical to FP3232_TO_DOUBLE from libxi's XExtInt.c
double Fp3232ToDouble(const x11::Input::Fp3232& x) {}

bool GetSourceId(const x11::Event& x11_event, uint16_t* sourceid) {}

}  // namespace

bool DeviceDataManagerX11::IsCMTDataType(const int type) {}

bool DeviceDataManagerX11::IsTouchDataType(const int type) {}

bool DeviceDataManagerX11::IsStylusDataType(const int type) {}

// static
void DeviceDataManagerX11::CreateInstance() {}

// static
DeviceDataManagerX11* DeviceDataManagerX11::GetInstance() {}

DeviceDataManagerX11::DeviceDataManagerX11()
    :{}

DeviceDataManagerX11::~DeviceDataManagerX11() = default;

bool DeviceDataManagerX11::IsXInput2Available() const {}

void DeviceDataManagerX11::UpdateDeviceList(x11::Connection* connection) {}

bool DeviceDataManagerX11::GetSlotNumber(const x11::Input::DeviceEvent& xiev,
                                         int* slot) {}

void DeviceDataManagerX11::GetEventRawData(const x11::Event& x11_event,
                                           EventData* data) {}

bool DeviceDataManagerX11::GetEventData(const x11::Event& x11_event,
                                        const DataType type,
                                        double* value) {}

bool DeviceDataManagerX11::IsXIDeviceEvent(const x11::Event& x11_event) const {}

bool DeviceDataManagerX11::IsStylusXInputEvent(
    const x11::Event& x11_event) const {}

bool DeviceDataManagerX11::IsTouchpadXInputEvent(
    const x11::Event& x11_event) const {}

bool DeviceDataManagerX11::IsCMTDeviceEvent(const x11::Event& x11_event) const {}

int DeviceDataManagerX11::GetScrollClassEventDetail(
    const x11::Event& x11_event) const {}

int DeviceDataManagerX11::GetScrollClassDeviceDetail(
    const x11::Event& x11_event) const {}

bool DeviceDataManagerX11::IsCMTGestureEvent(const x11::Event& xev) const {}

bool DeviceDataManagerX11::HasEventData(const x11::Event& xev,
                                        const DataType type) const {}

bool DeviceDataManagerX11::IsScrollEvent(const x11::Event& x11_event) const {}

bool DeviceDataManagerX11::IsFlingEvent(const x11::Event& x11_event) const {}

bool DeviceDataManagerX11::IsCMTMetricsEvent(
    const x11::Event& x11_event) const {}

bool DeviceDataManagerX11::HasGestureTimes(const x11::Event& x11_event) const {}

void DeviceDataManagerX11::GetScrollOffsets(const x11::Event& xev,
                                            float* x_offset,
                                            float* y_offset,
                                            float* x_offset_ordinal,
                                            float* y_offset_ordinal,
                                            int* finger_count) {}

void DeviceDataManagerX11::GetScrollClassOffsets(const x11::Event& x11_event,
                                                 double* x_offset,
                                                 double* y_offset) {}

void DeviceDataManagerX11::InvalidateScrollClasses(
    x11::Input::DeviceId device_id) {}

void DeviceDataManagerX11::GetFlingData(const x11::Event& xev,
                                        float* vx,
                                        float* vy,
                                        float* vx_ordinal,
                                        float* vy_ordinal,
                                        bool* is_cancel) {}

void DeviceDataManagerX11::GetMetricsData(const x11::Event& xev,
                                          GestureMetricsType* type,
                                          float* data1,
                                          float* data2) {}

int DeviceDataManagerX11::GetMappedButton(int button) {}

void DeviceDataManagerX11::UpdateButtonMap() {}

void DeviceDataManagerX11::GetGestureTimes(const x11::Event& xev,
                                           double* start_time,
                                           double* end_time) {}

bool DeviceDataManagerX11::NormalizeData(x11::Input::DeviceId deviceid,
                                         const DataType type,
                                         double* value) {}

bool DeviceDataManagerX11::GetDataRange(x11::Input::DeviceId deviceid,
                                        const DataType type,
                                        double* min,
                                        double* max) {}

void DeviceDataManagerX11::SetDeviceListForTest(
    const std::vector<int>& touchscreen,
    const std::vector<int>& cmt_devices,
    const std::vector<int>& other_devices) {}

void DeviceDataManagerX11::SetValuatorDataForTest(
    x11::Input::DeviceEvent* devev,
    DataType type,
    double value) {}

void DeviceDataManagerX11::InitializeValuatorsForTest(int deviceid,
                                                      int start_valuator,
                                                      int end_valuator,
                                                      double min_value,
                                                      double max_value) {}

DeviceDataManagerX11::DataType DeviceDataManagerX11::UpdateValuatorClassDevice(
    const x11::Input::DeviceClass::Valuator& valuator_class_info,
    x11::Atom* atoms,
    uint16_t deviceid) {}

void DeviceDataManagerX11::UpdateScrollClassDevice(
    const x11::Input::DeviceClass::Scroll& scroll_class_info,
    uint16_t deviceid) {}

double DeviceDataManagerX11::ExtractAndUpdateScrollOffset(
    ScrollInfo::AxisInfo* axis,
    double valuator) const {}

void DeviceDataManagerX11::SetDisabledKeyboardAllowedKeys(
    std::unique_ptr<std::set<KeyboardCode>> excepted_keys) {}

void DeviceDataManagerX11::DisableDevice(x11::Input::DeviceId deviceid) {}

void DeviceDataManagerX11::EnableDevice(x11::Input::DeviceId deviceid) {}

bool DeviceDataManagerX11::IsDeviceEnabled(
    x11::Input::DeviceId device_id) const {}

bool DeviceDataManagerX11::IsEventBlocked(const x11::Event& x11_event) {}

void DeviceDataManagerX11::OnKeyboardDevicesUpdated(
    const std::vector<KeyboardDevice>& devices) {}

}  // namespace ui