]> khamidou — GitHub mirrors - electron.git/commitdiff
removed move utility and replaced with setbounds
authordeepak1556 <hop2deep@gmail.com>
Fri, 1 May 2015 14:40:46 +0000 (20:10 +0530)
committerdeepak1556 <hop2deep@gmail.com>
Fri, 1 May 2015 14:40:46 +0000 (20:10 +0530)
atom/browser/native_window.cc
atom/browser/native_window.h
atom/browser/native_window_mac.h
atom/browser/native_window_mac.mm
atom/browser/native_window_views.cc
atom/browser/native_window_views.h

index 0f757e8c619f4ad893519aeb004f5fb9fecb93ea..2920178058df060c2f083eb942ece1b631e7dc7e 100644 (file)
@@ -192,7 +192,7 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
     int width = -1, height = -1;
     options.Get(switches::kWidth, &width);
     options.Get(switches::kHeight, &height);
-    Move(gfx::Rect(x, y, width, height));
+    SetBounds(gfx::Rect(x, y, width, height));
   } else if (options.Get(switches::kCenter, &center) && center) {
     Center();
   }
@@ -646,8 +646,7 @@ void NativeWindow::DeactivateContents(content::WebContents* contents) {
 
 void NativeWindow::MoveContents(content::WebContents* source,
                                 const gfx::Rect& pos) {
-  SetPosition(pos.origin());
-  SetSize(pos.size());
+  SetBounds(pos);
 }
 
 void NativeWindow::CloseContents(content::WebContents* source) {
index d04769f171f8c47a254076d5f5e6a358c1b00307..72056715837aa2c939cdfc6e3928646676be7879 100644 (file)
@@ -98,7 +98,6 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
 
   virtual void Close() = 0;
   virtual void CloseImmediately() = 0;
-  virtual void Move(const gfx::Rect& pos) = 0;
   virtual void Focus(bool focus) = 0;
   virtual bool IsFocused() = 0;
   virtual void Show() = 0;
index 24d52664a0507d232648311fe710ccbcf8326b31..0fa3fe9cce4274fc809099ab8e3293ef3c1c3460 100644 (file)
@@ -30,7 +30,6 @@ class NativeWindowMac : public NativeWindow {
   // NativeWindow implementation.
   void Close() override;
   void CloseImmediately() override;
-  void Move(const gfx::Rect& pos) override;
   void Focus(bool focus) override;
   bool IsFocused() override;
   void Show() override;
@@ -46,7 +45,7 @@ class NativeWindowMac : public NativeWindow {
   void SetFullScreen(bool fullscreen) override;
   bool IsFullscreen() const override;
   void SetBounds(const gfx::Rect& bounds) override;
-  gfx::Rect GetBounds() override;  
+  gfx::Rect GetBounds() override;
   void SetSize(const gfx::Size& size) override;
   gfx::Size GetSize() override;
   void SetContentSize(const gfx::Size& size) override;
index d1cb82a2f4f19fa50bb24a89c526f12bab86426e..e2b58e96c7f786117f87a3f0abca9c46c933d703 100644 (file)
@@ -382,18 +382,6 @@ void NativeWindowMac::CloseImmediately() {
   [window_ close];
 }
 
-void NativeWindowMac::Move(const gfx::Rect& pos) {
-  NSRect cocoa_bounds = NSMakeRect(pos.x(), 0,
-                                   pos.width(),
-                                   pos.height());
-  // Flip coordinates based on the primary screen.
-  NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
-  cocoa_bounds.origin.y =
-      NSHeight([screen frame]) - pos.height() - pos.y();
-
-  [window_ setFrame:cocoa_bounds display:YES];
-}
-
 void NativeWindowMac::Focus(bool focus) {
   if (!IsVisible())
     return;
@@ -471,12 +459,26 @@ bool NativeWindowMac::IsFullscreen() const {
 }
 
 void NativeWindowMac::SetBounds(const gfx::Rect& bounds) {
-  Move(bounds);
+  NSRect cocoa_bounds = NSMakeRect(bounds.x(), 0,
+                                   bounds.width(),
+                                   bounds.height());
+  // Flip coordinates based on the primary screen.
+  NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+  cocoa_bounds.origin.y =
+      NSHeight([screen frame]) - bounds.height() - bounds.y();
+
+  [window_ setFrame:cocoa_bounds display:YES];
 }
 
 gfx::Rect NativeWindowMac::GetBounds() {
-  return gfx::Rect(GetPosition(),
-                   GetSize());
+  NSRect frame = [window_ frame];
+  NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
+
+  gfx::Point pos(frame.origin.x,
+      NSHeight([screen frame]) - frame.origin.y - frame.size.height);
+  gfx::Size size(frame.size.width, frame.size.height);
+
+  return gfx::Rect(pos, size);
 }
 
 void NativeWindowMac::SetSize(const gfx::Size& size) {
@@ -489,8 +491,7 @@ void NativeWindowMac::SetSize(const gfx::Size& size) {
 }
 
 gfx::Size NativeWindowMac::GetSize() {
-  NSRect frame = [window_ frame];
-  return gfx::Size(frame.size.width, frame.size.height);
+  return GetBounds().size();
 }
 
 void NativeWindowMac::SetContentSize(const gfx::Size& size) {
@@ -564,15 +565,11 @@ void NativeWindowMac::Center() {
 }
 
 void NativeWindowMac::SetPosition(const gfx::Point& position) {
-  Move(gfx::Rect(position, GetSize()));
+  SetBounds(gfx::Rect(position, GetSize()));
 }
 
 gfx::Point NativeWindowMac::GetPosition() {
-  NSRect frame = [window_ frame];
-  NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
-
-  return gfx::Point(frame.origin.x,
-      NSHeight([screen frame]) - frame.origin.y - frame.size.height);
+  return GetBounds().origin();
 }
 
 void NativeWindowMac::SetTitle(const std::string& title) {
index d8eed64009c13678eff4affb9d20b398feb0753e..3b283ddbecf4adf4b4ec64646c7a74024d97a396 100644 (file)
@@ -291,10 +291,6 @@ void NativeWindowViews::CloseImmediately() {
   window_->CloseNow();
 }
 
-void NativeWindowViews::Move(const gfx::Rect& bounds) {
-  window_->SetBounds(bounds);
-}
-
 void NativeWindowViews::Focus(bool focus) {
   if (focus)
     window_->Activate();
@@ -374,11 +370,25 @@ bool NativeWindowViews::IsFullscreen() const {
 }
 
 void NativeWindowViews::SetBounds(const gfx::Rect& bounds) {
-  window_->SetBoundsConstrained(bounds);
+#if defined(USE_X11)
+  // On Linux the minimum and maximum size should be updated with window size
+  // when window is not resizable.
+  if (!resizable_) {
+    SetMaximumSize(bounds.size());
+    SetMinimumSize(bounds.size());
+  }
+#endif
+
+  window_->SetBounds(bounds);
 }
 
 gfx::Rect NativeWindowViews::GetBounds() {
-  return window_->GetRestoredBounds();
+#if defined(OS_WIN)
+  if (IsMinimized())
+    return window_->GetRestoredBounds();
+#endif
+
+  return window_->GetWindowBoundsInScreen();
 }
 
 void NativeWindowViews::SetSize(const gfx::Size& size) {
@@ -395,12 +405,7 @@ void NativeWindowViews::SetSize(const gfx::Size& size) {
 }
 
 gfx::Size NativeWindowViews::GetSize() {
-#if defined(OS_WIN)
-  if (IsMinimized())
-    return window_->GetRestoredBounds().size();
-#endif
-
-  return window_->GetWindowBoundsInScreen().size();
+  return GetBounds().size();
 }
 
 void NativeWindowViews::SetContentSize(const gfx::Size& size) {
index 020e349332bfbea70ecd9af6d60692a30fde3b57..978aac826272456b3e2e4a9c73df7e0d276dde3a 100644 (file)
@@ -35,7 +35,6 @@ class NativeWindowViews : public NativeWindow,
   // NativeWindow:
   void Close() override;
   void CloseImmediately() override;
-  void Move(const gfx::Rect& pos) override;
   void Focus(bool focus) override;
   bool IsFocused() override;
   void Show() override;