Commit 07c50437 authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Revert "Make all MacViews windows potentially draggable."

This reverts commit 330fc4a1.

Reason for revert: speculative revert to fix views_unittests (https://bugs.chromium.org/p/chromium/issues/detail?id=859829).

Original change's description:
> Make all MacViews windows potentially draggable.
>
> This fixes the PiP window not being draggable on Mac.
>
> Bug: 849983
> Change-Id: I1b0f503de1a1f154f23afd1870943a6b7009be75
> Reviewed-on: https://chromium-review.googlesource.com/1121145
> Commit-Queue: Sidney San Martín <sdy@chromium.org>
> Reviewed-by: Avi Drissman <avi@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#572038}

TBR=avi@chromium.org,sdy@chromium.org

Change-Id: Ic1e718a03d272c2c1b4646ead018ad776d03fd18
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 849983,859829
Reviewed-on: https://chromium-review.googlesource.com/1124299
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572161}
parent ce19c6d8
......@@ -15,13 +15,19 @@
@interface NSWindow (PrivateAPI)
+ (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle;
// Available in later point releases of 10.10. On 10.11+, use the public
// -performWindowDragWithEvent: instead.
- (void)beginWindowDragWithEvent:(NSEvent*)event;
@end
@interface NSThemeFrame (PrivateAPI)
// Weak lets Chrome launch even if a future macOS doesn't have NSThemeFrame.
WEAK_IMPORT_ATTRIBUTE
@interface NSThemeFrame : NSView
- (CGFloat)_titlebarHeight;
@end
@interface BrowserWindowFrame : NativeWidgetMacNSWindowTitledFrame
@interface BrowserWindowFrame : NSThemeFrame
@end
@implementation BrowserWindowFrame
......@@ -72,6 +78,20 @@
return NSZeroRect;
}
// Lets the window be dragged by its title bar on 10.11 and older.
- (void)mouseDown:(NSEvent*)event {
if (@available(macOS 10.12, *))
; // Not needed on 10.12 and up.
else if (@available(macOS 10.11, *))
[self.window performWindowDragWithEvent:event];
else if ([self.window
respondsToSelector:@selector(beginWindowDragWithEvent:)])
[self.window beginWindowDragWithEvent:event];
else
NOTREACHED();
[super mouseDown:event];
}
@end
@implementation BrowserNativeWidgetWindow
......@@ -87,6 +107,13 @@
return [super frameViewClassForStyleMask:windowStyle];
}
// The base implementation returns YES if the window's frame view is a custom
// class, which causes undesirable changes in behavior. AppKit NSWindow
// subclasses are known to override it and return NO.
- (BOOL)_usesCustomDrawing {
return NO;
}
// Handle "Move focus to the window toolbar" configured in System Preferences ->
// Keyboard -> Shortcuts -> Keyboard. Usually Ctrl+F5. The argument (|unknown|)
// tends to just be nil.
......
......@@ -6,13 +6,31 @@
@interface NSWindow (PrivateAPI)
+ (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle;
- (void)beginWindowDragWithEvent:(NSEvent*)event
NS_DEPRECATED_MAC(10_10, 10_11, "Use performWindowDragWithEvent: instead.");
@end
@interface NativeWidgetMacFramelessNSWindowFrame
: NativeWidgetMacNSWindowTitledFrame
// Weak lets Chrome launch even if a future macOS doesn't have NSThemeFrame.
WEAK_IMPORT_ATTRIBUTE
@interface NSThemeFrame : NSView
@end
@interface NativeWidgetMacFramelessNSWindowFrame : NSThemeFrame
@end
@implementation NativeWidgetMacFramelessNSWindowFrame
// If a mouseDown: falls through to the frame view, turn it into a window drag.
- (void)mouseDown:(NSEvent*)event {
if (@available(macOS 10.11, *))
[self.window performWindowDragWithEvent:event];
else if (@available(macOS 10.10, *))
[self.window beginWindowDragWithEvent:event];
else
NOTREACHED();
[super mouseDown:event];
}
- (BOOL)_hidingTitlebar {
return YES;
}
......@@ -27,4 +45,8 @@
return [super frameViewClassForStyleMask:windowStyle];
}
- (BOOL)_usesCustomDrawing {
return NO;
}
@end
......@@ -12,24 +12,6 @@
@protocol WindowTouchBarDelegate;
// Weak lets Chrome launch even if a future macOS doesn't have the below classes
WEAK_IMPORT_ATTRIBUTE
@interface NSNextStepFrame : NSView
@end
WEAK_IMPORT_ATTRIBUTE
@interface NSThemeFrame : NSView
@end
VIEWS_EXPORT
@interface NativeWidgetMacNSWindowBorderlessFrame : NSNextStepFrame
@end
VIEWS_EXPORT
@interface NativeWidgetMacNSWindowTitledFrame : NSThemeFrame
@end
// The NSWindow used by BridgedNativeWidget. Provides hooks into AppKit that
// can only be accomplished by overriding methods.
VIEWS_EXPORT
......
......@@ -15,12 +15,7 @@
#include "ui/views/widget/widget_delegate.h"
@interface NSWindow (Private)
+ (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle;
- (BOOL)hasKeyAppearance;
// Available in later point releases of 10.10. On 10.11+, use the public
// -performWindowDragWithEvent: instead.
- (void)beginWindowDragWithEvent:(NSEvent*)event;
@end
@interface NativeWidgetMacNSWindow ()
......@@ -34,38 +29,6 @@
- (BOOL)_isTitleHidden;
@end
// Use this category to implement mouseDown: on multiple frame view classes
// with different superclasses.
@interface NSView (CRFrameViewAdditions)
- (void)cr_mouseDownOnFrameView:(NSEvent*)event;
@end
@implementation NSView (CRFrameViewAdditions)
// If a mouseDown: falls through to the frame view, turn it into a window drag.
- (void)cr_mouseDownOnFrameView:(NSEvent*)event {
if (@available(macOS 10.11, *))
return [self.window performWindowDragWithEvent:event];
else if ([self.window
respondsToSelector:@selector(beginWindowDragWithEvent:)])
return [self.window beginWindowDragWithEvent:event];
else
NOTREACHED();
[super mouseDown:event];
}
@end
@implementation NativeWidgetMacNSWindowTitledFrame
- (void)mouseDown:(NSEvent*)event {
[self cr_mouseDownOnFrameView:event];
}
@end
@implementation NativeWidgetMacNSWindowBorderlessFrame
- (void)mouseDown:(NSEvent*)event {
[self cr_mouseDownOnFrameView:event];
}
@end
@implementation NativeWidgetMacNSWindow {
@private
base::scoped_nsobject<CommandDispatcher> commandDispatcher_;
......@@ -136,17 +99,6 @@
// NSWindow overrides.
+ (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle {
if (windowStyle & NSWindowStyleMaskTitled) {
if (Class customFrame = [NativeWidgetMacNSWindowTitledFrame class])
return customFrame;
} else if (Class customFrame =
[NativeWidgetMacNSWindowBorderlessFrame class]) {
return customFrame;
}
return [super frameViewClassForStyleMask:windowStyle];
}
- (BOOL)_isTitleHidden {
if (![self delegate])
return NO;
......@@ -154,13 +106,6 @@
return ![self viewsWidget]->widget_delegate()->ShouldShowWindowTitle();
}
// The base implementation returns YES if the window's frame view is a custom
// class, which causes undesirable changes in behavior. AppKit NSWindow
// subclasses are known to override it and return NO.
- (BOOL)_usesCustomDrawing {
return NO;
}
// Ignore [super canBecome{Key,Main}Window]. The default is NO for windows with
// NSBorderlessWindowMask, which is not the desired behavior.
// Note these can be called via -[NSWindow close] while the widget is being torn
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment