Skip to content

Commit

Permalink
aura: Some event-related cleanup in RootWindow.
Browse files Browse the repository at this point in the history
The RootWindow no longer needs to keep track of the mouse-flags. So remove
|mouse_button_flags_|. Also, make sure the synthesized mouse-enter/exit
events have the EF_IS_SYNTHESIZED flag set.

BUG=none
R=sky@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207338 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
sadrul@chromium.org committed Jun 20, 2013
1 parent c577b2c commit 925a1b8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
5 changes: 4 additions & 1 deletion ash/display/display_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,11 @@ class TestEventHandler : public ui::EventHandler {
virtual ~TestEventHandler() {}

virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
if (event->flags() & ui::EF_IS_SYNTHESIZED)
if (event->flags() & ui::EF_IS_SYNTHESIZED &&
event->type() != ui::ET_MOUSE_EXITED &&
event->type() != ui::ET_MOUSE_ENTERED) {
return;
}
aura::Window* target = static_cast<aura::Window*>(event->target());
mouse_location_ = event->root_location();
target_root_ = target->GetRootWindow();
Expand Down
14 changes: 5 additions & 9 deletions ui/aura/root_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ RootWindow::RootWindow(const CreateParams& params)
host_(CreateHost(this, params)),
schedule_paint_factory_(this),
event_factory_(this),
mouse_button_flags_(0),
touch_ids_down_(0),
last_cursor_(ui::kCursorNull),
mouse_pressed_handler_(NULL),
Expand Down Expand Up @@ -751,7 +750,7 @@ void RootWindow::DispatchMouseEnterOrExit(const ui::MouseEvent& event,
static_cast<Window*>(this),
mouse_moved_handler_,
type,
event.flags());
event.flags() | ui::EF_IS_SYNTHESIZED);
ProcessEvent(mouse_moved_handler_, &translated_event);
}

Expand Down Expand Up @@ -1060,14 +1059,13 @@ bool RootWindow::DispatchMouseEventToTarget(ui::MouseEvent* event,
// sent to the wrong target.
if (!(event->flags() & ui::EF_IS_NON_CLIENT) && !mouse_pressed_handler_)
mouse_pressed_handler_ = target;
mouse_button_flags_ = event->flags() & kMouseButtonFlagMask;
Env::GetInstance()->set_mouse_button_flags(mouse_button_flags_);
Env::GetInstance()->set_mouse_button_flags(
event->flags() & kMouseButtonFlagMask);
break;
case ui::ET_MOUSE_RELEASED:
mouse_pressed_handler_ = NULL;
mouse_button_flags_ = event->flags() & kMouseButtonFlagMask &
~event->changed_button_flags();
Env::GetInstance()->set_mouse_button_flags(mouse_button_flags_);
Env::GetInstance()->set_mouse_button_flags(event->flags() &
kMouseButtonFlagMask & ~event->changed_button_flags());
break;
default:
break;
Expand Down Expand Up @@ -1195,8 +1193,6 @@ void RootWindow::SynthesizeMouseMoveEvent() {
gfx::Point host_mouse_location = root_mouse_location;
ConvertPointToHost(&host_mouse_location);

// TODO(derat|oshima): Don't use mouse_button_flags_ as it's
// currently broken. See/ crbug.com/107931.
ui::MouseEvent event(ui::ET_MOUSE_MOVED,
host_mouse_location,
host_mouse_location,
Expand Down
3 changes: 0 additions & 3 deletions ui/aura/root_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,6 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate,
// Use to post mouse move event.
base::WeakPtrFactory<RootWindow> event_factory_;

// ui::EventFlags containing the current state of the mouse buttons.
int mouse_button_flags_;

// Touch ids that are currently down.
uint32 touch_ids_down_;

Expand Down
2 changes: 2 additions & 0 deletions ui/aura/window_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1166,9 +1166,11 @@ class MouseEnterExitWindowDelegate : public TestWindowDelegate {
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
switch (event->type()) {
case ui::ET_MOUSE_ENTERED:
EXPECT_TRUE(event->flags() & ui::EF_IS_SYNTHESIZED);
entered_ = true;
break;
case ui::ET_MOUSE_EXITED:
EXPECT_TRUE(event->flags() & ui::EF_IS_SYNTHESIZED);
exited_ = true;
break;
default:
Expand Down

0 comments on commit 925a1b8

Please sign in to comment.