comparison src/video/gem/SDL_gemevents.c @ 926:83db694556eb

Give mouse position relative to window position, and do not generate mouse button event if outside of the window
author Patrice Mandin <patmandin@gmail.com>
date Tue, 10 Aug 2004 18:53:38 +0000
parents 7b920743ce57
children c5689bd09eaa
comparison
equal deleted inserted replaced
925:15ff92ae7e1b 926:83db694556eb
296 } 296 }
297 297
298 static void do_mouse(_THIS, short mx, short my, short mb, short ks) 298 static void do_mouse(_THIS, short mx, short my, short mb, short ks)
299 { 299 {
300 static short prevmousex=0, prevmousey=0, prevmouseb=0; 300 static short prevmousex=0, prevmousey=0, prevmouseb=0;
301 short x2, y2, w2, h2;
302
303 /* Retrieve window coords, and generate mouse events accordingly */
304 x2 = y2 = 0;
305 if ((!GEM_fullscreen) && (GEM_handle>=0)) {
306 wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
307
308 /* Do not generate mouse button event if out of window working area */
309 if ((mx<x2) || (mx>=x2+w2) || (my<y2) || (my>=y2+h2)) {
310 mb=prevmouseb;
311 }
312 }
301 313
302 /* Mouse motion ? */ 314 /* Mouse motion ? */
303 if ((prevmousex!=mx) || (prevmousey!=my)) { 315 if ((prevmousex!=mx) || (prevmousey!=my)) {
304 if (GEM_mouse_relative) { 316 if (GEM_mouse_relative) {
305 SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey); 317 SDL_PrivateMouseMotion(0, 1, SDL_AtariXbios_mousex, SDL_AtariXbios_mousey);
306 SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0; 318 SDL_AtariXbios_mousex = SDL_AtariXbios_mousey = 0;
307 } else { 319 } else {
308 SDL_PrivateMouseMotion(0, 0, mx, my); 320 int posx, posy;
321
322 /* Give mouse position relative to window position */
323 posx = mx - x2;
324 if (posx<0) posx = x2;
325 if (posx>w2) posx = w2-1;
326 posy = my - y2;
327 if (posy<0) posy = y2;
328 if (posy>h2) posy = h2-1;
329
330 SDL_PrivateMouseMotion(0, 0, posx, posy);
309 } 331 }
310 prevmousex = mx; 332 prevmousex = mx;
311 prevmousey = my; 333 prevmousey = my;
312 } 334 }
313 335