comparison src/video/photon/SDL_ph_wm.c @ 19:8cc4dbfab9ab

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
author Sam Lantinga <slouken@lokigames.com>
date Thu, 10 May 2001 18:42:17 +0000
parents 74212992fb08
children e4af2c852c09
comparison
equal deleted inserted replaced
18:d9e3595b63d5 19:8cc4dbfab9ab
23 #ifdef SAVE_RCSID 23 #ifdef SAVE_RCSID
24 static char rcsid = 24 static char rcsid =
25 "@(#) $Id$"; 25 "@(#) $Id$";
26 #endif 26 #endif
27 27
28 #define DISABLE_X11
29
28 #include <stdlib.h> 30 #include <stdlib.h>
29 #include <string.h> 31 #include <string.h>
30 #include <Ph.h> 32 #include <Ph.h>
33 #include <photon/PpProto.h>
34 #include <photon/PhWm.h>
35 #include <photon/wmapi.h>
31 #include "SDL_version.h" 36 #include "SDL_version.h"
32 #include "SDL_error.h" 37 #include "SDL_error.h"
33 #include "SDL_timer.h" 38 #include "SDL_timer.h"
34 #include "SDL_video.h" 39 #include "SDL_video.h"
35 #include "SDL_syswm.h" 40 #include "SDL_syswm.h"
213 218
214 #endif /*big*/ 219 #endif /*big*/
215 return; 220 return;
216 } 221 }
217 222
223 /* Set window caption */
218 void ph_SetCaption(_THIS, const char *title, const char *icon) 224 void ph_SetCaption(_THIS, const char *title, const char *icon)
219 { 225 {
220 226 SDL_Lock_EventThread();
221 #if 0
222 XTextProperty titleprop, iconprop;
223
224 /* Lock the event thread, in multi-threading environments */
225 SDL_Lock_EventThread();
226
227 if ( title != NULL ) { 227 if ( title != NULL ) {
228 XStringListToTextProperty((char **)&title, 1, &titleprop); 228 PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0);
229 XSetWMName(SDL_Display, WMwindow, &titleprop); 229 }
230 XFree(titleprop.value); 230 SDL_Unlock_EventThread();
231 } 231 }
232 if ( icon != NULL ) { 232
233 XStringListToTextProperty((char **)&icon, 1, &iconprop); 233 /* Iconify the window (stolen from PhHotKey sources by phearbear ;-) */
234 XSetWMIconName(SDL_Display, WMwindow, &iconprop);
235 XFree(iconprop.value);
236 }
237 XSync(SDL_Display, False);
238
239 SDL_Unlock_EventThread();
240 #endif
241 }
242
243 /* Iconify the window */
244 int ph_IconifyWindow(_THIS) 234 int ph_IconifyWindow(_THIS)
245 { 235 {
246 int result; 236 int result=0;
237 int myerr;
238 int num;
239 PtConnectionClient_t *Client=0;
240 WmMsg_t* Message=malloc(sizeof(WmMsg_t));
241 WmReply_t *Reply=malloc(sizeof(WmReply_t));
242 WmApiContext_t MsgStruct=malloc(sizeof(WmApiContext_t));
243 WmWindowDefinition_t **WNDDEF=malloc(sizeof(WmWindowDefinition_t)*2);
247 244
248 #if 0 245 SDL_Lock_EventThread();
249 SDL_Lock_EventThread(); 246
250 result = XIconifyWindow(SDL_Display, WMwindow, SDL_Screen); 247 PtInit("/dev/photon");
251 XSync(SDL_Display, False); 248
252 SDL_Unlock_EventThread(); 249 Client=PtConnectionFindName("pwm",0,0);
253 #endif 250
251 if(!Client)
252 {
253 return result;
254 }
255
256 MsgStruct->input_group=PhInputGroup(0);
257 MsgStruct->connection=PtConnectionFindName("pwm",0,0);
258 myerr=WmGetFocusList(MsgStruct,2,&num,WNDDEF);
259
260 Message->hdr.type=WM_REQUEST_WIN_ACTION;
261 Message->hdr.subtype=Pt_ACTION_MIN;
262 Message->hdr.rid=WNDDEF[0]->rid;
263 myerr=WmSendMessage(Client,Message,Reply,0);
264
265 free(Message);
266 free(Reply);
267
268 SDL_Unlock_EventThread();
269
254 return(result); 270 return(result);
255 } 271 }
256 272
257 SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode) 273 SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
258 { 274 {
333 { 349 {
334 #if 0 350 #if 0
335 /* Make sure any X11 transactions are completed */ 351 /* Make sure any X11 transactions are completed */
336 SDL_VideoDevice *this = current_video; 352 SDL_VideoDevice *this = current_video;
337 XSync(SDL_Display, False); 353 XSync(SDL_Display, False);
338 SDL_Unlock_EventThread(); 354 #endif
339 #endif 355 SDL_Unlock_EventThread();
340 } 356 }
341 int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info) 357 int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
342 { 358 {
343 #if 0 359 #if 0
344 if ( info->version.major <= SDL_MAJOR_VERSION ) { 360 if ( info->version.major <= SDL_MAJOR_VERSION ) {
358 SDL_SetError("Application not compiled with SDL %d.%d\n", 374 SDL_SetError("Application not compiled with SDL %d.%d\n",
359 SDL_MAJOR_VERSION, SDL_MINOR_VERSION); 375 SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
360 return(-1); 376 return(-1);
361 } 377 }
362 #endif 378 #endif
363 } 379 return -1; // for now ...
380 }
381
382