chromium/ui/events/x/events_x_utils.cc

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

#include "ui/events/x/events_x_utils.h"

#include <stddef.h>
#include <string.h>

#include <algorithm>
#include <cmath>

#include "base/logging.h"
#include "base/memory/singleton.h"
#include "base/metrics/histogram_macros.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/devices/x11/device_data_manager_x11.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/keycodes/keyboard_code_conversion_x.h"
#include "ui/events/pointer_details.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/x/atom_cache.h"
#include "ui/gfx/x/extension_manager.h"
#include "ui/gfx/x/xproto.h"

namespace {

// Scroll amount for each wheelscroll event.  120 is what Chrome uses on
// Windows, Fuchsia WHEEL_DELTA, and also it roughly matches Firefox on Linux.
// See https://crbug.com/1270089 for the detailed reasoning.
const int kWheelScrollAmount =;

const int kMinWheelButton =;
const int kMaxWheelButton =;

// A class to track current modifier state on master device. Only track ctrl,
// alt, shift and caps lock keys currently. The tracked state can then be used
// by floating device.
class XModifierStateWatcher {};

// Detects if a touch event is a driver-generated 'special event'.
// A 'special event' is a touch event with maximum radius and pressure at
// location (0, 0).
// This needs to be done in a cleaner way: http://crbug.com/169256
bool TouchEventIsGeneratedHack(const x11::Event& x11_event) {}

int GetEventFlagsFromXState(x11::KeyButMask state) {}

int GetEventFlagsFromXState(uint32_t state) {}

int GetEventFlagsFromXGenericEvent(const x11::Event& x11_event) {}

// Get the event flag for the button in XButtonEvent. During a ButtonPress
// event, |state| in XButtonEvent does not include the button that has just been
// pressed. Instead |state| contains flags for the buttons (if any) that had
// already been pressed before the current button, and |button| stores the most
// current pressed button. So, if you press down left mouse button, and while
// pressing it down, press down the right mouse button, then for the latter
// event, |state| would have Button1Mask set but not Button3Mask, and |button|
// would be 3.
int GetEventFlagsForButton(int button) {}

int GetEventFlagsForButton(x11::Button button) {}

int GetButtonMaskForX2Event(const x11::Input::DeviceEvent& xievent) {}

ui::EventType GetTouchEventType(const x11::Event& x11_event) {}

double GetParamFromXEvent(const x11::Event& xev,
                          ui::DeviceDataManagerX11::DataType val,
                          double default_value) {}

void ScaleTouchRadius(const x11::Event& x11_event, double* radius) {}

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

int64_t g_last_seen_timestamp_ms =;
int64_t g_rollover_ms =;

// Takes Xlib Time and returns a time delta that is immune to timer rollover.
// This function is not thread safe as we do not use a lock.
base::TimeTicks TimeTicksFromXEventTime(x11::Time timestamp) {}

base::TimeTicks TimeTicksFromXEvent(const x11::Event& xev) {}

// This is ported from libxi's FP1616toDBL in XExtInt.c
double Fp1616ToDouble(x11::Input::Fp1616 x) {}

}  // namespace

namespace ui {

EventType EventTypeFromXEvent(const x11::Event& xev) {}

int GetEventFlagsFromXKeyEvent(const x11::KeyEvent& key, bool send_event) {}

int EventFlagsFromXEvent(const x11::Event& xev) {}

base::TimeTicks EventTimeFromXEvent(const x11::Event& xev) {}

gfx::Point EventLocationFromXEvent(const x11::Event& xev) {}

gfx::Point EventSystemLocationFromXEvent(const x11::Event& xev) {}

int EventButtonFromXEvent(const x11::Event& xev) {}

int GetChangedMouseButtonFlagsFromXEvent(const x11::Event& xev) {}

gfx::Vector2d GetMouseWheelOffsetFromXEvent(const x11::Event& xev) {}

float GetStylusForceFromXEvent(const x11::Event& x11_event) {}

float GetStylusTiltXFromXEvent(const x11::Event& x11_event) {}

float GetStylusTiltYFromXEvent(const x11::Event& x11_event) {}

PointerDetails GetStylusPointerDetailsFromXEvent(const x11::Event& xev) {}

int GetTouchIdFromXEvent(const x11::Event& xev) {}

float GetTouchRadiusXFromXEvent(const x11::Event& xev) {}

float GetTouchRadiusYFromXEvent(const x11::Event& xev) {}

float GetTouchAngleFromXEvent(const x11::Event& xev) {}

float GetTouchForceFromXEvent(const x11::Event& x11_event) {}

PointerDetails GetTouchPointerDetailsFromXEvent(const x11::Event& xev) {}

bool GetScrollOffsetsFromXEvent(const x11::Event& xev,
                                float* x_offset,
                                float* y_offset,
                                float* x_offset_ordinal,
                                float* y_offset_ordinal,
                                int* finger_count) {}

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

bool IsAltPressed() {}

int GetModifierKeyState() {}

void ResetTimestampRolloverCountersForTesting() {}

}  // namespace ui