X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c978d36124197b5612a2cabefed7591ad0eea6e2..904ccf52370e021b55b8a4c1afc5f62bc904da20:/src/x11/reparent.cpp diff --git a/src/x11/reparent.cpp b/src/x11/reparent.cpp index 349aea15e8..bbeedaea5d 100644 --- a/src/x11/reparent.cpp +++ b/src/x11/reparent.cpp @@ -22,6 +22,9 @@ #endif #include "wx/x11/reparent.h" + +#if !wxUSE_NANOX + #include "wx/evtloop.h" #include "wx/log.h" #include "wx/app.h" @@ -91,7 +94,7 @@ wxAdoptedWindow::wxAdoptedWindow() wxAdoptedWindow::wxAdoptedWindow(WXWindow window) { - m_mainWidget = window; + m_mainWindow = window; } wxAdoptedWindow::~wxAdoptedWindow() @@ -128,15 +131,15 @@ bool wxReparenter::Reparent(wxWindow* newParent, wxAdoptedWindow* toReparent) int parentOffset = 0; old = XSetErrorHandler(ErrorHandler); - XReparentWindow((Display*) newParent->GetXDisplay(), - (Window) toReparent->GetXWindow(), - (Window) newParent->GetXWindow(), - 0, 0); - - if (!XQueryTree((Display*) newParent->GetXDisplay(), - (Window) toReparent->GetXWindow(), - &returnroot, &returnparent, - &children, &numchildren) || Xerror) + XReparentWindow( wxGlobalDisplay(), + (Window) toReparent->GetMainWindow(), + (Window) newParent->GetMainWindow(), + 0, 0); + + if (!XQueryTree( wxGlobalDisplay(), + (Window) toReparent->GetMainWindow(), + &returnroot, &returnparent, + &children, &numchildren) || Xerror) { XSetErrorHandler(old); return TRUE; @@ -144,20 +147,27 @@ bool wxReparenter::Reparent(wxWindow* newParent, wxAdoptedWindow* toReparent) if (numchildren > 0) { - fprintf(stderr, "Reparenting %d children.\n", numchildren); + // TEST: see if we can get away with reparenting just + // first one + if (numchildren > 1) + { + wxLogDebug(wxT("Found %d, but only reparenting 1 child."), numchildren); + numchildren = 1; + } + wxLogDebug(wxT("Reparenting %d children."), numchildren); /* Stacking order is preserved since XQueryTree returns its children in bottommost to topmost order */ for (each=0; eachGetXDisplay(), - children[each], &xwa); + XGetWindowAttributes( wxGlobalDisplay(), + children[each], &xwa); fprintf(stderr, "Reparenting child at offset %d and position %d, %d.\n", parentOffset, parentOffset+xwa.x, parentOffset+xwa.y); - XReparentWindow((Display*) newParent->GetXDisplay(), - children[each], (Window) newParent->GetXWindow(), - xwa.x, xwa.y); + XReparentWindow( wxGlobalDisplay(), + children[each], (Window) newParent->GetMainWindow(), + xwa.x, xwa.y); } } @@ -177,7 +187,7 @@ bool wxReparenter::WaitAndReparent(wxWindow* newParent, wxAdoptedWindow* toRepar sm_exactMatch = exactMatch; sm_name = windowName; - Display* display = (Display*) newParent->GetXDisplay() ; + Display* display = wxGlobalDisplay(); XSelectInput(display, RootWindowOfScreen(DefaultScreenOfDisplay(display)), SubstructureNotifyMask); @@ -320,3 +330,4 @@ WXWindow wxReparenter::FindAClientWindow(WXWindow window, const wxString& name) } return (WXWindow) result; } +#endif