Skip to content

Commit

Permalink
Date: Thu, 19 Apr 2001 08:36:54 +0300
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Sam Lantinga committed May 10, 2001
1 parent ec59fb5 commit 6e71e37
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 38 deletions.
1 change: 1 addition & 0 deletions configure.in
Expand Up @@ -545,6 +545,7 @@ CheckPHOTON()
])
AC_MSG_RESULT($video_photon)
if test x$video_photon = xyes; then
CFLAGS="$CFLAGS -DENABLE_PHOTON"
SYSTEM_LIBS="$SYSTEM_LIBS -lph"
VIDEO_SUBDIRS="$VIDEO_SUBDIRS photon"
VIDEO_DRIVERS="$VIDEO_DRIVERS photon/libvideo_photon.la"
Expand Down
3 changes: 3 additions & 0 deletions src/video/SDL_sysvideo.h
Expand Up @@ -358,6 +358,9 @@ extern VideoBootStrap BWINDOW_bootstrap;
#ifdef ENABLE_DUMMYVIDEO
extern VideoBootStrap DUMMY_bootstrap;
#endif
#ifdef ENABLE_PHOTON
extern VideoBootStrap ph_bootstrap;
#endif
/* MacOS X gets the proper defines from configure */
#if defined(macintosh) && !defined(MACOSX)
#define ENABLE_TOOLBOX
Expand Down
3 changes: 3 additions & 0 deletions src/video/SDL_video.c
Expand Up @@ -86,6 +86,9 @@ static VideoBootStrap *bootstrap[] = {
#endif
#ifdef ENABLE_DUMMYVIDEO
&DUMMY_bootstrap,
#endif
#ifdef ENABLE_PHOTON
&ph_bootstrap,
#endif
NULL
};
Expand Down
2 changes: 2 additions & 0 deletions src/video/photon/SDL_ph_events.c
Expand Up @@ -27,6 +27,8 @@ static char rcsid =

/* Handle the event stream, converting photon events into SDL events */

#define DISABLE_X11

#include <Ph.h>
#include <stdio.h>
#include <setjmp.h>
Expand Down
17 changes: 9 additions & 8 deletions src/video/photon/SDL_ph_image.c
Expand Up @@ -78,8 +78,7 @@ int ph_SetupImage(_THIS, SDL_Surface *screen)
}

//using shared memory for speed (set last param to 1)
if ((SDL_Image = PhCreateImage( NULL, screen->w, screen->h, type, NULL, 0, 1 ))
== NULL)
if ((SDL_Image = PhCreateImage( NULL, screen->w, screen->h, type, NULL, 0, 1 )) == NULL)
{
fprintf(stderr,"error: PhCreateImage failed.\n");
return -1;
Expand Down Expand Up @@ -194,14 +193,16 @@ void ph_DestroyImage(_THIS, SDL_Surface *screen)

if (SDL_Image->image)
{
//free(SDL_Image->image);
//SDL_Image->image = NULL;
PhReleaseImage(SDL_Image);
SDL_Image = NULL;
// SDL_Image->flags=Ph_RELEASE_IMAGE;
// PhReleaseImage(SDL_Image);
PgShmemDestroy(SDL_Image->image); // Use this if you using shared memory, or uncomment
// lines above if not (and comment this line ;-)
free(SDL_Image);
}

if ( screen ) {
screen->pixels = NULL;
if ( screen )
{
screen->pixels = NULL;
}

SDL_Image = NULL;
Expand Down
17 changes: 11 additions & 6 deletions src/video/photon/SDL_ph_video.c
Expand Up @@ -46,6 +46,7 @@ static char rcsid =
#include "SDL_ph_image_c.h"
#include "SDL_ph_events_c.h"
#include "SDL_ph_mouse_c.h"
#include "SDL_ph_wm_c.h"
#include "SDL_phyuv_c.h"
#include "blank_cursor.h"

Expand Down Expand Up @@ -103,9 +104,9 @@ static SDL_VideoDevice *ph_CreateDevice(int devindex)
device->UnlockHWSurface = ph_UnlockHWSurface;
device->FlipHWSurface = ph_FlipHWSurface;
device->FreeHWSurface = ph_FreeHWSurface;
device->SetCaption = NULL;
device->SetCaption = ph_SetCaption;
device->SetIcon = NULL;
device->IconifyWindow = NULL;
device->IconifyWindow = ph_IconifyWindow;
device->GrabInput = NULL;
device->GetWMInfo = NULL;
device->FreeWMCursor = ph_FreeWMCursor;
Expand All @@ -121,7 +122,7 @@ static SDL_VideoDevice *ph_CreateDevice(int devindex)
return device;
}

VideoBootStrap X11_bootstrap = {
VideoBootStrap ph_bootstrap = {
"photon", "QNX Photon video output",
ph_Available, ph_CreateDevice
};
Expand Down Expand Up @@ -183,8 +184,9 @@ static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)

if(window == NULL)
{
printf("PtAppInit failed\n");
PtExit(EXIT_FAILURE);
printf("Photon application init failed, probably Photon is not running.\n");
exit( EXIT_FAILURE );
// PtExit(EXIT_FAILURE); // Got SEGFAULT.
}

//PgSetDrawBufferSize(16 *1024);
Expand Down Expand Up @@ -244,7 +246,10 @@ static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)
}


currently_fullscreen = 0;
currently_fullscreen = 0;

this->info.wm_available = 1;

return 0;
}

Expand Down
67 changes: 43 additions & 24 deletions src/video/photon/SDL_ph_wm.c
Expand Up @@ -25,9 +25,14 @@ static char rcsid =
"@(#) $Id$";
#endif

#define DISABLE_X11

#include <stdlib.h>
#include <string.h>
#include <Ph.h>
#include <photon/PpProto.h>
#include <photon/PhWm.h>
#include <photon/wmapi.h>
#include "SDL_version.h"
#include "SDL_error.h"
#include "SDL_timer.h"
Expand Down Expand Up @@ -215,42 +220,53 @@ void ph_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
return;
}

/* Set window caption */
void ph_SetCaption(_THIS, const char *title, const char *icon)
{

#if 0
XTextProperty titleprop, iconprop;

/* Lock the event thread, in multi-threading environments */
SDL_Lock_EventThread();

if ( title != NULL ) {
XStringListToTextProperty((char **)&title, 1, &titleprop);
XSetWMName(SDL_Display, WMwindow, &titleprop);
XFree(titleprop.value);
PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0);
}
if ( icon != NULL ) {
XStringListToTextProperty((char **)&icon, 1, &iconprop);
XSetWMIconName(SDL_Display, WMwindow, &iconprop);
XFree(iconprop.value);
}
XSync(SDL_Display, False);

SDL_Unlock_EventThread();
#endif
}

/* Iconify the window */
/* Iconify the window (stolen from PhHotKey sources by phearbear ;-) */
int ph_IconifyWindow(_THIS)
{
int result;
int result=0;
int myerr;
int num;
PtConnectionClient_t *Client=0;
WmMsg_t* Message=malloc(sizeof(WmMsg_t));
WmReply_t *Reply=malloc(sizeof(WmReply_t));
WmApiContext_t MsgStruct=malloc(sizeof(WmApiContext_t));
WmWindowDefinition_t **WNDDEF=malloc(sizeof(WmWindowDefinition_t)*2);

#if 0
SDL_Lock_EventThread();
result = XIconifyWindow(SDL_Display, WMwindow, SDL_Screen);
XSync(SDL_Display, False);

PtInit("/dev/photon");

Client=PtConnectionFindName("pwm",0,0);

if(!Client)
{
return result;
}

MsgStruct->input_group=PhInputGroup(0);
MsgStruct->connection=PtConnectionFindName("pwm",0,0);
myerr=WmGetFocusList(MsgStruct,2,&num,WNDDEF);

Message->hdr.type=WM_REQUEST_WIN_ACTION;
Message->hdr.subtype=Pt_ACTION_MIN;
Message->hdr.rid=WNDDEF[0]->rid;
myerr=WmSendMessage(Client,Message,Reply,0);

free(Message);
free(Reply);

SDL_Unlock_EventThread();
#endif

return(result);
}

Expand Down Expand Up @@ -335,8 +351,8 @@ static void unlock_display(void)
/* Make sure any X11 transactions are completed */
SDL_VideoDevice *this = current_video;
XSync(SDL_Display, False);
SDL_Unlock_EventThread();
#endif
SDL_Unlock_EventThread();
}
int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
{
Expand All @@ -360,4 +376,7 @@ int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
return(-1);
}
#endif
return -1; // for now ...
}


0 comments on commit 6e71e37

Please sign in to comment.