Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!gem.mps.ohio-state.edu!ginosko!uunet!kddlab!titcca!sragwa!srava!erik From: erik@srava.sra.JUNET (Erik M. van der Poel) Newsgroups: comp.windows.x Subject: Re: rubberbanding with Xlib Message-ID: <2449@srava.sra.JUNET> Date: 29 Aug 89 06:52:31 GMT References: <123886@sun.Eng.Sun.COM> Reply-To: erik@sra.co.jp (Erik M. van der Poel) Organization: Software Research Associates, Inc., Japan Lines: 46 Does anyone have a good way of doing rubberbanding with Xlib, by good I mean where rubberband box keeps up with the cursor. I have found that you can keep up with the cursor quite well if you first erase the box, then call XTrackMouse (supplied below), and finally draw the box again. XTrackMouse first calls XSync to make sure the server has processed all of your requests and has sent all events. Then all mouse events (except for the last one) are skipped to obtain the most up-to-date one. XTrackMouse(event) register XMotionEvent *event; { register Display *display; register Window window; if (event->type != MotionNotify) { return; } display = event->display; window = event->window; XSync(display, 0); while (XCheckTypedWindowEvent(display, window, MotionNotify, event)) { } } Note that XTrackMouse only works for rubberbanding in a window (as opposed to rubberbanding all over the display like window managers do). However, this can be changed easily by using XCheckTypedEvent instead of XCheckTypedWindowEvent. As far as I know, Xlib does not contain a convenience function like this, although it might be nice if it did (nudge nudge :-). -- Erik M. van der Poel erik@sra.junet (Japan) SRA, 1-1-1 Hirakawa-cho, Chiyoda-ku erik%sra.junet@uunet.uu.net (USA) Tokyo 102 Japan. TEL +81-3-234-2692 erik%sra.junet@mcvax.uucp (Europe)