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

Side by Side Diff: ui/views/widget/widget.cc

Issue 1953753002: Turn RootWindowController Menus Async (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « ui/views/widget/native_widget_private.h ('k') | ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/widget.h" 5 #include "ui/views/widget/widget.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 void Widget::OnMouseEvent(ui::MouseEvent* event) { 1164 void Widget::OnMouseEvent(ui::MouseEvent* event) {
1165 View* root_view = GetRootView(); 1165 View* root_view = GetRootView();
1166 switch (event->type()) { 1166 switch (event->type()) {
1167 case ui::ET_MOUSE_PRESSED: { 1167 case ui::ET_MOUSE_PRESSED: {
1168 last_mouse_event_was_move_ = false; 1168 last_mouse_event_was_move_ = false;
1169 1169
1170 // We may get deleted by the time we return from OnMousePressed. So we 1170 // We may get deleted by the time we return from OnMousePressed. So we
1171 // use an observer to make sure we are still alive. 1171 // use an observer to make sure we are still alive.
1172 WidgetDeletionObserver widget_deletion_observer(this); 1172 WidgetDeletionObserver widget_deletion_observer(this);
1173 1173
1174 gfx::NativeView current_capture =
1175 internal::NativeWidgetPrivate::GetGlobalCapture(
1176 native_widget_->GetNativeView());
1174 // Make sure we're still visible before we attempt capture as the mouse 1177 // Make sure we're still visible before we attempt capture as the mouse
1175 // press processing may have made the window hide (as happens with menus). 1178 // press processing may have made the window hide (as happens with menus).
1176 1179 //
1177 // It is possible for a View to show a context menu on mouse-press. Since 1180 // It is possible that capture has changed as a result of a mouse-press.
1178 // the menu does a capture and starts a nested message-loop, the release 1181 // In these cases do not update internal state.
1179 // would go to the menu. The next click (i.e. both mouse-press and release 1182 //
1180 // events) also go to the menu. The menu (and the nested message-loop) 1183 // A mouse-press may trigger a nested message-loop, and absorb the paired
1181 // gets closed after this second release event. The code then resumes from 1184 // release. If so the code returns here. So make sure that that
1182 // here. So make sure that the mouse-button is still down before doing a 1185 // mouse-button is still down before attempting to do a capture.
1183 // capture.
1184 if (root_view && root_view->OnMousePressed(*event) && 1186 if (root_view && root_view->OnMousePressed(*event) &&
1185 widget_deletion_observer.IsWidgetAlive() && IsVisible() && 1187 widget_deletion_observer.IsWidgetAlive() && IsVisible() &&
1186 internal::NativeWidgetPrivate::IsMouseButtonDown()) { 1188 internal::NativeWidgetPrivate::IsMouseButtonDown() &&
1189 current_capture == internal::NativeWidgetPrivate::GetGlobalCapture(
1190 native_widget_->GetNativeView())) {
1187 is_mouse_button_pressed_ = true; 1191 is_mouse_button_pressed_ = true;
1188 if (!native_widget_->HasCapture()) 1192 if (!native_widget_->HasCapture())
1189 native_widget_->SetCapture(); 1193 native_widget_->SetCapture();
1190 event->SetHandled(); 1194 event->SetHandled();
1191 } 1195 }
1192 return; 1196 return;
1193 } 1197 }
1194 1198
1195 case ui::ET_MOUSE_RELEASED: 1199 case ui::ET_MOUSE_RELEASED:
1196 last_mouse_event_was_move_ = false; 1200 last_mouse_event_was_move_ = false;
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 1487
1484 //////////////////////////////////////////////////////////////////////////////// 1488 ////////////////////////////////////////////////////////////////////////////////
1485 // internal::NativeWidgetPrivate, NativeWidget implementation: 1489 // internal::NativeWidgetPrivate, NativeWidget implementation:
1486 1490
1487 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { 1491 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() {
1488 return this; 1492 return this;
1489 } 1493 }
1490 1494
1491 } // namespace internal 1495 } // namespace internal
1492 } // namespace views 1496 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/native_widget_private.h ('k') | ui/views/widget/widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698