Skip to content

Commit

Permalink
Add time_stamp parameter to MouseEvent constructor
Browse files Browse the repository at this point in the history
In order to allow the use of accurate kernel timestamps in the events from
Ozone it is necessary to add a parameter to the constructor for MouseEvent.
This CL was partially generated from using a clang tool with some manual
changes for files not included in my build and to add header files as necessary.

This change fills in all users of the newly added time_stamp parameter with a
call into ui::EventTimeForNow() which was the original behaviour used by the
constructor.

BUG=450341
TEST=Build on all try bots and all unit tests pass.

Review URL: https://codereview.chromium.org/934653002

Cr-Commit-Position: refs/heads/master@{#316869}
  • Loading branch information
rbradford authored and Commit bot committed Feb 18, 2015
1 parent 7e58ae8 commit b3d800b
Show file tree
Hide file tree
Showing 79 changed files with 770 additions and 752 deletions.
11 changes: 5 additions & 6 deletions ash/autoclick/autoclick_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "ui/events/event_constants.h"
#include "ui/events/event_handler.h"
#include "ui/events/event_processor.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/wm/core/coordinate_conversion.h"
Expand Down Expand Up @@ -190,14 +191,12 @@ void AutoclickControllerImpl::DoAutoclick() {
aura::WindowTreeHost* host = root_window->GetHost();
host->ConvertPointToHost(&click_location);

ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED,
click_location,
click_location,
ui::MouseEvent press_event(ui::ET_MOUSE_PRESSED, click_location,
click_location, ui::EventTimeForNow(),
mouse_event_flags_ | ui::EF_LEFT_MOUSE_BUTTON,
ui::EF_LEFT_MOUSE_BUTTON);
ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED,
click_location,
click_location,
ui::MouseEvent release_event(ui::ET_MOUSE_RELEASED, click_location,
click_location, ui::EventTimeForNow(),
mouse_event_flags_ | ui::EF_LEFT_MOUSE_BUTTON,
ui::EF_LEFT_MOUSE_BUTTON);

Expand Down
11 changes: 5 additions & 6 deletions ash/autoclick/autoclick_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
#include "ui/events/event_handler.h"
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/events/test/event_generator.h"

Expand All @@ -33,12 +34,10 @@ class MouseEventCapturer : public ui::EventHandler {
ui::EventType type = event->type();
if (type == ui::ET_MOUSE_MOVED || type == ui::ET_MOUSE_PRESSED ||
type == ui::ET_MOUSE_RELEASED) {
events_.push_back(ui::MouseEvent(
event->type(),
event->location(),
event->root_location(),
event->flags(),
event->changed_button_flags()));
events_.push_back(ui::MouseEvent(event->type(), event->location(),
event->root_location(),
ui::EventTimeForNow(), event->flags(),
event->changed_button_flags()));
// Stop event propagation so we don't click on random stuff that
// might break test assumptions.
event->StopPropagation();
Expand Down
9 changes: 5 additions & 4 deletions ash/display/mouse_cursor_event_filter_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "ash/display/display_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"

Expand Down Expand Up @@ -39,16 +40,16 @@ class MouseCursorEventFilterTest : public test::AshTestBase {
aura::Window* target_root,
gfx::Point point_in_screen) {
gfx::Point location = drag_source_root->bounds().CenterPoint();
ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, location,
location, 0, 0);
ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, location, location,
ui::EventTimeForNow(), 0, 0);
ui::Event::DispatcherApi(&pressed).set_target(drag_source_root);
event_filter()->OnMouseEvent(&pressed);
bool is_warped = event_filter()->WarpMouseCursorIfNecessaryForTest(
target_root, point_in_screen);
event_filter()->reset_was_mouse_warped_for_test();

ui::MouseEvent released(ui::ET_MOUSE_RELEASED, location,
location, 0, 0);
ui::MouseEvent released(ui::ET_MOUSE_RELEASED, location, location,
ui::EventTimeForNow(), 0, 0);
ui::Event::DispatcherApi(&released).set_target(drag_source_root);
event_filter()->OnMouseEvent(&released);
return is_warped;
Expand Down
26 changes: 9 additions & 17 deletions ash/drag_drop/drag_drop_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ TEST_F(DragDropControllerTest, SyntheticEventsDuringDragDrop) {
// The DragDropController should simply ignore these events.
gfx::Point mouse_move_location = drag_view->bounds().CenterPoint();
ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, mouse_move_location,
mouse_move_location, 0, 0);
mouse_move_location, ui::EventTimeForNow(), 0, 0);
ui::EventDispatchDetails details = Shell::GetPrimaryRootWindow()->
GetHost()->event_processor()->OnEventFromSource(&mouse_move);
ASSERT_FALSE(details.dispatcher_destroyed);
Expand Down Expand Up @@ -1006,18 +1006,14 @@ TEST_F(DragDropControllerTest, DragCancelAcrossDisplays) {
GetDragImageWindow()->AddObserver(&observer);

{
ui::MouseEvent e(ui::ET_MOUSE_DRAGGED,
gfx::Point(200, 0),
gfx::Point(200, 0),
ui::EF_NONE,
ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0),
gfx::Point(200, 0), ui::EventTimeForNow(), ui::EF_NONE,
ui::EF_NONE);
drag_drop_controller_->DragUpdate(window, e);
}
{
ui::MouseEvent e(ui::ET_MOUSE_DRAGGED,
gfx::Point(600, 0),
gfx::Point(600, 0),
ui::EF_NONE,
ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0),
gfx::Point(600, 0), ui::EventTimeForNow(), ui::EF_NONE,
ui::EF_NONE);
drag_drop_controller_->DragUpdate(window, e);
}
Expand All @@ -1043,18 +1039,14 @@ TEST_F(DragDropControllerTest, DragCancelAcrossDisplays) {
GetDragImageWindow()->AddObserver(&observer);

{
ui::MouseEvent e(ui::ET_MOUSE_DRAGGED,
gfx::Point(600, 0),
gfx::Point(600, 0),
ui::EF_NONE,
ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0),
gfx::Point(600, 0), ui::EventTimeForNow(), ui::EF_NONE,
ui::EF_NONE);
drag_drop_controller_->DragUpdate(window, e);
}
{
ui::MouseEvent e(ui::ET_MOUSE_DRAGGED,
gfx::Point(200, 0),
gfx::Point(200, 0),
ui::EF_NONE,
ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0),
gfx::Point(200, 0), ui::EventTimeForNow(), ui::EF_NONE,
ui::EF_NONE);
drag_drop_controller_->DragUpdate(window, e);
}
Expand Down
11 changes: 5 additions & 6 deletions ash/drag_drop/drag_drop_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/screen.h"
#include "ui/wm/core/coordinate_conversion.h"
#include "ui/wm/public/activation_delegate.h"
Expand Down Expand Up @@ -91,12 +92,10 @@ ui::LocatedEvent* DragDropTracker::ConvertEvent(
capture_window_->GetRootWindow(),
ash::wm::GetRootWindowAt(location_in_screen),
&target_root_location);
return new ui::MouseEvent(event.type(),
target_location,
target_root_location,
event.flags(),
static_cast<const ui::MouseEvent&>(event).
changed_button_flags());
return new ui::MouseEvent(
event.type(), target_location, target_root_location,
ui::EventTimeForNow(), event.flags(),
static_cast<const ui::MouseEvent&>(event).changed_button_flags());
}

} // namespace ash
40 changes: 15 additions & 25 deletions ash/drag_drop/drag_drop_tracker_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "ui/aura/test/test_windows.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/events/event_utils.h"

namespace ash {
namespace test {
Expand All @@ -30,11 +31,8 @@ class DragDropTrackerTest : public test::AshTestBase {
static aura::Window* GetTarget(const gfx::Point& location) {
scoped_ptr<DragDropTracker> tracker(
new DragDropTracker(Shell::GetPrimaryRootWindow(), NULL));
ui::MouseEvent e(ui::ET_MOUSE_DRAGGED,
location,
location,
ui::EF_NONE,
ui::EF_NONE);
ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, location, location,
ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
aura::Window* target = tracker->GetTarget(e);
return target;
}
Expand Down Expand Up @@ -132,11 +130,9 @@ TEST_F(DragDropTrackerTest, ConvertEvent) {

// Start tracking from the RootWindow0 and converts the mouse event into
// |window0|'s coodinates.
ui::MouseEvent original00(ui::ET_MOUSE_DRAGGED,
gfx::Point(50, 50),
gfx::Point(50, 50),
ui::EF_NONE,
ui::EF_NONE);
ui::MouseEvent original00(ui::ET_MOUSE_DRAGGED, gfx::Point(50, 50),
gfx::Point(50, 50), ui::EventTimeForNow(),
ui::EF_NONE, ui::EF_NONE);
scoped_ptr<ui::LocatedEvent> converted00(ConvertEvent(window0.get(),
original00));
EXPECT_EQ(original00.type(), converted00->type());
Expand All @@ -146,11 +142,9 @@ TEST_F(DragDropTrackerTest, ConvertEvent) {

// Start tracking from the RootWindow0 and converts the mouse event into
// |window1|'s coodinates.
ui::MouseEvent original01(ui::ET_MOUSE_DRAGGED,
gfx::Point(350, 150),
gfx::Point(350, 150),
ui::EF_NONE,
ui::EF_NONE);
ui::MouseEvent original01(ui::ET_MOUSE_DRAGGED, gfx::Point(350, 150),
gfx::Point(350, 150), ui::EventTimeForNow(),
ui::EF_NONE, ui::EF_NONE);
scoped_ptr<ui::LocatedEvent> converted01(ConvertEvent(window1.get(),
original01));
EXPECT_EQ(original01.type(), converted01->type());
Expand All @@ -163,11 +157,9 @@ TEST_F(DragDropTrackerTest, ConvertEvent) {

// Start tracking from the RootWindow1 and converts the mouse event into
// |window0|'s coodinates.
ui::MouseEvent original10(ui::ET_MOUSE_DRAGGED,
gfx::Point(-150, 50),
gfx::Point(-150, 50),
ui::EF_NONE,
ui::EF_NONE);
ui::MouseEvent original10(ui::ET_MOUSE_DRAGGED, gfx::Point(-150, 50),
gfx::Point(-150, 50), ui::EventTimeForNow(),
ui::EF_NONE, ui::EF_NONE);
scoped_ptr<ui::LocatedEvent> converted10(ConvertEvent(window0.get(),
original10));
EXPECT_EQ(original10.type(), converted10->type());
Expand All @@ -177,11 +169,9 @@ TEST_F(DragDropTrackerTest, ConvertEvent) {

// Start tracking from the RootWindow1 and converts the mouse event into
// |window1|'s coodinates.
ui::MouseEvent original11(ui::ET_MOUSE_DRAGGED,
gfx::Point(150, 150),
gfx::Point(150, 150),
ui::EF_NONE,
ui::EF_NONE);
ui::MouseEvent original11(ui::ET_MOUSE_DRAGGED, gfx::Point(150, 150),
gfx::Point(150, 150), ui::EventTimeForNow(),
ui::EF_NONE, ui::EF_NONE);
scoped_ptr<ui::LocatedEvent> converted11(ConvertEvent(window1.get(),
original11));
EXPECT_EQ(original11.type(), converted11->type());
Expand Down
9 changes: 5 additions & 4 deletions ash/shelf/shelf_tooltip_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
#include "ui/events/event_handler.h"
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/events/test/events_test_utils.h"
#include "ui/views/widget/widget.h"
Expand Down Expand Up @@ -231,8 +232,8 @@ TEST_F(ShelfTooltipManagerTest, HideForMouseMoveEvent) {

// Shouldn't hide if the mouse is in the tooltip.
ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, tooltip_rect.CenterPoint(),
tooltip_rect.CenterPoint(), ui::EF_NONE,
ui::EF_NONE);
tooltip_rect.CenterPoint(), ui::EventTimeForNow(),
ui::EF_NONE, ui::EF_NONE);
ui::LocatedEventTestApi test_api(&mouse_event);

SetEventTarget(root_window, &mouse_event);
Expand Down Expand Up @@ -261,8 +262,8 @@ TEST_F(ShelfTooltipManagerTest, HideForMouseClickEvent) {

// Should hide if the mouse is pressed in the tooltip.
ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, tooltip_rect.CenterPoint(),
tooltip_rect.CenterPoint(), ui::EF_NONE,
ui::EF_NONE);
tooltip_rect.CenterPoint(), ui::EventTimeForNow(),
ui::EF_NONE, ui::EF_NONE);

SetEventTarget(root_window, &mouse_event);
event_handler->OnMouseEvent(&mouse_event);
Expand Down
7 changes: 5 additions & 2 deletions ash/shelf/shelf_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animator.h"
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/point.h"
#include "ui/views/animation/bounds_animator.h"
Expand Down Expand Up @@ -621,7 +622,8 @@ bool ShelfView::StartDrag(const std::string& app_id,
gfx::Point point_in_root = location_in_screen_coordinates;
::wm::ConvertPointFromScreen(
ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root);
ui::MouseEvent event(ui::ET_MOUSE_PRESSED, pt, point_in_root, 0, 0);
ui::MouseEvent event(ui::ET_MOUSE_PRESSED, pt, point_in_root,
ui::EventTimeForNow(), 0, 0);
PointerPressedOnButton(drag_and_drop_view,
ShelfButtonHost::DRAG_AND_DROP,
event);
Expand All @@ -643,7 +645,8 @@ bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) {
gfx::Point point_in_root = location_in_screen_coordinates;
::wm::ConvertPointFromScreen(
ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root);
ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, point_in_root, 0, 0);
ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, point_in_root,
ui::EventTimeForNow(), 0, 0);
PointerDraggedOnButton(drag_and_drop_view,
ShelfButtonHost::DRAG_AND_DROP,
event);
Expand Down
Loading

0 comments on commit b3d800b

Please sign in to comment.