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
--- a/configure.in Thu May 10 18:31:21 2001 +0000
+++ b/configure.in Thu May 10 18:42:17 2001 +0000
@@ -545,6 +545,7 @@
])
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"
--- a/src/video/SDL_sysvideo.h Thu May 10 18:31:21 2001 +0000
+++ b/src/video/SDL_sysvideo.h Thu May 10 18:42:17 2001 +0000
@@ -358,6 +358,9 @@
#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
--- a/src/video/SDL_video.c Thu May 10 18:31:21 2001 +0000
+++ b/src/video/SDL_video.c Thu May 10 18:42:17 2001 +0000
@@ -87,6 +87,9 @@
#ifdef ENABLE_DUMMYVIDEO
&DUMMY_bootstrap,
#endif
+#ifdef ENABLE_PHOTON
+ &ph_bootstrap,
+#endif
NULL
};
SDL_VideoDevice *current_video = NULL;
--- a/src/video/photon/SDL_ph_events.c Thu May 10 18:31:21 2001 +0000
+++ b/src/video/photon/SDL_ph_events.c Thu May 10 18:42:17 2001 +0000
@@ -27,6 +27,8 @@
/* Handle the event stream, converting photon events into SDL events */
+#define DISABLE_X11
+
#include <Ph.h>
#include <stdio.h>
#include <setjmp.h>
--- a/src/video/photon/SDL_ph_image.c Thu May 10 18:31:21 2001 +0000
+++ b/src/video/photon/SDL_ph_image.c Thu May 10 18:42:17 2001 +0000
@@ -78,8 +78,7 @@
}
//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,14 +193,16 @@
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;
--- a/src/video/photon/SDL_ph_video.c Thu May 10 18:31:21 2001 +0000
+++ b/src/video/photon/SDL_ph_video.c Thu May 10 18:42:17 2001 +0000
@@ -46,6 +46,7 @@
#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 @@
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 @@
return device;
}
-VideoBootStrap X11_bootstrap = {
+VideoBootStrap ph_bootstrap = {
"photon", "QNX Photon video output",
ph_Available, ph_CreateDevice
};
@@ -183,8 +184,9 @@
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);
@@ -244,7 +246,10 @@
}
- currently_fullscreen = 0;
+ currently_fullscreen = 0;
+
+ this->info.wm_available = 1;
+
return 0;
}
--- a/src/video/photon/SDL_ph_wm.c Thu May 10 18:31:21 2001 +0000
+++ b/src/video/photon/SDL_ph_wm.c Thu May 10 18:42:17 2001 +0000
@@ -25,9 +25,14 @@
"@(#) $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 @@
return;
}
+/* Set window caption */
void ph_SetCaption(_THIS, const char *title, const char *icon)
{
+ SDL_Lock_EventThread();
+ if ( title != NULL ) {
+ PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0);
+ }
+ SDL_Unlock_EventThread();
+}
-#if 0
- XTextProperty titleprop, iconprop;
-
- /* Lock the event thread, in multi-threading environments */
+/* Iconify the window (stolen from PhHotKey sources by phearbear ;-) */
+int ph_IconifyWindow(_THIS)
+{
+ 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);
+
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);
- }
- 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
-}
-/* Iconify the window */
-int ph_IconifyWindow(_THIS)
-{
- int result;
-
-#if 0
- SDL_Lock_EventThread();
- result = XIconifyWindow(SDL_Display, WMwindow, SDL_Screen);
- XSync(SDL_Display, False);
- SDL_Unlock_EventThread();
-#endif
return(result);
}
@@ -335,8 +351,8 @@
/* Make sure any X11 transactions are completed */
SDL_VideoDevice *this = current_video;
XSync(SDL_Display, False);
+#endif
SDL_Unlock_EventThread();
-#endif
}
int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
{
@@ -360,4 +376,7 @@
return(-1);
}
#endif
+ return -1; // for now ...
}
+
+