44 #ifndef QT_NO_QWS_MANAGER 52 #include "private/qpainter_p.h" 59 #include <private/qapplication_p.h> 60 #include <private/qwidget_p.h> 61 #include <private/qbackingstore_p.h> 62 #include <private/qwindowsurface_qws_p.h> 73 QWidget *QWSManagerPrivate::active = 0;
74 QPoint QWSManagerPrivate::mousePos;
77 QWSManagerPrivate::QWSManagerPrivate()
79 previousRegionType(0), previousRegionRepainted(false), entireDecorationNeedsRepaint(false)
81 cached_region.regionType = 0;
84 QRegion &QWSManager::cachedRegion()
86 return d_func()->cached_region.region;
98 QWSManager::QWSManager(
QWidget *w)
101 d_func()->managed = w;
105 QWSManager::~QWSManager()
112 if (
d->managed == QWSManagerPrivate::active)
113 QWSManagerPrivate::active = 0;
122 QWidget *QWSManager::grabbedMouse()
124 return QWSManagerPrivate::active;
130 return QApplication::qwsDecoration().region(
d->managed,
d->managed->geometry());
171 d->activeRegion = QApplication::qwsDecoration().regionAt(
d->managed,
d->mousePos);
172 if(
d->cached_region.regionType)
177 ?
d->managed->geometry().topLeft()
178 :
d->managed->geometry().topRight());
183 d->active =
d->managed;
184 d->managed->grabMouse();
201 d->managed->releaseMouse();
206 d->previousRegionRepainted =
false;
212 int itm = QApplication::qwsDecoration().regionAt(
d->managed, e->
globalPos());
213 int activatedItem =
d->activeRegion;
216 if (activatedItem == itm)
217 QApplication::qwsDecoration().regionClicked(
d->managed, itm);
223 void QWSManager::mouseDoubleClickEvent(
QMouseEvent *e)
227 QApplication::qwsDecoration().regionDoubleClicked(
d->managed,
228 QApplication::qwsDecoration().regionAt(
d->managed, e->
globalPos()));
236 static const struct {
252 while (region != r2s[i].region && r2s[i].region)
261 if(
d->previousRegionType &&
d->previousRegionRepainted)
263 if(
d->cached_region.regionType) {
270 if (
d->managed->minimumSize() !=
d->managed->maximumSize()) {
272 qwsd->
selectCursor(
d->managed, regionToShape(
d->cachedRegionAt()));
274 #endif //QT_NO_CURSOR 280 void QWSManager::handleMove(
QPoint g)
288 if (g.
x() < maxWindowRect.
x())
289 g.
setX(maxWindowRect.
x());
290 if (g.
y() < maxWindowRect.
y())
291 g.
setY(maxWindowRect.
y());
292 if (g.
x() > maxWindowRect.
right())
294 if (g.
y() > maxWindowRect.
bottom())
298 if (g ==
d->mousePos)
301 if (
d->managed->isMaximized() )
304 int x =
d->managed->geometry().x();
305 int y =
d->managed->geometry().y();
306 int w =
d->managed->width();
307 int h =
d->managed->height();
309 QRect geom(
d->managed->geometry());
311 QPoint delta = g -
d->mousePos;
315 geom =
QRect(x + delta.x(), y + delta.y(), w, h);
318 bool keepLeft =
true;
319 switch (
d->activeRegion) {
321 geom.setTop(geom.top() + delta.y());
325 geom.setBottom(geom.bottom() + delta.y());
329 geom.setLeft(geom.left() + delta.x());
333 geom.setRight(geom.right() + delta.x());
337 geom.setTopRight(geom.topRight() + delta);
342 geom.setTopLeft(geom.topLeft() + delta);
347 geom.setBottomLeft(geom.bottomLeft() + delta);
352 geom.setBottomRight(geom.bottomRight() + delta);
362 int dx = newSize.
width() - geom.width();
363 int dy = newSize.
height() - geom.height();
366 geom.setBottom(geom.bottom() + dy);
367 d->mousePos.ry() += dy;
369 geom.setTop(geom.top() - dy);
370 d->mousePos.ry() -= dy;
373 geom.setRight(geom.right() + dx);
374 d->mousePos.rx() += dx;
376 geom.setLeft(geom.left() - dx);
377 d->mousePos.rx() -= dx;
380 if (geom !=
d->managed->geometry()) {
382 d->managed->setGeometry(geom);
392 void QWSManagerPrivate::dirtyRegion(
int decorationRegion,
396 QTLWExtra *topextra = managed->d_func()->extra->topextra;
398 const bool pendingUpdateRequest = bs->
isDirty();
402 entireDecorationNeedsRepaint =
true;
403 dirtyRegions.clear();
406 int i = dirtyRegions.indexOf(decorationRegion);
408 dirtyRegions.removeAt(i);
409 dirtyStates.removeAt(i);
412 dirtyRegions.append(decorationRegion);
413 dirtyStates.append(state);
414 if (!entireDecorationNeedsRepaint)
417 if (!pendingUpdateRequest)
421 void QWSManagerPrivate::clearDirtyRegions()
423 dirtyRegions.clear();
426 entireDecorationNeedsRepaint =
false;
433 d->dirtyRegion(decorationRegion, state);
437 void QWSManager::menu(
const QPoint &pos)
448 QApplication::qwsDecoration().buildSysMenu(
d->managed,
d->popup);
451 d->popup->popup(pos);
456 void QWSManager::menuTriggered(
QAction *action)
462 QApplication::qwsDecoration().menuTriggered(
d->managed, action);
463 d->popup->deleteLater();
468 void QWSManager::startMove()
473 d->active =
d->managed;
474 d->managed->grabMouse();
477 void QWSManager::startResize()
481 d->active =
d->managed;
482 d->managed->grabMouse();
485 void QWSManager::maximize()
491 QRect dummy(0, 0, 1, 1);
493 QRegion r = QApplication::qwsDecoration().region(
d->managed, dummy);
499 nr =
QRect(desk.
x()-rect.
x(), desk.
y()-rect.
y(),
503 d->managed->setGeometry(nr);
506 bool QWSManagerPrivate::newCachedRegion(
const QPoint &pos)
509 if (managed->windowFlags() == cached_region.windowFlags
510 && managed->geometry() == cached_region.windowGeometry
511 && cached_region.region.contains(pos))
515 int reg = QApplication::qwsDecoration().regionAt(managed, pos);
519 previousRegionType = cached_region.regionType;
520 cached_region.regionType = reg;
521 cached_region.region = QApplication::qwsDecoration().region(managed, managed->geometry(),
525 cached_region.region -= QApplication::qwsDecoration().region(managed, managed->geometry(),
QDecoration::Borders);
527 cached_region.windowFlags = managed->windowFlags();
528 cached_region.windowGeometry = managed->geometry();
537 #endif //QT_NO_QWS_MANAGER
Q_GUI_EXPORT QScreen * qt_screen
static Qt::LayoutDirection layoutDirection()
The QWSDisplay class provides a display for QWS; it is an internal class.
QRect maxWindowRect(const QScreen *screen) const
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
void selectCursor(QWidget *w, unsigned int id)
static QWSDisplay * qwsDisplay()
static void postEvent(QObject *receiver, QEvent *event)
Adds the event event, with the object receiver as the receiver of the event, to an event queue and re...
int width() const
Returns the width of the rectangle.
static QApplicationPrivate * instance()
QRect boundingRect() const
Returns the bounding rectangle of this region.
int height() const
Returns the height of the rectangle.
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
The QObject class is the base class of all Qt objects.
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
static QSize closestAcceptableSize(const QWidget *w, const QSize &s)
Returns a size that satisfies all size constraints on widget, including heightForWidth() and that is ...
The QDecoration class is a base class for window decorations in Qt for Embedded Linux.
int width() const
Returns the width.
#define QT_BEGIN_NAMESPACE
This macro expands to.
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
static void sendPostedEvents()
The QRegion class specifies a clip region for a painter.
Qt::MouseButton button() const
Returns the button that caused the event.
The QMouseEvent class contains parameters that describe a mouse event.
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
int right() const
Returns the x-coordinate of the rectangle's right edge.
int y() const
Returns the y-coordinate of the rectangle's top edge.
int x() const
Returns the x-coordinate of the rectangle's left edge.
The QPoint class defines a point in the plane using integer precision.
int height() const
Returns the height.
The QRect class defines a rectangle in the plane using integer precision.
DecorationState
This enum describes the various states of a decoration region.
int y() const
Returns the y coordinate of this point.
The QSize class defines the size of a two-dimensional object using integer point precision.
static Qt::MouseButtons mouseButtons()
Returns the current state of the buttons on the mouse.
int x() const
Returns the x coordinate of this point.
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
The QPaintEvent class contains event parameters for paint events.
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
const QPoint & globalPos() const
Returns the global position of the mouse cursor at the time of the event.
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
The QAction class provides an abstract user interface action that can be inserted into widgets...
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.