Skip to content
Permalink
Browse files

Call GEM_CheckMouseMode everytime something may change mouse form, an…

…d do it properly
  • Loading branch information
pmandin committed Jul 13, 2007
1 parent 6c2dde0 commit 69917f2fc3a12dd3b1e9f35b31418c3e6f9803d4
Showing with 46 additions and 36 deletions.
  1. +16 −22 src/video/gem/SDL_gemevents.c
  2. +30 −14 src/video/gem/SDL_gemmouse.c
@@ -89,11 +89,8 @@ void GEM_PumpEvents(_THIS)
if (!GEM_fullscreen && (GEM_handle>=0)) {
wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
event_mask |= MU_M1;
if ( (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
mouse_event = MO_LEAVE;
} else {
mouse_event = MO_ENTER;
}
mouse_event = ( (SDL_GetAppState() & SDL_APPMOUSEFOCUS)
== SDL_APPMOUSEFOCUS) ? MO_LEAVE : MO_ENTER;
}

resultat = evnt_multi(
@@ -123,22 +120,11 @@ void GEM_PumpEvents(_THIS)
/* Mouse entering/leaving window */
if (resultat & MU_M1) {
if (this->input_grab == SDL_GRAB_OFF) {
if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) {
SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
if (SDL_GetAppState() & SDL_APPINPUTFOCUS) {
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);
}
}
}
/* Switch mouse focus state */
SDL_PrivateAppActive((mouse_event == MO_ENTER),
SDL_APPMOUSEFOCUS);
}
GEM_CheckMouseMode(this);
}

/* Timer event ? */
@@ -182,10 +168,10 @@ void GEM_PumpEvents(_THIS)

static int do_messages(_THIS, short *message)
{
int quit, posted;
int quit, posted, check_mouse_mode;
short x2,y2,w2,h2;

quit=0;
quit = check_mouse_mode = 0;
switch (message[0]) {
case WM_CLOSED:
case AP_TERM:
@@ -203,6 +189,7 @@ static int do_messages(_THIS, short *message)
if (VDI_setpalette) {
VDI_setpalette(this, VDI_curpalette);
}
check_mouse_mode = 1;
break;
case WM_REDRAW:
if (!GEM_lock_redraw) {
@@ -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);
GEM_refresh_name = SDL_FALSE;
}
check_mouse_mode = 1;
break;
case WM_UNICONIFY:
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)
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;
}
check_mouse_mode = 1;
break;
case WM_SIZED:
wind_set (message[3], WF_CURRXYWH, message[4], message[5], message[6], message[7]);
@@ -270,8 +259,13 @@ static int do_messages(_THIS, short *message)
if (VDI_setpalette) {
VDI_setpalette(this, VDI_oldpalette);
}
check_mouse_mode = 1;
break;
}

if (check_mouse_mode) {
GEM_CheckMouseMode(this);
}

return quit;
}
@@ -140,12 +140,8 @@ WMcursor *GEM_CreateWMCursor(_THIS,
int GEM_ShowWMCursor(_THIS, WMcursor *cursor)
{
GEM_cursor = cursor;
if (cursor == NULL) {
graf_mouse(M_OFF, NULL);
GEM_cursor = (void *) -1;
} else if (cursor->mform_p) {
graf_mouse(USER_DEF, cursor->mform_p);
}

GEM_CheckMouseMode(this);

#ifdef DEBUG_VIDEO_GEM
printf("sdl:video:gem: ShowWMCursor(0x%08x)\n", (long) cursor);
@@ -170,19 +166,39 @@ void GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y)

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
printf("sdl:video:gem: check mouse mode\n");
#endif

/* If the mouse is hidden and input is grabbed, we use relative mode */
if ( (!(SDL_cursorstate & CURSOR_VISIBLE)) &&
(this->input_grab != SDL_GRAB_OFF) &&
(SDL_GetAppState() & SDL_APPACTIVE) ) {
SDL_AtariXbios_LockMousePosition(SDL_TRUE);
GEM_mouse_relative = SDL_TRUE;
GEM_mouse_relative = (!(SDL_cursorstate & CURSOR_VISIBLE))
&& (this->input_grab != SDL_GRAB_OFF)
&& (SDL_GetAppState() & SDL_APPACTIVE);
SDL_AtariXbios_LockMousePosition(GEM_mouse_relative);

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 {
SDL_AtariXbios_LockMousePosition(SDL_FALSE);
GEM_mouse_relative = SDL_FALSE;
graf_mouse(M_ON, NULL);
/* Mouse cursor hidden only over the application window */
if ((SDL_GetAppState() & full_focus) == full_focus) {
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);
}
}

0 comments on commit 69917f2

Please sign in to comment.