Index: ui/views/cocoa/cocoa_non_client_drag.h |
diff --git a/ui/views/cocoa/cocoa_non_client_drag.h b/ui/views/cocoa/cocoa_non_client_drag.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bbc54443c2083e7383394f1c19bde465c732e7bb |
--- /dev/null |
+++ b/ui/views/cocoa/cocoa_non_client_drag.h |
@@ -0,0 +1,45 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef UI_VIEWS_COCOA_COCOA_NON_CLIENT_DRAG_H_ |
+#define UI_VIEWS_COCOA_COCOA_NON_CLIENT_DRAG_H_ |
+ |
+#include "base/macros.h" |
+#import "ui/views/cocoa/native_widget_mac_nswindow.h" |
+#include "ui/views/views_export.h" |
+ |
+@interface NativeWidgetMacNSWindow (CocoaNonClientDrag) |
tapted
2015/05/20 07:18:17
I don't think this is needed (see later comments)
|
+// Called when the application receives a mouse-down, but before the event |
+// is processed by NSWindows. Returns NO if the event should be processed as-is, |
+// or YES if the event should be reposted to handle window dragging. Events are |
+// reposted at the CGSessionEventTap level because window dragging happens there |
+// before the application receives the event. |
+- (BOOL)willReceiveLeftMouseDown:(NSPoint)locationInWindow; |
+@end |
+ |
+namespace views { |
+ |
+// Support window caption/draggable regions. |
+// In AppKit, non-client regions are set by overriding |
+// -[NSView mouseDownCanMoveWindow]. NSApplication caches this area as views are |
+// installed and performs window moving when mouse-downs land in the area. |
+// In Views, non-client regions are determined via hit-tests when the event |
+// occurs. |
+// To bridge the two models, we monitor mouse-downs with |
+// +[NSEvent addLocalMonitorForEventsMatchingMask:handler:]. This receives |
+// events after window dragging is handled, so for mouse-downs that land on a |
+// draggable point, we cancel the event and repost it at the CGSessionEventTap |
+// level so that window dragging will be handled again. |
+class VIEWS_EXPORT CocoaNonClientDrag { |
jackhou1
2015/05/20 05:50:37
It feels kind of roundabout that a class instantia
|
+ public: |
+ CocoaNonClientDrag(); |
+ ~CocoaNonClientDrag(); |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(CocoaNonClientDrag); |
+}; |
+ |
+} // namespace views |
+ |
+#endif // UI_VIEWS_COCOA_COCOA_NON_CLIENT_DRAG_H_ |