This is the mail archive of the cygwin-xfree@cygwin.com mailing list for the Cygwin XFree86 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Starting web site updates


On Thu, 12 Apr 2001, Harold Hunt wrote:

> Alexander,
> 
> > I tried getting the AltGr keystate via GetAsyncKeyState when
> > processing
> > the Control_L press. Was there any problem with it?
> 
> GetAsyncKeyState isn't appropriate because it gets the key state at the time
> of the function call; that seems like a fine idea until you consider that
> you may be processing the Control_L message several milliseconds to several
> seconds after the key was actually pressed; in that amount of time the Alt_R
> key may be released if it was pressed, or pressed if it was released.
> 
> GetKeyState gets the state of a key at the time that the current message was
> generated; thus, you'll always get the correct state for the Alt_R key when
> processing the Control_L message.
> 
> > This might break some older applications which use the
> > keyboard modifiers
> > even as mouse modifier. I believe some window managers use
> > this. Even KDE
> > uses it (Pressing Control when selecting another icon adds it
> > to the selection
> > list).
> 
> That is good to know.
> 
> I think we both realize that this is not trivial, but it is solveable.  :)
> 
> Harold
> 
Could you please take a look if the GetMessageTime differs for the AltGr
press and the fake Control press. If not we could use the following:
(not tested, just an idea)

if (message == WM_KEYDOWN && ((lparam >>16) & 0x1ff == 0x1d)
if (lParam & 0xffff) { // initial press of Control_L
	last_control_time = msg.time;
	SendMessage(hwnd,WM_USER+x,wparam,lparam); // x can be any fixed
		// number (see WM_USER doc) 
}
if (message == WM_KEYDOWN && ((lparam >>16) & 0x1ff == AltGr) {
	last_altgr_time = msg.time;
	SendAltGrEvent
}
if (message == WM_USER+x) { // the control press again
	if (abs(last_altgr_time - last_control_time) >0 ) { // instead of
		// 0 we can use any other timeout
		SendControlEvent
	} else {
		// discard control_l event
	}
 
}

I expect the message queue to look like this if AltGr was pressed

WM_KEYPRESS Control_L
WM_KEYPRESS Alt_Gr
WM_USER+x

if Control was pressed its
WM_KEYPRESS Control_L
WM_USER+x

Maybe we have to take care of this
WM_KEYPRESS Control_L
WM_KEYPRESS "A"
WM_USER+x

but since the keypress is not AltGr we can easily send the ControlL message 
and discard the WM_USER+x later.

I will not be able to respond to mail until tomorrow.

bye
	ago
-- 
 Alexander.Gottwald@informatik.tu-chemnitz.de 
 http://www.gotti.org
 +49 3752 349 80 80


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]