| Index: ui/events/x/events_x.cc
|
| diff --git a/ui/events/platform/x11/platform_event_utils_x11.cc b/ui/events/x/events_x.cc
|
| similarity index 79%
|
| rename from ui/events/platform/x11/platform_event_utils_x11.cc
|
| rename to ui/events/x/events_x.cc
|
| index 056dc26ce3400b5a7774dd989ff4bd11c271afb5..64da7ca6c8626085e4308056c225f829659c9a1f 100644
|
| --- a/ui/events/platform/x11/platform_event_utils_x11.cc
|
| +++ b/ui/events/x/events_x.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "ui/events/platform/platform_event_utils.h"
|
| +#include "ui/events/event_constants.h"
|
|
|
| #include <string.h>
|
| #include <X11/extensions/XInput.h>
|
| @@ -14,16 +14,16 @@
|
|
|
| #include "base/logging.h"
|
| #include "base/memory/singleton.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/event.h"
|
| -#include "ui/events/event_constants.h"
|
| #include "ui/events/event_utils.h"
|
| -#include "ui/events/platform/x11/device_data_manager_x11.h"
|
| -#include "ui/events/platform/x11/device_list_cache_x.h"
|
| -#include "ui/events/platform/x11/keyboard_code_conversion_x11.h"
|
| -#include "ui/events/platform/x11/touch_factory_x11.h"
|
| +#include "ui/events/keycodes/keyboard_code_conversion_x.h"
|
| #include "ui/gfx/display.h"
|
| -#include "ui/gfx/point.h"
|
| -#include "ui/gfx/rect.h"
|
| +#include "ui/gfx/geometry/point.h"
|
| +#include "ui/gfx/geometry/rect.h"
|
| +#include "ui/gfx/screen.h"
|
| #include "ui/gfx/x/x11_atom_cache.h"
|
| #include "ui/gfx/x/x11_types.h"
|
|
|
| @@ -38,7 +38,7 @@ const int kMaxWheelButton = 7;
|
| // 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 {
|
| +class XModifierStateWatcher{
|
| public:
|
| static XModifierStateWatcher* GetInstance() {
|
| return Singleton<XModifierStateWatcher>::get();
|
| @@ -102,14 +102,13 @@ class XModifierStateWatcher {
|
| private:
|
| friend struct DefaultSingletonTraits<XModifierStateWatcher>;
|
|
|
| - XModifierStateWatcher() : state_(0) {}
|
| + XModifierStateWatcher() : state_(0) { }
|
|
|
| unsigned int state_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(XModifierStateWatcher);
|
| };
|
|
|
| -#if defined(USE_XI2_MT)
|
| // 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).
|
| @@ -117,7 +116,8 @@ class XModifierStateWatcher {
|
| bool TouchEventIsGeneratedHack(const base::NativeEvent& native_event) {
|
| XIDeviceEvent* event =
|
| static_cast<XIDeviceEvent*>(native_event->xcookie.data);
|
| - CHECK(event->evtype == XI_TouchBegin || event->evtype == XI_TouchUpdate ||
|
| + CHECK(event->evtype == XI_TouchBegin ||
|
| + event->evtype == XI_TouchUpdate ||
|
| event->evtype == XI_TouchEnd);
|
|
|
| // Force is normalized to [0, 1].
|
| @@ -132,13 +132,12 @@ bool TouchEventIsGeneratedHack(const base::NativeEvent& native_event) {
|
| unsigned int deviceid =
|
| static_cast<XIDeviceEvent*>(native_event->xcookie.data)->sourceid;
|
| if (!ui::DeviceDataManagerX11::GetInstance()->GetDataRange(
|
| - deviceid, ui::DeviceDataManagerX11::DT_TOUCH_MAJOR, &min, &max)) {
|
| + deviceid, ui::DeviceDataManagerX11::DT_TOUCH_MAJOR, &min, &max)) {
|
| return false;
|
| }
|
|
|
| return radius * 2 == max;
|
| }
|
| -#endif
|
|
|
| int GetEventFlagsFromXState(unsigned int state) {
|
| int flags = 0;
|
| @@ -162,6 +161,8 @@ int GetEventFlagsFromXState(unsigned int state) {
|
| flags |= ui::EF_MIDDLE_MOUSE_BUTTON;
|
| if (state & Button3Mask)
|
| flags |= ui::EF_RIGHT_MOUSE_BUTTON;
|
| + // There are no masks for EF_BACK_MOUSE_BUTTON and
|
| + // EF_FORWARD_MOUSE_BUTTON.
|
| return flags;
|
| }
|
|
|
| @@ -182,18 +183,15 @@ int GetEventFlagsFromXKeyEvent(XEvent* xevent) {
|
| // handle the character compositions.
|
| const unsigned int shift_lock_mask = ShiftMask | LockMask;
|
| const bool fabricated_by_xim =
|
| - xevent->xkey.keycode == 0 && (xevent->xkey.state & ~shift_lock_mask) == 0;
|
| + xevent->xkey.keycode == 0 &&
|
| + (xevent->xkey.state & ~shift_lock_mask) == 0;
|
| const int ime_fabricated_flag =
|
| fabricated_by_xim ? ui::EF_IME_FABRICATED_KEY : 0;
|
| #endif
|
|
|
| return GetEventFlagsFromXState(xevent->xkey.state) |
|
| - (xevent->xkey.send_event ? ui::EF_FINAL : 0) |
|
| - (IsKeypadKey(XLookupKeysym(&xevent->xkey, 0)) ? ui::EF_NUMPAD_KEY
|
| - : 0) |
|
| - (IsFunctionKey(XLookupKeysym(&xevent->xkey, 0)) ? ui::EF_FUNCTION_KEY
|
| - : 0) |
|
| - ime_fabricated_flag;
|
| + (xevent->xkey.send_event ? ui::EF_FINAL : 0) |
|
| + ime_fabricated_flag;
|
| }
|
|
|
| int GetEventFlagsFromXGenericEvent(XEvent* xevent) {
|
| @@ -202,11 +200,7 @@ int GetEventFlagsFromXGenericEvent(XEvent* xevent) {
|
| DCHECK((xievent->evtype == XI_KeyPress) ||
|
| (xievent->evtype == XI_KeyRelease));
|
| return GetEventFlagsFromXState(xievent->mods.effective) |
|
| - (xevent->xkey.send_event ? ui::EF_FINAL : 0) |
|
| - (IsKeypadKey(
|
| - XkbKeycodeToKeysym(xievent->display, xievent->detail, 0, 0))
|
| - ? ui::EF_NUMPAD_KEY
|
| - : 0);
|
| + (xevent->xkey.send_event ? ui::EF_FINAL : 0);
|
| }
|
|
|
| // Get the event flag for the button in XButtonEvent. During a ButtonPress
|
| @@ -225,6 +219,10 @@ int GetEventFlagsForButton(int button) {
|
| return ui::EF_MIDDLE_MOUSE_BUTTON;
|
| case 3:
|
| return ui::EF_RIGHT_MOUSE_BUTTON;
|
| + case 8:
|
| + return ui::EF_BACK_MOUSE_BUTTON;
|
| + case 9:
|
| + return ui::EF_FORWARD_MOUSE_BUTTON;
|
| default:
|
| return 0;
|
| }
|
| @@ -234,10 +232,8 @@ int GetButtonMaskForX2Event(XIDeviceEvent* xievent) {
|
| int buttonflags = 0;
|
| for (int i = 0; i < 8 * xievent->buttons.mask_len; i++) {
|
| if (XIMaskIsSet(xievent->buttons.mask, i)) {
|
| - int button =
|
| - (xievent->sourceid == xievent->deviceid)
|
| - ? ui::DeviceDataManagerX11::GetInstance()->GetMappedButton(i)
|
| - : i;
|
| + int button = (xievent->sourceid == xievent->deviceid) ?
|
| + ui::DeviceDataManagerX11::GetInstance()->GetMappedButton(i) : i;
|
| buttonflags |= GetEventFlagsForButton(button);
|
| }
|
| }
|
| @@ -247,19 +243,17 @@ int GetButtonMaskForX2Event(XIDeviceEvent* xievent) {
|
| ui::EventType GetTouchEventType(const base::NativeEvent& native_event) {
|
| XIDeviceEvent* event =
|
| static_cast<XIDeviceEvent*>(native_event->xcookie.data);
|
| -#if defined(USE_XI2_MT)
|
| - switch (event->evtype) {
|
| + switch(event->evtype) {
|
| case XI_TouchBegin:
|
| - return TouchEventIsGeneratedHack(native_event) ? ui::ET_UNKNOWN
|
| - : ui::ET_TOUCH_PRESSED;
|
| + return TouchEventIsGeneratedHack(native_event) ? ui::ET_UNKNOWN :
|
| + ui::ET_TOUCH_PRESSED;
|
| case XI_TouchUpdate:
|
| - return TouchEventIsGeneratedHack(native_event) ? ui::ET_UNKNOWN
|
| - : ui::ET_TOUCH_MOVED;
|
| + return TouchEventIsGeneratedHack(native_event) ? ui::ET_UNKNOWN :
|
| + ui::ET_TOUCH_MOVED;
|
| case XI_TouchEnd:
|
| - return TouchEventIsGeneratedHack(native_event) ? ui::ET_TOUCH_CANCELLED
|
| - : ui::ET_TOUCH_RELEASED;
|
| + return TouchEventIsGeneratedHack(native_event) ? ui::ET_TOUCH_CANCELLED :
|
| + ui::ET_TOUCH_RELEASED;
|
| }
|
| -#endif // defined(USE_XI2_MT)
|
|
|
| DCHECK(ui::TouchFactory::GetInstance()->IsTouchDevice(event->sourceid));
|
| switch (event->evtype) {
|
| @@ -270,7 +264,8 @@ ui::EventType GetTouchEventType(const base::NativeEvent& native_event) {
|
| case XI_Motion:
|
| // Should not convert any emulated Motion event from touch device to
|
| // touch event.
|
| - if (!(event->flags & XIPointerEmulated) && GetButtonMaskForX2Event(event))
|
| + if (!(event->flags & XIPointerEmulated) &&
|
| + GetButtonMaskForX2Event(event))
|
| return ui::ET_TOUCH_MOVED;
|
| return ui::ET_UNKNOWN;
|
| default:
|
| @@ -280,18 +275,58 @@ ui::EventType GetTouchEventType(const base::NativeEvent& native_event) {
|
| }
|
|
|
| double GetTouchParamFromXEvent(XEvent* xev,
|
| - ui::DeviceDataManagerX11::DataType val,
|
| - double default_value) {
|
| - ui::DeviceDataManagerX11::GetInstance()->GetEventData(*xev, val,
|
| - &default_value);
|
| + ui::DeviceDataManagerX11::DataType val,
|
| + double default_value) {
|
| + ui::DeviceDataManagerX11::GetInstance()->GetEventData(
|
| + *xev, val, &default_value);
|
| return default_value;
|
| }
|
|
|
| void ScaleTouchRadius(XEvent* xev, double* radius) {
|
| DCHECK_EQ(GenericEvent, xev->type);
|
| XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev->xcookie.data);
|
| - ui::DeviceDataManagerX11::GetInstance()->ApplyTouchRadiusScale(xiev->sourceid,
|
| - radius);
|
| + ui::DeviceDataManagerX11::GetInstance()->ApplyTouchRadiusScale(
|
| + xiev->sourceid, radius);
|
| +}
|
| +
|
| +unsigned int UpdateX11EventFlags(int ui_flags, unsigned int old_x_flags) {
|
| + static struct {
|
| + int ui;
|
| + int x;
|
| + } flags[] = {
|
| + {ui::EF_CONTROL_DOWN, ControlMask},
|
| + {ui::EF_SHIFT_DOWN, ShiftMask},
|
| + {ui::EF_ALT_DOWN, Mod1Mask},
|
| + {ui::EF_CAPS_LOCK_DOWN, LockMask},
|
| + {ui::EF_ALTGR_DOWN, Mod5Mask},
|
| + {ui::EF_COMMAND_DOWN, Mod4Mask},
|
| + {ui::EF_MOD3_DOWN, Mod3Mask},
|
| + {ui::EF_LEFT_MOUSE_BUTTON, Button1Mask},
|
| + {ui::EF_MIDDLE_MOUSE_BUTTON, Button2Mask},
|
| + {ui::EF_RIGHT_MOUSE_BUTTON, Button3Mask},
|
| + };
|
| + unsigned int new_x_flags = old_x_flags;
|
| + for (size_t i = 0; i < arraysize(flags); ++i) {
|
| + if (ui_flags & flags[i].ui)
|
| + new_x_flags |= flags[i].x;
|
| + else
|
| + new_x_flags &= ~flags[i].x;
|
| + }
|
| + return new_x_flags;
|
| +}
|
| +
|
| +unsigned int UpdateX11EventButton(int ui_flag, unsigned int old_x_button) {
|
| + switch (ui_flag) {
|
| + case ui::EF_LEFT_MOUSE_BUTTON:
|
| + return Button1;
|
| + case ui::EF_MIDDLE_MOUSE_BUTTON:
|
| + return Button2;
|
| + case ui::EF_RIGHT_MOUSE_BUTTON:
|
| + return Button3;
|
| + default:
|
| + return old_x_button;
|
| + }
|
| + NOTREACHED();
|
| }
|
|
|
| bool GetGestureTimes(const base::NativeEvent& native_event,
|
| @@ -317,7 +352,7 @@ namespace ui {
|
|
|
| void UpdateDeviceList() {
|
| XDisplay* display = gfx::GetXDisplay();
|
| - DeviceListCacheX::GetInstance()->UpdateDeviceList(display);
|
| + DeviceListCacheX11::GetInstance()->UpdateDeviceList(display);
|
| TouchFactory::GetInstance()->UpdateDeviceList(display);
|
| DeviceDataManagerX11::GetInstance()->UpdateDeviceList(display);
|
| }
|
| @@ -327,8 +362,8 @@ EventType EventTypeFromNative(const base::NativeEvent& native_event) {
|
| // ET_UNKNOWN as the type so this event will not be further processed.
|
| // NOTE: During some events unittests there is no device data manager.
|
| if (DeviceDataManager::HasInstance() &&
|
| - static_cast<DeviceDataManagerX11*>(DeviceDataManager::GetInstance())
|
| - ->IsEventBlocked(native_event)) {
|
| + static_cast<DeviceDataManagerX11*>(DeviceDataManager::GetInstance())->
|
| + IsEventBlocked(native_event)) {
|
| return ET_UNKNOWN;
|
| }
|
|
|
| @@ -407,6 +442,14 @@ EventType EventTypeFromNative(const base::NativeEvent& native_event) {
|
| return ET_UMA_DATA;
|
| if (GetButtonMaskForX2Event(xievent))
|
| return ET_MOUSE_DRAGGED;
|
| + if (DeviceDataManagerX11::GetInstance()->HasEventData(
|
| + xievent, DeviceDataManagerX11::DT_CMT_SCROLL_X) ||
|
| + DeviceDataManagerX11::GetInstance()->HasEventData(
|
| + xievent, DeviceDataManagerX11::DT_CMT_SCROLL_Y)) {
|
| + // Don't produce mouse move events for mousewheel scrolls.
|
| + return ET_UNKNOWN;
|
| + }
|
| +
|
| return ET_MOUSE_MOVED;
|
| }
|
| case XI_KeyPress:
|
| @@ -446,7 +489,6 @@ int EventFlagsFromNative(const base::NativeEvent& native_event) {
|
| static_cast<XIDeviceEvent*>(native_event->xcookie.data);
|
|
|
| switch (xievent->evtype) {
|
| -#if defined(USE_XI2_MT)
|
| case XI_TouchBegin:
|
| case XI_TouchUpdate:
|
| case XI_TouchEnd:
|
| @@ -455,7 +497,6 @@ int EventFlagsFromNative(const base::NativeEvent& native_event) {
|
| GetEventFlagsFromXState(
|
| XModifierStateWatcher::GetInstance()->state());
|
| break;
|
| -#endif
|
| case XI_ButtonPress:
|
| case XI_ButtonRelease: {
|
| const bool touch =
|
| @@ -489,7 +530,7 @@ int EventFlagsFromNative(const base::NativeEvent& native_event) {
|
| }
|
|
|
| base::TimeDelta EventTimeFromNative(const base::NativeEvent& native_event) {
|
| - switch (native_event->type) {
|
| + switch(native_event->type) {
|
| case KeyPress:
|
| case KeyRelease:
|
| return base::TimeDelta::FromMilliseconds(native_event->xkey.time);
|
| @@ -511,9 +552,9 @@ base::TimeDelta EventTimeFromNative(const base::NativeEvent& native_event) {
|
| // If the driver supports gesture times, use them.
|
| return base::TimeDelta::FromMicroseconds(end * 1000000);
|
| } else if (DeviceDataManagerX11::GetInstance()->GetEventData(
|
| - *native_event,
|
| - DeviceDataManagerX11::DT_TOUCH_RAW_TIMESTAMP,
|
| - &touch_timestamp)) {
|
| + *native_event,
|
| + DeviceDataManagerX11::DT_TOUCH_RAW_TIMESTAMP,
|
| + &touch_timestamp)) {
|
| return base::TimeDelta::FromMicroseconds(touch_timestamp * 1000000);
|
| } else {
|
| XIDeviceEvent* xide =
|
| @@ -593,16 +634,15 @@ int EventButtonFromNative(const base::NativeEvent& native_event) {
|
| static_cast<XIDeviceEvent*>(native_event->xcookie.data);
|
| int button = xievent->detail;
|
|
|
| - return (xievent->sourceid == xievent->deviceid)
|
| - ? DeviceDataManagerX11::GetInstance()->GetMappedButton(button)
|
| - : button;
|
| + return (xievent->sourceid == xievent->deviceid) ?
|
| + DeviceDataManagerX11::GetInstance()->GetMappedButton(button) : button;
|
| }
|
|
|
| KeyboardCode KeyboardCodeFromNative(const base::NativeEvent& native_event) {
|
| return KeyboardCodeFromXKeyEvent(native_event);
|
| }
|
|
|
| -const char* CodeFromNative(const base::NativeEvent& native_event) {
|
| +DomCode CodeFromNative(const base::NativeEvent& native_event) {
|
| return CodeFromXEvent(native_event);
|
| }
|
|
|
| @@ -650,7 +690,7 @@ int GetChangedMouseButtonFlagsFromNative(
|
| switch (native_event->type) {
|
| case ButtonPress:
|
| case ButtonRelease:
|
| - return GetEventFlagsFromXState(native_event->xbutton.state);
|
| + return GetEventFlagsForButton(native_event->xbutton.button);
|
| case GenericEvent: {
|
| XIDeviceEvent* xievent =
|
| static_cast<XIDeviceEvent*>(native_event->xcookie.data);
|
| @@ -670,14 +710,14 @@ int GetChangedMouseButtonFlagsFromNative(
|
|
|
| gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& native_event) {
|
| float x_offset, y_offset;
|
| - if (GetScrollOffsets(native_event, &x_offset, &y_offset, NULL, NULL, NULL)) {
|
| + if (GetScrollOffsets(
|
| + native_event, &x_offset, &y_offset, NULL, NULL, NULL)) {
|
| return gfx::Vector2d(static_cast<int>(x_offset),
|
| static_cast<int>(y_offset));
|
| }
|
|
|
| - int button = native_event->type == GenericEvent
|
| - ? EventButtonFromNative(native_event)
|
| - : native_event->xbutton.button;
|
| + int button = native_event->type == GenericEvent ?
|
| + EventButtonFromNative(native_event) : native_event->xbutton.button;
|
|
|
| switch (button) {
|
| case 4:
|
| @@ -693,27 +733,27 @@ gfx::Vector2d GetMouseWheelOffset(const base::NativeEvent& native_event) {
|
| }
|
| }
|
|
|
| -void IncrementTouchIdRefCount(const base::NativeEvent& xev) {
|
| - ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance();
|
| - double tracking_id;
|
| - if (!manager->GetEventData(
|
| - *xev, ui::DeviceDataManagerX11::DT_TOUCH_TRACKING_ID, &tracking_id)) {
|
| - return;
|
| - }
|
| +base::NativeEvent CopyNativeEvent(const base::NativeEvent& event) {
|
| + if (!event || event->type == GenericEvent)
|
| + return NULL;
|
| + XEvent* copy = new XEvent;
|
| + *copy = *event;
|
| + return copy;
|
| +}
|
|
|
| - ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
|
| - factory->AcquireSlotForTrackingID(tracking_id);
|
| +void ReleaseCopiedNativeEvent(const base::NativeEvent& event) {
|
| + delete event;
|
| }
|
|
|
| void ClearTouchIdIfReleased(const base::NativeEvent& xev) {
|
| ui::EventType type = ui::EventTypeFromNative(xev);
|
| - if (type == ui::ET_TOUCH_CANCELLED || type == ui::ET_TOUCH_RELEASED) {
|
| + if (type == ui::ET_TOUCH_CANCELLED ||
|
| + type == ui::ET_TOUCH_RELEASED) {
|
| ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
|
| ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance();
|
| double tracking_id;
|
| - if (manager->GetEventData(*xev,
|
| - ui::DeviceDataManagerX11::DT_TOUCH_TRACKING_ID,
|
| - &tracking_id)) {
|
| + if (manager->GetEventData(
|
| + *xev, ui::DeviceDataManagerX11::DT_TOUCH_TRACKING_ID, &tracking_id)) {
|
| factory->ReleaseSlotForTrackingID(tracking_id);
|
| }
|
| }
|
| @@ -724,7 +764,7 @@ int GetTouchId(const base::NativeEvent& xev) {
|
| ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance();
|
| double tracking_id;
|
| if (!manager->GetEventData(
|
| - *xev, ui::DeviceDataManagerX11::DT_TOUCH_TRACKING_ID, &tracking_id)) {
|
| + *xev, ui::DeviceDataManagerX11::DT_TOUCH_TRACKING_ID, &tracking_id)) {
|
| LOG(ERROR) << "Could not get the tracking ID for the event. Using 0.";
|
| } else {
|
| ui::TouchFactory* factory = ui::TouchFactory::GetInstance();
|
| @@ -734,39 +774,33 @@ int GetTouchId(const base::NativeEvent& xev) {
|
| }
|
|
|
| float GetTouchRadiusX(const base::NativeEvent& native_event) {
|
| - double radius =
|
| - GetTouchParamFromXEvent(native_event,
|
| - ui::DeviceDataManagerX11::DT_TOUCH_MAJOR, 0.0) /
|
| - 2.0;
|
| + double radius = GetTouchParamFromXEvent(native_event,
|
| + ui::DeviceDataManagerX11::DT_TOUCH_MAJOR, 0.0) / 2.0;
|
| ScaleTouchRadius(native_event, &radius);
|
| return radius;
|
| }
|
|
|
| float GetTouchRadiusY(const base::NativeEvent& native_event) {
|
| - double radius =
|
| - GetTouchParamFromXEvent(native_event,
|
| - ui::DeviceDataManagerX11::DT_TOUCH_MINOR, 0.0) /
|
| - 2.0;
|
| + double radius = GetTouchParamFromXEvent(native_event,
|
| + ui::DeviceDataManagerX11::DT_TOUCH_MINOR, 0.0) / 2.0;
|
| ScaleTouchRadius(native_event, &radius);
|
| return radius;
|
| }
|
|
|
| float GetTouchAngle(const base::NativeEvent& native_event) {
|
| return GetTouchParamFromXEvent(native_event,
|
| - ui::DeviceDataManagerX11::DT_TOUCH_ORIENTATION,
|
| - 0.0) /
|
| - 2.0;
|
| + ui::DeviceDataManagerX11::DT_TOUCH_ORIENTATION, 0.0) / 2.0;
|
| }
|
|
|
| float GetTouchForce(const base::NativeEvent& native_event) {
|
| double force = 0.0;
|
| - force = GetTouchParamFromXEvent(
|
| - native_event, ui::DeviceDataManagerX11::DT_TOUCH_PRESSURE, 0.0);
|
| + force = GetTouchParamFromXEvent(native_event,
|
| + ui::DeviceDataManagerX11::DT_TOUCH_PRESSURE, 0.0);
|
| unsigned int deviceid =
|
| static_cast<XIDeviceEvent*>(native_event->xcookie.data)->sourceid;
|
| // Force is normalized to fall into [0, 1]
|
| if (!ui::DeviceDataManagerX11::GetInstance()->NormalizeData(
|
| - deviceid, ui::DeviceDataManagerX11::DT_TOUCH_PRESSURE, &force))
|
| + deviceid, ui::DeviceDataManagerX11::DT_TOUCH_PRESSURE, &force))
|
| force = 0.0;
|
| return force;
|
| }
|
| @@ -796,7 +830,9 @@ bool GetScrollOffsets(const base::NativeEvent& native_event,
|
| finger_count = &finger_count_;
|
|
|
| DeviceDataManagerX11::GetInstance()->GetScrollOffsets(
|
| - native_event, x_offset, y_offset, x_offset_ordinal, y_offset_ordinal,
|
| + native_event,
|
| + x_offset, y_offset,
|
| + x_offset_ordinal, y_offset_ordinal,
|
| finger_count);
|
| return true;
|
| }
|
| @@ -829,4 +865,53 @@ bool GetFlingData(const base::NativeEvent& native_event,
|
| return true;
|
| }
|
|
|
| +void UpdateX11EventForFlags(Event* event) {
|
| + XEvent* xev = event->native_event();
|
| + if (!xev)
|
| + return;
|
| + switch (xev->type) {
|
| + case KeyPress:
|
| + case KeyRelease:
|
| + xev->xkey.state = UpdateX11EventFlags(event->flags(), xev->xkey.state);
|
| + break;
|
| + case ButtonPress:
|
| + case ButtonRelease:
|
| + xev->xbutton.state =
|
| + UpdateX11EventFlags(event->flags(), xev->xbutton.state);
|
| + break;
|
| + case GenericEvent: {
|
| + XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data);
|
| + DCHECK(xievent);
|
| + xievent->mods.effective =
|
| + UpdateX11EventFlags(event->flags(), xievent->mods.effective);
|
| + break;
|
| + }
|
| + default:
|
| + break;
|
| + }
|
| +}
|
| +
|
| +void UpdateX11EventForChangedButtonFlags(MouseEvent* event) {
|
| + XEvent* xev = event->native_event();
|
| + if (!xev)
|
| + return;
|
| + switch (xev->type) {
|
| + case ButtonPress:
|
| + case ButtonRelease:
|
| + xev->xbutton.button = UpdateX11EventButton(event->changed_button_flags(),
|
| + xev->xbutton.button);
|
| + break;
|
| + case GenericEvent: {
|
| + XIDeviceEvent* xievent = static_cast<XIDeviceEvent*>(xev->xcookie.data);
|
| + CHECK(xievent && (xievent->evtype == XI_ButtonPress ||
|
| + xievent->evtype == XI_ButtonRelease));
|
| + xievent->detail =
|
| + UpdateX11EventButton(event->changed_button_flags(), xievent->detail);
|
| + break;
|
| + }
|
| + default:
|
| + break;
|
| + }
|
| +}
|
| +
|
| } // namespace ui
|
|
|