fix: windows global hotkey Win/Meta and 1-9 doesn't work

This commit is contained in:
shenleban tongying 2024-11-14 04:06:23 -05:00 committed by GitHub
parent beef6dd138
commit 5cc43a3dc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,8 +1,3 @@
#ifdef __WIN32 // Q_OS_WIN32 isn't available at this point
#define _WIN32_WINNT 0x0430
#include <windows.h>
#endif
#include "hotkeywrapper.hh"
#include "gddebug.hh"
@ -12,6 +7,7 @@
#ifdef Q_OS_WIN
#include "mainwindow.hh"
#include <windows.h>
#endif
//////////////////////////////////////////////////////////////////////////
@ -332,13 +328,13 @@ bool HotkeyWrapper::winEvent( MSG * message, qintptr * result )
return false;
}
/// Ref: https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
quint32 HotkeyWrapper::nativeKey( int key )
{
if ( key >= Qt::Key_0 && key <= Qt::Key_9 )
return VK_NUMPAD0 + ( key - Qt::Key_0 );
if ( key >= Qt::Key_A && key <= Qt::Key_Z )
// Qt's 0-9 & A-Z overlaps with Windows's VK
if ( key >= Qt::Key_0 && key <= Qt::Key_9 || key >= Qt::Key_A && key <= Qt::Key_Z ) {
return key;
}
switch ( key ) {
case Qt::Key_Space:
@ -485,6 +481,8 @@ quint32 HotkeyWrapper::nativeKey( int key )
return 0x39;
case Qt::Key_Underscore:
return VK_OEM_MINUS;
case Qt::Key_Meta:
return VK_LWIN;
default:;
}