Chromium Code Reviews| 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 0fe8fbb63b51164b3cf9fc373cc6960cf76ef4fc..64594616e729bf88cfae7a9fd470e8a9c7b3f4b9 100644 |
| --- a/ui/views/controls/menu/menu_controller.cc |
| +++ b/ui/views/controls/menu/menu_controller.cc |
| @@ -34,6 +34,10 @@ |
| #include "ui/aura/window.h" |
| #endif |
| +#if defined(OS_CHROMEOS) |
|
oshima
2013/01/08 23:26:10
shouldn't we use USE_X11?
sschmitz
2013/01/18 20:30:16
Done.
|
| +#include <X11/Xlib.h> |
| +#endif |
| + |
| using base::Time; |
| using base::TimeDelta; |
| using ui::OSExchangeData; |
| @@ -803,9 +807,8 @@ 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)) || defined(OS_CHROMEOS) |
| RepostEvent(source, event); |
| - // NOTE: not reposting on linux seems fine. |
| #endif |
| // And close. |
| @@ -1995,7 +1998,32 @@ void MenuController::RepostEvent(SubmenuView* source, |
| } |
| } |
| } |
| -#endif // defined(OS_WIN) |
| +#elif defined(OS_CHROMEOS) |
| +void MenuController::RepostEvent(SubmenuView* source, |
| + const ui::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(); |
| + |
| + // We putback the X11 event. We set the "send_event" field in the |
| + // XEvent. Otherwise a mouse click would generate a double click |
| + // event. The field "send_event" is in the same place for all event |
| + // types so we can use "xany" regardless of type. |
| + if (!event.native_event()) |
| + return; |
| + XEvent xevent = *event.native_event(); |
| + xevent.xany.send_event = True; |
| + XPutBackEvent(xevent.xany.display, &xevent); |
|
oshima
2013/01/08 23:26:10
Won't this cause clicking on a button actually act
sschmitz
2013/01/18 20:30:16
The function is only invoked when the mouse was no
|
| +} |
| +#endif |
| void MenuController::SetDropMenuItem( |
| MenuItemView* new_target, |