home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / windows / x / 15466 < prev    next >
Encoding:
Internet Message Format  |  1992-08-20  |  1.5 KB

  1. Path: sparky!uunet!kithrup!stanford.edu!ames!haven.umd.edu!darwin.sura.net!dtix!mimsy!ra!peyton@itd.nrl.navy.mil
  2. From: peyton@itd.nrl.navy.mil (Rodney D. Peyton,B16/R132,X79091,)
  3. Newsgroups: comp.windows.x
  4. Subject: Young and Pew's Tracker2 Example
  5. Message-ID: <3410@ra.nrl.navy.mil>
  6. Date: 20 Aug 92 22:25:25 GMT
  7. Sender: usenet@ra.nrl.navy.mil
  8. Reply-To: peyton@itd.nrl.navy.mil
  9. Organization: Information Technology Division, Naval Research Laboratory
  10. Lines: 26
  11.  
  12. I am in the process of teaching myself X window programming. I've
  13. started by working through Young and Pew's book titled "The X Window
  14. System Programming and Applications with Xt" the Open Look Edition. In
  15. chapter 5 there is an example program that tracks the mouse pointer.
  16. The example on page 200 suppose to track the mouse only while a mouse
  17. button is pressed. I compiled this example (I got the code from
  18. expo.lcs.mit.edu) and noticed that the pointer was continuously
  19. tracked. My solution to the problem was to check the XMotionEvent
  20. structure to see if the any keys (button1) were pressed before calling xs_wprintf,
  21. i.e,
  22.  
  23. in track_mouse_position() I replaced 
  24.  
  25. xs_wprintf(tracker, "X: %4d, Y: %4d", event->xmotion.x, event->xmotion.y);
  26.  
  27. with 
  28.  
  29. if (event->xmotion.state == Button1Mask)
  30.                 xs_wprintf(tracker, "X: %4d, Y: %4d", event->xmotion.x,
  31.                 event->xmotion.y);
  32.  
  33. was this the correct thing to do ?  I don't see why it was necessary since
  34. the event handler was created with
  35.  
  36. XtAddEventHandler(target, Button1MotionMask | Button2MotionMask, FALSE,
  37.         track_mouse_position, tracker);
  38.