[haiku-webkit-commits] r368 - webkit/trunk/WebKit/haiku/WebPositive

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Fri, 02 Apr 2010 21:16:25 +0000

Author: stippi
Date: Fri Apr  2 21:16:25 2010
New Revision: 368
URL: http://mmlr.dyndns.org/changeset/368

Log:
Replace the previous resize request implementation by a more advanced one:
* Ignore resize requests when the window has more than one tab at all.
* Make sure the new size is not larger than the screen and shift the window so
  everything is visible.

Modified:
   webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp

Modified: webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Fri Apr  2 
18:02:42 2010        (r367)
+++ webkit/trunk/WebKit/haiku/WebPositive/BrowserWindow.cpp     Fri Apr  2 
21:16:25 2010        (r368)
@@ -60,6 +60,7 @@
 #include <NodeInfo.h>
 #include <Path.h>
 #include <Roster.h>
+#include <Screen.h>
 #include <SeparatorView.h>
 #include <SpaceLayoutItem.h>
 #include <StatusBar.h>
@@ -953,8 +954,41 @@
        if (view != CurrentWebView())
                return;
 
-       // TODO: Ignore request when there is more than one BWebView embedded!
+       // Ignore request when there is more than one BWebView embedded.
+       if (fTabManager->CountTabs() > 1)
+               return;
+
+       // Make sure the new frame is not larger than the screen frame minus
+       // window decorator border.
+       BScreen screen(this);
+       BRect screenFrame = screen.Frame();
+       BRect decoratorFrame = DecoratorFrame();
+       BRect frame = Frame();
+
+       screenFrame.left += decoratorFrame.left - frame.left;
+       screenFrame.right += decoratorFrame.right - frame.right;
+       screenFrame.top += decoratorFrame.top - frame.top;
+       screenFrame.bottom += decoratorFrame.bottom - frame.bottom;
+
+       width = min_c(width, screen.Frame().Width());
+       height = min_c(height, screen.Frame().Height());
+
+       frame.right = frame.left + width;
+       frame.bottom = frame.top + height;
+
+       // frame is now not larger than screenFrame, but may still be partly 
outside
+       if (!screenFrame.Contains(frame)) {
+               if (frame.left < screenFrame.left)
+                       frame.OffsetBy(screenFrame.left - frame.left, 0);
+               else if (frame.right > screenFrame.right)
+                       frame.OffsetBy(screenFrame.right - frame.right, 0);
+               if (frame.top < screenFrame.top)
+                       frame.OffsetBy(screenFrame.top - frame.top, 0);
+               else if (frame.bottom > screenFrame.bottom)
+                       frame.OffsetBy(screenFrame.bottom - frame.bottom, 0);
+       }
 
+       MoveTo(frame.left, frame.top);
        ResizeTo(width, height);
 }
 

Other related posts:

  • » [haiku-webkit-commits] r368 - webkit/trunk/WebKit/haiku/WebPositive - webkit