From 02311c07cf98d5a39a05a81aac5d5fc318f2d822 Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Sat, 18 May 2013 09:19:38 -0300 Subject: QNX: normalize braces Change-Id: I05f140a0626e543535cc74c6f737be9be1e27a5d Reviewed-by: Thomas McGuire --- src/plugins/platforms/qnx/qqnxbuffer.cpp | 21 ++---- src/plugins/platforms/qnx/qqnxglcontext.cpp | 30 +++------ src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp | 19 ++---- src/plugins/platforms/qnx/qqnxintegration.cpp | 12 ++-- src/plugins/platforms/qnx/qqnxnavigatorpps.cpp | 3 +- src/plugins/platforms/qnx/qqnxrootwindow.cpp | 60 ++++++----------- src/plugins/platforms/qnx/qqnxscreen.cpp | 10 ++- .../platforms/qnx/qqnxscreeneventhandler.cpp | 53 ++++++--------- .../platforms/qnx/qqnxvirtualkeyboardpps.cpp | 15 +++-- src/plugins/platforms/qnx/qqnxwindow.cpp | 78 ++++++++-------------- 10 files changed, 106 insertions(+), 195 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/qnx/qqnxbuffer.cpp b/src/plugins/platforms/qnx/qqnxbuffer.cpp index c5e99a2001..abb8a07026 100644 --- a/src/plugins/platforms/qnx/qqnxbuffer.cpp +++ b/src/plugins/platforms/qnx/qqnxbuffer.cpp @@ -69,36 +69,31 @@ QQnxBuffer::QQnxBuffer(screen_buffer_t buffer) errno = 0; int size[2]; int result = screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_BUFFER_SIZE, size); - if (result != 0) { + if (result != 0) qFatal("QQNX: failed to query buffer size, errno=%d", errno); - } // Get stride of buffer errno = 0; int stride; result = screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_STRIDE, &stride); - if (result != 0) { + if (result != 0) qFatal("QQNX: failed to query buffer stride, errno=%d", errno); - } // Get access to buffer's data errno = 0; uchar *dataPtr = 0; result = screen_get_buffer_property_pv(buffer, SCREEN_PROPERTY_POINTER, (void **)&dataPtr); - if (result != 0) { + if (result != 0) qFatal("QQNX: failed to query buffer pointer, errno=%d", errno); - } - if (dataPtr == 0) { + if (dataPtr == 0) qFatal("QQNX: buffer pointer is NULL, errno=%d", errno); - } // Get format of buffer errno = 0; int screenFormat; result = screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_FORMAT, &screenFormat); - if (result != 0) { + if (result != 0) qFatal("QQNX: failed to query buffer format, errno=%d", errno); - } // Convert screen format to QImage format QImage::Format imageFormat = QImage::Format_Invalid; @@ -146,16 +141,14 @@ void QQnxBuffer::invalidateInCache() qBufferDebug() << Q_FUNC_INFO; // Verify native buffer exists - if (m_buffer == 0) { + if (m_buffer == 0) qFatal("QQNX: can't invalidate cache for null buffer"); - } // Evict buffer's data from cache errno = 0; int result = msync(m_image.bits(), m_image.height() * m_image.bytesPerLine(), MS_INVALIDATE | MS_CACHE_ONLY); - if (result != 0) { + if (result != 0) qFatal("QQNX: failed to invalidate cache, errno=%d", errno); - } } QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxglcontext.cpp b/src/plugins/platforms/qnx/qqnxglcontext.cpp index f77bb73614..005b6d272a 100644 --- a/src/plugins/platforms/qnx/qqnxglcontext.cpp +++ b/src/plugins/platforms/qnx/qqnxglcontext.cpp @@ -96,9 +96,8 @@ QQnxGLContext::QQnxGLContext(QOpenGLContext *glContext) // Set current rendering API EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API); - if (eglResult != EGL_TRUE) { + if (eglResult != EGL_TRUE) qFatal("QQNX: failed to set EGL API, err=%d", eglGetError()); - } // Get colour channel sizes from window format int alphaSize = format.alphaBufferSize(); @@ -149,9 +148,8 @@ QQnxGLContext::QQnxGLContext(QOpenGLContext *glContext) // Select EGL config based on requested window format m_eglConfig = q_configFromGLFormat(ms_eglDisplay, format); - if (m_eglConfig == 0) { + if (m_eglConfig == 0) qFatal("QQnxGLContext: failed to find EGL config"); - } m_eglContext = eglCreateContext(ms_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, contextAttrs()); if (m_eglContext == EGL_NO_CONTEXT) { @@ -168,9 +166,8 @@ QQnxGLContext::~QQnxGLContext() qGLContextDebug() << Q_FUNC_INFO; // Cleanup EGL context if it exists - if (m_eglContext != EGL_NO_CONTEXT) { + if (m_eglContext != EGL_NO_CONTEXT) eglDestroyContext(ms_eglDisplay, m_eglContext); - } // Cleanup EGL surface if it exists destroySurface(); @@ -216,9 +213,8 @@ bool QQnxGLContext::makeCurrent(QPlatformSurface *surface) // Set current rendering API EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API); - if (eglResult != EGL_TRUE) { + if (eglResult != EGL_TRUE) qFatal("QQnxGLContext: failed to set EGL API, err=%d", eglGetError()); - } if (m_newSurfaceRequested.testAndSetOrdered(true, false)) { qGLContextDebug() << "New EGL surface requested"; @@ -241,15 +237,13 @@ void QQnxGLContext::doneCurrent() // set current rendering API EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API); - if (eglResult != EGL_TRUE) { + if (eglResult != EGL_TRUE) qFatal("QQNX: failed to set EGL API, err=%d", eglGetError()); - } // clear curent EGL context and unbind EGL surface eglResult = eglMakeCurrent(ms_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - if (eglResult != EGL_TRUE) { + if (eglResult != EGL_TRUE) qFatal("QQNX: failed to clear current EGL context, err=%d", eglGetError()); - } } void QQnxGLContext::swapBuffers(QPlatformSurface *surface) @@ -259,15 +253,13 @@ void QQnxGLContext::swapBuffers(QPlatformSurface *surface) // Set current rendering API EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API); - if (eglResult != EGL_TRUE) { + if (eglResult != EGL_TRUE) qFatal("QQNX: failed to set EGL API, err=%d", eglGetError()); - } // Post EGL surface to window eglResult = eglSwapBuffers(ms_eglDisplay, m_eglSurface); - if (eglResult != EGL_TRUE) { + if (eglResult != EGL_TRUE) qFatal("QQNX: failed to swap EGL buffers, err=%d", eglGetError()); - } } QFunctionPointer QQnxGLContext::getProcAddress(const QByteArray &procName) @@ -276,9 +268,8 @@ QFunctionPointer QQnxGLContext::getProcAddress(const QByteArray &procName) // Set current rendering API EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API); - if (eglResult != EGL_TRUE) { + if (eglResult != EGL_TRUE) qFatal("QQNX: failed to set EGL API, err=%d", eglGetError()); - } // Lookup EGL extension function pointer return static_cast(eglGetProcAddress(procName.constData())); @@ -309,9 +300,8 @@ void QQnxGLContext::createSurface(QPlatformSurface *surface) // Get a pointer to the corresponding platform window QQnxWindow *platformWindow = dynamic_cast(surface); - if (!platformWindow) { + if (!platformWindow) qFatal("QQNX: unable to create EGLSurface without a QQnxWindow"); - } // Link the window and context platformWindow->setPlatformOpenGLContext(this); diff --git a/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp b/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp index 97a361158e..580553f6e2 100644 --- a/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp +++ b/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp @@ -606,12 +606,10 @@ static bool imfAvailable() static bool s_imfDisabled = getenv("DISABLE_IMF") != 0; static bool s_imfReady = false; - if ( s_imfInitFailed || s_imfDisabled) { + if ( s_imfInitFailed || s_imfDisabled) return false; - } - else if ( s_imfReady ) { + else if ( s_imfReady ) return true; - } if ( p_imf_client_init == 0 ) { void *handle = dlopen("libinput_client.so.1", 0); @@ -623,17 +621,15 @@ static bool imfAvailable() p_ictrl_dispatch_event = (int32_t (*)(event_t *))dlsym(handle, "ictrl_dispatch_event"); p_vkb_init_selection_service = (int32_t (*)())dlsym(handle, "vkb_init_selection_service"); p_ictrl_get_num_active_sessions = (int32_t (*)())dlsym(handle, "ictrl_get_num_active_sessions"); - } - else - { + } else { qCritical() << Q_FUNC_INFO << "libinput_client.so.1 is not present - IMF services are disabled."; s_imfDisabled = true; return false; } + if ( p_imf_client_init && p_ictrl_open_session && p_ictrl_dispatch_event ) { s_imfReady = true; - } - else { + } else { p_ictrl_open_session = 0; p_ictrl_dispatch_event = 0; s_imfDisabled = true; @@ -1400,11 +1396,10 @@ spannable_string_t *QQnxInputContext::onGetTextBeforeCursor(input_session_t *ic, QString text = query.value(Qt::ImSurroundingText).toString(); m_lastCaretPos = query.value(Qt::ImCursorPosition).toInt(); - if (n < m_lastCaretPos) { + if (n < m_lastCaretPos) return toSpannableString(text.mid(m_lastCaretPos - n, n)); - } else { + else return toSpannableString(text.mid(0, m_lastCaretPos)); - } } int32_t QQnxInputContext::onPerformEditorAction(input_session_t *ic, int32_t editor_action) diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index 4cbbfa4da8..072f60dff8 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -139,9 +139,8 @@ QQnxIntegration::QQnxIntegration() // Open connection to QNX composition manager errno = 0; int result = screen_create_context(&m_screenContext, SCREEN_APPLICATION_CONTEXT); - if (result != 0) { + if (result != 0) qFatal("QQnx: failed to connect to composition manager, errno=%d", errno); - } // Not on BlackBerry, it has specialized event dispatcher which also handles navigator events #if !defined(Q_OS_BLACKBERRY) && defined(QQNX_PPS) @@ -367,9 +366,8 @@ QPlatformClipboard *QQnxIntegration::clipboard() const qIntegrationDebug() << Q_FUNC_INFO; #if defined(QQNX_PPS) - if (!m_clipboard) { + if (!m_clipboard) m_clipboard = new QQnxClipboard; - } #endif return m_clipboard; } @@ -442,9 +440,8 @@ void QQnxIntegration::createDisplays() errno = 0; int displayCount; int result = screen_get_context_property_iv(m_screenContext, SCREEN_PROPERTY_DISPLAY_COUNT, &displayCount); - if (result != 0) { + if (result != 0) qFatal("QQnxIntegration: failed to query display count, errno=%d", errno); - } if (displayCount < 1) { // Never happens, even if there's no display, libscreen returns 1 @@ -455,9 +452,8 @@ void QQnxIntegration::createDisplays() errno = 0; screen_display_t *displays = (screen_display_t *)alloca(sizeof(screen_display_t) * displayCount); result = screen_get_context_property_pv(m_screenContext, SCREEN_PROPERTY_DISPLAYS, (void **)displays); - if (result != 0) { + if (result != 0) qFatal("QQnxIntegration: failed to query displays, errno=%d", errno); - } // If it's primary, we create a QScreen for it even if it's not attached // since Qt will dereference QGuiApplication::primaryScreen() diff --git a/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp b/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp index 1656ab029b..c5c40f5a23 100644 --- a/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp +++ b/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp @@ -150,9 +150,8 @@ void QQnxNavigatorPps::parsePPS(const QByteArray &ppsData, QHash lines = ppsData.split('\n'); // validate pps object - if (lines.size() == 0 || lines.at(0) != "@control") { + if (lines.size() == 0 || lines.at(0) != "@control") qFatal("QQNX: unrecognized pps object, data=%s", ppsData.constData()); - } // parse pps object attributes and extract values for (int i = 1; i < lines.size(); i++) { diff --git a/src/plugins/platforms/qnx/qqnxrootwindow.cpp b/src/plugins/platforms/qnx/qqnxrootwindow.cpp index 198801a832..dddadb5ca8 100644 --- a/src/plugins/platforms/qnx/qqnxrootwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxrootwindow.cpp @@ -68,17 +68,15 @@ QQnxRootWindow::QQnxRootWindow(const QQnxScreen *screen) errno = 0; int result = screen_create_window(&m_window, m_screen->nativeContext()); int val[2]; - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to create window, errno=%d", errno); - } // Move window to proper display errno = 0; screen_display_t display = m_screen->nativeDisplay(); result = screen_set_window_property_pv(m_window, SCREEN_PROPERTY_DISPLAY, (void **)&display); - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to set window display, errno=%d", errno); - } // Make sure window is above navigator but below keyboard if running as root // since navigator won't automatically set our z-order in this case @@ -86,39 +84,34 @@ QQnxRootWindow::QQnxRootWindow(const QQnxScreen *screen) errno = 0; val[0] = MAGIC_ZORDER_FOR_NO_NAV; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ZORDER, val); - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to set window z-order, errno=%d", errno); - } } // Window won't be visible unless it has some buffers so make one dummy buffer that is 1x1 errno = 0; val[0] = SCREEN_USAGE_NATIVE; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_USAGE, val); - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to set window buffer usage, errno=%d", errno); - } errno = 0; val[0] = m_screen->nativeFormat(); result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_FORMAT, val); - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to set window pixel format, errno=%d", errno); - } errno = 0; val[0] = 1; val[1] = 1; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, val); - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to set window buffer size, errno=%d", errno); - } errno = 0; result = screen_create_window_buffers(m_window, 1); - if (result != 0) { + if (result != 0) qFatal("QQNX: failed to create window buffer, errno=%d", errno); - } // Window is always the size of the display errno = 0; @@ -126,50 +119,44 @@ QQnxRootWindow::QQnxRootWindow(const QQnxScreen *screen) val[0] = geometry.width(); val[1] = geometry.height(); result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, val); - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to set window size, errno=%d", errno); - } // Fill the window with solid black errno = 0; val[0] = 0; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_COLOR, val); - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to set window colour, errno=%d", errno); - } // Make the window opaque errno = 0; val[0] = SCREEN_TRANSPARENCY_NONE; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_TRANSPARENCY, val); - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to set window transparency, errno=%d", errno); - } // Set the swap interval to 1 errno = 0; val[0] = 1; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SWAP_INTERVAL, val); - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to set window swap interval, errno=%d", errno); - } // Set viewport size equal to window size but move outside buffer so the fill colour is used exclusively errno = 0; val[0] = geometry.width(); val[1] = geometry.height(); result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_SIZE, val); - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to set window source size, errno=%d", errno); - } errno = 0; val[0] = 1; val[1] = 0; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_POSITION, val); - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to set window source position, errno=%d", errno); - } createWindowGroup(); post(); @@ -187,16 +174,14 @@ void QQnxRootWindow::post() const errno = 0; screen_buffer_t buffer; int result = screen_get_window_property_pv(m_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&buffer); - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to query window buffer, errno=%d", errno); - } errno = 0; int dirtyRect[] = {0, 0, 1, 1}; result = screen_post_window(m_window, buffer, 1, dirtyRect, 0); - if (result != 0) { + if (result != 0) qFatal("QQNX: failed to post window buffer, errno=%d", errno); - } } void QQnxRootWindow::flush() const @@ -205,9 +190,8 @@ void QQnxRootWindow::flush() const // Force immediate display update errno = 0; int result = screen_flush_context(m_screen->nativeContext(), 0); - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to flush context, errno=%d", errno); - } } void QQnxRootWindow::setRotation(int rotation) @@ -215,9 +199,8 @@ void QQnxRootWindow::setRotation(int rotation) qRootWindowDebug() << Q_FUNC_INFO << "angle =" << rotation; errno = 0; int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ROTATION, &rotation); - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to set window rotation, errno=%d", errno); - } } void QQnxRootWindow::resize(const QSize &size) @@ -225,15 +208,13 @@ void QQnxRootWindow::resize(const QSize &size) errno = 0; int val[] = {size.width(), size.height()}; int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, val); - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to set window size, errno=%d", errno); - } errno = 0; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_SIZE, val); - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to set window source size, errno=%d", errno); - } // NOTE: display will update when child windows relayout and repaint } @@ -246,7 +227,6 @@ void QQnxRootWindow::createWindowGroup() // Create window group so child windows can be parented by container window errno = 0; int result = screen_create_window_group(m_window, m_windowGroupName.constData()); - if (result != 0) { + if (result != 0) qFatal("QQnxRootWindow: failed to create app window group, errno=%d", errno); - } } diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp index 2b81559ab6..f8203b2329 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.cpp +++ b/src/plugins/platforms/qnx/qqnxscreen.cpp @@ -118,18 +118,17 @@ QQnxScreen::QQnxScreen(screen_context_t screenContext, screen_display_t display, // Cache initial orientation of this display errno = 0; int result = screen_get_display_property_iv(m_display, SCREEN_PROPERTY_ROTATION, &m_initialRotation); - if (result != 0) { + if (result != 0) qFatal("QQnxScreen: failed to query display rotation, errno=%d", errno); - } + m_currentRotation = m_initialRotation; // Cache size of this display in pixels errno = 0; int val[2]; result = screen_get_display_property_iv(m_display, SCREEN_PROPERTY_SIZE, val); - if (result != 0) { + if (result != 0) qFatal("QQnxScreen: failed to query display size, errno=%d", errno); - } m_currentGeometry = m_initialGeometry = QRect(0, 0, val[0], val[1]); @@ -165,9 +164,8 @@ static int defaultDepth() // check if display depth was specified in environment variable; // use default value if no valid value found defaultDepth = qgetenv("QQNX_DISPLAY_DEPTH").toInt(); - if (defaultDepth != 16 && defaultDepth != 32) { + if (defaultDepth != 16 && defaultDepth != 32) defaultDepth = 32; - } } return defaultDepth; } diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp index 57cfdc5eb6..c2d0e3e41c 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp +++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp @@ -90,9 +90,8 @@ bool QQnxScreenEventHandler::handleEvent(screen_event_t event) errno = 0; int qnxType; int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_TYPE, &qnxType); - if (result) { + if (result) qFatal("QQNX: failed to query event type, errno=%d", errno); - } return handleEvent(event, qnxType); } @@ -161,9 +160,8 @@ void QQnxScreenEventHandler::injectKeyboardEvent(int flags, int sym, int modifie if ( qtMod & Qt::ControlModifier ) { keyStr = QChar((int)(key & 0x3f)); } else { - if (flags & KEY_SYM_VALID) { + if (flags & KEY_SYM_VALID) keyStr = QChar(sym); - } } } else if ((cap > 0x0ff && cap < UNICODE_PRIVATE_USE_AREA_FIRST) || cap > UNICODE_PRIVATE_USE_AREA_LAST) { key = (Qt::Key)cap; @@ -186,35 +184,30 @@ void QQnxScreenEventHandler::handleKeyboardEvent(screen_event_t event) errno = 0; int flags; int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_FLAGS, &flags); - if (result) { + if (result) qFatal("QQNX: failed to query event flags, errno=%d", errno); - } // get key code errno = 0; int sym; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SYM, &sym); - if (result) { + if (result) qFatal("QQNX: failed to query event sym, errno=%d", errno); - } int modifiers; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_MODIFIERS, &modifiers); - if (result) { + if (result) qFatal("QQNX: failed to query event modifiers, errno=%d", errno); - } int scan; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SCAN, &scan); - if (result) { + if (result) qFatal("QQNX: failed to query event modifiers, errno=%d", errno); - } int cap; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_CAP, &cap); - if (result) { + if (result) qFatal("QQNX: failed to query event cap, errno=%d", errno); - } injectKeyboardEvent(flags, sym, modifiers, scan, cap); } @@ -227,38 +220,34 @@ void QQnxScreenEventHandler::handlePointerEvent(screen_event_t event) screen_window_t qnxWindow; void *handle; int result = screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, &handle); - if (result) { + if (result) qFatal("QQNX: failed to query event window, errno=%d", errno); - } + qnxWindow = static_cast(handle); // Query the button states int buttonState = 0; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_BUTTONS, &buttonState); - if (result) { + if (result) qFatal("QQNX: failed to query event button state, errno=%d", errno); - } // Query the window position int windowPos[2]; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, windowPos); - if (result) { + if (result) qFatal("QQNX: failed to query event window position, errno=%d", errno); - } // Query the screen position int pos[2]; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, pos); - if (result) { + if (result) qFatal("QQNX: failed to query event position, errno=%d", errno); - } // Query the wheel delta int wheelDelta = 0; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_MOUSE_WHEEL, &wheelDelta); - if (result) { + if (result) qFatal("QQNX: failed to query event wheel delta, errno=%d", errno); - } // Map window handle to top-level QWindow QWindow *w = QQnxIntegration::window(qnxWindow); @@ -343,9 +332,8 @@ void QQnxScreenEventHandler::handleTouchEvent(screen_event_t event, int qnxType) errno = 0; int pos[2]; int result = screen_get_event_property_iv(event, SCREEN_PROPERTY_POSITION, pos); - if (result) { + if (result) qFatal("QQNX: failed to query event position, errno=%d", errno); - } QCursor::setPos(pos[0], pos[1]); @@ -353,25 +341,23 @@ void QQnxScreenEventHandler::handleTouchEvent(screen_event_t event, int qnxType) errno = 0; int windowPos[2]; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, windowPos); - if (result) { + if (result) qFatal("QQNX: failed to query event window position, errno=%d", errno); - } // determine which finger touched errno = 0; int touchId; result = screen_get_event_property_iv(event, SCREEN_PROPERTY_TOUCH_ID, &touchId); - if (result) { + if (result) qFatal("QQNX: failed to query event touch id, errno=%d", errno); - } // determine which window was touched errno = 0; void *handle; result = screen_get_event_property_pv(event, SCREEN_PROPERTY_WINDOW, &handle); - if (result) { + if (result) qFatal("QQNX: failed to query event window, errno=%d", errno); - } + screen_window_t qnxWindow = static_cast(handle); // check if finger is valid @@ -454,9 +440,8 @@ void QQnxScreenEventHandler::handleCloseEvent(screen_event_t event) // Map window handle to top-level QWindow QWindow *w = QQnxIntegration::window(window); - if (w != 0) { + if (w != 0) QWindowSystemInterface::handleCloseEvent(w); - } } void QQnxScreenEventHandler::handleCreateEvent(screen_event_t event) diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp index e810b47c22..20fce3da70 100644 --- a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp +++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp @@ -209,13 +209,14 @@ void QQnxVirtualKeyboardPps::ppsDataReady() } if (pps_decoder_get_string(m_decoder, "msg", &value) == PPS_DECODER_OK) { - if (strcmp(value, "show") == 0) { + if (strcmp(value, "show") == 0) setVisible(true); - } else if (strcmp(value, "hide") == 0) { + else if (strcmp(value, "hide") == 0) setVisible(false); - } else if (strcmp(value, "info") == 0) + else if (strcmp(value, "info") == 0) handleKeyboardInfoMessage(); - else if (strcmp(value, "connect") == 0) { } + else if (strcmp(value, "connect") == 0) + qVirtualKeyboardDebug() << Q_FUNC_INFO << "Unhandled command 'connect'"; else qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS msg value: %s", value ? value : "[null]"); } else if (pps_decoder_get_string(m_decoder, "res", &value) == PPS_DECODER_OK) { @@ -223,8 +224,9 @@ void QQnxVirtualKeyboardPps::ppsDataReady() handleKeyboardInfoMessage(); else qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS res value: %s", value ? value : "[null]"); - } else + } else { qCritical("QQnxVirtualKeyboard: Unexpected keyboard PPS message type"); + } } void QQnxVirtualKeyboardPps::handleKeyboardInfoMessage() @@ -368,9 +370,8 @@ void QQnxVirtualKeyboardPps::applyKeyboardModeOptions(KeyboardMode mode) pps_encoder_end_object(m_encoder); - if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) { + if (::write(m_fd, pps_encoder_buffer(m_encoder), pps_encoder_length(m_encoder)) == -1) close(); - } pps_encoder_reset(m_encoder); } diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index a556bed76a..f4cbb0e9db 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -87,9 +87,8 @@ QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context) // Create child QNX window errno = 0; result = screen_create_window_type(&m_window, m_screenContext, SCREEN_CHILD_WINDOW); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to create window, errno=%d", errno); - } // Set window buffer usage based on rendering API int val; @@ -108,41 +107,36 @@ QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context) errno = 0; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_USAGE, &val); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to set window buffer usage, errno=%d", errno); - } // Alpha channel is always pre-multiplied if present errno = 0; val = SCREEN_PRE_MULTIPLIED_ALPHA; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_ALPHA_MODE, &val); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to set window alpha mode, errno=%d", errno); - } // Make the window opaque errno = 0; val = SCREEN_TRANSPARENCY_NONE; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_TRANSPARENCY, &val); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to set window transparency, errno=%d", errno); - } // Set the window swap interval errno = 0; val = 1; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SWAP_INTERVAL, &val); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to set window swap interval, errno=%d", errno); - } if (window->flags() && Qt::WindowDoesNotAcceptFocus) { errno = 0; val = SCREEN_SENSITIVITY_NO_FOCUS; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SENSITIVITY, &val); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to set window sensitivity, errno=%d", errno); - } } setScreen(static_cast(window->screen()->handle())); @@ -228,24 +222,21 @@ QRect QQnxWindow::setGeometryHelper(const QRect &rect) val[0] = rect.x(); val[1] = rect.y(); int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_POSITION, val); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to set window position, errno=%d", errno); - } errno = 0; val[0] = rect.width(); val[1] = rect.height(); result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SIZE, val); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to set window size, errno=%d", errno); - } // Set viewport size equal to window size errno = 0; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_SOURCE_SIZE, val); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to set window source size, errno=%d", errno); - } return oldGeometry; } @@ -266,9 +257,8 @@ void QQnxWindow::setOffset(const QPoint &offset) val[0] = newGeometry.x(); val[1] = newGeometry.y(); int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_POSITION, val); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to set window position, errno=%d", errno); - } Q_FOREACH (QQnxWindow *childWindow, m_childWindows) childWindow->setOffset(offset); @@ -305,9 +295,8 @@ void QQnxWindow::updateVisibility(bool parentVisible) errno = 0; int val = (m_visible && parentVisible) ? 1 : 0; int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_VISIBLE, &val); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to set window visibility, errno=%d", errno); - } Q_FOREACH (QQnxWindow *childWindow, m_childWindows) childWindow->updateVisibility(m_visible && parentVisible); @@ -320,9 +309,8 @@ void QQnxWindow::setOpacity(qreal level) errno = 0; int val = (int)(level * 255); int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_GLOBAL_ALPHA, &val); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to set window global alpha, errno=%d", errno); - } // TODO: How to handle children of this window? If we change all the visibilities, then // the transparency will look wrong... @@ -358,9 +346,8 @@ void QQnxWindow::setBufferSize(const QSize &size) int val[2] = { nonEmptySize.width(), nonEmptySize.height() }; int result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_BUFFER_SIZE, val); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to set window buffer size, errno=%d", errno); - } // Create window buffers if they do not exist if (m_bufferSize.isEmpty()) { @@ -368,31 +355,27 @@ void QQnxWindow::setBufferSize(const QSize &size) #if !defined(QT_NO_OPENGL) // Get pixel format from EGL config if using OpenGL; // otherwise inherit pixel format of window's screen - if (m_platformOpenGLContext != 0) { + if (m_platformOpenGLContext != 0) val[0] = platformWindowFormatToNativeFormat(m_platformOpenGLContext->format()); - } #endif errno = 0; result = screen_set_window_property_iv(m_window, SCREEN_PROPERTY_FORMAT, val); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to set window pixel format, errno=%d", errno); - } errno = 0; result = screen_create_window_buffers(m_window, MAX_BUFFER_COUNT); - if (result != 0) { + if (result != 0) qWarning() << "QQnxWindow: Buffer size was" << size; qFatal("QQnxWindow: failed to create window buffers, errno=%d", errno); - } // check if there are any buffers available int bufferCount = 0; result = screen_get_window_property_iv(m_window, SCREEN_PROPERTY_RENDER_BUFFER_COUNT, &bufferCount); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to query window buffer count, errno=%d", errno); - } if (bufferCount != MAX_BUFFER_COUNT) { qFatal("QQnxWindow: invalid buffer count. Expected = %d, got = %d. You might experience problems.", @@ -422,9 +405,8 @@ QQnxBuffer &QQnxWindow::renderBuffer() errno = 0; screen_buffer_t buffers[MAX_BUFFER_COUNT]; const int result = screen_get_window_property_pv(m_window, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)buffers); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to query window buffers, errno=%d", errno); - } // Wrap each buffer for (int i = 0; i < MAX_BUFFER_COUNT; ++i) { @@ -488,24 +470,21 @@ void QQnxWindow::post(const QRegion &dirty) // Update the display with contents of render buffer errno = 0; int result = screen_post_window(m_window, currentBuffer.nativeBuffer(), 1, dirtyRect, 0); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to post window buffer, errno=%d", errno); - } // Advance to next nender buffer m_previousBufferIndex = m_currentBufferIndex++; - if (m_currentBufferIndex >= MAX_BUFFER_COUNT) { + if (m_currentBufferIndex >= MAX_BUFFER_COUNT) m_currentBufferIndex = 0; - } // Save modified region and clear scrolled region m_previousDirty = dirty; m_scrolled = QRegion(); // Notify screen that window posted - if (m_screen != 0) { + if (m_screen != 0) m_screen->onWindowPost(this); - } } } @@ -530,16 +509,14 @@ void QQnxWindow::setScreen(QQnxScreen *platformScreen) errno = 0; screen_display_t display = platformScreen->nativeDisplay(); int result = screen_set_window_property_pv(m_window, SCREEN_PROPERTY_DISPLAY, (void **)&display); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to set window display, errno=%d", errno); - } // Add window to display's window group errno = 0; result = screen_join_window_group(m_window, platformScreen->windowGroupName()); - if (result != 0) { + if (result != 0) qFatal("QQnxWindow: failed to join window group, errno=%d", errno); - } Q_FOREACH (QQnxWindow *childWindow, m_childWindows) { // Only subwindows and tooltips need necessarily be moved to another display with the window. @@ -809,19 +786,16 @@ int QQnxWindow::platformWindowFormatToNativeFormat(const QSurfaceFormat &format) qWindowDebug() << Q_FUNC_INFO; // Extract size of colour channels from window format int redSize = format.redBufferSize(); - if (redSize == -1) { + if (redSize == -1) qFatal("QQnxWindow: red size not defined"); - } int greenSize = format.greenBufferSize(); - if (greenSize == -1) { + if (greenSize == -1) qFatal("QQnxWindow: green size not defined"); - } int blueSize = format.blueBufferSize(); - if (blueSize == -1) { + if (blueSize == -1) qFatal("QQnxWindow: blue size not defined"); - } // select matching native format if (redSize == 5 && greenSize == 6 && blueSize == 5) { -- cgit v1.2.3