summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-05-27 13:41:01 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-05-27 13:52:28 (GMT)
commitdf4a095019638356520728f88ac4d919e654dcdd (patch)
treef8044662d2c292b204a11c25fb43272d3cda05de /src/gui
parent14b0be5b4eabf7e52a4c3f6d5696aacacb11878b (diff)
downloadQt-df4a095019638356520728f88ac4d919e654dcdd.zip
Qt-df4a095019638356520728f88ac4d919e654dcdd.tar.gz
Qt-df4a095019638356520728f88ac4d919e654dcdd.tar.bz2
Modify QDesktopWidget to emit proper signals on resize.
The resize behavior of QDesktopWidget was somewhat undefined on Symbian because we weren't actually changing the size of the widget. This patch fixes that and also implements the resizeEvent() function so that it properly emits signals. We didn't call resize() to change the size here because our implementation of setGeometry_sys() ignores the desktop widget since it doesn't have a backing store and isn't a real window. Task-number: 253930
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qapplication_s60.cpp10
-rw-r--r--src/gui/kernel/qdesktopwidget_s60.cpp63
2 files changed, 65 insertions, 8 deletions
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp
index dd51fcd..5b2c1fb 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/gui/kernel/qapplication_s60.cpp
@@ -14,6 +14,7 @@
#include "qevent.h"
#include "qeventdispatcher_s60_p.h"
#include "qwidget.h"
+#include "qdesktopwidget.h"
#include "private/qbackingstore_p.h"
#include "qt_s60_p.h"
#include "private/qevent_p.h"
@@ -49,6 +50,8 @@ static bool appNoGrab = false; // Grabbing enabled
Q_GUI_EXPORT QS60Data *qt_s60Data = 0;
extern bool qt_sendSpontaneousEvent(QObject*,QEvent*);
+extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp
+
QWidget *qt_button_down = 0; // widget got last button-down
bool qt_nograb() // application no-grab option
@@ -988,6 +991,13 @@ int QApplication::s60ProcessEvent(TWsEvent *event)
case EEventScreenDeviceChanged:
if (S60)
S60->updateScreenSize();
+ if (qt_desktopWidget) {
+ QSize oldSize = qt_desktopWidget->size();
+ qt_desktopWidget->data->crect.setWidth(S60->screenWidthInPixels);
+ qt_desktopWidget->data->crect.setHeight(S60->screenHeightInPixels);
+ QResizeEvent e(qt_desktopWidget->size(), oldSize);
+ QApplication::sendEvent(qt_desktopWidget, &e);
+ }
return 0; // Propagate to CONE
case EEventWindowVisibilityChanged:
if (controlInMap) {
diff --git a/src/gui/kernel/qdesktopwidget_s60.cpp b/src/gui/kernel/qdesktopwidget_s60.cpp
index 029892e..d57d289 100644
--- a/src/gui/kernel/qdesktopwidget_s60.cpp
+++ b/src/gui/kernel/qdesktopwidget_s60.cpp
@@ -32,34 +32,58 @@ public:
static int screenCount;
static int primaryScreen;
+
+ static QVector<QRect> *rects;
+ static QVector<QRect> *workrects;
+
+ static int refcount;
};
int QDesktopWidgetPrivate::screenCount = 1;
int QDesktopWidgetPrivate::primaryScreen = 0;
+QVector<QRect> *QDesktopWidgetPrivate::rects = 0;
+QVector<QRect> *QDesktopWidgetPrivate::workrects = 0;
+int QDesktopWidgetPrivate::refcount = 0;
QDesktopWidgetPrivate::QDesktopWidgetPrivate()
{
+ ++refcount;
}
QDesktopWidgetPrivate::~QDesktopWidgetPrivate()
{
+ if (!--refcount)
+ cleanup();
}
void QDesktopWidgetPrivate::init(QDesktopWidget *that)
{
- TInt screenCount=0;
- TInt result=0;
+ int screenCount=0;
+
+ if (HAL::Get(0, HALData::EDisplayNumberOfScreens, screenCount) == KErrNone)
+ QDesktopWidgetPrivate::screenCount = screenCount;
+ else
+ QDesktopWidgetPrivate::screenCount = 0;
- result = HAL::Get(0, HALData::EDisplayNumberOfScreens, screenCount);
- QDesktopWidgetPrivate::screenCount = screenCount;
- if( result != KErrNone)
- {
- // ### What to do if no screens found?
- }
+ rects = new QVector<QRect>();
+ workrects = new QVector<QRect>();
+
+ rects->resize(QDesktopWidgetPrivate::screenCount);
+ workrects->resize(QDesktopWidgetPrivate::screenCount);
+
+ // ### TODO: Implement proper multi-display support
+ rects->resize(1);
+ rects->replace(0, that->rect());
+ workrects->resize(1);
+ workrects->replace(0, that->rect());
}
void QDesktopWidgetPrivate::cleanup()
{
+ delete rects;
+ rects = 0;
+ delete workrects;
+ workrects = 0;
}
@@ -120,6 +144,29 @@ int QDesktopWidget::screenNumber(const QPoint &point) const
void QDesktopWidget::resizeEvent(QResizeEvent *)
{
+ Q_D(QDesktopWidget);
+ QVector<QRect> oldrects;
+ oldrects = *d->rects;
+ QVector<QRect> oldworkrects;
+ oldworkrects = *d->workrects;
+ int oldscreencount = d->screenCount;
+
+ QDesktopWidgetPrivate::cleanup();
+ QDesktopWidgetPrivate::init(this);
+
+ for (int i = 0; i < qMin(oldscreencount, d->screenCount); ++i) {
+ QRect oldrect = oldrects[i];
+ QRect newrect = d->rects->at(i);
+ if (oldrect != newrect)
+ emit resized(i);
+ }
+
+ for (int j = 0; j < qMin(oldscreencount, d->screenCount); ++j) {
+ QRect oldrect = oldworkrects[j];
+ QRect newrect = d->workrects->at(j);
+ if (oldrect != newrect)
+ emit workAreaResized(j);
+ }
}
QT_END_NAMESPACE