| Index: ui/views/cocoa/bridged_native_widget.mm
|
| diff --git a/ui/views/cocoa/bridged_native_widget.mm b/ui/views/cocoa/bridged_native_widget.mm
|
| index 107896f931f200368571f936db5dd58cc4eebeb7..7025517f72ddcaa10cdd2cacc54434678af8a6f5 100644
|
| --- a/ui/views/cocoa/bridged_native_widget.mm
|
| +++ b/ui/views/cocoa/bridged_native_widget.mm
|
| @@ -10,6 +10,7 @@
|
| #include "base/mac/mac_util.h"
|
| #import "base/mac/sdk_forward_declarations.h"
|
| #include "base/thread_task_runner_handle.h"
|
| +#include "ui/base/hit_test.h"
|
| #include "ui/base/ime/input_method.h"
|
| #include "ui/base/ime/input_method_factory.h"
|
| #include "ui/base/ui_base_switches_util.h"
|
| @@ -19,6 +20,7 @@
|
| #import "ui/gfx/mac/nswindow_frame_controls.h"
|
| #include "ui/gfx/screen.h"
|
| #import "ui/views/cocoa/cocoa_mouse_capture.h"
|
| +#import "ui/views/cocoa/cocoa_non_client_drag.h"
|
| #import "ui/views/cocoa/bridged_content_view.h"
|
| #import "ui/views/cocoa/views_nswindow_delegate.h"
|
| #import "ui/views/cocoa/widget_owner_nswindow_adapter.h"
|
| @@ -92,6 +94,7 @@ gfx::Size BridgedNativeWidget::GetWindowSizeForClientSize(
|
|
|
| BridgedNativeWidget::BridgedNativeWidget(NativeWidgetMac* parent)
|
| : native_widget_mac_(parent),
|
| + non_client_drag_(new CocoaNonClientDrag()),
|
| focus_manager_(nullptr),
|
| widget_type_(Widget::InitParams::TYPE_WINDOW), // Updated in Init().
|
| parent_(nullptr),
|
| @@ -522,6 +525,71 @@ void BridgedNativeWidget::OnWindowKeyStatusChangedTo(bool is_key) {
|
| }
|
| }
|
|
|
| +bool BridgedNativeWidget::OnWindowWillReceiveLeftMouseDown(
|
| + NSPoint location_in_window) {
|
| + bool was_draggable = draggable_;
|
| + gfx::Point point(location_in_window.x,
|
| + NSHeight([window_ frame]) - location_in_window.y);
|
| + draggable_ = native_widget_mac()->GetWidget()->GetNonClientComponent(point) ==
|
| + HTCAPTION;
|
| + LOG(INFO) << "OnWindowWillReceiveLeftMouseDown " << location_in_window.x
|
| + << ", " << location_in_window.y << " " << was_draggable << " "
|
| + << draggable_;
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// Behavior when using CGEventTap.
|
| +/*
|
| + // If draggability has not changed, do nothing.
|
| + if (was_draggable == draggable_)
|
| + return false;
|
| +
|
| + // Otherwise, either make the window draggable or non-draggable, then return
|
| + // true to repost the event.
|
| + NSView* content_view = [window_ contentView];
|
| + if (draggable_) {
|
| + NSView* mask_view = nil;
|
| + for (NSView* view in [content_view subviews]) {
|
| + if ([view isKindOfClass:[CocoaNonClientDragMaskView class]])
|
| + mask_view = view;
|
| + }
|
| + [mask_view removeFromSuperview];
|
| + } else {
|
| + base::scoped_nsobject<CocoaNonClientDragMaskView> mask_view(
|
| + [[CocoaNonClientDragMaskView alloc]
|
| + initWithFrame:[content_view bounds]]);
|
| + [content_view addSubview:mask_view];
|
| + }
|
| + return true;
|
| +*/
|
| +//
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +// Behavior when using NSEvent local monitor.
|
| + NSView* content_view = [window_ contentView];
|
| + if (was_draggable) {
|
| + // This is a re-post, the movement has already completed, so we can make the
|
| + // window non-draggable again.
|
| + draggable_ = false;
|
| + base::scoped_nsobject<CocoaNonClientDragMaskView> mask_view(
|
| + [[CocoaNonClientDragMaskView alloc]
|
| + initWithFrame:[content_view bounds]]);
|
| + [content_view addSubview:mask_view];
|
| + return false;
|
| + }
|
| +
|
| + if (draggable_) {
|
| + // Make the window draggable, then return true to repost the event.
|
| + NSView* mask_view = nil;
|
| + for (NSView* view in [content_view subviews]) {
|
| + if ([view isKindOfClass:[CocoaNonClientDragMaskView class]])
|
| + mask_view = view;
|
| + }
|
| + [mask_view removeFromSuperview];
|
| + return true;
|
| + }
|
| + return false;
|
| +//
|
| +////////////////////////////////////////////////////////////////////////////////
|
| +}
|
| +
|
| void BridgedNativeWidget::OnSizeConstraintsChanged() {
|
| NSWindow* window = ns_window();
|
| Widget* widget = native_widget_mac()->GetWidget();
|
|
|