[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: CapsLock, NumLock keyboard status
From:       Lubos Lunak <l.lunak () sh ! cvut ! cz>
Date:       1999-03-08 19:11:50
[Download RAW message or body]

On Po, 08 bøezen 1999, Hans-Peter Jansen wrote :
>Ralf Nolden wrote:
>> 
>> Carsten Pfeiffer wrote:
>> >
>> > On Fri, Mar 05, 1999 at 10:04:59AM +0100, Ralf Nolden wrote:
>> >
>> > Hi,
>> >
>> > > I thought about adding statusbar indicators for the CapsLock and NumLock
>> > > keyboard status just like we have the insert/overwrite status shown in
>> > > kdevelop.

<snip>

>> So, again, does anyone have a solution for this or is there none ?
>
>You're right, it's a somehow missing feature. But I thing, that it is 
>worth thinking about a panel docking app, which displays CAPSLOCK (and
>maybe NUMLOCK) state and optionally set a configurable default value 
>at startup. This would satisfy at least my users (from a company office
>environment). So, if you have a solution, it would be kind to send me 
>a hint. If noone else does such a thing, I would do it sometimes.
>
>Cheers
>Hans-Peter
>
>> Best,
>> 
>> Ralf Nolden
>> The KDevelop Team

Well, I _maybe_ know. 'Maybe' because the piece of code looks terrible. Take a
look :
In <yourApp>::x11EventFilter() add at the beginning :
----------------------
    if( _ev->type == KeyPress )
	{
	XKeyEvent* ev = ( XKeyEvent* ) _ev;
	static caps_ignore = true;
	if( ev->keycode == XKeysymToKeycode( qt_xdisplay(), XK_Caps_Lock ))
	    if( caps_ignore )
		caps_ignore = false;
	    else
    		bool caps = ! (ev->state & LockMask); // capslock
	if( ev->keycode == XKeysymToKeycode( qt_xdisplay(), XK_Num_Lock ))
	    bool num = !( ev->state & Mod2Mask );  // numlock
	}
----------------------
Use variables 'caps' and 'num' ( they're only local in the example ).
I have read a Xlib reference recently in order to find some info I needed for
my KHotKeys and I'm quite sure there's nothing better that this. 
( XGetKeyboardControl() doesn't seem to be working on my computer ). I also
don't know how to set the modifiers state. The problem with this piece of code
is also that you simply don't know before the user presses a key, and you have
to remember the state somewhere.
I'm new to KDE/X programming, so maybe I missed the appropriate function, but
because nobody else replied, and even KiKbd uses some strange magic to find out
the current CapsLock state, I'm really afraid it can't be done better. (  I'm
also not sure if Mod2Mask is always NumLock ).

 Lubos Lunak
 l.lunak@email.cz

And now I am going to map that ugly CapsLock to Shift ...

------------------------------------------------------
Miguel de Icaza : 'KDE ... uses up too much memory.'
On my computer, Gnome uses the same amount of memory as KDE.
So the logical conclusion seems to be : 'Gnome uses up too much memory.' 
( Or at least Mr. de Icaza seems to think so ... )

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic