From a135cdfbde72e42f306c2f9e87b8bb6d9d0569c2 Mon Sep 17 00:00:00 2001 From: Mattia Barbon Date: Sun, 16 Nov 2003 11:19:13 +0000 Subject: [PATCH] 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 --- include/wx/motif/dialog.h | 6 +++++- src/motif/dialog.cpp | 22 ++++++++++++++++++++++ src/motif/window.cpp | 10 ++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/include/wx/motif/dialog.h b/include/wx/motif/dialog.h index bdfd0a056d..a97d5bb203 100644 --- a/include/wx/motif/dialog.h +++ b/include/wx/motif/dialog.h @@ -114,7 +114,11 @@ 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() }; diff --git a/src/motif/dialog.cpp b/src/motif/dialog.cpp index 19a321cc02..bfe4501f37 100644 --- a/src/motif/dialog.cpp +++ b/src/motif/dialog.cpp @@ -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); diff --git a/src/motif/window.cpp b/src/motif/window.cpp index 3325d6cb13..64112b13cd 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -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);