Added QPA window system interface handler for logical DPI changes.

Logical DPI is independent from geometry and physical DPI.

Change-Id: Ice487f61e1bda9e6791e2adf6998ebf61cdbaef2
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
This commit is contained in:
Samuel Rødal 2011-11-22 11:06:15 +01:00 committed by Qt by Nokia
parent 4eedb335c6
commit 89aee9ecde
5 changed files with 37 additions and 3 deletions

View File

@ -586,6 +586,10 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv
QGuiApplicationPrivate::reportAvailableGeometryChange(
static_cast<QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *>(e));
break;
case QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInch:
QGuiApplicationPrivate::reportLogicalDotsPerInchChange(
static_cast<QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *>(e));
break;
case QWindowSystemInterfacePrivate::Map:
QGuiApplicationPrivate::processMapEvent(static_cast<QWindowSystemInterfacePrivate::MapEvent *>(e));
break;
@ -998,9 +1002,6 @@ void QGuiApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate:
emit s->physicalDotsPerInchXChanged(s->physicalDotsPerInchX());
emit s->physicalDotsPerInchYChanged(s->physicalDotsPerInchY());
emit s->physicalDotsPerInchChanged(s->physicalDotsPerInch());
emit s->logicalDotsPerInchXChanged(s->logicalDotsPerInchX());
emit s->logicalDotsPerInchYChanged(s->logicalDotsPerInchY());
emit s->logicalDotsPerInchChanged(s->logicalDotsPerInch());
emit s->availableSizeChanged(s->availableSize());
emit s->availableGeometryChanged(s->availableGeometry());
}
@ -1021,6 +1022,22 @@ void QGuiApplicationPrivate::reportAvailableGeometryChange(
emit s->availableGeometryChanged(s->availableGeometry());
}
void QGuiApplicationPrivate::reportLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e)
{
// This operation only makes sense after the QGuiApplication constructor runs
if (QCoreApplication::startingUp())
return;
if (!e->screen)
return;
QScreen *s = e->screen.data();
emit s->logicalDotsPerInchXChanged(s->logicalDotsPerInchX());
emit s->logicalDotsPerInchYChanged(s->logicalDotsPerInchY());
emit s->logicalDotsPerInchChanged(s->logicalDotsPerInch());
}
void QGuiApplicationPrivate::processMapEvent(QWindowSystemInterfacePrivate::MapEvent *e)
{
if (!e->mapped)

View File

@ -125,6 +125,7 @@ public:
static void reportScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e);
static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e);
static void reportLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e);
static void processMapEvent(QWindowSystemInterfacePrivate::MapEvent *e);
static void processUnmapEvent(QWindowSystemInterfacePrivate::UnmapEvent *e);

View File

@ -278,6 +278,13 @@ void QWindowSystemInterface::handleScreenAvailableGeometryChange(QScreen *screen
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
}
void QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(QScreen *screen)
{
QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e =
new QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent(screen);
QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
}
void QWindowSystemInterface::handleMapEvent(QWindow *tlw)
{
QWindowSystemInterfacePrivate::MapEvent *e = new QWindowSystemInterfacePrivate::MapEvent(tlw);

View File

@ -117,6 +117,7 @@ public:
static void handleScreenOrientationChange(QScreen *screen);
static void handleScreenGeometryChange(QScreen *screen);
static void handleScreenAvailableGeometryChange(QScreen *screen);
static void handleScreenLogicalDotsPerInchChange(QScreen *screen);
// For event dispatcher implementations
static bool sendWindowSystemEvents(QAbstractEventDispatcher *eventDispatcher, QEventLoop::ProcessEventsFlags flags);

View File

@ -63,6 +63,7 @@ public:
ScreenOrientation,
ScreenGeometry,
ScreenAvailableGeometry,
ScreenLogicalDotsPerInch,
Map,
Unmap,
Expose
@ -215,6 +216,13 @@ public:
QWeakPointer<QScreen> screen;
};
class ScreenLogicalDotsPerInchEvent : public WindowSystemEvent {
public:
ScreenLogicalDotsPerInchEvent(QScreen *s)
: WindowSystemEvent(ScreenLogicalDotsPerInch), screen(s) { }
QWeakPointer<QScreen> screen;
};
class MapEvent : public WindowSystemEvent {
public:
MapEvent(QWindow *mapped)