[comp.windows.x] state mask in button Press and Button Release

razdan@chanakya.oakhill.uucp (Anshuman Razdan) (02/20/90)

This question is regarding the state component of the
XButtonEvent (Button press or Button Release). I am running
X11R4 on sun 3/470.

When I have a Button Press or Button Release events reported
to me the state member is NULL (or 0 as it comes out in the printf).
This is the case no matter what modifier is present i.e. ShiftMask etc.
Surprisingly, even the state does not reflect the appropriate number of the
Button pressed (for ex: if button press was caused by Button2 then the 
state member should have the Button2Mask turned on). Although, one can find out this from
the button member of the event structure (But that is not the point).

My question is:

Is X designed to report the XButtonEvent in the way I have described or is it just me and
my server that behave in this particular way.

Does any body have any input on this?  May be it is a policy issue, may be it is a bug - who knows!!!

Anshumna Razdan
Sector CAD 
Motorola, Austin
oakhill!chanakya!razdan@cs.utexas.edu

PS: I selected for the event thru XtAddEventHandler (if that makes any difference)
and only one button press event was generated.

rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (02/20/90)

    PS: I selected for the event thru XtAddEventHandler (if that makes any
    difference)

It doesn't.

    and only one button press event was generated.

From the Xlib manual, section 8.4.1.2 (my emphasis added):

The state member is set to indicate the logical state of the pointer buttons
and modifier keys *just prior* to the event ...

Thus, when you press a button, the state won't indicate that button (although
the state will indicate that button in the button release event).

Now, if you'd already pressed the Shift key (and kept it pressed) and then
pressed the button, the state should indeed indicate Shift (and it does on
my machine).

toml@marvin.Solbourne.COM (Tom LaStrange) (02/20/90)

> When I have a Button Press or Button Release events reported
> to me the state member is NULL (or 0 as it comes out in the printf).
> This is the case no matter what modifier is present i.e. ShiftMask etc.
> Surprisingly, even the state does not reflect the appropriate number of the
> Button pressed (for ex: if button press was caused by Button2 then the 
> state member should have the Button2Mask turned on). Although, one can
> find out this from
> the button member of the event structure (But that is not the point).


I quote from the Red Book, page 223:

"The state member is set to indicate the logical state of the pointer buttons
and modifier keys just prior to the event ..."
		       ^^^^^

--
Tom LaStrange

Solbourne Computer Inc.    ARPA: toml@Solbourne.COM
1900 Pike Rd.              UUCP: ...!{boulder,sun}!stan!toml
Longmont, CO  80501