report correct content size in AtomNSWindow
The views framework relies on NSWindow to return content size of window, since we don't use the borderless window, the original result would include titlebar. We have to override the function to return correct result for frameless window.
This commit is contained in:
parent
28fc58067b
commit
5547df6073
5 changed files with 35 additions and 14 deletions
|
@ -7,6 +7,7 @@
|
|||
#include "atom/browser/native_window_mac.h"
|
||||
#include "atom/browser/ui/cocoa/atom_preview_item.h"
|
||||
#include "atom/browser/ui/cocoa/atom_touch_bar.h"
|
||||
#include "ui/base/cocoa/window_size_constants.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -23,14 +24,25 @@ bool ScopedDisableResize::disable_resize_ = false;
|
|||
@synthesize windowButtonsOffset;
|
||||
@synthesize vibrantView;
|
||||
|
||||
- (void)setShell:(atom::NativeWindowMac*)shell {
|
||||
shell_ = shell;
|
||||
- (id)initWithShell:(atom::NativeWindowMac*)shell
|
||||
styleMask:(NSUInteger)styleMask {
|
||||
if ((self = [super initWithContentRect:ui::kWindowSizeDeterminedLater
|
||||
styleMask:styleMask
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:YES])) {
|
||||
shell_ = shell;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (atom::NativeWindowMac*)shell {
|
||||
return shell_;
|
||||
}
|
||||
|
||||
- (NSRect)originalContentRectForFrameRect:(NSRect)frameRect {
|
||||
return [super contentRectForFrameRect:frameRect];
|
||||
}
|
||||
|
||||
- (NSTouchBar*)makeTouchBar API_AVAILABLE(macosx(10.12.2)) {
|
||||
if (shell_->touch_bar())
|
||||
return [shell_->touch_bar() makeTouchBar];
|
||||
|
@ -52,6 +64,13 @@ bool ScopedDisableResize::disable_resize_ = false;
|
|||
}
|
||||
}
|
||||
|
||||
- (NSRect)contentRectForFrameRect:(NSRect)frameRect {
|
||||
if (shell_->has_frame())
|
||||
return [super contentRectForFrameRect:frameRect];
|
||||
else
|
||||
return frameRect;
|
||||
}
|
||||
|
||||
- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen*)screen {
|
||||
// Resizing is disabled.
|
||||
if (atom::ScopedDisableResize::IsResizeDisabled())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue