From: Cheng Zhao Date: Thu, 18 Jun 2015 08:17:13 +0000 (+0800) Subject: win: Fix setContentSize changing window position X-Git-Tag: v0.28.3~14 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=19436358fb91638bedacd5309ed537d7c8b017e9;p=electron.git win: Fix setContentSize changing window position Close #1934. --- diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 697d0779..52309ba2 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -945,6 +945,7 @@ void NativeWindowViews::RegisterAccelerators(ui::MenuModel* menu_model) { gfx::Rect NativeWindowViews::ContentBoundsToWindowBounds( const gfx::Rect& bounds) { + gfx::Point origin = bounds.origin(); #if defined(OS_WIN) gfx::Rect dpi_bounds = gfx::win::DIPToScreenRect(bounds); gfx::Rect window_bounds = gfx::win::ScreenToDIPRect( @@ -953,6 +954,9 @@ gfx::Rect NativeWindowViews::ContentBoundsToWindowBounds( gfx::Rect window_bounds = window_->non_client_view()->GetWindowBoundsForClientBounds(bounds); #endif + // The window's position would also be changed, but we only want to change + // the size. + window_bounds.set_origin(origin); if (menu_bar_ && menu_bar_visible_) window_bounds.set_height(window_bounds.height() + kMenuBarHeight);