+// For implementation purposes - sometimes decorations make the client area
+// smaller
+wxPoint wxTopLevelWindowX11::GetClientAreaOrigin() const
+{
+ // wxFrame::GetClientAreaOrigin
+ // does the required calculation already.
+ return wxPoint(0, 0);
+}
+
+void wxTopLevelWindowX11::DoGetClientSize( int *width, int *height ) const
+{
+ if (width)
+ *width = m_width;
+ if (height)
+ *height = m_height;
+}
+
+void wxTopLevelWindowX11::DoGetSize( int *width, int *height ) const
+{
+ // TODO add non-client size
+
+ if (width)
+ *width = m_width;
+ if (height)
+ *height = m_height;
+}
+
+void wxTopLevelWindowX11::DoSetClientSize(int width, int height)
+{
+ int old_width = m_width;
+ int old_height = m_height;
+
+ m_width = width;
+ m_height = height;
+
+ if (m_width == old_width && m_height == old_height)
+ return;
+
+ // wxLogDebug("DoSetClientSize: %s (%ld) %dx%d", GetClassInfo()->GetClassName(), GetId(), width, height);
+
+#if !wxUSE_NANOX
+ XSizeHints size_hints;
+ size_hints.flags = PSize;
+ size_hints.width = width;
+ size_hints.height = height;
+ XSetWMNormalHints( wxGlobalDisplay(), (Window) GetMainWindow(), &size_hints );
+#endif
+
+ wxWindowX11::DoSetClientSize(width, height);
+}
+
+void wxTopLevelWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags)
+{
+ int old_x = m_x;
+ int old_y = m_y;
+ int old_width = m_width;
+ int old_height = m_height;
+
+ if (x != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ m_x = x;
+
+ if (y != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ m_y = y;
+
+ if (width != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ m_width = width;
+
+ if (height != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ m_height = height;
+
+ if (m_x == old_x && m_y == old_y && m_width == old_width && m_height == old_height)
+ return;
+
+ // wxLogDebug("DoSetSize: %s (%ld) %d, %d %dx%d", GetClassInfo()->GetClassName(), GetId(), x, y, width, height);
+
+#if !wxUSE_NANOX
+ XSizeHints size_hints;
+ size_hints.flags = 0;
+ size_hints.flags |= PPosition;
+ size_hints.flags |= PSize;
+ size_hints.x = m_x;
+ size_hints.y = m_y;
+ size_hints.width = m_width;
+ size_hints.height = m_height;
+ XSetWMNormalHints( wxGlobalDisplay(), (Window) GetMainWindow(), &size_hints);
+#endif
+
+ wxWindowX11::DoSetSize(x, y, width, height, sizeFlags);
+
+#if 0
+ Display *display = wxGlobalDisplay();
+ Window root = RootWindowOfScreen(DefaultScreenOfDisplay(display));
+ Window parent_window = window,
+ next_parent = window;
+
+ // 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;
+#if wxUSE_NANOX
+ GR_COUNT n;
+#else
+ unsigned int n;
+#endif
+ parent_window = next_parent;
+ XQueryTree(display, parent_window, &root,
+ &next_parent, &theChildren, &n);
+ XFree(theChildren); // not needed
+ }
+
+ XWindowChanges windowChanges;
+ windowChanges.x = x;
+ windowChanges.y = y;
+ windowChanges.width = width;
+ windowChanges.height = height;
+ windowChanges.stack_mode = 0;
+ int valueMask = CWX | CWY | CWWidth | CWHeight;
+
+ if (x != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ {
+ valueMask |= CWX;
+ }
+ if (y != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ {
+ valueMask |= CWY;
+ }
+ if (width != -1)
+ {
+ windowChanges.width = wxMax(1, width);
+ valueMask |= CWWidth;
+ }
+ if (height != -1)
+ {
+ windowChanges.height = wxMax(1, height);
+ valueMask |= CWHeight;
+ }
+
+ XConfigureWindow( display, parent_window, valueMask, &windowChanges );
+#endif
+}
+
+void wxTopLevelWindowX11::DoGetPosition(int *x, int *y) const
+{
+ XSync(wxGlobalDisplay(), False);
+ Window window = (Window) m_mainWindow;
+ if (!window)
+ return ;
+
+ Display *display = wxGlobalDisplay();
+ Window root = RootWindowOfScreen(DefaultScreenOfDisplay(display));
+ Window parent_window = window,
+ next_parent = window;
+
+ // 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;
+#if wxUSE_NANOX
+ GR_COUNT n;
+#else
+ unsigned int n;
+#endif
+ parent_window = next_parent;
+ XQueryTree(display, parent_window, &root,
+ &next_parent, &theChildren, &n);
+ XFree(theChildren); // not needed
+ }
+#if 0
+ int xx, yy; unsigned int dummy;
+ XGetGeometry(display, parent_window, &root,
+ &xx, &yy, &dummy, &dummy, &dummy, &dummy);
+ if (x) *x = xx;
+ if (y) *y = yy;
+#else
+ XWindowAttributes attr;
+ Status status = XGetWindowAttributes( wxGlobalDisplay(), parent_window, & attr);
+ if (status)
+ {
+ if (x) *x = attr.x;
+ if (y) *y = attr.y;
+ }
+ else
+ {
+ if (x) *x = 0;
+ if (y) *y = 0;
+ }
+#endif
+}
+
+