Fixing Bug 46200 [Easy Hack]

Tharindu Amila Perera amilastbmmv at
Fri Apr 4 00:16:02 PDT 2014

First of all Thank you for the help. :)

On Fri, Apr 4, 2014 at 1:56 AM, Michael Stahl <mstahl at> wrote:
> On 01/04/14 06:50, Tharindu Amila Perera wrote:
>> Hi all,
>> Using the reply I found out that the events coming from the keyboard
>> has this behavior.
>> Using the argument KeyEvent coming to function in file tabvwsh4.cxx
>>     bool ScTabViewShell::TabKeyInput(const KeyEvent& rKEvt)
>> I can get codes of all keys except of Caps-Lock, NumLock and
>> Scroll(Which is the needed input).
>> I noticed that when any of the above keys are pressed this function is
>> called twice. But in both events the keycodes are not accessible.
> hmm... indeed the keycode is 0 there... it looks like the "lock" keys
> are not mapped to a keycode in VCL... perhaps intentionally.

Maybe they did it on purpose as only finding if it is on or off is the
only operation done on the value.

>> When CapsLock is on pressing key 'A' in keyboard will give the same
>> keycode as when it is not on. So there must be a place where it is
>> handled to differentiate a and A inputs. It would be appreciated if I
>> can get a code pointer for this.
> if i read the bug correctly you don't actually need the key events, you
> just need to know if the lock key is active when some other input happens.
 Yes I only need to know if it was on or not.
> vcl/unx/generic/app/saldisp.cxx:
>  sal_uInt16 SalDisplay::GetIndicatorState() const
>  {
>     unsigned int _state = 0;
>     sal_uInt16 nState = 0;
>     XkbGetIndicatorState(pDisp_, XkbUseCoreKbd, &_state);
>     if ((_state & 0x00000001))
>         nState |= INDICATOR_CAPSLOCK;
>     if ((_state & 0x00000002))
>         nState |= INDICATOR_NUMLOCK;
>     if ((_state & 0x00000004))
>         nState |= INDICATOR_SCROLLLOCK;
>     return nState;
>  }
> there is an example for requesting the caps-lock key state in
> editeng/source/misc/svxacorr.cxx:
>  bool bLockKeyOn = pFrameWin && (pFrameWin->GetIndicatorState() &
> so you need a VCL Window to get the state; a SfxViewShell like the
> ScTabVierwShell has a pointer to its Window.
> (since i read the bug too late i've already got a patch to assign a
> keycode for the scroll-lock key (see attachment), but i now think that
> is actually useless)

Following your example I went ahead and added

Window* pWin = &(pThisFrame->GetWindow());
bool bScrollLockKeyOn = pWin && (pWin->GetIndicatorState() &

to tabvwsh4.cxx

If I'm using this method to find capslock on it works fine. I checked
the value of pWin->GetIndicatorState()
It returns 1 for CapsLock 2 for NumLock and 0 for ScrollLock.

My keyboard doesn't have ScrollLock key in it. I was using the onboard
app in Ubuntu. Maybe it caused the error.

I'm going ahead with the rest of the implementation. And try to fix
getting the input later :).
Thanks and regards,
Tharindu Amila Perera
Department of Computer Science & Engineering
University of Moratuwa

More information about the LibreOffice mailing list