summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authordavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-20 02:00:56 +0000
committerdavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-20 02:00:56 +0000
commit1903e1981631ce99a9e5539e2596ea90695db82f (patch)
tree56b0b6a937d18dc1eff0a98188b6cb0f5193532b /ui
parente82730935edb15650a5a59986eb539fd1bc30fb5 (diff)
downloadchromium_src-1903e1981631ce99a9e5539e2596ea90695db82f.zip
chromium_src-1903e1981631ce99a9e5539e2596ea90695db82f.tar.gz
chromium_src-1903e1981631ce99a9e5539e2596ea90695db82f.tar.bz2
Revert 127606 - Send GestureFlingStart and GestureFlingCancel when cmt sends them
BUG=114818 TEST=None Review URL: https://chromiumcodereview.appspot.com/9601022 TBR=davemoore@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@127616 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/event.cc10
-rw-r--r--ui/aura/root_window_host_linux.cc2
-rw-r--r--ui/base/events.h14
-rw-r--r--ui/base/x/events_x.cc122
4 files changed, 22 insertions, 126 deletions
diff --git a/ui/aura/event.cc b/ui/aura/event.cc
index 37076dc..c2a0510 100644
--- a/ui/aura/event.cc
+++ b/ui/aura/event.cc
@@ -368,14 +368,7 @@ KeyEvent* KeyEvent::Copy() {
ScrollEvent::ScrollEvent(const base::NativeEvent& native_event)
: MouseEvent(native_event) {
- if (type() == ui::ET_SCROLL) {
- ui::GetScrollOffsets(native_event, &x_offset_, &y_offset_);
- double start, end;
- ui::GetGestureTimes(native_event, &start, &end);
- } else if (type() == ui::ET_SCROLL_FLING_START) {
- bool is_cancel;
- ui::GetFlingData(native_event, &x_offset_, &y_offset_, &is_cancel);
- }
+ ui::GetScrollOffsets(native_event, &x_offset_, &y_offset_);
}
GestureEvent::GestureEvent(ui::EventType type,
@@ -388,6 +381,7 @@ GestureEvent::GestureEvent(ui::EventType type,
: LocatedEvent(type, gfx::Point(x, y), gfx::Point(x, y), flags),
delta_x_(delta_x),
delta_y_(delta_y) {
+ // XXX: Why is aura::Event::time_stamp_ a TimeDelta instead of a Time?
set_time_stamp(base::TimeDelta::FromSeconds(time_stamp.ToDoubleT()));
}
diff --git a/ui/aura/root_window_host_linux.cc b/ui/aura/root_window_host_linux.cc
index 8fa1cec..3a91aea 100644
--- a/ui/aura/root_window_host_linux.cc
+++ b/ui/aura/root_window_host_linux.cc
@@ -419,8 +419,6 @@ base::MessagePumpDispatcher::DispatchStatus RootWindowHostLinux::Dispatch(
handled = root_window_->DispatchMouseEvent(&mouseev);
break;
}
- case ui::ET_SCROLL_FLING_START:
- case ui::ET_SCROLL_FLING_CANCEL:
case ui::ET_SCROLL: {
ScrollEvent scrollev(xev);
handled = root_window_->DispatchScrollEvent(&scrollev);
diff --git a/ui/base/events.h b/ui/base/events.h
index 3f14254..8d5b120 100644
--- a/ui/base/events.h
+++ b/ui/base/events.h
@@ -40,6 +40,7 @@ enum EventType {
ET_TOUCH_CANCELLED,
ET_DROP_TARGET_EVENT,
ET_FOCUS_CHANGE,
+ ET_SCROLL,
ET_TRANSLATED_KEY_PRESS,
ET_TRANSLATED_KEY_RELEASE,
@@ -54,12 +55,6 @@ enum EventType {
ET_GESTURE_PINCH_END,
ET_GESTURE_PINCH_UPDATE,
ET_GESTURE_LONG_PRESS,
-
- // Scroll support.
- // TODO[davemoore] we need to unify these events w/ touch and gestures.
- ET_SCROLL,
- ET_SCROLL_FLING_START,
- ET_SCROLL_FLING_CANCEL,
};
// Event flags currently supported
@@ -165,13 +160,6 @@ UI_EXPORT float GetTouchAngle(const base::NativeEvent& native_event);
// Gets the force from a native_event. Normalized to be [0, 1]. Default is 0.0.
UI_EXPORT float GetTouchForce(const base::NativeEvent& native_event);
-// Gets the fling velocity from a native event. is_cancel is set to true if
-// this was a tap down, intended to stop an ongoing fling.
-UI_EXPORT bool GetFlingData(const base::NativeEvent& native_event,
- float* vx,
- float* vy,
- bool* is_cancel);
-
// Returns whether this is a scroll event and optionally gets the amount to be
// scrolled. |x_offset| and |y_offset| can be NULL.
UI_EXPORT bool GetScrollOffsets(const base::NativeEvent& native_event,
diff --git a/ui/base/x/events_x.cc b/ui/base/x/events_x.cc
index 1674cd2..7d69dc6 100644
--- a/ui/base/x/events_x.cc
+++ b/ui/base/x/events_x.cc
@@ -27,11 +27,6 @@
#define AXIS_LABEL_PROP_ABS_START_TIME "Abs Start Timestamp"
#define AXIS_LABEL_PROP_ABS_END_TIME "Abs End Timestamp"
-// Fling properties
-#define AXIS_LABEL_PROP_ABS_FLING_X "Abs Fling X Velocity"
-#define AXIS_LABEL_PROP_ABS_FLING_Y "Abs Fling Y Velocity"
-#define AXIS_LABEL_PROP_ABS_FLING_STATE "Abs Fling State"
-
namespace {
// Scroll amount for each wheelscroll event. 53 is also the value used for GTK+.
@@ -69,10 +64,6 @@ class UI_EXPORT CMTEventData {
Atom start_time =
XInternAtom(display, AXIS_LABEL_PROP_ABS_START_TIME, false);
Atom end_time = XInternAtom(display, AXIS_LABEL_PROP_ABS_END_TIME, false);
- Atom fling_vx = XInternAtom(display, AXIS_LABEL_PROP_ABS_FLING_X, false);
- Atom fling_vy = XInternAtom(display, AXIS_LABEL_PROP_ABS_FLING_Y, false);
- Atom fling_state =
- XInternAtom(display, AXIS_LABEL_PROP_ABS_FLING_STATE, false);
for (int i = 0; i < count; ++i) {
XIDeviceInfo* info = info_list + i;
@@ -81,7 +72,6 @@ class UI_EXPORT CMTEventData {
continue;
Valuators valuators;
- bool is_cmt = false;
for (int j = 0; j < info->num_classes; ++j) {
if (info->classes[j]->type != XIValuatorClass)
continue;
@@ -91,30 +81,19 @@ class UI_EXPORT CMTEventData {
int number = v->number;
if (number > valuators.max)
valuators.max = number;
- if (v->label == x_axis) {
- valuators.scroll_x = number;
- is_cmt = true;
- } else if (v->label == y_axis) {
- valuators.scroll_y = number;
- is_cmt = true;
- } else if (v->label == start_time) {
+ if (v->label == x_axis)
+ valuators.x_scroll = number;
+ else if (v->label == y_axis)
+ valuators.y_scroll = number;
+ else if (v->label == start_time)
valuators.start_time = number;
- is_cmt = true;
- } else if (v->label == end_time) {
+ else if (v->label == end_time)
valuators.end_time = number;
- is_cmt = true;
- } else if (v->label == fling_vx) {
- valuators.fling_vx = number;
- is_cmt = true;
- } else if (v->label == fling_vy) {
- valuators.fling_vy = number;
- is_cmt = true;
- } else if (v->label == fling_state) {
- valuators.fling_state = number;
- is_cmt = true;
- }
}
- if (is_cmt) {
+ if (valuators.x_scroll >= 0 ||
+ valuators.y_scroll >= 0 ||
+ valuators.start_time >= 0 ||
+ valuators.end_time >= 0) {
device_to_valuators_[info->deviceid] = valuators;
cmt_devices_[info->deviceid] = true;
}
@@ -137,8 +116,8 @@ class UI_EXPORT CMTEventData {
return false;
const Valuators v = device_to_valuators_[xiev->deviceid];
- bool has_x_offset = XIMaskIsSet(xiev->valuators.mask, v.scroll_x);
- bool has_y_offset = XIMaskIsSet(xiev->valuators.mask, v.scroll_y);
+ bool has_x_offset = XIMaskIsSet(xiev->valuators.mask, v.x_scroll);
+ bool has_y_offset = XIMaskIsSet(xiev->valuators.mask, v.y_scroll);
bool is_scroll = has_x_offset || has_y_offset;
if (!is_scroll || (!x_offset && !y_offset))
@@ -147,9 +126,9 @@ class UI_EXPORT CMTEventData {
double* valuators = xiev->valuators.values;
for (int i = 0; i <= v.max; ++i) {
if (XIMaskIsSet(xiev->valuators.mask, i)) {
- if (x_offset && v.scroll_x == i)
+ if (x_offset && v.x_scroll == i)
*x_offset = -(*valuators);
- else if (y_offset && v.scroll_y == i)
+ else if (y_offset && v.y_scroll == i)
*y_offset = -(*valuators);
valuators++;
}
@@ -158,44 +137,6 @@ class UI_EXPORT CMTEventData {
return true;
}
- bool GetFlingData(const XEvent& xev,
- float* vx, float* vy,
- bool* is_cancel) {
- XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev.xcookie.data);
-
- *vx = 0;
- *vy = 0;
- *is_cancel = false;
-
- if (!cmt_devices_[xiev->deviceid])
- return false;
-
- const Valuators v = device_to_valuators_[xiev->deviceid];
- if (!XIMaskIsSet(xiev->valuators.mask, v.fling_vx) ||
- !XIMaskIsSet(xiev->valuators.mask, v.fling_vy) ||
- !XIMaskIsSet(xiev->valuators.mask, v.fling_state))
- return false;
-
- double* valuators = xiev->valuators.values;
- for (int i = 0; i <= v.max; ++i) {
- if (XIMaskIsSet(xiev->valuators.mask, i)) {
- // Convert values to unsigned ints represending ms before storing them,
- // as that is how they were encoded before conversion to doubles.
- if (v.fling_vx == i)
- *vx =
- -static_cast<double>(static_cast<int>(*valuators)) / 1000;
- else if (v.fling_vy == i)
- *vy =
- -static_cast<double>(static_cast<int>(*valuators)) / 1000;
- else if (v.fling_state == i)
- *is_cancel = !!static_cast<unsigned int>(*valuators);
- valuators++;
- }
- }
-
- return true;
- }
-
bool GetGestureTimes(const XEvent& xev,
double* start_time,
double* end_time) {
@@ -235,25 +176,13 @@ class UI_EXPORT CMTEventData {
struct Valuators {
int max;
- int scroll_x;
- int scroll_y;
+ int x_scroll;
+ int y_scroll;
int start_time;
int end_time;
- int fling_vx;
- int fling_vy;
- int fling_state;
Valuators()
- : max(-1),
- scroll_x(-1),
- scroll_y(-1),
- start_time(-1),
- end_time(-1),
- fling_vx(-1),
- fling_vy(-1),
- fling_state(-1) {
-
- }
+ : max(-1), x_scroll(-1), y_scroll(-1), start_time(-1), end_time(-1) {}
};
@@ -531,18 +460,13 @@ EventType EventTypeFromNative(const base::NativeEvent& native_event) {
return xievent->evtype == XI_ButtonPress ?
ET_MOUSE_PRESSED : ET_MOUSE_RELEASED;
}
- case XI_Motion: {
- float vx, vy;
- bool is_cancel;
- if (GetFlingData(native_event, &vx, &vy, &is_cancel)) {
- return is_cancel ? ET_SCROLL_FLING_CANCEL : ET_SCROLL_FLING_START;
- } else if (GetScrollOffsets(native_event, NULL, NULL))
+ case XI_Motion:
+ if (GetScrollOffsets(native_event, NULL, NULL))
return ET_SCROLL;
else if (GetButtonMaskForX2Event(xievent)) {
return ET_MOUSE_DRAGGED;
} else
return ET_MOUSE_MOVED;
- }
}
}
default:
@@ -797,14 +721,6 @@ bool GetScrollOffsets(const base::NativeEvent& native_event,
*native_event, x_offset, y_offset);
}
-bool GetFlingData(const base::NativeEvent& native_event,
- float* vx,
- float* vy,
- bool* is_cancel) {
- return CMTEventData::GetInstance()->GetFlingData(
- *native_event, vx, vy, is_cancel);
-}
-
bool GetGestureTimes(const base::NativeEvent& native_event,
double* start_time,
double* end_time) {