rick@ut-ngp.UUCP (Rick Watson) (11/23/87)
I have an application where I am using mouse movement within a window to control a cursor on another (graphics) display. I use LeaveWindow events to detect when the mouse has gone out of the window bounds and then warp it back inside the window. This works, but tends to be jittery, etc. Is there a better way to constrain mouse movements, that doesn't rely on interaction with the user program? Rick Watson University of Texas Computation Center arpa: ccaw001@utadnx.cc.utexas.edu uucp: ...seismo!ut-sally!ut-ngp!rick bitnet: ccaw001@utadnx span: utspan::watson phone: 512/471-8220 512/471-3241
markc@hpcvlo.HP.COM (Mark F. Cook) (11/24/87)
>I have an application where I am using mouse movement within a window to >control a cursor on another (graphics) display. I use LeaveWindow >events to detect when the mouse has gone out of the window bounds and >then warp it back inside the window. This works, but tends to be jittery, >etc. Is there a better way to constrain mouse movements, that doesn't >rely on interaction with the user program? > >Rick Watson >University of Texas Computation Center > arpa: ccaw001@utadnx.cc.utexas.edu > uucp: ...seismo!ut-sally!ut-ngp!rick > bitnet: ccaw001@utadnx span: utspan::watson > phone: 512/471-8220 512/471-3241 >---------- One way that I have used to do this is detection of MouseMoved events followed by 4 XCondWarpMouse() calls (1 for each border). You could specify some reasonable zone of sensitivity near each border (perhaps just a wide border itself would do). Then, if the mouse gets too close to the window border, you can, for example, warp it back to the window center. You will probably still want to check for LeaveWindow events, since it is possible, on some computers, to move the mouse fast enough to get across the sensitive border region between mouse polling intervals (the amount of time between to checks on the current mouse position). This is the only situation I'm aware of the the MouseMoved/XCondWarpMouse() combination doesn't take care of, and the LeaveWindow detection should cover that. Regards, Mark F. Cook - CWO Tech. Support USMail: Technical Support Hewlett-Packard - Corvallis Workstation Operation 1000 NE Circle Blvd. Corvallis, OR 97330 ARPA: markc@hpcvlo.HP.COM UUCP: {cmcl2, harpo, hplabs, rice, tektronix}!hp-pcd!markc
karlton@decwrl.dec.com (Philip Karlton) (11/25/87)
In article <6908@ut-ngp.UUCP> rick@ut-ngp.UUCP (Rick Watson) writes: >... Is there a better way to constrain mouse movements, that doesn't >rely on interaction with the user program? Yes. When the pointer is grabbed (either using GrabPointer or as the result of a GrabButton being triggered), a "confine-to" window may be specified which will cause the server to restrict the pointer to stay in that window. PK