Fixing Bug 46200 [Easy Hack]

Michael Stahl mstahl at redhat.com
Thu Apr 3 13:26:40 PDT 2014


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.

> 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.

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() &
INDICATOR_CAPSLOCK);

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)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: scroll_lock_key.patch
Type: text/x-patch
Size: 1979 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20140403/b1d7b42c/attachment.bin>


More information about the LibreOffice mailing list