Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!hplabs!hp-pcd!hpcvlo!markc From: markc@hpcvlo.HP.COM (Mark F. Cook) Newsgroups: comp.windows.x Subject: Re: Keeping the mouse within a window Message-ID: <3940048@hpcvlo.HP.COM> Date: Tue, 24-Nov-87 14:31:06 EST Article-I.D.: hpcvlo.3940048 Posted: Tue Nov 24 14:31:06 1987 Date-Received: Sat, 28-Nov-87 18:45:11 EST References: <6908@ut-ngp.UUCP> Organization: Hewlett-Packard Co., Corvallis, OR, USA Lines: 37 >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