[comp.windows.x] Propagation of Device Event?

jhsieh@grapevine.EBay.Sun.COM (James Hsieh) (07/13/90)

Hi,
	Could you help me to understand the propagation of device events?

	Assuming window tree hierarchy in the server is:
                     root
                    /  | \
                  c1   A  B
                  /
                c2
	and
            pointer is in c2, 
            button pressed,
            no active/passive grabs,
            no do-not-propagate masks,
            just normal event distribution in the server.
	the screen appearance is:
     ---------------------------    
     |                 root    |    
     |   -----------------     |     
     |   |           A   |     |                       
     |  --------------   |     |
     |  |        B   |   |     |
     |  |            |-----    |     
     |  |      ----  |c1  |    |    
     |  |      |c2|  |    |    |    
     |  |      |x |  |    |    |
     |  |      ----  |    |    |
     |  --------------    |    |
     |   |   --------------    |
     |   |               |     |
     |   -----------------     |
     |                         |
     ---------------------------

case 1: client 1 selects ButtonPressMask on window A
	client 2 selects ButtonPressMask on window B
	client 3 selects ButtonPressMask on window c1, but not c2

	Question:
          1. what is the seach path for this ButtonPress event?
          2. which client will receive this ButtonPress event?
          3. is the search path from source window to event window 
             determined by looking up the window hierarchy in the server,
             not by the current appearance on screen?

        My answer is:
          1. c2-c1-stop.
          2. server sends this event to client 3.
          3. yes.  the event propagation is based on window hierarchy IN 
             the server, NOT based on physical layout of screen.

case 2: client 1 selects ButtonPressMask on window A
	client 2 selects ButtonPressMask on window B
	client 3 is not interested in ButtonPress on c1 or c2.

	Question:
          1. what is the seach path for this ButtonPress event?
          2. which client will receive this button press event?
          3. why isn't window B included in the search path 
	     to receive the event?

  	My answer is:
          1. c2-c1-root-stop.
          2. evnet thrown away, none of the clients receives this event.
          3. window B does NOT contain the pointer, so window B
             is not in the search path to receive this evnet?

case 3: none of the clients selects ButtonPressMask on any window.

	Question:
          1. what is the search path for this ButtonPress event?
          2. which client will receive this button press event?

	My answer is:
	  1. search path is still c2-c1-root-Stop
          2. event thrown away, none of the clients receives this event.

Thank you very much for your kind help.
Yungchien 

rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (07/14/90)

On a quick scan I think your statements are correct, but your picture
looks wrong.  It would appear to show c1 underneath B, but c2 on top
of B.  If c2 is a child of c1 then this it not possible in X.

mouse@SHAMASH.MCRCIM.MCGILL.EDU (der Mouse) (07/14/90)

> 	Assuming window tree hierarchy in the server is:
>                      root
>                     /  | \
>                   c1   A  B
>                   /
>                 c2
> 	and
>             pointer is in c2, 
>             button pressed,
>             no active/passive grabs,
>             no do-not-propagate masks,
>             just normal event distribution in the server.

Well, grabs and do-not-propagate masks are part of normal event
distribution, but aside from that....

> 	the screen appearance is:
>      ---------------------------
>      |                 root    |
>      |   -----------------     |
>      |   |           A   |     |
>      |  --------------   |     |
>      |  |        B   |   |     |
>      |  |            |-----    |
>      |  |      ----  |c1  |    |
>      |  |      |c2|  |    |    |
>      |  |      |x |  |    |    |
>      |  |      ----  |    |    |
>      |  --------------    |    |
>      |   |   --------------    |
>      |   |               |     |
>      |   -----------------     |
>      |                         |
>      ---------------------------

This is not possible.  Given your hierarchy above, c2 can't be in front
of B unless c1 also is.  (All the children of a window W always have
the same relationship as W in the global front-to-back stacking order
relative to any other window X which is neither W nor a child of W.  In
this case, W is c1, the child is c2, and X is B.)

If, however, c1 in your picture is raised to in front of B, all the
answers you gave to your own questions are (according to my own
understanding of event distribution, which may well be flawed) correct.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu