]> khamidou — GitHub mirrors - electron.git/commitdiff
gtk: Fix setting content size.
authorCheng Zhao <zcbenz@gmail.com>
Thu, 15 May 2014 08:27:18 +0000 (16:27 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 15 May 2014 08:27:18 +0000 (16:27 +0800)
atom/browser/native_window_gtk.cc

index f07d4cb85407a29bafd2bdf0a293e2fc88cfb3ef..205201e5b7f222eecaa8fc81d58103742a48edec 100644 (file)
@@ -263,8 +263,15 @@ gfx::Size NativeWindowGtk::GetSize() {
 }
 
 void NativeWindowGtk::SetContentSize(const gfx::Size& size) {
-  GtkAllocation size = { 0, 0, size.width(), size.height() };
-  gtk_widget_size_allocate(GetWebContents()->GetView()->GetNativeView(), &size);
+  if (!has_frame_ || !has_ever_been_shown_) {
+    gtk_window_util::SetWindowSize(window_, size);
+  } else {
+    gfx::Size window_size = GetSize();
+    gfx::Size content_size = GetContentSize();
+    gfx::Size target(size.width() + window_size.width() - content_size.width(),
+                     size.height() + window_size.height() - content_size.height());
+    gtk_window_util::SetWindowSize(window_, target);
+  }
 }
 
 gfx::Size NativeWindowGtk::GetContentSize() {