Date: Mon, 18 Feb 2002 16:46:59 +1200
authorSam Lantinga <slouken@libsdl.org>
Wed, 20 Feb 2002 01:05:51 +0000
changeset 2833d8b6b9f1e18
parent 282 b42d80e73896
child 284 d8b7eae78652
Date: Mon, 18 Feb 2002 16:46:59 +1200
From: Julian Kinraid <jkinraid@clear.net.nz>
Subject: Patches for photon port of SDL

Hi,

A couple more patches for photon and the nto audio. Adds mouse grabbing
support, fixed cursor images, unicode keyboard events (though no unicode
data on kye release, is that a problem?), hopefully fixing some audio
lag problems, and a few other fixes.

Thanks,
Julian Kinraid
src/audio/nto/SDL_nto_audio.c
src/video/photon/SDL_ph_events.c
src/video/photon/SDL_ph_image.c
src/video/photon/SDL_ph_mouse.c
src/video/photon/SDL_ph_video.c
src/video/photon/SDL_ph_wm.c
     1.1 --- a/src/audio/nto/SDL_nto_audio.c	Wed Feb 20 01:02:33 2002 +0000
     1.2 +++ b/src/audio/nto/SDL_nto_audio.c	Wed Feb 20 01:05:51 2002 +0000
     1.3 @@ -55,7 +55,7 @@
     1.4  #define DEFAULT_CPARAMS_VOICES 1
     1.5  #define DEFAULT_CPARAMS_FRAG_SIZE 4096  //was 512
     1.6  #define DEFAULT_CPARAMS_FRAGS_MIN 1
     1.7 -#define DEFAULT_CPARAMS_FRAGS_MAX -1
     1.8 +#define DEFAULT_CPARAMS_FRAGS_MAX 1
     1.9  
    1.10  /* Open the audio device for playback, and don't block if busy */
    1.11  #define OPEN_FLAGS	SND_PCM_OPEN_PLAYBACK
    1.12 @@ -384,9 +384,9 @@
    1.13      }
    1.14  
    1.15      /* enable count status parameter */
    1.16 -    if ((rval = snd_plugin_set_disable(audio_handle, PLUGIN_DISABLE_MMAP))<0)
    1.17 +    if ((rval = snd_pcm_plugin_set_disable(audio_handle, PLUGIN_DISABLE_MMAP))<0)
    1.18      {
    1.19 -        SDL_SetError("snd_plugin_set_disable failed: %s\n", snd_strerror(rval));
    1.20 +        SDL_SetError("snd_pcm_plugin_set_disable failed: %s\n", snd_strerror(rval));
    1.21          return(-1);
    1.22      }
    1.23  
     2.1 --- a/src/video/photon/SDL_ph_events.c	Wed Feb 20 01:02:33 2002 +0000
     2.2 +++ b/src/video/photon/SDL_ph_events.c	Wed Feb 20 01:05:51 2002 +0000
     2.3 @@ -55,7 +55,7 @@
     2.4     (idea shamelessly lifted from GII -- thanks guys! :)
     2.5   */
     2.6  
     2.7 -/*
     2.8 +#if 0
     2.9  static int ph_KeyRepeat(_THIS, PhKeyEvent_t* keyevent)
    2.10  {
    2.11  //	PhEvent_t* peekevent;
    2.12 @@ -89,78 +89,33 @@
    2.13  	}
    2.14  	return(repeated);
    2.15  }
    2.16 +#endif
    2.17  
    2.18 -*/
    2.19 +static int ph_WarpedMotion(_THIS, PhEvent_t *winEvent)
    2.20 +{
    2.21 +	PhPointerEvent_t *pointer = PhGetData( winEvent );
    2.22 +	PhRect_t *rect = PhGetRects( winEvent );
    2.23  
    2.24 -/* Note:  The X server buffers and accumulates mouse motion events, so
    2.25 -   the motion event generated by the warp may not appear exactly as we
    2.26 -   expect it to.  We work around this (and improve performance) by only
    2.27 -   warping the pointer when it reaches the edge, and then wait for it.
    2.28 -*/
    2.29 -/*
    2.30 -#define MOUSE_FUDGE_FACTOR	8
    2.31 -
    2.32 -static inline int X11_WarpedMotion(_THIS, XEvent *xevent)
    2.33 -{
    2.34 -	int w, h, i;
    2.35 -	int deltax, deltay;
    2.36 +	int centre_x, centre_y;
    2.37 +	int dx, dy, abs_x, abs_y;
    2.38  	int posted;
    2.39  
    2.40 -	w = SDL_VideoSurface->w;
    2.41 -	h = SDL_VideoSurface->h;
    2.42 -	deltax = xevent->xmotion.x - mouse_last.x;
    2.43 -	deltay = xevent->xmotion.y - mouse_last.y;
    2.44 -#ifdef DEBUG_MOTION
    2.45 -  printf("Warped mouse motion: %d,%d\n", deltax, deltay);
    2.46 -#endif
    2.47 -	mouse_last.x = xevent->xmotion.x;
    2.48 -	mouse_last.y = xevent->xmotion.y;
    2.49 -	posted = SDL_PrivateMouseMotion(0, 1, deltax, deltay);
    2.50 +	centre_x = SDL_VideoSurface->w / 2;
    2.51 +	centre_y = SDL_VideoSurface->h / 2;
    2.52  
    2.53 -	if ( (xevent->xmotion.x < MOUSE_FUDGE_FACTOR) ||
    2.54 -	     (xevent->xmotion.x > (w-MOUSE_FUDGE_FACTOR)) ||
    2.55 -	     (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) ||
    2.56 -	     (xevent->xmotion.y > (h-MOUSE_FUDGE_FACTOR)) ) {
    2.57 -		// Get the events that have accumulated
    2.58 -/*		while ( XCheckTypedEvent(SDL_Display, MotionNotify, xevent) ) {
    2.59 -			deltax = xevent->xmotion.x - mouse_last.x;
    2.60 -			deltay = xevent->xmotion.y - mouse_last.y;
    2.61 -#ifdef DEBUG_MOTION
    2.62 -  printf("Extra mouse motion: %d,%d\n", deltax, deltay);
    2.63 -#endif
    2.64 -			mouse_last.x = xevent->xmotion.x;
    2.65 -			mouse_last.y = xevent->xmotion.y;
    2.66 -			posted += SDL_PrivateMouseMotion(0, 1, deltax, deltay);
    2.67 -		}
    2.68 -		mouse_last.x = w/2;
    2.69 -		mouse_last.y = h/2;
    2.70 -		XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0,
    2.71 -					mouse_last.x, mouse_last.y);
    2.72 -		for ( i=0; i<10; ++i ) {
    2.73 -        		XMaskEvent(SDL_Display, PointerMotionMask, xevent);
    2.74 -			if ( (xevent->xmotion.x >
    2.75 -			          (mouse_last.x-MOUSE_FUDGE_FACTOR)) &&
    2.76 -			     (xevent->xmotion.x <
    2.77 -			          (mouse_last.x+MOUSE_FUDGE_FACTOR)) &&
    2.78 -			     (xevent->xmotion.y >
    2.79 -			          (mouse_last.y-MOUSE_FUDGE_FACTOR)) &&
    2.80 -			     (xevent->xmotion.y <
    2.81 -			          (mouse_last.y+MOUSE_FUDGE_FACTOR)) ) {
    2.82 -				break;
    2.83 -			}
    2.84 -#ifdef DEBUG_XEVENTS
    2.85 -  printf("Lost mouse motion: %d,%d\n", xevent->xmotion.x, xevent->xmotion.y);
    2.86 -#endif
    2.87 -		}
    2.88 -#ifdef DEBUG_XEVENTS
    2.89 -		if ( i == 10 ) {
    2.90 -			printf("Warning: didn't detect mouse warp motion\n");
    2.91 -		}
    2.92 -#endif
    2.93 -	}
    2.94 +	dx = rect->ul.x - centre_x;
    2.95 +	dy = rect->ul.y - centre_y;
    2.96 +
    2.97 +	posted = SDL_PrivateMouseMotion( 0, 1, dx, dy );
    2.98 +
    2.99 +	/* Move mouse cursor to middle of the window */
   2.100 +	PtGetAbsPosition( window, &abs_x, &abs_y );
   2.101 +	PhMoveCursorAbs( PhInputGroup(NULL),
   2.102 +			abs_x + centre_x,
   2.103 +			abs_y + centre_y );
   2.104 +
   2.105  	return(posted);
   2.106  }
   2.107 -*/
   2.108  
   2.109  /* Control which motion flags the window has set, a flags value of -1 sets
   2.110   * MOTION_BUTTON and MOTION_NOBUTTON */
   2.111 @@ -226,8 +181,13 @@
   2.112  			if ( SDL_VideoSurface ) {
   2.113  				pointerEvent = PhGetData( event );
   2.114  				rect = PhGetRects( event );
   2.115 -				posted = SDL_PrivateMouseMotion(0, 0,
   2.116 -						rect->ul.x, rect->ul.y);		
   2.117 +				if( mouse_relative )
   2.118 +				{
   2.119 +					posted = ph_WarpedMotion(this, event);
   2.120 +				}
   2.121 +				else
   2.122 +					posted = SDL_PrivateMouseMotion(0, 0,
   2.123 +							rect->ul.x, rect->ul.y);
   2.124  			}
   2.125  		}
   2.126  		break;
   2.127 @@ -291,10 +251,11 @@
   2.128  			{
   2.129  				set_motion_sensitivity(this, -1);
   2.130  				posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
   2.131 -
   2.132 +#if 0
   2.133  				/* Queue entry into fullscreen mode */
   2.134  				switch_waiting = 0x01 | SDL_FULLSCREEN;
   2.135  				switch_time = SDL_GetTicks() + 1500;
   2.136 +#endif
   2.137  			}
   2.138  
   2.139  			/* request to quit */
   2.140 @@ -302,6 +263,13 @@
   2.141  			{
   2.142  				posted = SDL_PrivateQuit();
   2.143  			}
   2.144 +			else if (winEvent->event_f==Ph_WM_RESIZE)
   2.145 +			{
   2.146 +				PhDim_t *size;
   2.147 +
   2.148 +				PtGetResource( window, Pt_ARG_DIM, &size, 0 );
   2.149 +				SDL_PrivateResize(size->w,size->h);
   2.150 +			}
   2.151  		}
   2.152  		break;
   2.153  		
   2.154 @@ -445,6 +413,7 @@
   2.155  		Uint32 now;
   2.156  
   2.157  		now  = SDL_GetTicks();
   2.158 +#if 0
   2.159  		if ( pending || !SDL_VideoSurface ) {
   2.160  			/* Try again later... */
   2.161  			if ( switch_waiting & SDL_FULLSCREEN ) {
   2.162 @@ -473,6 +442,7 @@
   2.163  			}
   2.164  */
   2.165  		}
   2.166 +#endif
   2.167  	}
   2.168  }
   2.169  
   2.170 @@ -573,6 +543,7 @@
   2.171  	This member is valid only if Pk_KF_Sym_Valid is set in the key_flags.
   2.172  	We will assume it is valid.
   2.173  */
   2.174 +	/* FIXME: This needs to check whether the cap & scancode is valid */
   2.175  	cap = key->key_cap;
   2.176  	switch (cap>>8) {
   2.177              case 0x00:  /* Latin 1 */
   2.178 @@ -599,10 +570,27 @@
   2.179                  keysym->sym = MISC_keymap[cap&0xFF];
   2.180                  break;
   2.181              default:
   2.182 -                fprintf(stderr,"Photon: Unknown key_cap, cap = 0x%.4x\n", (unsigned int)cap);
   2.183 +/*                fprintf(stderr,"Photon: Unknown key_cap, cap = 0x%.4x\n", (unsigned int)cap); */
   2.184 +		keysym->sym = SDLK_UNKNOWN;                
   2.185                  break;
   2.186  	}
   2.187  	keysym->scancode = key->key_scan;
   2.188 +	keysym->unicode = 0;
   2.189 +	if( SDL_TranslateUNICODE )
   2.190 +	{
   2.191 +		char utf8[MB_CUR_MAX];
   2.192 +		int utf8len;
   2.193 +		wchar_t unicode;
   2.194 +
   2.195 +		utf8len = PhKeyToMb( utf8, key );
   2.196 +		if( utf8len > 0 )
   2.197 +		{
   2.198 +			utf8len = mbtowc( &unicode, utf8, utf8len );
   2.199 +			if( utf8len > 0)
   2.200 +				keysym->unicode = unicode;
   2.201 +		}
   2.202 +	}
   2.203 +
   2.204  	return (keysym);
   2.205  }
   2.206  
     3.1 --- a/src/video/photon/SDL_ph_image.c	Wed Feb 20 01:02:33 2002 +0000
     3.2 +++ b/src/video/photon/SDL_ph_image.c	Wed Feb 20 01:05:51 2002 +0000
     3.3 @@ -175,8 +175,10 @@
     3.4  
     3.5  void ph_DestroyImage(_THIS, SDL_Surface *screen)
     3.6  {
     3.7 +#if 0
     3.8     if(SDL_Image == NULL)
     3.9       return;
    3.10 +#endif
    3.11  
    3.12     if (OCImage.offscreen_context != NULL)
    3.13     {
    3.14 @@ -188,21 +190,21 @@
    3.15        OCImage.FrameData1 = NULL;
    3.16     }
    3.17  
    3.18 -	if (SDL_Image->image)
    3.19 +	if (SDL_Image)
    3.20  	{
    3.21                  // SDL_Image->flags=Ph_RELEASE_IMAGE;
    3.22                  // PhReleaseImage(SDL_Image);
    3.23 -                PgShmemDestroy(SDL_Image->image); // Use this if you using shared memory, or uncomment
    3.24 +		if (SDL_Image->image)
    3.25 +			PgShmemDestroy(SDL_Image->image); // Use this if you using shared memory, or uncomment
    3.26                                                    // lines above if not (and comment this line ;-)
    3.27                  free(SDL_Image);
    3.28 +		SDL_Image = NULL;
    3.29  	}
    3.30  
    3.31  	if ( screen )
    3.32          {
    3.33      	        screen->pixels = NULL;
    3.34  	}
    3.35 -	
    3.36 -	SDL_Image = NULL;
    3.37  }
    3.38  
    3.39  int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)
     4.1 --- a/src/video/photon/SDL_ph_mouse.c	Wed Feb 20 01:02:33 2002 +0000
     4.2 +++ b/src/video/photon/SDL_ph_mouse.c	Wed Feb 20 01:05:51 2002 +0000
     4.3 @@ -62,6 +62,7 @@
     4.4  {
     4.5  	WMcursor* cursor;
     4.6  	int clen, i;
     4.7 +	unsigned char bit, databit, maskbit;
     4.8  
     4.9  	/* Allocate and initialize the cursor memory */
    4.10  	if ((cursor = (WMcursor*)malloc(sizeof(WMcursor))) == NULL)
    4.11 @@ -70,13 +71,13 @@
    4.12          return(NULL);
    4.13  	}
    4.14  	memset(cursor,0,sizeof(WMcursor));
    4.15 -	
    4.16 +
    4.17  	cursor->ph_cursor = (PhCursorDef_t *) malloc(sizeof(PhCursorDef_t) + 32*4*2);
    4.18  	if(cursor->ph_cursor == NULL)
    4.19  	   printf("cursor malloc failed\n");
    4.20  
    4.21  	memset(cursor->ph_cursor,0,(sizeof(PhCursorDef_t) + 32*4*2));
    4.22 -	   
    4.23 +
    4.24  	cursor->ph_cursor->hdr.type =Ph_RDATA_CURSOR;   
    4.25  	cursor->ph_cursor->size1.x = (short)w;
    4.26  	cursor->ph_cursor->size1.y = (short)h;
    4.27 @@ -90,18 +91,27 @@
    4.28          cursor->ph_cursor->offset2.y = (short)hot_y;
    4.29          cursor->ph_cursor->bytesperline2 = (char)w/8;
    4.30          cursor->ph_cursor->color2 = Pg_BLACK;
    4.31 -      
    4.32 +
    4.33  	clen = (w/8)*h;
    4.34  
    4.35  	/* Copy the mask and the data to different 
    4.36  	   bitmap planes */
    4.37  	for ( i=0; i<clen; ++i )
    4.38 -        {
    4.39 -           cursor->ph_cursor->images[i] = data[i];
    4.40 -           cursor->ph_cursor->images[i+clen] = mask[i];
    4.41 -        }
    4.42 -    
    4.43 -        //#bytes following the hdr struct
    4.44 +	{
    4.45 +		for ( bit = 0; bit < 8; bit++ )
    4.46 +		{
    4.47 +			databit = data[i] & (1 << bit);
    4.48 +			maskbit = mask[i] & (1 << bit);
    4.49 +
    4.50 +			cursor->ph_cursor->images[i] |= 
    4.51 +				(databit == 0) ? maskbit : 0;
    4.52 +			/* If the databit != 0, treat it as a black pixel and
    4.53 +			 * ignore the maskbit (can't do an inverted color) */
    4.54 +			cursor->ph_cursor->images[i+clen] |= databit;
    4.55 +		}
    4.56 +	}
    4.57 +
    4.58 +        /* #bytes following the hdr struct */
    4.59  	cursor->ph_cursor->hdr.len =sizeof(PhCursorDef_t) + clen*2 - sizeof(PhRegionDataHdr_t); 
    4.60  
    4.61  	return (cursor);
    4.62 @@ -113,7 +123,6 @@
    4.63  	return(*cursor->ph_cursor);
    4.64  }
    4.65  
    4.66 -
    4.67  int ph_ShowWMCursor(_THIS, WMcursor *cursor)
    4.68  {
    4.69  	PtArg_t args[3];
    4.70 @@ -130,13 +139,13 @@
    4.71  		
    4.72  		if ( cursor != NULL ) {
    4.73  			PtSetArg( &args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0 );
    4.74 -			// Could set next to any PgColor_t value
    4.75 +			/* Could set next to any PgColor_t value */
    4.76  			PtSetArg( &args[1], Pt_ARG_CURSOR_COLOR,Ph_CURSOR_DEFAULT_COLOR , 0 );
    4.77  			PtSetArg( &args[2], Pt_ARG_BITMAP_CURSOR, cursor->ph_cursor, (cursor->ph_cursor->hdr.len + sizeof(PhRegionDataHdr_t)) );
    4.78  			nargs = 3;
    4.79  			cursor_is_defined = 1;
    4.80  		}
    4.81 -		else // Ph_CURSOR_NONE
    4.82 +		else /* Ph_CURSOR_NONE */
    4.83  		{
    4.84  			PtSetArg( &args[0], Pt_ARG_CURSOR_TYPE,Ph_CURSOR_NONE, 0);
    4.85  			nargs = 1;
    4.86 @@ -161,13 +170,22 @@
    4.87  
    4.88  void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
    4.89  {
    4.90 -   SDL_Lock_EventThread();
    4.91 -   PhMoveCursorRel( PhInputGroup(NULL), x, y );	
    4.92 -   SDL_Unlock_EventThread();
    4.93 +	short abs_x, abs_y;
    4.94 +
    4.95 +	SDL_Lock_EventThread();
    4.96 +	PtGetAbsPosition( window, &abs_x, &abs_y );
    4.97 +	PhMoveCursorAbs( PhInputGroup(NULL), x + abs_x, y + abs_y );
    4.98 +	SDL_Unlock_EventThread();
    4.99  }
   4.100  
   4.101  
   4.102  void ph_CheckMouseMode(_THIS)
   4.103  {
   4.104 -   mouse_relative = 1;
   4.105 +        /* If the mouse is hidden and input is grabbed, we use relative mode */
   4.106 +        if ( !(SDL_cursorstate & CURSOR_VISIBLE) &&
   4.107 +             (this->input_grab != SDL_GRAB_OFF) ) {
   4.108 +                mouse_relative = 1;
   4.109 +        } else {
   4.110 +                mouse_relative = 0;
   4.111 +        }
   4.112  }
     5.1 --- a/src/video/photon/SDL_ph_video.c	Wed Feb 20 01:02:33 2002 +0000
     5.2 +++ b/src/video/photon/SDL_ph_video.c	Wed Feb 20 01:05:51 2002 +0000
     5.3 @@ -111,7 +111,7 @@
     5.4      device->SetCaption = ph_SetCaption;
     5.5      device->SetIcon = NULL;
     5.6      device->IconifyWindow = ph_IconifyWindow;
     5.7 -    device->GrabInput = NULL;
     5.8 +    device->GrabInput = ph_GrabInput;
     5.9      device->GetWMInfo = NULL;
    5.10      device->FreeWMCursor = ph_FreeWMCursor;
    5.11      device->CreateWMCursor = ph_CreateWMCursor;
    5.12 @@ -329,7 +329,7 @@
    5.13  
    5.14  		/* Get the true height and width */
    5.15  		
    5.16 -      current->flags = (flags|(~SDL_RESIZABLE)); /* no resize for Direct Context */
    5.17 +      current->flags = (flags & (~SDL_RESIZABLE)); /* no resize for Direct Context */
    5.18  
    5.19  		 /* Begin direct mode */
    5.20  		 ph_EnterFullScreen(this);
    5.21 @@ -342,11 +342,11 @@
    5.22         if (flags & SDL_HWSURFACE)  /* Use offscreen memory iff SDL_HWSURFACE flag is set */
    5.23         {
    5.24           /* Hardware surface is Offsceen Context.  ph_ResizeImage handles the switch */
    5.25 -         current->flags = (flags|(~SDL_RESIZABLE)); /* no stretch blit in offscreen context */
    5.26 +         current->flags = (flags & (~SDL_RESIZABLE)); /* no stretch blit in offscreen context */
    5.27         }
    5.28         else /* must be SDL_SWSURFACE */
    5.29         {
    5.30 -          current->flags = (flags|SDL_RESIZABLE); /* yes we can resize as this is a software surface */
    5.31 +          current->flags = (flags | SDL_RESIZABLE); /* yes we can resize as this is a software surface */
    5.32         }
    5.33  
    5.34  #ifdef HAVE_OPENGL       
    5.35 @@ -415,10 +415,7 @@
    5.36  
    5.37  static void ph_VideoQuit(_THIS)
    5.38  {
    5.39 -    if (SDL_Image != NULL)
    5.40 -    {
    5.41 -        ph_DestroyImage(this, SDL_VideoSurface); 
    5.42 -    }
    5.43 +    ph_DestroyImage(this, SDL_VideoSurface); 
    5.44  
    5.45      if (currently_fullscreen)
    5.46      {
     6.1 --- a/src/video/photon/SDL_ph_wm.c	Wed Feb 20 01:02:33 2002 +0000
     6.2 +++ b/src/video/photon/SDL_ph_wm.c	Wed Feb 20 01:05:51 2002 +0000
     6.3 @@ -233,19 +233,15 @@
     6.4  /* Iconify current window */
     6.5  int ph_IconifyWindow(_THIS)
     6.6  {
     6.7 -   WmApiContext_t context=WmCreateContext();
     6.8 -   WmWindowDefinition_t **wininfo=malloc(sizeof(WmWindowDefinition_t)*2);
     6.9 -   int num;
    6.10 +	PhWindowEvent_t windowevent;
    6.11  
    6.12 -   SDL_Lock_EventThread();
    6.13 -   WmGetFocusList(context,2,&num,wininfo);
    6.14 -   WmPerformFrameAction(context, wininfo[0]->rid,Pt_ACTION_MIN);
    6.15 -
    6.16 -   WmDestroyContext (context);   
    6.17 -   SDL_Unlock_EventThread();	 
    6.18 -   free(wininfo);		   
    6.19 -
    6.20 -   return (0);   
    6.21 +	SDL_Lock_EventThread();
    6.22 +	memset( &windowevent, 0, sizeof (event) );
    6.23 +	windowevent.event_f = Ph_WM_HIDE;
    6.24 +	windowevent.event_state = Ph_WM_EVSTATE_HIDE;
    6.25 +	windowevent.rid = PtWidgetRid( window );
    6.26 +	PtForwardWindowEvent( &windowevent );
    6.27 +	SDL_Unlock_EventThread();
    6.28  }
    6.29  
    6.30  SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
    6.31 @@ -255,7 +251,29 @@
    6.32  
    6.33  SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode)
    6.34  {
    6.35 -   return(mode);
    6.36 +	short abs_x, abs_y;
    6.37 +
    6.38 +	SDL_Lock_EventThread();
    6.39 +/*	mode = ph_GrabInputNoLock(this, mode);*/
    6.40 +
    6.41 +	if( mode == SDL_GRAB_OFF )
    6.42 +	{
    6.43 +		PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_FALSE,
    6.44 +				Ph_WM_STATE_ISALTKEY );
    6.45 +	}
    6.46 +	else
    6.47 +	{
    6.48 +		PtSetResource(window, Pt_ARG_WINDOW_STATE, Pt_TRUE,
    6.49 +				Ph_WM_STATE_ISALTKEY );
    6.50 +
    6.51 +		PtGetAbsPosition( window, &abs_x, &abs_y );
    6.52 +		PhMoveCursorAbs( PhInputGroup( NULL ),
    6.53 +				abs_x + SDL_VideoSurface->w/2,
    6.54 +				abs_y + SDL_VideoSurface->h/2 );
    6.55 +	}
    6.56 +
    6.57 +	SDL_Unlock_EventThread();
    6.58 +	return(mode);
    6.59  }
    6.60  
    6.61  int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)