-bool wxMWMIsRunning(Window w)
-{
-#if wxUSE_NANOX
- return FALSE;
-#else
- Display *dpy = (Display*)wxGetDisplay();
- Atom motifWmInfo = XInternAtom(dpy, "_MOTIF_WM_INFO", False);
-
- unsigned long length, bytesafter;
- unsigned char value[20];
- unsigned char *ptr = &value[0];
- int ret, format;
- Atom type;
-
- type = format = length = 0;
- value[0] = 0;
-
- ret = XGetWindowProperty(wxGlobalDisplay(), w, motifWmInfo,
- 0L, 2, False, motifWmInfo,
- &type, &format, &length, &bytesafter, &ptr);
-
- return (ret == Success);
-#endif
-}
-
-// 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
-{
- XSync(wxGlobalDisplay(), False);
- wxWindowX11::DoGetClientSize(width, height);
-}
-
-void wxTopLevelWindowX11::DoSetClientSize(int width, int height)
-{
- wxWindowX11::DoSetClientSize(width, height);
-
- // Set the top-level window size
- XSizeHints size_hints;
- wxSize oldSize = GetSize();
- wxSize oldClientSize = GetClientSize();
-
- size_hints.flags = PSize;
- size_hints.width = width + (oldSize.x - oldClientSize.x);
- size_hints.height = height + (oldSize.y - oldClientSize.y);
- XSetWMNormalHints( (Display*) GetXDisplay(), (Window) GetMainWindow(),
- &size_hints);
-
- // This seems to be necessary or resizes don't get performed
- XSync(wxGlobalDisplay(), False);
- XSync(wxGlobalDisplay(), False);
-
-#if 0
- wxLogDebug("DoSetClientSize: Tried to set size to %d, %d", (int) size_hints.width, (int) size_hints.height);
-
- XSync(wxGlobalDisplay(), False);
- wxSize newSize = GetSize();
- wxLogDebug("New size is %d, %d", (int) newSize.x, (int) newSize.y);
-#endif
-
-#if 0
- if (!GetMainWindow())
- return;
-
- XWindowChanges windowChanges;
- int valueMask = 0;
-
- if (width != -1)
- {
- windowChanges.width = width ;
- valueMask |= CWWidth;
- }
- if (height != -1)
- {
- windowChanges.height = height ;
- valueMask |= CWHeight;
- }
- XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(),
- valueMask, & windowChanges);
-#endif
-}
-
-void wxTopLevelWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags)
-{
-#if 0
- // wxLogDebug( "Setting pos: %d, %d", x, y );
- wxWindowX11::DoSetSize(x, y, width, height, sizeFlags);
-#endif
- XSync(wxGlobalDisplay(), False);
- Window window = (Window) m_mainWidget;
- if (!window)
- return ;
-
- Display *display = (Display*) GetXDisplay();
- 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; unsigned int n;
- 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 );
-
- XSizeHints size_hints;
- size_hints.flags = 0;
- if (x > -1 && y > -1)
- size_hints.flags |= PPosition;
- if (width > -1 && height > -1)
- size_hints.flags |= PSize;
- size_hints.width = width;
- size_hints.height = height;
- size_hints.x = x;
- size_hints.y = y;
- XSetWMNormalHints( (Display*) GetXDisplay(), (Window) GetMainWindow(),
- &size_hints);
-
- // This seems to be necessary or resizes don't get performed.
- // Take them out (or even just one of them), and the About
- // box of the minimal sample probably won't be resized right.
- XSync(wxGlobalDisplay(), False);
- XSync(wxGlobalDisplay(), False);
-
-#if 0
- wxLogDebug("DoSetSize: Tried to set size to %d, %d", (int) size_hints.width, (int) size_hints.height);
-
- XSync(wxGlobalDisplay(), False);
- wxSize newSize = GetSize();
- wxLogDebug("New size is %d, %d", (int) newSize.x, (int) newSize.y);
-#endif
-
-#if 0
- wxPoint pt = GetPosition();
- // wxLogDebug( "After, pos: %d, %d", pt.x, pt.y );
-
- XSync(wxGlobalDisplay(), False);
- int w, h;
- GetSize(& w, & h);
- wxString msg;
- msg.Printf("Before setting size: %d, %d", w, h);
- wxLogDebug(msg);
- if (!GetMainWindow())
- return;
-
- XWindowChanges windowChanges;
- int valueMask = 0;
-
- if (x != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
- {
- int yy = 0;
- AdjustForParentClientOrigin( x, yy, sizeFlags);
- windowChanges.x = x;
- valueMask |= CWX;
- }
- if (y != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
- {
- int xx = 0;
- AdjustForParentClientOrigin( xx, y, sizeFlags);
- windowChanges.y = y;
- valueMask |= CWY;
- }
- if (width != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
- {
- windowChanges.width = width /* - m_borderSize*2 */;
- valueMask |= CWWidth;
- }
- if (height != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
- {
- windowChanges.height = height /* -m_borderSize*2*/;
- valueMask |= CWHeight;
- }
-
- XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(),
- valueMask, & windowChanges);
- XSync(wxGlobalDisplay(), False);
- GetSize(& w, & h);
- msg.Printf("Tried to set to %d, %d. After setting size: %d, %d", width, height, w, h);
- wxLogDebug(msg);
-#endif
-}
-
-void wxTopLevelWindowX11::DoGetPosition(int *x, int *y) const
-{
- XSync(wxGlobalDisplay(), False);
- Window window = (Window) m_mainWidget;
- if (!window)
- return ;
-
- Display *display = (Display*) GetXDisplay();
- 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; unsigned int n;
- parent_window = next_parent;
- XQueryTree(display, parent_window, &root,
- &next_parent, &theChildren, &n);
- XFree(theChildren); // not needed
- }
- 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;
-
-#if 0
- if (window)
- {
- int offsetX = 0;
- int offsetY = 0;
-
-#if !wxUSE_NANOX
- // wxLogDebug("Translating...");
- Window childWindow;
- XTranslateCoordinates(wxGlobalDisplay(), window, XDefaultRootWindow(wxGlobalDisplay()),
- 0, 0, & offsetX, & offsetY, & childWindow);