5
#define protected public
12
#include<qobjectlist.h>
17
// taken from qt/x11 (doing this sucks sucks sucks sucks sucks)
18
void reparent_good(QWidget *that, WFlags f, bool showIt)
20
extern void qPRCreate( const QWidget *, Window );
21
extern void qt_XDestroyWindow( const QWidget *destroyer, Display *display, Window window );
22
extern bool qt_dnd_enable( QWidget* w, bool on );
25
Display *dpy = that->x11Display();
27
bool setcurs = that->testWState(Qt::WState_OwnCursor);
29
oldcurs = that->cursor();
33
// dnd unregister (we will register again below)
34
bool accept_drops = that->acceptDrops();
35
that->setAcceptDrops( FALSE );
37
// clear mouse tracking, re-enabled below
38
bool mouse_tracking = that->hasMouseTracking();
39
that->clearWState(Qt::WState_MouseTracking);
41
QWidget* oldtlw = that->topLevelWidget();
42
QWidget *oldparent = that->parentWidget();
43
WId old_winid = that->winid;
44
if ( that->testWFlags(Qt::WType_Desktop) )
48
// hide and reparent our own window away. Otherwise we might get
49
// destroyed when emitting the child remove event below. See QWorkspace.
50
XUnmapWindow( that->x11Display(), old_winid );
51
XReparentWindow( that->x11Display(), old_winid,
52
RootWindow( that->x11Display(), that->x11Screen() ), 0, 0 );
54
if ( that->isTopLevel() ) {
55
// input contexts are associated with toplevel widgets, so we need
56
// destroy the context here. if we are reparenting back to toplevel,
57
// then we will have another context created, otherwise we will
58
// use our new toplevel's context
59
that->destroyInputContext();
62
if ( that->isTopLevel() || !parent ) // we are toplevel, or reparenting to toplevel
63
that->topData()->parentWinId = 0;
65
if ( parent != that->parentObj ) {
66
if ( that->parentObj ) // remove from parent
67
that->parentObj->removeChild( that );
68
if ( parent ) // insert into new parent
69
parent->insertChild( that );
71
bool enable = that->isEnabled(); // remember status
72
QWidget::FocusPolicy fp = that->focusPolicy();
73
QSize s = that->size();
74
QPixmap *bgp = (QPixmap *)that->backgroundPixmap();
75
QColor bgc = that->bg_col; // save colors
76
QString capt= that->caption();
77
that->widget_flags = f;
78
that->clearWState( Qt::WState_Created | Qt::WState_Visible | Qt::WState_ForceHide );
80
if ( that->isTopLevel() || (!parent || parent->isVisible() ) )
81
that->setWState( Qt::WState_ForceHide ); // new widgets do not show up in already visible parents
83
const QObjectList *chlist = that->children();
84
if ( chlist ) { // reparent children
85
QObjectListIt it( *chlist );
87
while ( (obj=it.current()) ) {
88
if ( obj->isWidgetType() ) {
89
QWidget *w = (QWidget *)obj;
90
if ( !w->isTopLevel() ) {
91
XReparentWindow( that->x11Display(), w->winId(), that->winId(),
92
w->geometry().x(), w->geometry().y() );
93
} else if ( w->isPopup()
94
|| w->testWFlags(Qt::WStyle_DialogBorder)
95
|| w->testWFlags(Qt::WType_Dialog)
96
|| w->testWFlags(Qt::WStyle_Tool) ) {
97
XSetTransientForHint( that->x11Display(), w->winId(), that->winId() );
103
qPRCreate( that, old_winid );
105
XSetWindowBackgroundPixmap( dpy, that->winid, bgp->handle() );
107
XSetWindowBackground( dpy, that->winid, bgc.pixel(that->x11Screen()) );
109
// all this just to do a stupid resize instead of setGeometry
110
//setGeometry( p.x(), p.y(), s.width(), s.height() );
111
that->resize(s.width(), s.height());
113
that->setEnabled( enable );
114
that->setFocusPolicy( fp );
115
if ( !capt.isNull() ) {
116
that->extra->topextra->caption = QString::null;
117
that->setCaption( capt );
122
qt_XDestroyWindow( that, dpy, old_winid );
124
that->setCursor(oldcurs);
126
that->reparentFocusWidgets( oldtlw );
130
oldparent->checkChildrenDnd();
133
that->setAcceptDrops( TRUE );
135
that->checkChildrenDnd();
136
that->topData()->dnd = 0;
137
qt_dnd_enable(that, (that->extra && that->extra->children_use_dnd));
140
// re-enable mouse tracking
142
that->setMouseTracking(mouse_tracking);