Commit 62b02c63 authored by Sam Lantinga's avatar Sam Lantinga

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

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%4020
parent 22f0ac25
......@@ -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"
......
......@@ -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
......
......@@ -86,6 +86,9 @@ static VideoBootStrap *bootstrap[] = {
#endif
#ifdef ENABLE_DUMMYVIDEO
&DUMMY_bootstrap,
#endif
#ifdef ENABLE_PHOTON
&ph_bootstrap,
#endif
NULL
};
......
......@@ -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>
......
......@@ -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;
......@@ -194,13 +193,15 @@ 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 ) {
if ( screen )
{
screen->pixels = NULL;
}
......
......@@ -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"
......@@ -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;
......@@ -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
};
......@@ -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);
......@@ -245,6 +247,9 @@ static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)
currently_fullscreen = 0;
this->info.wm_available = 1;
return 0;
}
......
......@@ -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"
......@@ -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);
}
if ( icon != NULL ) {
XStringListToTextProperty((char **)&icon, 1, &iconprop);
XSetWMIconName(SDL_Display, WMwindow, &iconprop);
XFree(iconprop.value);
PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0);
}
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);
}
......@@ -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)
{
......@@ -360,4 +376,7 @@ int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
return(-1);
}
#endif
return -1; // for now ...
}
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