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

Unified Diff: ui/views/cocoa/bridged_content_view.mm

Issue 1747803003: MacViews: Implement Tab Dragging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace GCD with DelegateSimpleThread, remove ConstrainToEnclosingRect function, cleanup code. Created 4 years, 8 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
Index: ui/views/cocoa/bridged_content_view.mm
diff --git a/ui/views/cocoa/bridged_content_view.mm b/ui/views/cocoa/bridged_content_view.mm
index 6d72fef5cf7ece1d35262f4b7b1a572622710f05..e7df206f2a659b7ed6c4b1a0360913acd8f5aa09 100644
--- a/ui/views/cocoa/bridged_content_view.mm
+++ b/ui/views/cocoa/bridged_content_view.mm
@@ -23,6 +23,7 @@
#import "ui/gfx/path_mac.h"
#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
#include "ui/strings/grit/ui_strings.h"
+#include "ui/views/cocoa/cocoa_window_move_loop.h"
#include "ui/views/controls/menu/menu_config.h"
#include "ui/views/controls/menu/menu_controller.h"
#include "ui/views/view.h"
@@ -32,6 +33,13 @@ using views::MenuController;
namespace {
+// We're sending simulated mouse events in CocoaWindowMoveLoop, and don't want
+// BridgedContentView to react when we're starting/ending the RunMoveLoop.
+// When reattaching the dragged tab we're sending the mouse down event to the
+// parent window we don't have the pointer to, so this flag is global for the
+// RunMoveLoop.
+bool g_ignore_mouse_events = false;
+
// Returns true if all four corners of |rect| are contained inside |path|.
bool IsRectInsidePath(NSRect rect, NSBezierPath* path) {
return [path containsPoint:rect.origin] &&
@@ -225,6 +233,10 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client,
return self;
}
++ (void)setIgnoreMouseEvents:(BOOL)flag {
+ g_ignore_mouse_events = flag;
+}
+
- (void)clearView {
textInputClient_ = nullptr;
hostedView_ = nullptr;
@@ -233,6 +245,11 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client,
}
- (void)processCapturedMouseEvent:(NSEvent*)theEvent {
+ if (CGEventGetIntegerValueField([theEvent CGEvent], kCGEventSourceUserData) ==
+ views::CocoaWindowMoveLoop::kCocoaWindowMoveLoopSimulatedEventUserData) {
+ return;
+ }
+
if (!hostedView_)
return;
@@ -391,7 +408,12 @@ gfx::Rect GetFirstRectForRangeHelper(const ui::TextInputClient* client,
// Translates the location of |theEvent| to toolkit-views coordinates and passes
// the event to NativeWidgetMac for handling.
- (void)mouseEvent:(NSEvent*)theEvent {
- if (!hostedView_)
+ if (CGEventGetIntegerValueField([theEvent CGEvent], kCGEventSourceUserData) ==
+ views::CocoaWindowMoveLoop::kCocoaWindowMoveLoopSimulatedEventUserData) {
+ return;
+ }
+
+ if (!hostedView_ || g_ignore_mouse_events)
return;
ui::MouseEvent event(theEvent);

Powered by Google App Engine
This is Rietveld 408576698