Give mouse position relative to window position, and do not generate mouse button event if outside of the window
authorPatrice Mandin <patmandin@gmail.com>
Tue, 10 Aug 2004 18:53:38 +0000
changeset 92683db694556eb
parent 925 15ff92ae7e1b
child 927 c5689bd09eaa
Give mouse position relative to window position, and do not generate mouse button event if outside of the window
src/video/gem/SDL_gemevents.c
src/video/gem/SDL_gemvideo.c
src/video/gem/SDL_gemvideo.h
     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;
     2.1 --- a/src/video/gem/SDL_gemvideo.c	Mon Aug 09 11:53:14 2004 +0000
     2.2 +++ b/src/video/gem/SDL_gemvideo.c	Tue Aug 10 18:53:38 2004 +0000
     2.3 @@ -400,6 +400,7 @@
     2.4  	GEM_handle = -1;
     2.5  	GEM_locked = SDL_FALSE;
     2.6  	GEM_win_fulled = SDL_FALSE;
     2.7 +	GEM_fullscreen = SDL_FALSE;
     2.8  
     2.9  	VDI_screen = NULL;
    2.10  	VDI_pitch = VDI_w * VDI_pixelsize;
    2.11 @@ -641,6 +642,8 @@
    2.12  		} else {
    2.13  			modeflags |= SDL_SWSURFACE;
    2.14  		}
    2.15 +
    2.16 +		GEM_fullscreen = SDL_TRUE;
    2.17  	} else {
    2.18  		int old_win_type;
    2.19  		short x2,y2,w2,h2;
    2.20 @@ -701,6 +704,8 @@
    2.21  	
    2.22  		/* Open the window */
    2.23  		wind_open(GEM_handle,x2,y2,w2,h2);
    2.24 +
    2.25 +		GEM_fullscreen = SDL_FALSE;
    2.26  	}
    2.27  
    2.28  	/* Set up the new mode framebuffer */
     3.1 --- a/src/video/gem/SDL_gemvideo.h	Mon Aug 09 11:53:14 2004 +0000
     3.2 +++ b/src/video/gem/SDL_gemvideo.h	Tue Aug 10 18:53:38 2004 +0000
     3.3 @@ -80,6 +80,8 @@
     3.4  	SDL_bool mouse_relative;	/* Report relative mouse movement */
     3.5  	SDL_bool locked;			/* AES locked for fullscreen ? */
     3.6  	short message[8];			/* To self-send an AES message */
     3.7 +
     3.8 +	SDL_bool fullscreen;		/* Fullscreen or windowed mode ? */
     3.9  	SDL_Rect *SDL_modelist[SDL_NUMMODES+1];	/* Mode list */
    3.10  	SDL_Surface *icon;			/* The icon */
    3.11  };
    3.12 @@ -121,6 +123,7 @@
    3.13  #define GEM_message			(this->hidden->message)
    3.14  #define SDL_modelist		(this->hidden->SDL_modelist)
    3.15  #define GEM_icon			(this->hidden->icon)
    3.16 +#define GEM_fullscreen		(this->hidden->fullscreen)
    3.17  
    3.18  #define GEM_buffer1			(this->hidden->buffer1)
    3.19  #define GEM_buffer2			(this->hidden->buffer2)