]> git.saurik.com Git - wxWidgets.git/commitdiff
Sometimes, m_x and m_y don't reflect the true position of the window,
authorJulian Smart <julian@anthemion.co.uk>
Tue, 12 Sep 2006 11:57:55 +0000 (11:57 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Tue, 12 Sep 2006 11:57:55 +0000 (11:57 +0000)
for example after using wxToolBar::AddControl. This change gets the
actual position if necessary; it fixes a popup window positioning problem
for combo controls on a toolbar.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41176 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/window.cpp

index 9f639a35865efbb6e2cfdb520696b8c814a86fd2..ccc7fe9e9b532334b581920df65ea63cb4100642 100644 (file)
@@ -3066,6 +3066,28 @@ void wxWindowGTK::DoGetPosition( int *x, int *y ) const
         dy = gtk_pizza_get_yoffset( pizza );
     }
 
+    if (m_x == -1 && m_y == -1)
+    {
+        GdkWindow *source = (GdkWindow *) NULL;
+        if (m_wxwindow)
+            source = GTK_PIZZA(m_wxwindow)->bin_window;
+        else
+            source = m_widget->window;
+
+        if (source)
+        {
+            int org_x = 0;
+            int org_y = 0;
+            gdk_window_get_origin( source, &org_x, &org_y );
+
+            if (GetParent())
+                GetParent()->ScreenToClient(&org_x, &org_y);
+
+            ((wxWindowGTK*) this)->m_x = org_x;
+            ((wxWindowGTK*) this)->m_y = org_y;
+       }
+    }
+
     if (x) (*x) = m_x - dx;
     if (y) (*y) = m_y - dy;
 }