Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!uunet!mstan!chuck From: chuck@Morgan.COM (Chuck Ocheret) Newsgroups: comp.windows.x Subject: Re: How to constrain pointer movement Keywords: movement, Xlib Message-ID: <2660@s5.Morgan.COM> Date: 5 Feb 91 15:54:42 GMT References: <1991Jan21.151609.934@cbnewsh.att.com> Distribution: na Organization: Morgan Stanley, & Co., Inc. / New York City, NY Lines: 20 > Is there a way using Xlib of constraining the mouse motion so that > it will be entirely horizontal or vertial? In other words, if the > mouse is moved 5 pixels up and 15 pixels to the right, the pointer > image and reported position should be 0 pixels up and 15 pixels > right. Whichever direction, horizontal or vertical, had the > lesser movement since last observation is locked at 0. The way I have done this is to turn off the cursor for the particular window and to draw in my own cursor which I constrain. If you are constraining in the horizontal direction, the actual vertical position of the invisible cursor is unknown, so the user can wander out of the window and loose the pointer. Therefore, I do a passive grab to keep reading the pointer even if it wanders off. ~chuck -- +--------------------+ Chuck Ocheret, Sr. Staff Engineer +---------------+ |chuck@fid.Morgan.COM| Morgan Stanley & Co., Inc. |(212) 703-4474 | | Duty now ... |19th Floor, 1251 Avenue of the Americas|for the future.| +--------------------+ New York, N.Y. 10020 USA +---------------+