]> git.saurik.com Git - wxWidgets.git/commitdiff
position the popup on the correct screen (see #10462)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 1 Feb 2009 12:42:49 +0000 (12:42 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 1 Feb 2009 12:42:49 +0000 (12:42 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58592 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/popupcmn.cpp

index a0480aea56e14017457ca45438123f8069bf8f1e..bc28d8708ec0a65104cc1a536330209f3a73311e 100644 (file)
@@ -34,6 +34,7 @@
     #include "wx/log.h"
 #endif //WX_PRECOMP
 
+#include "wx/display.h"
 #include "wx/recguard.h"
 
 #ifdef __WXUNIVERSAL__
@@ -134,8 +135,26 @@ bool wxPopupWindowBase::Create(wxWindow* WXUNUSED(parent), int WXUNUSED(flags))
 void wxPopupWindowBase::Position(const wxPoint& ptOrigin,
                                  const wxSize& size)
 {
-    wxSize sizeScreen = wxGetDisplaySize(),
-           sizeSelf = GetSize();
+    // determine the position and size of the screen we clamp the popup to
+    wxPoint posScreen;
+    wxSize sizeScreen;
+
+    const int displayNum = wxDisplay::GetFromPoint(ptOrigin);
+    if ( displayNum != wxNOT_FOUND )
+    {
+        const wxRect rectScreen = wxDisplay(displayNum).GetGeometry();
+        posScreen = rectScreen.GetPosition();
+        sizeScreen = rectScreen.GetSize();
+    }
+    else // outside of any display?
+    {
+        // just use the primary one then
+        posScreen = wxPoint(0, 0);
+        sizeScreen = wxGetDisplaySize();
+    }
+
+
+    const wxSize sizeSelf = GetSize();
 
     // is there enough space to put the popup below the window (where we put it
     // by default)?
@@ -153,7 +172,7 @@ void wxPopupWindowBase::Position(const wxPoint& ptOrigin,
 
     // now check left/right too
     wxCoord x = ptOrigin.x;
-            
+
     if ( wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft )
     {
         // shift the window to the left instead of the right.
@@ -163,7 +182,7 @@ void wxPopupWindowBase::Position(const wxPoint& ptOrigin,
     else
         x += size.x;
 
-    
+
     if ( x + sizeSelf.x > sizeScreen.x )
     {
         // check if there is enough space to the left