Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Unified Diff: ui/views/controls/menu/menu_controller.cc

Issue 11761027: context menu does not work if one already open (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: test Created 7 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698