From 6aa09123df99f94111b60f3117bde992fbbe7dc4 Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Wed, 6 Jun 2012 11:12:25 +0100 Subject: QNX: Take nativeOrientation into account for QNX device orientations Change-Id: Idfe4a5bd9c9638a1f9ae52a7b1def3f869286587 Reviewed-by: Kevin Ottens Reviewed-by: Kevin Krammer Reviewed-by: Giuseppe D'Angelo --- src/plugins/platforms/qnx/qqnxscreen.cpp | 35 +++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp index 7ec84a47ec..0b28557998 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.cpp +++ b/src/plugins/platforms/qnx/qqnxscreen.cpp @@ -87,7 +87,7 @@ QQnxScreen::QQnxScreen(screen_context_t screenContext, screen_display_t display, // Cache size of this display in millimeters. We have to take care of the orientation. // libscreen always reports the physical size dimensions as width and height in the - // landscape orientation. Contrary to this, QPlatformScreen::physicalSize() expects the + // native orientation. Contrary to this, QPlatformScreen::physicalSize() expects the // returned dimensions to follow the current orientation. errno = 0; result = screen_get_display_property_iv(m_display, SCREEN_PROPERTY_PHYSICAL_SIZE, val); @@ -97,7 +97,8 @@ QQnxScreen::QQnxScreen(screen_context_t screenContext, screen_display_t display, m_nativeOrientation = val[0] >= val[1] ? Qt::LandscapeOrientation : Qt::PortraitOrientation; - if (m_currentRotation == 0 || m_currentRotation == 180) + const int angle = screen()->angleBetween(m_nativeOrientation, orientation()); + if (angle == 0 || angle == 180) m_currentPhysicalSize = m_initialPhysicalSize = QSize(val[0], val[1]); else m_currentPhysicalSize = m_initialPhysicalSize = QSize(val[1], val[0]); @@ -164,14 +165,28 @@ Qt::ScreenOrientation QQnxScreen::nativeOrientation() const Qt::ScreenOrientation QQnxScreen::orientation() const { Qt::ScreenOrientation orient; - if (m_currentRotation == 0) - orient = Qt::LandscapeOrientation; - else if (m_currentRotation == 90) - orient = Qt::PortraitOrientation; - else if (m_currentRotation == 180) - orient = Qt::InvertedLandscapeOrientation; - else - orient = Qt::InvertedPortraitOrientation; + if (m_nativeOrientation == Qt::LandscapeOrientation) { + // Landscape devices e.g. PlayBook + if (m_currentRotation == 0) + orient = Qt::LandscapeOrientation; + else if (m_currentRotation == 90) + orient = Qt::PortraitOrientation; + else if (m_currentRotation == 180) + orient = Qt::InvertedLandscapeOrientation; + else + orient = Qt::InvertedPortraitOrientation; + } else { + // Portrait devices e.g. Phones + // ###TODO Check these on an actual phone device + if (m_currentRotation == 0) + orient = Qt::PortraitOrientation; + else if (m_currentRotation == 90) + orient = Qt::LandscapeOrientation; + else if (m_currentRotation == 180) + orient = Qt::InvertedPortraitOrientation; + else + orient = Qt::InvertedLandscapeOrientation; + } qScreenDebug() << Q_FUNC_INFO << "orientation =" << orient; return orient; } -- cgit v1.2.3