Applied patch #841324 from Ian Brown:

"GetPosition() returns wrong result for dialog"
modified for better backward binary compatibility.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@24574 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Mattia Barbon
2003-11-16 11:19:13 +00:00
parent d45ea58833
commit a135cdfbde
3 changed files with 37 additions and 1 deletions

View File

@@ -114,6 +114,10 @@ protected:
int sizeFlags = wxSIZE_AUTO);
virtual void DoSetClientSize(int width, int height);
public:
// hack for binary compatibility
void DoGetPosition_(int* x, int* y) const;
private:
private:
DECLARE_EVENT_TABLE()

View File

@@ -395,6 +395,28 @@ void wxDialog::DoSetSize(int x, int y, int width, int height, int sizeFlags)
XtVaSetValues((Widget) m_mainWidget, XmNresizePolicy, XmRESIZE_NONE, NULL);
}
void wxDialog::DoGetPosition_(int *x, int *y) const
{
Window parent_window = XtWindow((Widget) m_mainWidget),
next_parent = XtWindow((Widget) m_mainWidget),
root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
// search for the parent that is child of ROOT, because the WM may
// reparent twice and notify only the next parent (like FVWM)
while (next_parent != root) {
Window *theChildren; unsigned int n;
parent_window = next_parent;
XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
&next_parent, &theChildren, &n);
XFree(theChildren); // not needed
}
int xx, yy; unsigned int dummy;
XGetGeometry(XtDisplay((Widget) m_mainWidget), parent_window, &root,
&xx, &yy, &dummy, &dummy, &dummy, &dummy);
if (x) *x = xx;
if (y) *y = yy;
}
void wxDialog::DoSetClientSize(int width, int height)
{
wxWindow::SetSize(-1, -1, width, height);

View File

@@ -1282,6 +1282,16 @@ void wxWindow::DoGetPosition(int *x, int *y) const
CanvasGetPosition(x, y);
return;
}
// hack for binary compatibility
if (IsTopLevel())
{
wxDialog* dlg = wxDynamicCast(this, wxDialog);
if (dlg)
{
dlg->DoGetPosition_(x, y);
return;
}
}
Widget widget = (Widget) GetTopWidget();
Position xx, yy;
XtVaGetValues(widget, XmNx, &xx, XmNy, &yy, NULL);