src/video/gem/SDL_gemevents.c
changeset 926 83db694556eb
parent 922 7b920743ce57
child 927 c5689bd09eaa
     1.1 --- a/src/video/gem/SDL_gemevents.c	Mon Aug 09 11:53:14 2004 +0000
     1.2 +++ b/src/video/gem/SDL_gemevents.c	Tue Aug 10 18:53:38 2004 +0000
     1.3 @@ -298,6 +298,18 @@
     1.4  static void do_mouse(_THIS, short mx, short my, short mb, short ks)
     1.5  {
     1.6  	static short prevmousex=0, prevmousey=0, prevmouseb=0;
     1.7 +	short x2, y2, w2, h2;
     1.8 +
     1.9 +	/* Retrieve window coords, and generate mouse events accordingly */
    1.10 +	x2 = y2 = 0;
    1.11 +	if ((!GEM_fullscreen) && (GEM_handle>=0)) {
    1.12 +		wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
    1.13 +
    1.14 +		/* Do not generate mouse button event if out of window working area */
    1.15 +		if ((mx<x2) || (mx>=x2+w2) || (my<y2) || (my>=y2+h2)) {
    1.16 +			mb=prevmouseb;
    1.17 +		}
    1.18 +	}
    1.19  
    1.20  	/* Mouse motion ? */
    1.21  	if ((prevmousex!=mx) || (prevmousey!=my)) {
    1.22 @@ -305,7 +317,17 @@
    1.23  			SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey);
    1.24  			SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0;
    1.25  		} else {
    1.26 -			SDL_PrivateMouseMotion(0, 0, mx, my);
    1.27 +			int posx, posy;
    1.28 +
    1.29 +			/* Give mouse position relative to window position */
    1.30 +			posx = mx - x2;
    1.31 +			if (posx<0) posx = x2;
    1.32 +			if (posx>w2) posx = w2-1;
    1.33 +			posy = my - y2;
    1.34 +			if (posy<0) posy = y2;
    1.35 +			if (posy>h2) posy = h2-1;
    1.36 +
    1.37 +			SDL_PrivateMouseMotion(0, 0, posx, posy);
    1.38  		}
    1.39  		prevmousex = mx;
    1.40  		prevmousey = my;