| Index: ui/views/controls/menu/menu_controller.cc
|
| diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc
|
| index d3b8e3fe9a0b433aaa8b12d13135cccf51967335..04435250691d4f95d064b3559f12ac6f52caa20f 100644
|
| --- a/ui/views/controls/menu/menu_controller.cc
|
| +++ b/ui/views/controls/menu/menu_controller.cc
|
| @@ -27,12 +27,16 @@
|
| #if defined(USE_AURA)
|
| #include "ui/aura/client/dispatcher_client.h"
|
| #include "ui/aura/env.h"
|
| +#include "ui/aura/event.h"
|
| #include "ui/aura/root_window.h"
|
| #elif defined(TOOLKIT_USES_GTK)
|
| #include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
|
| #endif
|
|
|
| -using base::Time;
|
| +#if defined(USE_AURA) && defined(USE_X11)
|
| +#include <X11/Xlib.h>
|
| +#endif
|
| +
|
| using base::TimeDelta;
|
| using ui::OSExchangeData;
|
|
|
| @@ -163,7 +167,7 @@ class MenuController::MenuScrollTask {
|
| if (new_menu == submenu_ && is_scrolling_up_ == new_is_up)
|
| return;
|
|
|
| - start_scroll_time_ = Time::Now();
|
| + start_scroll_time_ = base::Time::Now();
|
| start_y_ = part.submenu->GetVisibleBounds().y();
|
| submenu_ = new_menu;
|
| is_scrolling_up_ = new_is_up;
|
| @@ -190,7 +194,7 @@ class MenuController::MenuScrollTask {
|
| DCHECK(submenu_);
|
| gfx::Rect vis_rect = submenu_->GetVisibleBounds();
|
| const int delta_y = static_cast<int>(
|
| - (Time::Now() - start_scroll_time_).InMilliseconds() *
|
| + (base::Time::Now() - start_scroll_time_).InMilliseconds() *
|
| pixels_per_second_ / 1000);
|
| vis_rect.set_y(is_scrolling_up_ ?
|
| std::max(0, start_y_ - delta_y) :
|
| @@ -208,7 +212,7 @@ class MenuController::MenuScrollTask {
|
| base::RepeatingTimer<MenuScrollTask> scrolling_timer_;
|
|
|
| // Time we started scrolling at.
|
| - Time start_scroll_time_;
|
| + base::Time start_scroll_time_;
|
|
|
| // How many pixels to scroll per second.
|
| int pixels_per_second_;
|
| @@ -785,7 +789,7 @@ void MenuController::SetSelectionOnPointerDown(SubmenuView* source,
|
| // We're going to close and we own the mouse capture. We need to repost the
|
| // mouse down, otherwise the window the user clicked on won't get the
|
| // event.
|
| -#if defined(OS_WIN) && !defined(USE_AURA)
|
| +#if defined(OS_WIN) || defined(USE_AURA)
|
| RepostEvent(source, event);
|
| // NOTE: not reposting on linux seems fine.
|
| #endif
|
| @@ -1836,7 +1840,7 @@ bool MenuController::SelectByChar(char16 character) {
|
| return false;
|
| }
|
|
|
| -#if defined(OS_WIN) && !defined(USE_AURA)
|
| +#if defined(OS_WIN)
|
| void MenuController::RepostEvent(SubmenuView* source,
|
| const LocatedEvent& event) {
|
| if (!state_.item) {
|
| @@ -1904,7 +1908,43 @@ void MenuController::RepostEvent(SubmenuView* source,
|
| }
|
| }
|
| }
|
| -#endif // defined(OS_WIN)
|
| +#elif defined(USE_AURA)
|
| +void MenuController::RepostEvent(SubmenuView* source,
|
| + const LocatedEvent& event) {
|
| + if (!state_.item) {
|
| + // We some times get an event after closing all the menus. Ignore it.
|
| + // Make sure the menu is in fact not visible. If the menu is visible, then
|
| + // we're in a bad state where we think the menu isn't visibile but it is.
|
| + DCHECK(!source->GetWidget()->IsVisible());
|
| + return;
|
| + }
|
| +
|
| + // Release the capture.
|
| + SubmenuView* submenu = state_.item->GetRootMenuItem()->GetSubmenu();
|
| + submenu->ReleaseCapture();
|
| +
|
| + gfx::Point screen_loc(event.location());
|
| + View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc);
|
| +
|
| + XEvent xevent;
|
| + xevent.type = ButtonPress;
|
| + xevent.xbutton.x = screen_loc.x();
|
| + xevent.xbutton.y = screen_loc.y();
|
| + xevent.xbutton.state = 0;
|
| + xevent.xbutton.same_screen = True;
|
| + int flags = event.flags();
|
| + if (flags & ui::EF_LEFT_MOUSE_BUTTON)
|
| + xevent.xbutton.button = 1;
|
| + else if (flags & ui::EF_MIDDLE_MOUSE_BUTTON)
|
| + xevent.xbutton.button = 2;
|
| + else if (flags & ui::EF_RIGHT_MOUSE_BUTTON)
|
| + xevent.xbutton.button = 3;
|
| + else
|
| + return;
|
| +
|
| + aura::RootWindow::GetInstance()->PostNativeEvent(&xevent);
|
| +}
|
| +#endif // defined(USE_AURA)
|
|
|
| void MenuController::SetDropMenuItem(
|
| MenuItemView* new_target,
|
|
|