Date: Thu, 19 Apr 2001 08:36:54 +0300
authorSam Lantinga <slouken@lokigames.com>
Thu, 10 May 2001 18:42:17 +0000
changeset 198cc4dbfab9ab
parent 18 d9e3595b63d5
child 20 3dc008dc229d
Date: Thu, 19 Apr 2001 08:36:54 +0300
From: "Mike Gorchak" <mike@malva.com.ua>
Subject: Patches for QNX RtP

Here my patch for QNX RtP/Photon for SDL-1.2.

Detailed description of my changes:

SDL/configure.in:
If Photon detected declare define ENABLE_PHOTON.

SDL/src/video/SDL_sysvideo.h:
Added extern to ph_bootstrap.

SDL/src/video/SDL_video.c:
Added ph_bootstrap to bootstrap array.

SDL/src/video/photon/SDL_ph_events.c:
Declare DISABLE_X11 if compiled for Photon.

SDL/src/video/photon/SDL_ph_image.c:
Fixed segment violation on exit. Please update BUGS file.

SDL/src/video/photon/SDL_ph_video.c:
1. Enabling window manager.
2. Added to device capabilities Photon Window Manager functions:
SetCaption and IconifyWindow.
3. Renamed X11_bootstrap to ph_bootstrap.
4. Removed SEGFAULT termination of programs if Photon not available.

SDL/src/video/photon/SDL_ph_wm.c:
1. Declare DISABLE_X11 if compiled for Photon.
2. Added ph_SetCaption and ph_IconifyWindow code. (Thanks to
'phearbear' for iconify window source).
3. Some stubers for other wm functions.

Thanks !

----------------------------
Mike Gorchak
CJSC Malva
System Programmer
configure.in
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/photon/SDL_ph_events.c
src/video/photon/SDL_ph_image.c
src/video/photon/SDL_ph_video.c
src/video/photon/SDL_ph_wm.c
     1.1 --- a/configure.in	Thu May 10 18:31:21 2001 +0000
     1.2 +++ b/configure.in	Thu May 10 18:42:17 2001 +0000
     1.3 @@ -545,6 +545,7 @@
     1.4          ])
     1.5          AC_MSG_RESULT($video_photon)
     1.6          if test x$video_photon = xyes; then
     1.7 +            CFLAGS="$CFLAGS -DENABLE_PHOTON"
     1.8              SYSTEM_LIBS="$SYSTEM_LIBS -lph"
     1.9              VIDEO_SUBDIRS="$VIDEO_SUBDIRS photon"
    1.10              VIDEO_DRIVERS="$VIDEO_DRIVERS photon/libvideo_photon.la"
     2.1 --- a/src/video/SDL_sysvideo.h	Thu May 10 18:31:21 2001 +0000
     2.2 +++ b/src/video/SDL_sysvideo.h	Thu May 10 18:42:17 2001 +0000
     2.3 @@ -358,6 +358,9 @@
     2.4  #ifdef ENABLE_DUMMYVIDEO
     2.5  extern VideoBootStrap DUMMY_bootstrap;
     2.6  #endif
     2.7 +#ifdef ENABLE_PHOTON
     2.8 +extern VideoBootStrap ph_bootstrap;
     2.9 +#endif
    2.10  /* MacOS X gets the proper defines from configure */
    2.11  #if defined(macintosh) && !defined(MACOSX)
    2.12  #define ENABLE_TOOLBOX
     3.1 --- a/src/video/SDL_video.c	Thu May 10 18:31:21 2001 +0000
     3.2 +++ b/src/video/SDL_video.c	Thu May 10 18:42:17 2001 +0000
     3.3 @@ -87,6 +87,9 @@
     3.4  #ifdef ENABLE_DUMMYVIDEO
     3.5  	&DUMMY_bootstrap,
     3.6  #endif
     3.7 +#ifdef ENABLE_PHOTON
     3.8 +	&ph_bootstrap,
     3.9 +#endif
    3.10  	NULL
    3.11  };
    3.12  SDL_VideoDevice *current_video = NULL;
     4.1 --- a/src/video/photon/SDL_ph_events.c	Thu May 10 18:31:21 2001 +0000
     4.2 +++ b/src/video/photon/SDL_ph_events.c	Thu May 10 18:42:17 2001 +0000
     4.3 @@ -27,6 +27,8 @@
     4.4  
     4.5  /* Handle the event stream, converting photon events into SDL events */
     4.6  
     4.7 +#define DISABLE_X11
     4.8 +
     4.9  #include <Ph.h>
    4.10  #include <stdio.h>
    4.11  #include <setjmp.h>
     5.1 --- a/src/video/photon/SDL_ph_image.c	Thu May 10 18:31:21 2001 +0000
     5.2 +++ b/src/video/photon/SDL_ph_image.c	Thu May 10 18:42:17 2001 +0000
     5.3 @@ -78,8 +78,7 @@
     5.4  	}
     5.5  
     5.6  	//using shared memory for speed (set last param to 1)
     5.7 -	if ((SDL_Image = PhCreateImage( NULL, screen->w, screen->h, type, NULL, 0, 1 )) 
     5.8 -		== NULL)
     5.9 +	if ((SDL_Image = PhCreateImage( NULL, screen->w, screen->h, type, NULL, 0, 1 )) == NULL)
    5.10  	{
    5.11  		fprintf(stderr,"error: PhCreateImage failed.\n");
    5.12  		return -1;
    5.13 @@ -194,14 +193,16 @@
    5.14  
    5.15  	if (SDL_Image->image)
    5.16  	{
    5.17 -		//free(SDL_Image->image);
    5.18 -		//SDL_Image->image = NULL;
    5.19 -		PhReleaseImage(SDL_Image);
    5.20 -		SDL_Image = NULL;
    5.21 +                // SDL_Image->flags=Ph_RELEASE_IMAGE;
    5.22 +                // PhReleaseImage(SDL_Image);
    5.23 +                PgShmemDestroy(SDL_Image->image); // Use this if you using shared memory, or uncomment
    5.24 +                                                  // lines above if not (and comment this line ;-)
    5.25 +                free(SDL_Image);
    5.26  	}
    5.27  
    5.28 -	if ( screen ) {
    5.29 -    	screen->pixels = NULL;
    5.30 +	if ( screen )
    5.31 +        {
    5.32 +    	        screen->pixels = NULL;
    5.33  	}
    5.34  	
    5.35  	SDL_Image = NULL;
     6.1 --- a/src/video/photon/SDL_ph_video.c	Thu May 10 18:31:21 2001 +0000
     6.2 +++ b/src/video/photon/SDL_ph_video.c	Thu May 10 18:42:17 2001 +0000
     6.3 @@ -46,6 +46,7 @@
     6.4  #include "SDL_ph_image_c.h"
     6.5  #include "SDL_ph_events_c.h"
     6.6  #include "SDL_ph_mouse_c.h"
     6.7 +#include "SDL_ph_wm_c.h"
     6.8  #include "SDL_phyuv_c.h"
     6.9  #include "blank_cursor.h"
    6.10  
    6.11 @@ -103,9 +104,9 @@
    6.12      device->UnlockHWSurface = ph_UnlockHWSurface;
    6.13      device->FlipHWSurface = ph_FlipHWSurface;
    6.14      device->FreeHWSurface = ph_FreeHWSurface;
    6.15 -    device->SetCaption = NULL;
    6.16 +    device->SetCaption = ph_SetCaption;
    6.17      device->SetIcon = NULL;
    6.18 -    device->IconifyWindow = NULL;
    6.19 +    device->IconifyWindow = ph_IconifyWindow;
    6.20      device->GrabInput = NULL;
    6.21      device->GetWMInfo = NULL;
    6.22      device->FreeWMCursor = ph_FreeWMCursor;
    6.23 @@ -121,7 +122,7 @@
    6.24      return device;
    6.25  }
    6.26  
    6.27 -VideoBootStrap X11_bootstrap = {
    6.28 +VideoBootStrap ph_bootstrap = {
    6.29          "photon", "QNX Photon video output",
    6.30  	ph_Available, ph_CreateDevice
    6.31  };
    6.32 @@ -183,8 +184,9 @@
    6.33  
    6.34    	if(window == NULL)
    6.35    	{
    6.36 -  		printf("PtAppInit failed\n");
    6.37 -        PtExit(EXIT_FAILURE);
    6.38 +  		printf("Photon application init failed, probably Photon is not running.\n");
    6.39 +        	exit( EXIT_FAILURE );
    6.40 +//        PtExit(EXIT_FAILURE);         // Got SEGFAULT.
    6.41    	}
    6.42  
    6.43      //PgSetDrawBufferSize(16 *1024);
    6.44 @@ -244,7 +246,10 @@
    6.45  		}
    6.46  
    6.47  
    6.48 -	currently_fullscreen = 0;
    6.49 +    currently_fullscreen = 0;
    6.50 +    
    6.51 +    this->info.wm_available = 1;
    6.52 +    
    6.53      return 0;
    6.54  }
    6.55  
     7.1 --- a/src/video/photon/SDL_ph_wm.c	Thu May 10 18:31:21 2001 +0000
     7.2 +++ b/src/video/photon/SDL_ph_wm.c	Thu May 10 18:42:17 2001 +0000
     7.3 @@ -25,9 +25,14 @@
     7.4   "@(#) $Id$";
     7.5  #endif
     7.6  
     7.7 +#define DISABLE_X11
     7.8 +
     7.9  #include <stdlib.h>
    7.10  #include <string.h>
    7.11  #include <Ph.h>
    7.12 +#include <photon/PpProto.h>
    7.13 +#include <photon/PhWm.h>
    7.14 +#include <photon/wmapi.h>
    7.15  #include "SDL_version.h"
    7.16  #include "SDL_error.h"
    7.17  #include "SDL_timer.h"
    7.18 @@ -215,42 +220,53 @@
    7.19  	return;
    7.20  }
    7.21  
    7.22 +/* Set window caption */
    7.23  void ph_SetCaption(_THIS, const char *title, const char *icon)
    7.24  {
    7.25 +	SDL_Lock_EventThread();
    7.26 +	if ( title != NULL ) {
    7.27 +		PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0);
    7.28 +	}
    7.29 +	SDL_Unlock_EventThread();
    7.30 +}
    7.31  
    7.32 -#if 0
    7.33 -	XTextProperty titleprop, iconprop;
    7.34 -
    7.35 -	/* Lock the event thread, in multi-threading environments */
    7.36 +/* Iconify the window (stolen from PhHotKey sources by phearbear ;-) */
    7.37 +int ph_IconifyWindow(_THIS)
    7.38 +{
    7.39 +	int result=0;
    7.40 +        int myerr;
    7.41 +        int num;
    7.42 +        PtConnectionClient_t *Client=0;
    7.43 +        WmMsg_t* Message=malloc(sizeof(WmMsg_t));
    7.44 +        WmReply_t *Reply=malloc(sizeof(WmReply_t));
    7.45 +        WmApiContext_t MsgStruct=malloc(sizeof(WmApiContext_t));
    7.46 +        WmWindowDefinition_t **WNDDEF=malloc(sizeof(WmWindowDefinition_t)*2);
    7.47 +	
    7.48  	SDL_Lock_EventThread();
    7.49  
    7.50 -	if ( title != NULL ) {
    7.51 -		XStringListToTextProperty((char **)&title, 1, &titleprop);
    7.52 -		XSetWMName(SDL_Display, WMwindow, &titleprop);
    7.53 -		XFree(titleprop.value);
    7.54 -	}
    7.55 -	if ( icon != NULL ) {
    7.56 -		XStringListToTextProperty((char **)&icon, 1, &iconprop);
    7.57 -		XSetWMIconName(SDL_Display, WMwindow, &iconprop);
    7.58 -		XFree(iconprop.value);
    7.59 -	}
    7.60 -	XSync(SDL_Display, False);
    7.61 +        PtInit("/dev/photon");
    7.62 +
    7.63 +        Client=PtConnectionFindName("pwm",0,0);
    7.64 +
    7.65 +        if(!Client)
    7.66 +        {
    7.67 +           return result;
    7.68 +        }
    7.69 +
    7.70 +        MsgStruct->input_group=PhInputGroup(0);
    7.71 +        MsgStruct->connection=PtConnectionFindName("pwm",0,0);
    7.72 +        myerr=WmGetFocusList(MsgStruct,2,&num,WNDDEF);
    7.73 +
    7.74 +        Message->hdr.type=WM_REQUEST_WIN_ACTION;
    7.75 +        Message->hdr.subtype=Pt_ACTION_MIN;	   
    7.76 +        Message->hdr.rid=WNDDEF[0]->rid;
    7.77 +        myerr=WmSendMessage(Client,Message,Reply,0);
    7.78 +
    7.79 +        free(Message);
    7.80 +        free(Reply);
    7.81  
    7.82  	SDL_Unlock_EventThread();
    7.83 -#endif
    7.84 -}
    7.85  
    7.86 -/* Iconify the window */
    7.87 -int ph_IconifyWindow(_THIS)
    7.88 -{
    7.89 -	int result;
    7.90 -	
    7.91 -#if 0
    7.92 -	SDL_Lock_EventThread();
    7.93 -	result = XIconifyWindow(SDL_Display, WMwindow, SDL_Screen);
    7.94 -	XSync(SDL_Display, False);
    7.95 -	SDL_Unlock_EventThread();
    7.96 -#endif
    7.97  	return(result);
    7.98  }
    7.99  
   7.100 @@ -335,8 +351,8 @@
   7.101  	/* Make sure any X11 transactions are completed */
   7.102  	SDL_VideoDevice *this = current_video;
   7.103  	XSync(SDL_Display, False);
   7.104 +#endif
   7.105  	SDL_Unlock_EventThread();
   7.106 -#endif
   7.107  }
   7.108  int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
   7.109  {
   7.110 @@ -360,4 +376,7 @@
   7.111  		return(-1);
   7.112  	}
   7.113  #endif
   7.114 +   return -1; // for now ...
   7.115  }
   7.116 +
   7.117 +