2 Modify from KTolBoxManager
5 **********************************/
8 This file is part of the KDE libraries
9 Copyright (C) 1998 Sven Radej (radej@kde.org)
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Library General Public
13 License as published by the Free Software Foundation; either
14 version 2 of the License, or (at your option) any later version.
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Library General Public License for more details.
21 You should have received a copy of the GNU Library General Public License
22 along with this library; see the file COPYING.LIB. If not, write to
23 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA.
28 #include <qapplication.h>
29 #include <qwindowdefs.h>
34 #include "dockmovemanager.h"
36 DockMoveManager::DockMoveManager(QWidget
*_widget
) : QObject ()
49 gv
.foreground
= WhitePixel(qt_xdisplay(), scr
)^BlackPixel(qt_xdisplay(), scr
);
50 gv
.subwindow_mode
= IncludeInferiors
;
51 long mask
= GCForeground
| GCFunction
| GCLineWidth
| GCSubwindowMode
;
52 rootgc
= XCreateGC(qt_xdisplay(), qt_xrootwin(), mask
, &gv
);
54 timer
= new QTimer(this);
57 DockMoveManager::~DockMoveManager()
62 void DockMoveManager::doMove (bool hot_static
, bool _dynamic
, bool dontmove
)
71 QRect rr
= QRect( widget
->mapToGlobal(QPoint(0,0)), widget
->size() );
72 QPoint
p(rr
.topLeft());
74 offX
= QCursor::pos().x() - p
.x();
75 offY
= QCursor::pos().y() - p
.y();
87 XQueryPointer( qt_xdisplay(), qt_xrootwin(), &wroot
, &wchild
,
88 &sx
, &sy
, &trash
, &trash
, &active_button
);
96 QApplication::setOverrideCursor(QCursor(sizeAllCursor
));
97 connect (timer
, SIGNAL(timeout()), this, SLOT (doMoveInternal()));
99 drawRectangle(xp
, yp
, w
, h
);
105 void DockMoveManager::doMoveInternal()
107 if ( pauseMove
) return;
109 Window wroot
, wchild
;
111 unsigned int buttons
;
113 XQueryPointer( qt_xdisplay(), qt_xrootwin(), &wroot
, &wchild
,
114 &rx
, &ry
, &trash
, &trash
, &buttons
);
116 if (buttons
!= active_button
)
122 if (rx
== sx
&& ry
== sy
) return;
130 deleteLastRectangle();
131 drawRectangle(xp
, yp
, w
, h
);
133 XFlush(qt_xdisplay());
134 XSync(qt_xdisplay(), False
);
137 void DockMoveManager::stop ()
139 if (!working
) return;
142 disconnect (timer
, SIGNAL(timeout()));
143 QApplication::restoreOverrideCursor();
145 deleteLastRectangle();
146 XFlush(qt_xdisplay());
147 QApplication::restoreOverrideCursor();
150 if (widget
->parent() != 0) p
=widget
->parentWidget()->mapFromGlobal(p
);
155 void DockMoveManager::setGeometry (int _x
, int _y
, int _w
, int _h
)
157 if (!working
) return;
162 deleteLastRectangle();
163 drawRectangle( _x
, _y
, _w
, _h
);
166 void DockMoveManager::drawRectangle(int _x
, int _y
, int _w
, int _h
)
173 XDrawRectangle(qt_xdisplay(), root
, rootgc
, _x
, _y
, _w
, _h
);
178 XDrawRectangle(qt_xdisplay(), root
, rootgc
, _x
+1, _y
+1, _w
, _h
);
183 XDrawRectangle(qt_xdisplay(), root
, rootgc
, _x
+2, _y
+2, _w
, _h
);
188 void DockMoveManager::deleteLastRectangle()
192 XDrawRectangle(qt_xdisplay(), root
, rootgc
, ox
, oy
, ow
, oh
);
197 XDrawRectangle(qt_xdisplay(), root
, rootgc
, ox
+1, oy
+1, ow
, oh
);
202 XDrawRectangle(qt_xdisplay(), root
, rootgc
, ox
+2, oy
+2, ow
, oh
);