#ifdef UNSAFE_BUFFERS_BUILD
#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"
#if !defined(XIScrollClass)
#define XIScrollClass …
#endif
#define AXIS_LABEL_PROP_REL_HWHEEL …
#define AXIS_LABEL_PROP_REL_WHEEL …
#define AXIS_LABEL_PROP_ABS_DBL_START_TIME …
#define AXIS_LABEL_PROP_ABS_DBL_END_TIME …
#define AXIS_LABEL_PROP_ABS_DBL_ORDINAL_X …
#define AXIS_LABEL_PROP_ABS_DBL_ORDINAL_Y …
#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 …
#define AXIS_LABEL_PROP_ABS_METRICS_TYPE …
#define AXIS_LABEL_PROP_ABS_DBL_METRICS_DATA1 …
#define AXIS_LABEL_PROP_ABS_DBL_METRICS_DATA2 …
#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 …
#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 …
constexpr const char* kCachedAtoms[] = …;
static_assert …;
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) { … }
const char kDisableHighPrecisionScrolling[] = …;
bool IsHighPrecisionScrollingDisabled() { … }
x11::Input::Fp3232 DoubleToFp3232(double in) { … }
double Fp3232ToDouble(const x11::Input::Fp3232& x) { … }
bool GetSourceId(const x11::Event& x11_event, uint16_t* sourceid) { … }
}
bool DeviceDataManagerX11::IsCMTDataType(const int type) { … }
bool DeviceDataManagerX11::IsTouchDataType(const int type) { … }
bool DeviceDataManagerX11::IsStylusDataType(const int type) { … }
void DeviceDataManagerX11::CreateInstance() { … }
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) { … }
}