Commit 739cd03b authored by Patrice Mandin's avatar Patrice Mandin

Call GEM_CheckMouseMode everytime something may change mouse form, and do it properly

--HG--
branch : SDL-1.2
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%402513
parent 5aafadda
...@@ -89,11 +89,8 @@ void GEM_PumpEvents(_THIS) ...@@ -89,11 +89,8 @@ void GEM_PumpEvents(_THIS)
if (!GEM_fullscreen && (GEM_handle>=0)) { if (!GEM_fullscreen && (GEM_handle>=0)) {
wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2); wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
event_mask |= MU_M1; event_mask |= MU_M1;
if ( (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) { mouse_event = ( (SDL_GetAppState() & SDL_APPMOUSEFOCUS)
mouse_event = MO_LEAVE; == SDL_APPMOUSEFOCUS) ? MO_LEAVE : MO_ENTER;
} else {
mouse_event = MO_ENTER;
}
} }
resultat = evnt_multi( resultat = evnt_multi(
...@@ -123,22 +120,11 @@ void GEM_PumpEvents(_THIS) ...@@ -123,22 +120,11 @@ void GEM_PumpEvents(_THIS)
/* Mouse entering/leaving window */ /* Mouse entering/leaving window */
if (resultat & MU_M1) { if (resultat & MU_M1) {
if (this->input_grab == SDL_GRAB_OFF) { if (this->input_grab == SDL_GRAB_OFF) {
if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) { /* Switch mouse focus state */
SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); SDL_PrivateAppActive((mouse_event == MO_ENTER),
if (SDL_GetAppState() & SDL_APPINPUTFOCUS) { SDL_APPMOUSEFOCUS);
graf_mouse(ARROW, NULL);
}
} else {
SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
if (SDL_GetAppState() & SDL_APPINPUTFOCUS) {
if (GEM_cursor == (void *) -1) {
graf_mouse(M_OFF, NULL);
} else if (GEM_cursor) {
graf_mouse(USER_DEF, GEM_cursor->mform_p);
}
}
}
} }
GEM_CheckMouseMode(this);
} }
/* Timer event ? */ /* Timer event ? */
...@@ -182,10 +168,10 @@ void GEM_PumpEvents(_THIS) ...@@ -182,10 +168,10 @@ void GEM_PumpEvents(_THIS)
static int do_messages(_THIS, short *message) static int do_messages(_THIS, short *message)
{ {
int quit, posted; int quit, posted, check_mouse_mode;
short x2,y2,w2,h2; short x2,y2,w2,h2;
quit=0; quit = check_mouse_mode = 0;
switch (message[0]) { switch (message[0]) {
case WM_CLOSED: case WM_CLOSED:
case AP_TERM: case AP_TERM:
...@@ -203,6 +189,7 @@ static int do_messages(_THIS, short *message) ...@@ -203,6 +189,7 @@ static int do_messages(_THIS, short *message)
if (VDI_setpalette) { if (VDI_setpalette) {
VDI_setpalette(this, VDI_curpalette); VDI_setpalette(this, VDI_curpalette);
} }
check_mouse_mode = 1;
break; break;
case WM_REDRAW: case WM_REDRAW:
if (!GEM_lock_redraw) { if (!GEM_lock_redraw) {
...@@ -222,6 +209,7 @@ static int do_messages(_THIS, short *message) ...@@ -222,6 +209,7 @@ static int do_messages(_THIS, short *message)
wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_icon_name)>>16),(short)(((unsigned long)GEM_icon_name) & 0xffff),0,0); wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_icon_name)>>16),(short)(((unsigned long)GEM_icon_name) & 0xffff),0,0);
GEM_refresh_name = SDL_FALSE; GEM_refresh_name = SDL_FALSE;
} }
check_mouse_mode = 1;
break; break;
case WM_UNICONIFY: case WM_UNICONIFY:
wind_set(message[3],WF_UNICONIFY,message[4],message[5],message[6],message[7]); wind_set(message[3],WF_UNICONIFY,message[4],message[5],message[6],message[7]);
...@@ -234,6 +222,7 @@ static int do_messages(_THIS, short *message) ...@@ -234,6 +222,7 @@ static int do_messages(_THIS, short *message)
wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0); wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0);
GEM_refresh_name = SDL_FALSE; GEM_refresh_name = SDL_FALSE;
} }
check_mouse_mode = 1;
break; break;
case WM_SIZED: case WM_SIZED:
wind_set (message[3], WF_CURRXYWH, message[4], message[5], message[6], message[7]); wind_set (message[3], WF_CURRXYWH, message[4], message[5], message[6], message[7]);
...@@ -270,9 +259,14 @@ static int do_messages(_THIS, short *message) ...@@ -270,9 +259,14 @@ static int do_messages(_THIS, short *message)
if (VDI_setpalette) { if (VDI_setpalette) {
VDI_setpalette(this, VDI_oldpalette); VDI_setpalette(this, VDI_oldpalette);
} }
check_mouse_mode = 1;
break; break;
} }
if (check_mouse_mode) {
GEM_CheckMouseMode(this);
}
return quit; return quit;
} }
......
...@@ -140,12 +140,8 @@ WMcursor *GEM_CreateWMCursor(_THIS, ...@@ -140,12 +140,8 @@ WMcursor *GEM_CreateWMCursor(_THIS,
int GEM_ShowWMCursor(_THIS, WMcursor *cursor) int GEM_ShowWMCursor(_THIS, WMcursor *cursor)
{ {
GEM_cursor = cursor; GEM_cursor = cursor;
if (cursor == NULL) {
graf_mouse(M_OFF, NULL); GEM_CheckMouseMode(this);
GEM_cursor = (void *) -1;
} else if (cursor->mform_p) {
graf_mouse(USER_DEF, cursor->mform_p);
}
#ifdef DEBUG_VIDEO_GEM #ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: ShowWMCursor(0x%08x)\n", (long) cursor); printf("sdl:video:gem: ShowWMCursor(0x%08x)\n", (long) cursor);
...@@ -170,19 +166,39 @@ void GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y) ...@@ -170,19 +166,39 @@ void GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
void GEM_CheckMouseMode(_THIS) void GEM_CheckMouseMode(_THIS)
{ {
const Uint8 full_focus = (SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
int set_system_cursor = 1, show_system_cursor = 1;
#ifdef DEBUG_VIDEO_GEM #ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: check mouse mode\n"); printf("sdl:video:gem: check mouse mode\n");
#endif #endif
/* If the mouse is hidden and input is grabbed, we use relative mode */ /* If the mouse is hidden and input is grabbed, we use relative mode */
if ( (!(SDL_cursorstate & CURSOR_VISIBLE)) && GEM_mouse_relative = (!(SDL_cursorstate & CURSOR_VISIBLE))
(this->input_grab != SDL_GRAB_OFF) && && (this->input_grab != SDL_GRAB_OFF)
(SDL_GetAppState() & SDL_APPACTIVE) ) { && (SDL_GetAppState() & SDL_APPACTIVE);
SDL_AtariXbios_LockMousePosition(SDL_TRUE); SDL_AtariXbios_LockMousePosition(GEM_mouse_relative);
GEM_mouse_relative = SDL_TRUE;
if (SDL_cursorstate & CURSOR_VISIBLE) {
/* Application defined cursor only over the application window */
if ((SDL_GetAppState() & full_focus) == full_focus) {
if (GEM_cursor) {
graf_mouse(USER_DEF, GEM_cursor->mform_p);
set_system_cursor = 0;
} else {
show_system_cursor = 0;
}
}
} else { } else {
SDL_AtariXbios_LockMousePosition(SDL_FALSE); /* Mouse cursor hidden only over the application window */
GEM_mouse_relative = SDL_FALSE; if ((SDL_GetAppState() & full_focus) == full_focus) {
graf_mouse(M_ON, NULL); set_system_cursor = 0;
show_system_cursor = 0;
}
}
graf_mouse(show_system_cursor ? M_ON : M_OFF, NULL);
if (set_system_cursor) {
graf_mouse(ARROW, NULL);
} }
} }
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