From b20548f9999d8c111268f3f2287c0801c6c5cbb0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 18 Feb 2016 13:13:49 +0100 Subject: Windows QPA: Fix warnings as shown by Qt Creator's Clang based code model. Code except font, accessibility and file qwindowswindow.cpp. Task-number: QTBUG-50804 Change-Id: I40848264f9fa16eea00cf70d7be009c484c49e92 Reviewed-by: Oliver Wolff --- .../platforms/windows/qwindowskeymapper.cpp | 66 +++++++++++----------- 1 file changed, 34 insertions(+), 32 deletions(-) (limited to 'src/plugins/platforms/windows/qwindowskeymapper.cpp') diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index b7e7867404..5790341dbf 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -541,7 +541,7 @@ Q_STATIC_ASSERT((NumMods == KeyboardLayoutItem::NumQtKeys)); /** Remap return or action key to select key for windows mobile. */ -inline int winceKeyBend(int keyCode) +inline quint32 winceKeyBend(quint32 keyCode) { return KeyTbl[keyCode]; } @@ -575,10 +575,10 @@ QT_END_INCLUDE_NAMESPACE #endif // Q_OS_WINCE // Translate a VK into a Qt key code, or unicode character -static inline int toKeyOrUnicode(int vk, int scancode, unsigned char *kbdBuffer, bool *isDeadkey = 0) +static inline quint32 toKeyOrUnicode(quint32 vk, quint32 scancode, unsigned char *kbdBuffer, bool *isDeadkey = 0) { Q_ASSERT(vk > 0 && vk < 256); - int code = 0; + quint32 code = 0; QChar unicodeBuffer[5]; int res = ToUnicode(vk, scancode, kbdBuffer, reinterpret_cast(unicodeBuffer), 5, 0); // When Ctrl modifier is used ToUnicode does not return correct values. In order to assign the @@ -632,13 +632,13 @@ void QWindowsKeyMapper::changeKeyboard() /* MAKELCID()'s first argument is a WORD, and GetKeyboardLayout() * returns a DWORD. */ - LCID newLCID = MAKELCID((quintptr)GetKeyboardLayout(0), SORT_DEFAULT); + LCID newLCID = MAKELCID(quintptr(GetKeyboardLayout(0)), SORT_DEFAULT); // keyboardInputLocale = qt_localeFromLCID(newLCID); bool bidi = false; wchar_t LCIDFontSig[16]; if (GetLocaleInfo(newLCID, LOCALE_FONTSIGNATURE, LCIDFontSig, sizeof(LCIDFontSig) / sizeof(wchar_t)) - && (LCIDFontSig[7] & (wchar_t)0x0800)) + && (LCIDFontSig[7] & wchar_t(0x0800))) bidi = true; keyboardInputDirection = bidi ? Qt::RightToLeft : Qt::LeftToRight; @@ -662,7 +662,7 @@ void QWindowsKeyMapper::updateKeyMap(const MSG &msg) unsigned char kbdBuffer[256]; // Will hold the complete keyboard state GetKeyboardState(kbdBuffer); const quint32 scancode = (msg.lParam >> 16) & scancodeBitmask; - updatePossibleKeyCodes(kbdBuffer, scancode, msg.wParam); + updatePossibleKeyCodes(kbdBuffer, scancode, quint32(msg.wParam)); } // Fills keyLayout for that vk_key. Values are all characters one can type using that key @@ -721,7 +721,7 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 keyLayout[vk_key].qtKey[7] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey); keyLayout[vk_key].deadkeys |= isDeadKey ? 0x80 : 0; // Add a fall back key for layouts which don't do composition and show non-latin1 characters - int fallbackKey = winceKeyBend(vk_key); + quint32 fallbackKey = winceKeyBend(vk_key); if (!fallbackKey || fallbackKey == Qt::Key_unknown) { fallbackKey = 0; if (vk_key != keyLayout[vk_key].qtKey[0] && vk_key < 0x5B && vk_key > 0x2F) @@ -762,7 +762,7 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 static inline QString messageKeyText(const MSG &msg) { - const QChar ch = QChar((ushort)msg.wParam); + const QChar ch = QChar(ushort(msg.wParam)); return ch.isNull() ? QString() : QString(ch); } @@ -807,7 +807,7 @@ static void showSystemMenu(QWindow* w) topLevelHwnd, 0); if (ret) - qWindowsWndProc(topLevelHwnd, WM_SYSCOMMAND, ret, 0); + qWindowsWndProc(topLevelHwnd, WM_SYSCOMMAND, WPARAM(ret), 0); } static inline void sendExtendedPressRelease(QWindow *w, int k, @@ -871,7 +871,7 @@ bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, con if (cmd < 0 || cmd > 52) return false; - const int qtKey = CmdTbl[cmd]; + const int qtKey = int(CmdTbl[cmd]); sendExtendedPressRelease(receiver, qtKey, Qt::KeyboardModifier(state), 0, 0, 0); // QTBUG-43343: Make sure to return false if Qt does not handle the key, otherwise, // the keys are not passed to the active media player. @@ -885,10 +885,10 @@ bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, con bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &msg, bool /* grab */) { - const int msgType = msg.message; + const UINT msgType = msg.message; const quint32 scancode = (msg.lParam >> 16) & scancodeBitmask; - quint32 vk_key = msg.wParam; + quint32 vk_key = quint32(msg.wParam); quint32 nModifiers = 0; QWindow *receiver = m_keyGrabber ? m_keyGrabber : window; @@ -949,13 +949,13 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms if (dirStatus == VK_LSHIFT && ((msg.wParam == VK_SHIFT && GetKeyState(VK_LCONTROL)) || (msg.wParam == VK_CONTROL && GetKeyState(VK_LSHIFT)))) { - sendExtendedPressRelease(receiver, Qt::Key_Direction_L, 0, scancode, msg.wParam, nModifiers, QString(), false); + sendExtendedPressRelease(receiver, Qt::Key_Direction_L, 0, scancode, vk_key, nModifiers, QString(), false); result = true; dirStatus = 0; } else if (dirStatus == VK_RSHIFT && ( (msg.wParam == VK_SHIFT && GetKeyState(VK_RCONTROL)) || (msg.wParam == VK_CONTROL && GetKeyState(VK_RSHIFT)))) { - sendExtendedPressRelease(receiver, Qt::Key_Direction_R, 0, scancode, msg.wParam, nModifiers, QString(), false); + sendExtendedPressRelease(receiver, Qt::Key_Direction_R, 0, scancode, vk_key, nModifiers, QString(), false); result = true; dirStatus = 0; } else { @@ -1030,7 +1030,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms || (msg.wParam >= VK_OEM_PLUS && msg.wParam <= VK_OEM_3)) ? 0 : int(Qt::KeypadModifier); default: - if ((uint)msg.lParam == 0x004c0001 || (uint)msg.lParam == 0xc04c0001) + if (uint(msg.lParam) == 0x004c0001 || uint(msg.lParam) == 0xc04c0001) state |= Qt::KeypadModifier; break; } @@ -1042,6 +1042,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms case Qt::Key_Slash: case Qt::Key_NumLock: state |= Qt::KeypadModifier; + break; default: break; } @@ -1051,13 +1052,13 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms if (msgType == WM_KEYDOWN || msgType == WM_IME_KEYDOWN || msgType == WM_SYSKEYDOWN) { // Get the last record of this key press, so we can validate the current state // The record is not removed from the list - KeyRecord *rec = key_recorder.findKey(msg.wParam, false); + KeyRecord *rec = key_recorder.findKey(int(msg.wParam), false); // If rec's state doesn't match the current state, something has changed behind our back // (Consumed by modal widget is one possibility) So, remove the record from the list // This will stop the auto-repeat of the key, should a modifier change, for example if (rec && rec->state != state) { - key_recorder.findKey(msg.wParam, true); + key_recorder.findKey(int(msg.wParam), true); rec = 0; } @@ -1070,11 +1071,11 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms QChar uch; if (PeekMessage(&wm_char, 0, charType, charType, PM_REMOVE)) { // Found a ?_CHAR - uch = QChar((ushort)wm_char.wParam); + uch = QChar(ushort(wm_char.wParam)); if (msgType == WM_SYSKEYDOWN && uch.isLetter() && (msg.lParam & KF_ALTDOWN)) uch = uch.toLower(); // (See doc of WM_SYSCHAR) Alt-letter if (!code && !uch.row()) - code = asciiToKeycode(uch.cell(), state); + code = asciiToKeycode(char(uch.cell()), state); } // Special handling for the WM_IME_KEYDOWN message. Microsoft IME (Korean) will not @@ -1085,7 +1086,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms const QWindowsInputContext *windowsInputContext = qobject_cast(QWindowsIntegration::instance()->inputContext()); if (!(windowsInputContext && windowsInputContext->isComposing())) - vk_key = ImmGetVirtualKey((HWND)window->winId()); + vk_key = ImmGetVirtualKey(reinterpret_cast(window->winId())); BYTE keyState[256]; wchar_t newKey[3] = {0}; GetKeyboardState(keyState); @@ -1105,14 +1106,14 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms uch = QChar(QLatin1Char(0x7f)); // Windows doesn't know this one. } else { if (msgType != WM_SYSKEYDOWN || !code) { - UINT map = MapVirtualKey(msg.wParam, 2); + UINT map = MapVirtualKey(UINT(msg.wParam), 2); // If the high bit of the return value is set, it's a deadkey if (!(map & 0x80000000)) - uch = QChar((ushort)map); + uch = QChar(ushort(map)); } } if (!code && !uch.row()) - code = asciiToKeycode(uch.cell(), state); + code = asciiToKeycode(char(uch.cell()), state); } // Special handling of global Windows hotkeys @@ -1141,9 +1142,9 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms if (rec) { if (code < Qt::Key_Shift || code > Qt::Key_ScrollLock) { QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyRelease, code, - Qt::KeyboardModifier(state), scancode, msg.wParam, nModifiers, rec->text, true); + Qt::KeyboardModifier(state), scancode, quint32(msg.wParam), nModifiers, rec->text, true); QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyPress, code, - Qt::KeyboardModifier(state), scancode, msg.wParam, nModifiers, rec->text, true); + Qt::KeyboardModifier(state), scancode, quint32(msg.wParam), nModifiers, rec->text, true); result = true; } } @@ -1151,7 +1152,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms // and store the key data into our records. else { const QString text = uch.isNull() ? QString() : QString(uch); - const char a = uch.row() ? 0 : uch.cell(); + const char a = uch.row() ? char(0) : char(uch.cell()); const Qt::KeyboardModifiers modifiers(state); #ifndef QT_NO_SHORTCUT // Is Qt interested in the context menu key? @@ -1160,9 +1161,9 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms return false; } #endif // !QT_NO_SHORTCUT - key_recorder.storeKey(msg.wParam, a, state, text); + key_recorder.storeKey(int(msg.wParam), a, state, text); QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyPress, code, - modifiers, scancode, msg.wParam, nModifiers, text, false); + modifiers, scancode, quint32(msg.wParam), nModifiers, text, false); result =true; bool store = true; #ifndef Q_OS_WINCE @@ -1181,7 +1182,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms } #endif // !Q_OS_WINCE if (!store) - key_recorder.findKey(msg.wParam, true); + key_recorder.findKey(int(msg.wParam), true); } } @@ -1191,7 +1192,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms // The key may not be in our records if, for example, the down event was handled by // win32 natively, or our window gets focus while a key is already press, but now gets // the key release event. - KeyRecord* rec = key_recorder.findKey(msg.wParam, true); + const KeyRecord *rec = key_recorder.findKey(int(msg.wParam), true); if (!rec && !(code == Qt::Key_Shift || code == Qt::Key_Control || code == Qt::Key_Meta @@ -1199,13 +1200,14 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms // Someone ate the key down event } else { if (!code) - code = asciiToKeycode(rec->ascii ? rec->ascii : msg.wParam, state); + code = asciiToKeycode(rec->ascii ? char(rec->ascii) : char(msg.wParam), state); // Map SHIFT + Tab to SHIFT + BackTab, QShortcutMap knows about this translation if (code == Qt::Key_Tab && (state & Qt::ShiftModifier) == Qt::ShiftModifier) code = Qt::Key_Backtab; QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyRelease, code, - Qt::KeyboardModifier(state), scancode, msg.wParam, nModifiers, + Qt::KeyboardModifier(state), scancode, quint32(msg.wParam), + nModifiers, (rec ? rec->text : QString()), false); result = true; #ifndef Q_OS_WINCE -- cgit v1.2.3