| Index: ui/views/view.cc
|
| diff --git a/ui/views/view.cc b/ui/views/view.cc
|
| index 6fbd5971f8ec53e09ff2771b3c07154d95585a41..431c42c43cc41403d845669f5e20f483a4a24cf6 100644
|
| --- a/ui/views/view.cc
|
| +++ b/ui/views/view.cc
|
| @@ -57,6 +57,12 @@ bool use_acceleration_when_possible = true;
|
| bool use_acceleration_when_possible = false;
|
| #endif
|
|
|
| +#if defined(OS_WIN)
|
| +const bool kContextMenuOnMousePress = false;
|
| +#else
|
| +const bool kContextMenuOnMousePress = true;
|
| +#endif
|
| +
|
| // Saves the drawing state, and restores the state when going out of scope.
|
| class ScopedCanvas {
|
| public:
|
| @@ -1130,6 +1136,11 @@ void View::ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) {
|
| context_menu_controller_->ShowContextMenuForView(this, p);
|
| }
|
|
|
| +// static
|
| +bool View::ShouldShowContextMenuOnMousePress() {
|
| + return kContextMenuOnMousePress;
|
| +}
|
| +
|
| // Drag and drop ---------------------------------------------------------------
|
|
|
| bool View::GetDropFormats(
|
| @@ -2060,16 +2071,29 @@ bool View::ProcessMousePressed(const ui::MouseEvent& event) {
|
| GetDragOperations(event.location()) : 0;
|
| ContextMenuController* context_menu_controller = event.IsRightMouseButton() ?
|
| context_menu_controller_ : 0;
|
| + View::DragInfo* drag_info = GetDragInfo();
|
|
|
| const bool enabled = enabled_;
|
| const bool result = OnMousePressed(event);
|
| - // WARNING: we may have been deleted, don't use any View variables.
|
|
|
| if (!enabled)
|
| return result;
|
|
|
| + if (event.IsOnlyRightMouseButton() && context_menu_controller &&
|
| + kContextMenuOnMousePress) {
|
| + // Assume that if there is a context menu controller we won't be deleted
|
| + // from mouse pressed.
|
| + gfx::Point location(event.location());
|
| + if (HitTestPoint(location)) {
|
| + ConvertPointToScreen(this, &location);
|
| + ShowContextMenu(location, true);
|
| + return true;
|
| + }
|
| + }
|
| +
|
| + // WARNING: we may have been deleted, don't use any View variables.
|
| if (drag_operations != ui::DragDropTypes::DRAG_NONE) {
|
| - GetDragInfo()->PossibleDrag(event.location());
|
| + drag_info->PossibleDrag(event.location());
|
| return true;
|
| }
|
| return !!context_menu_controller || result;
|
| @@ -2098,7 +2122,8 @@ bool View::ProcessMouseDragged(const ui::MouseEvent& event) {
|
| }
|
|
|
| void View::ProcessMouseReleased(const ui::MouseEvent& event) {
|
| - if (context_menu_controller_ && event.IsOnlyRightMouseButton()) {
|
| + if (!kContextMenuOnMousePress && context_menu_controller_ &&
|
| + event.IsOnlyRightMouseButton()) {
|
| // Assume that if there is a context menu controller we won't be deleted
|
| // from mouse released.
|
| gfx::Point location(event.location());
|
|
|