Commit b2f12b09 authored by Patrice Mandin's avatar Patrice Mandin

Better mouse lose/gain focus

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401068
parent d950aa13
...@@ -140,14 +140,23 @@ void GEM_PumpEvents(_THIS) ...@@ -140,14 +140,23 @@ void GEM_PumpEvents(_THIS)
{ {
int quit, resultat; int quit, resultat;
short buffer[8], kc; short buffer[8], kc;
short x2,y2,w2,h2;
quit = 0; quit = 0;
event_mask = MU_MESAG|MU_TIMER|MU_KEYBD;
if (!GEM_fullscreen && (GEM_handle>=0)) {
wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
event_mask |= MU_M1|MU_M2;
} else {
x2=y2=w2=h2=0;
}
resultat = evnt_multi( resultat = evnt_multi(
MU_MESAG|MU_TIMER|MU_KEYBD, event_mask,
0,0,0, 0,0,0,
0,0,0,0,0, MO_ENTER,x2,y2,w2,h2,
0,0,0,0,0, MO_LEAVE,x2,y2,w2,h2,
buffer, buffer,
10, 10,
&dummy,&dummy,&dummy,&kstate,&kc,&dummy &dummy,&dummy,&dummy,&kstate,&kc,&dummy
...@@ -167,6 +176,18 @@ void GEM_PumpEvents(_THIS) ...@@ -167,6 +176,18 @@ void GEM_PumpEvents(_THIS)
} }
} }
/* Mouse entering/leaving window */
if (resultat & MU_M1) {
if (this->input_grab == SDL_GRAB_OFF) {
SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
}
}
if (resultat & MU_M2) {
if (this->input_grab == SDL_GRAB_OFF) {
SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
}
}
/* Timer event ? */ /* Timer event ? */
if ((resultat & MU_TIMER) || quit) if ((resultat & MU_TIMER) || quit)
break; break;
...@@ -224,9 +245,6 @@ static int do_messages(_THIS, short *message) ...@@ -224,9 +245,6 @@ static int do_messages(_THIS, short *message)
case WM_TOPPED: case WM_TOPPED:
wind_set(message[3],WF_TOP,message[4],0,0,0); wind_set(message[3],WF_TOP,message[4],0,0,0);
SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
if (this->input_grab == SDL_GRAB_OFF) {
SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
}
break; break;
case WM_REDRAW: case WM_REDRAW:
if (!GEM_lock_redraw) { if (!GEM_lock_redraw) {
...@@ -289,9 +307,6 @@ static int do_messages(_THIS, short *message) ...@@ -289,9 +307,6 @@ static int do_messages(_THIS, short *message)
case WM_BOTTOMED: case WM_BOTTOMED:
case WM_UNTOPPED: case WM_UNTOPPED:
SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
if (this->input_grab == SDL_GRAB_OFF) {
SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
}
break; break;
} }
...@@ -326,6 +341,11 @@ static void do_mouse(_THIS, short mx, short my, short mb, short ks) ...@@ -326,6 +341,11 @@ 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; short x2, y2, w2, h2;
/* Don't return mouse events if out of window */
if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS)==0) {
return;
}
/* Retrieve window coords, and generate mouse events accordingly */ /* Retrieve window coords, and generate mouse events accordingly */
x2 = y2 = 0; x2 = y2 = 0;
w2 = VDI_w; w2 = VDI_w;
......
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