Commit aab65909 authored by Patrice Mandin's avatar Patrice Mandin

Give mouse position relative to window position, and do not generate mouse...

Give mouse position relative to window position, and do not generate mouse button event if outside of the window

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40927
parent 957b40a0
...@@ -298,6 +298,18 @@ static void do_keyboard(short kc, short ks) ...@@ -298,6 +298,18 @@ static void do_keyboard(short kc, short ks)
static void do_mouse(_THIS, short mx, short my, short mb, short ks) static void do_mouse(_THIS, short mx, short my, short mb, short ks)
{ {
static short prevmousex=0, prevmousey=0, prevmouseb=0; static short prevmousex=0, prevmousey=0, prevmouseb=0;
short x2, y2, w2, h2;
/* Retrieve window coords, and generate mouse events accordingly */
x2 = y2 = 0;
if ((!GEM_fullscreen) && (GEM_handle>=0)) {
wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
/* Do not generate mouse button event if out of window working area */
if ((mx<x2) || (mx>=x2+w2) || (my<y2) || (my>=y2+h2)) {
mb=prevmouseb;
}
}
/* Mouse motion ? */ /* Mouse motion ? */
if ((prevmousex!=mx) || (prevmousey!=my)) { if ((prevmousex!=mx) || (prevmousey!=my)) {
...@@ -305,7 +317,17 @@ static void do_mouse(_THIS, short mx, short my, short mb, short ks) ...@@ -305,7 +317,17 @@ static void do_mouse(_THIS, short mx, short my, short mb, short ks)
SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey); SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey);
SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0; SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0;
} else { } else {
SDL_PrivateMouseMotion(0, 0, mx, my); int posx, posy;
/* Give mouse position relative to window position */
posx = mx - x2;
if (posx<0) posx = x2;
if (posx>w2) posx = w2-1;
posy = my - y2;
if (posy<0) posy = y2;
if (posy>h2) posy = h2-1;
SDL_PrivateMouseMotion(0, 0, posx, posy);
} }
prevmousex = mx; prevmousex = mx;
prevmousey = my; prevmousey = my;
......
...@@ -400,6 +400,7 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -400,6 +400,7 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat)
GEM_handle = -1; GEM_handle = -1;
GEM_locked = SDL_FALSE; GEM_locked = SDL_FALSE;
GEM_win_fulled = SDL_FALSE; GEM_win_fulled = SDL_FALSE;
GEM_fullscreen = SDL_FALSE;
VDI_screen = NULL; VDI_screen = NULL;
VDI_pitch = VDI_w * VDI_pixelsize; VDI_pitch = VDI_w * VDI_pixelsize;
...@@ -641,6 +642,8 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -641,6 +642,8 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current,
} else { } else {
modeflags |= SDL_SWSURFACE; modeflags |= SDL_SWSURFACE;
} }
GEM_fullscreen = SDL_TRUE;
} else { } else {
int old_win_type; int old_win_type;
short x2,y2,w2,h2; short x2,y2,w2,h2;
...@@ -701,6 +704,8 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -701,6 +704,8 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current,
/* Open the window */ /* Open the window */
wind_open(GEM_handle,x2,y2,w2,h2); wind_open(GEM_handle,x2,y2,w2,h2);
GEM_fullscreen = SDL_FALSE;
} }
/* Set up the new mode framebuffer */ /* Set up the new mode framebuffer */
......
...@@ -80,6 +80,8 @@ struct SDL_PrivateVideoData { ...@@ -80,6 +80,8 @@ struct SDL_PrivateVideoData {
SDL_bool mouse_relative; /* Report relative mouse movement */ SDL_bool mouse_relative; /* Report relative mouse movement */
SDL_bool locked; /* AES locked for fullscreen ? */ SDL_bool locked; /* AES locked for fullscreen ? */
short message[8]; /* To self-send an AES message */ short message[8]; /* To self-send an AES message */
SDL_bool fullscreen; /* Fullscreen or windowed mode ? */
SDL_Rect *SDL_modelist[SDL_NUMMODES+1]; /* Mode list */ SDL_Rect *SDL_modelist[SDL_NUMMODES+1]; /* Mode list */
SDL_Surface *icon; /* The icon */ SDL_Surface *icon; /* The icon */
}; };
...@@ -121,6 +123,7 @@ struct SDL_PrivateVideoData { ...@@ -121,6 +123,7 @@ struct SDL_PrivateVideoData {
#define GEM_message (this->hidden->message) #define GEM_message (this->hidden->message)
#define SDL_modelist (this->hidden->SDL_modelist) #define SDL_modelist (this->hidden->SDL_modelist)
#define GEM_icon (this->hidden->icon) #define GEM_icon (this->hidden->icon)
#define GEM_fullscreen (this->hidden->fullscreen)
#define GEM_buffer1 (this->hidden->buffer1) #define GEM_buffer1 (this->hidden->buffer1)
#define GEM_buffer2 (this->hidden->buffer2) #define GEM_buffer2 (this->hidden->buffer2)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment