[comp.windows.x] Moving pointer in software ?

cadp16@vaxa.strath.ac.uk (03/12/91)

Is it possible to change the position of the mouse pointer through software?

I think I have seen this is a program somewhere, but I can`t remember
exactly.

all I want to do is specify where the mouse pointer has to be and send it
there.
 
--------------------------------------------------------------------------------
Electric Monk~~~			      		/^^^\                
					     	       > o.o <              
Strathclyde University			      		\___/           
Computer Science			      		/ V \            
3rd Year				     	       <==+==>        
Amiga and X-Windows a speciality	    	      /       \       
					  	     ^^^U^^^U^^^     
--------------------------------------------------------------------------------

cjmchale@cs.tcd.ie (Ciaran McHale) (03/13/91)

In <1991Mar12.094355.10444@vaxa.strath.ac.uk> cadp16@vaxa.strath.ac.uk writes:

>Is it possible to change the position of the mouse pointer through software?

You can use XWarpPointer to achieve this. However, it is very antisocial
behavior.


Ciaran.
-- 
Ciaran McHale		"Verbosity says it all"			      ____
Department of Computer Science, Trinity College, Dublin 2, Ireland.   \  /
Telephone: +353-1-772941 ext 1538	FAX: +353-1-772204	       \/
Telex: 93782 TCD EI			email: cjmchale@cs.tcd.ie

dshr@eng.sun.COM (David Rosenthal) (03/13/91)

> Is it possible to change the position of the mouse pointer through software?
> 
It is possible to do so,  but doing so is strongly deprecated.
Section 6.2 of the ICCCM (page 545 of the Digital Press 2nd
edition):

	In general,  clients should not warp the pointer.  Window managers,
	however,  may do so.  ......

			Conventions

	1.	Clients should not warp the pointer.

	2.	Clients that insist of warping the pointer should do so
		only with the src-window argument of the WarpPointer
		request set to one of their windows.

The point here is that the pointer is a shared resource between all the
clients.  You may think its just fine for your client to randomly warp
the pointer.  I may think so too.  The user who ends up running your
client and mine together sees chaos as they both fight over where the
pointer should be.  So,  don't warp the pointer.  Leave it to the user
to decide where it should be.

There is an exception for toolkit writers implementing scroll-bars and
popups which grab the server while they are warping.  But grabbing the
server except under tightly controlled situations is just as anti-social
as warping the pointer.

	David.

klee@wsl.dec.com (Ken Lee) (03/14/91)

In article <1991Mar12.094355.10444@vaxa.strath.ac.uk>, cadp16@vaxa.strath.ac.uk writes:
|> Is it possible to change the position of the mouse pointer through software?

XWarpPointer() does this, but is generally considered anti-social.

-- 
Ken Lee
DEC Western Software Laboratory, Palo Alto, Calif.
Internet: klee@wsl.dec.com
uucp: uunet!decwrl!klee

leconte@irisa.fr (Thierry Leconte) (03/14/91)

From article <1991Mar13.094825@wsl.dec.com>, by klee@wsl.dec.com (Ken Lee):
> In article <1991Mar12.094355.10444@vaxa.strath.ac.uk>, cadp16@vaxa.strath.ac.uk writes:
> |> Is it possible to change the position of the mouse pointer through software?
> 
> XWarpPointer() does this, but is generally considered anti-social.
> 

Yes but sometime very fun !

Try this : (cc xgag.c -lX -lXt -o xgag)
------------------------CUT HERE------------------------------------

/* ********************************************************************* * 
 * xgag.c T. Leconte 1 April 1990
 * ********************************************************************* */
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <stdio.h>



static Display *screen;
static XtAppContext context;

int xdel=2;
int ydel=3;
int timedel=50;

void 
bouge(cyc, id)
	char         *cyc;
	XtIntervalId   *id;
{


XWarpPointer(screen,None,None,0,0,0,0,xdel,ydel);

XtAppAddTimeOut(context, timedel , bouge, 0);
}

main(argc, argv)
	int             argc;
	char          **argv;
{

	XtToolkitInitialize();
	context = XtCreateApplicationContext();

	screen = XtOpenDisplay(context, NULL, "xgag", "XGag", 0,
		0, &argc, argv);
	if (screen==NULL) {
		fprintf(stderr,"Unable to open display\n");
		exit(-1);
	}
if (argc >1)
	xdel=atoi(argv[1]);

if (argc >2)
	ydel=atoi(argv[2]);

if (argc >3)
	timedel=atoi(argv[3]);

	XtAppAddTimeOut(context, timedel, bouge, 0);

XtAppMainLoop(context);
}

------------------------CUT HERE------------------------------------

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|   Thierry LECONTE     |      ,      ,---   ,---         |
|     INRIA/IRISA       |     /      /      /---          |
|  Campus de Beaulieu   |    (___   (___   (___           |
|  35042 RENNES CEDEX   |                                 |
|        FRANCE         |        (INRIA/BULL)             |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Tel: 99 36 20 00      e-mail: Thierry.Leconte@irisa.fr  |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~