From f25cf7481fc310afbd32d1954e56e43f40ef7027 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 21 Jul 2015 10:16:02 +0800 Subject: [PATCH 1/3] spec: Test setContentSize for frameless window --- spec/api-browser-window-spec.coffee | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/api-browser-window-spec.coffee b/spec/api-browser-window-spec.coffee index ce1282439a2..c6325426177 100644 --- a/spec/api-browser-window-spec.coffee +++ b/spec/api-browser-window-spec.coffee @@ -117,6 +117,15 @@ describe 'browser-window module', -> assert.equal after[0], size[0] assert.equal after[1], size[1] + it 'works for framless window', -> + w.destroy() + w = new BrowserWindow(show: false, frame: false, width: 400, height: 400) + size = [400, 400] + w.setContentSize size[0], size[1] + after = w.getContentSize() + assert.equal after[0], size[0] + assert.equal after[1], size[1] + describe 'BrowserWindow.fromId(id)', -> it 'returns the window with id', -> assert.equal w.id, BrowserWindow.fromId(w.id).id @@ -134,6 +143,16 @@ describe 'browser-window module', -> assert.equal size[0], 400 assert.equal size[1], 400 + it 'works for framless window', -> + w.destroy() + w = new BrowserWindow(show: false, frame: false, width: 400, height: 400, 'use-content-size': true) + contentSize = w.getContentSize() + assert.equal contentSize[0], 400 + assert.equal contentSize[1], 400 + size = w.getSize() + assert.equal size[0], 400 + assert.equal size[1], 400 + describe '"enable-larger-than-screen" option', -> return if process.platform is 'linux' From 3ea878941b7fcc7110cc26bd4f256d9f769a5fe0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 21 Jul 2015 10:29:05 +0800 Subject: [PATCH 2/3] mac: Always call SetSize for framless window --- atom/browser/native_window_mac.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index c0d358bb8f7..8d5cf7d414c 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -357,7 +357,7 @@ NativeWindowMac::NativeWindowMac( // On OS X the initial window size doesn't include window frame. bool use_content_size = false; options.Get(switches::kUseContentSize, &use_content_size); - if (has_frame_ && !use_content_size) + if (!has_frame_ || !use_content_size) SetSize(gfx::Size(width, height)); // Enable the NSView to accept first mouse event. @@ -494,6 +494,11 @@ gfx::Rect NativeWindowMac::GetBounds() { } void NativeWindowMac::SetContentSize(const gfx::Size& size) { + if (!has_frame_) { + SetSize(size); + return; + } + NSRect frame_nsrect = [window_ frame]; NSSize frame = frame_nsrect.size; NSSize content = [window_ contentRectForFrameRect:frame_nsrect].size; From 891d107a5169875634d260f5375aead19249db6d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 21 Jul 2015 10:34:37 +0800 Subject: [PATCH 3/3] mac: Always use GetSize for frameless window --- atom/browser/native_window_mac.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 8d5cf7d414c..a4c6ee03876 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -512,6 +512,9 @@ void NativeWindowMac::SetContentSize(const gfx::Size& size) { } gfx::Size NativeWindowMac::GetContentSize() { + if (!has_frame_) + return GetSize(); + NSRect bounds = [[window_ contentView] bounds]; return gfx::Size(bounds.size.width, bounds.size.height); }