Qt: implemented getKeyState for caps lock and numlock under x11 and win32 targets

git-svn-id: trunk@40764 -
This commit is contained in:
zeljko 2013-04-09 14:59:07 +00:00
parent f2e93a25c3
commit 1c03450e8b
2 changed files with 37 additions and 0 deletions

View File

@ -2990,6 +2990,17 @@ begin
VK_LWIN, VK_RWIN:
if (QApplication_keyboardModifiers and QtMetaModifier) > 0 then
Result := Result or StateDown;
VK_LCL_CAPSLOCK, VK_NUMLOCK:
begin
{$IFDEF MSWINDOWS}
Result := Windows.GetKeyState(nVirtKey);
{$ELSE}
{$IFDEF HASX11}
if GetKeyLockState(nVirtKey) then
Result := StateDown;
{$ENDIF}
{$ENDIF}
end;
{$ifdef VerboseQtWinAPI}
else
DebugLn('TQtWidgetSet.GetKeyState TODO ', DbgSVKCode(Word(nVirtkey)));

View File

@ -256,3 +256,29 @@ begin
@Xclient);
end;
{$warning xkblib is not included because of codetools errors. When codetools
are fixed remove this and include xkblib.}
function XkbGetIndicatorState (dpy : PDisplay; deviceSpec : Word; pStateRtrn : PWord) : TStatus;
cdecl; external libX11 name 'XkbGetIndicatorState';
function GetKeyLockState(const AKey: Byte): Boolean;
var
Display: PDisplay;
n: Cardinal;
begin
Result := False;
Display := QX11Info_display();
if (Display = nil) then
exit;
// to avoid XKB unit inclusion XkbUseCoreKbd = $0100;
if (XkbGetIndicatorState(Display, $0100, @n) = Success) then
begin
if (AKey = VK_LCL_CAPSLOCK) then
Result := (n and $01) = 1
else
if (AKey = VK_NUMLOCK) then
Result := (n and $02) = 2;
end;
end;