src/video/photon/SDL_ph_wm.c
changeset 19 8cc4dbfab9ab
parent 0 74212992fb08
child 190 e4af2c852c09
     1.1 --- a/src/video/photon/SDL_ph_wm.c	Thu May 10 18:31:21 2001 +0000
     1.2 +++ b/src/video/photon/SDL_ph_wm.c	Thu May 10 18:42:17 2001 +0000
     1.3 @@ -25,9 +25,14 @@
     1.4   "@(#) $Id$";
     1.5  #endif
     1.6  
     1.7 +#define DISABLE_X11
     1.8 +
     1.9  #include <stdlib.h>
    1.10  #include <string.h>
    1.11  #include <Ph.h>
    1.12 +#include <photon/PpProto.h>
    1.13 +#include <photon/PhWm.h>
    1.14 +#include <photon/wmapi.h>
    1.15  #include "SDL_version.h"
    1.16  #include "SDL_error.h"
    1.17  #include "SDL_timer.h"
    1.18 @@ -215,42 +220,53 @@
    1.19  	return;
    1.20  }
    1.21  
    1.22 +/* Set window caption */
    1.23  void ph_SetCaption(_THIS, const char *title, const char *icon)
    1.24  {
    1.25 +	SDL_Lock_EventThread();
    1.26 +	if ( title != NULL ) {
    1.27 +		PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0);
    1.28 +	}
    1.29 +	SDL_Unlock_EventThread();
    1.30 +}
    1.31  
    1.32 -#if 0
    1.33 -	XTextProperty titleprop, iconprop;
    1.34 -
    1.35 -	/* Lock the event thread, in multi-threading environments */
    1.36 +/* Iconify the window (stolen from PhHotKey sources by phearbear ;-) */
    1.37 +int ph_IconifyWindow(_THIS)
    1.38 +{
    1.39 +	int result=0;
    1.40 +        int myerr;
    1.41 +        int num;
    1.42 +        PtConnectionClient_t *Client=0;
    1.43 +        WmMsg_t* Message=malloc(sizeof(WmMsg_t));
    1.44 +        WmReply_t *Reply=malloc(sizeof(WmReply_t));
    1.45 +        WmApiContext_t MsgStruct=malloc(sizeof(WmApiContext_t));
    1.46 +        WmWindowDefinition_t **WNDDEF=malloc(sizeof(WmWindowDefinition_t)*2);
    1.47 +	
    1.48  	SDL_Lock_EventThread();
    1.49  
    1.50 -	if ( title != NULL ) {
    1.51 -		XStringListToTextProperty((char **)&title, 1, &titleprop);
    1.52 -		XSetWMName(SDL_Display, WMwindow, &titleprop);
    1.53 -		XFree(titleprop.value);
    1.54 -	}
    1.55 -	if ( icon != NULL ) {
    1.56 -		XStringListToTextProperty((char **)&icon, 1, &iconprop);
    1.57 -		XSetWMIconName(SDL_Display, WMwindow, &iconprop);
    1.58 -		XFree(iconprop.value);
    1.59 -	}
    1.60 -	XSync(SDL_Display, False);
    1.61 +        PtInit("/dev/photon");
    1.62 +
    1.63 +        Client=PtConnectionFindName("pwm",0,0);
    1.64 +
    1.65 +        if(!Client)
    1.66 +        {
    1.67 +           return result;
    1.68 +        }
    1.69 +
    1.70 +        MsgStruct->input_group=PhInputGroup(0);
    1.71 +        MsgStruct->connection=PtConnectionFindName("pwm",0,0);
    1.72 +        myerr=WmGetFocusList(MsgStruct,2,&num,WNDDEF);
    1.73 +
    1.74 +        Message->hdr.type=WM_REQUEST_WIN_ACTION;
    1.75 +        Message->hdr.subtype=Pt_ACTION_MIN;	   
    1.76 +        Message->hdr.rid=WNDDEF[0]->rid;
    1.77 +        myerr=WmSendMessage(Client,Message,Reply,0);
    1.78 +
    1.79 +        free(Message);
    1.80 +        free(Reply);
    1.81  
    1.82  	SDL_Unlock_EventThread();
    1.83 -#endif
    1.84 -}
    1.85  
    1.86 -/* Iconify the window */
    1.87 -int ph_IconifyWindow(_THIS)
    1.88 -{
    1.89 -	int result;
    1.90 -	
    1.91 -#if 0
    1.92 -	SDL_Lock_EventThread();
    1.93 -	result = XIconifyWindow(SDL_Display, WMwindow, SDL_Screen);
    1.94 -	XSync(SDL_Display, False);
    1.95 -	SDL_Unlock_EventThread();
    1.96 -#endif
    1.97  	return(result);
    1.98  }
    1.99  
   1.100 @@ -335,8 +351,8 @@
   1.101  	/* Make sure any X11 transactions are completed */
   1.102  	SDL_VideoDevice *this = current_video;
   1.103  	XSync(SDL_Display, False);
   1.104 +#endif
   1.105  	SDL_Unlock_EventThread();
   1.106 -#endif
   1.107  }
   1.108  int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
   1.109  {
   1.110 @@ -360,4 +376,7 @@
   1.111  		return(-1);
   1.112  	}
   1.113  #endif
   1.114 +   return -1; // for now ...
   1.115  }
   1.116 +
   1.117 +