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 bacc1c915bd9801a1b07ceb957de3ba47f442288..0c3104a72801e6517888e641c95684441670916e 100644 |
--- a/ui/views/controls/menu/menu_controller.cc |
+++ b/ui/views/controls/menu/menu_controller.cc |
@@ -34,6 +34,11 @@ |
#include "ui/aura/window.h" |
#endif |
+#if defined(USE_AURA) && defined(USE_X11) |
+#include "ui/aura/root_window.h" |
+#include <X11/Xlib.h> |
+#endif |
+ |
using base::Time; |
using base::TimeDelta; |
using ui::OSExchangeData; |
@@ -796,22 +801,55 @@ void MenuController::SetSelectionOnPointerDown(SubmenuView* source, |
// event. |
#if defined(OS_WIN) && !defined(USE_AURA) |
RepostEvent(source, event); |
- // NOTE: not reposting on linux seems fine. |
#endif |
+#if defined(USE_AURA) && defined(USE_X11) |
+ aura::RootWindow* root_window = |
+ source->GetWidget()->GetNativeWindow()->GetRootWindow(); |
+#endif |
+ |
+ gfx::Point screen_loc(event.location()); |
+ View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc); |
+ |
// And close. |
ExitType exit_type = EXIT_ALL; |
if (!menu_stack_.empty()) { |
// We're running nested menus. Only exit all if the mouse wasn't over one |
// of the menus from the last run. |
- gfx::Point screen_loc(event.location()); |
- View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc); |
MenuPart last_part = GetMenuPartByScreenCoordinateUsingMenu( |
menu_stack_.back().item, screen_loc); |
if (last_part.type != MenuPart::NONE) |
exit_type = EXIT_OUTERMOST; |
} |
Cancel(exit_type); |
+ |
+#if defined(USE_AURA) && defined(USE_X11) |
+ if (exit_type == EXIT_ALL && event.type() == ui::ET_MOUSE_PRESSED) { |
+ XEvent xevent = {0}; |
+ xevent.xbutton.x = screen_loc.x(); |
+ xevent.xbutton.y = screen_loc.y(); |
+ xevent.xbutton.type = ButtonPress; |
+ xevent.xbutton.same_screen = True; |
+ const int event_flags = event.flags(); |
+ bool do_it = true; |
+ if (event_flags & ui::EF_LEFT_MOUSE_BUTTON) { |
+ xevent.xbutton.button = Button1; |
+ xevent.xbutton.state = Button1Mask; |
+ } else if (event_flags & ui::EF_MIDDLE_MOUSE_BUTTON) { |
+ xevent.xbutton.button = Button2; |
+ xevent.xbutton.state = Button2Mask; |
+ } else if (event_flags & ui::EF_RIGHT_MOUSE_BUTTON) { |
+ xevent.xbutton.button = Button3; |
+ xevent.xbutton.state = Button3Mask; |
+ } else { |
+ do_it = false; |
+ } |
+ // RootWindow will take care of other necessary fields. |
+ if (do_it) |
+ root_window->PostNativeEvent(&xevent); |
sky
2013/01/07 16:06:13
Is PostNativeEvent async? I think this code will r
sschmitz
2013/01/08 22:48:57
Done.
|
+ } |
+#endif |
+ |
return; |
} |