src/video/photon/SDL_ph_wm.c
changeset 266 c6abdda2f666
parent 252 e8157fcb3114
child 283 3d8b6b9f1e18
     1.1 --- a/src/video/photon/SDL_ph_wm.c	Fri Jan 18 17:14:16 2002 +0000
     1.2 +++ b/src/video/photon/SDL_ph_wm.c	Fri Jan 18 18:14:03 2002 +0000
     1.3 @@ -230,168 +230,44 @@
     1.4  	SDL_Unlock_EventThread();
     1.5  }
     1.6  
     1.7 -/* Iconify the window (stolen from PhHotKey sources by phearbear ;-) */
     1.8 +/* Iconify current window */
     1.9  int ph_IconifyWindow(_THIS)
    1.10  {
    1.11 -#if 1 /* Code submitted by Luca <barbato_luca@yahoo.com> */
    1.12 -	WmApiContext_t context=WmCreateContext();
    1.13 -	WmWindowDefinition_t
    1.14 -**wininfo=malloc(sizeof(WmWindowDefinition_t)*2);
    1.15 -	int num;									
    1.16 -	SDL_Lock_EventThread();
    1.17 -	WmGetFocusList(context,2,&num,wininfo);
    1.18 -	WmPerformFrameAction(context, wininfo[0]->rid,Pt_ACTION_MIN);
    1.19 -
    1.20 -	WmDestroyContext (context);   
    1.21 -	SDL_Unlock_EventThread();	 
    1.22 -	free(wininfo);		   
    1.23 -	return (0);   
    1.24 -#else
    1.25 -	int result=0;
    1.26 -        int myerr;
    1.27 -        int num;
    1.28 -        PtConnectionClient_t *Client=0;
    1.29 -        WmMsg_t* Message=malloc(sizeof(WmMsg_t));
    1.30 -        WmReply_t *Reply=malloc(sizeof(WmReply_t));
    1.31 -        WmApiContext_t MsgStruct=malloc(sizeof(WmApiContext_t));
    1.32 -        WmWindowDefinition_t **WNDDEF=malloc(sizeof(WmWindowDefinition_t)*2);
    1.33 -	
    1.34 -	SDL_Lock_EventThread();
    1.35 +   WmApiContext_t context=WmCreateContext();
    1.36 +   WmWindowDefinition_t **wininfo=malloc(sizeof(WmWindowDefinition_t)*2);
    1.37 +   int num;
    1.38  
    1.39 -        PtInit("/dev/photon");
    1.40 -
    1.41 -        Client=PtConnectionFindName("pwm",0,0);
    1.42 -
    1.43 -        if(!Client)
    1.44 -        {
    1.45 -           return result;
    1.46 -        }
    1.47 -
    1.48 -        MsgStruct->input_group=PhInputGroup(0);
    1.49 -        MsgStruct->connection=PtConnectionFindName("pwm",0,0);
    1.50 -        myerr=WmGetFocusList(MsgStruct,2,&num,WNDDEF);
    1.51 +   SDL_Lock_EventThread();
    1.52 +   WmGetFocusList(context,2,&num,wininfo);
    1.53 +   WmPerformFrameAction(context, wininfo[0]->rid,Pt_ACTION_MIN);
    1.54  
    1.55 -        Message->hdr.type=WM_REQUEST_WIN_ACTION;
    1.56 -        Message->hdr.subtype=Pt_ACTION_MIN;	   
    1.57 -        Message->hdr.rid=WNDDEF[0]->rid;
    1.58 -        myerr=WmSendMessage(Client,Message,Reply,0);
    1.59 +   WmDestroyContext (context);   
    1.60 +   SDL_Unlock_EventThread();	 
    1.61 +   free(wininfo);		   
    1.62  
    1.63 -        free(Message);
    1.64 -        free(Reply);
    1.65 -
    1.66 -	SDL_Unlock_EventThread();
    1.67 -
    1.68 -	return(result);
    1.69 -#endif /* 1 */
    1.70 +   return (0);   
    1.71  }
    1.72  
    1.73  SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
    1.74  {
    1.75 -#if 0 /*big*/
    1.76 -	int numtries, result;
    1.77 -
    1.78 -	if ( this->screen == NULL ) {
    1.79 -		return(SDL_GRAB_OFF);
    1.80 -	}
    1.81 -	if ( ! SDL_Window ) {
    1.82 -		return(mode);	/* Will be set later on mode switch */
    1.83 -	}
    1.84 -	if ( mode == SDL_GRAB_OFF ) {
    1.85 -		XUngrabPointer(SDL_Display, CurrentTime);
    1.86 -		if ( this->screen->flags & SDL_FULLSCREEN ) {
    1.87 -			/* Rebind the mouse to the fullscreen window */
    1.88 -			for ( numtries = 0; numtries < 10; ++numtries ) {
    1.89 -				result = XGrabPointer(SDL_Display, FSwindow,
    1.90 -						True, 0,
    1.91 -						GrabModeAsync, GrabModeAsync,
    1.92 -						FSwindow, None, CurrentTime);
    1.93 -				if ( result == AlreadyGrabbed ) {
    1.94 -					break;
    1.95 -				}
    1.96 -				SDL_Delay(100);
    1.97 -			}
    1.98 -		}
    1.99 -#ifdef GRAB_FULLSCREEN
   1.100 -		if ( !(this->screen->flags & SDL_FULLSCREEN) )
   1.101 -#endif
   1.102 -		XUngrabKeyboard(SDL_Display, CurrentTime);
   1.103 -	} else {
   1.104 -		if ( this->screen->flags & SDL_FULLSCREEN ) {
   1.105 -			/* Unbind the mouse from the fullscreen window */
   1.106 -			XUngrabPointer(SDL_Display, CurrentTime);
   1.107 -		}
   1.108 -		/* Try to grab the mouse */
   1.109 -		for ( numtries = 0; numtries < 10; ++numtries ) {
   1.110 -			result = XGrabPointer(SDL_Display, SDL_Window, True, 0,
   1.111 -						GrabModeAsync, GrabModeAsync,
   1.112 -						SDL_Window, None, CurrentTime);
   1.113 -			if ( result != AlreadyGrabbed ) {
   1.114 -				break;
   1.115 -			}
   1.116 -			SDL_Delay(100);
   1.117 -		}
   1.118 -#ifdef GRAB_FULLSCREEN
   1.119 -		if ( !(this->screen->flags & SDL_FULLSCREEN) )
   1.120 -#endif
   1.121 -		XGrabKeyboard(SDL_Display, WMwindow, True,
   1.122 -			GrabModeAsync, GrabModeAsync, CurrentTime);
   1.123 -	}
   1.124 -	XSync(SDL_Display, False);
   1.125 -
   1.126 -
   1.127 -#endif /*big*/
   1.128 -	return(mode);
   1.129 +   return(mode);
   1.130  }
   1.131  
   1.132  SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode)
   1.133  {
   1.134 -#if 0
   1.135 -	SDL_Lock_EventThread();
   1.136 -	mode = X11_GrabInputNoLock(this, mode);
   1.137 -	SDL_Unlock_EventThread();
   1.138 -#endif
   1.139 -	return(mode);
   1.140 +   return(mode);
   1.141  }
   1.142  
   1.143 -/* If 'info' is the right version, this function fills it and returns 1.
   1.144 -   Otherwise, in case of a version mismatch, it returns -1.
   1.145 -*/
   1.146 -static void lock_display(void)
   1.147 -{
   1.148 -	SDL_Lock_EventThread();
   1.149 -}
   1.150 -static void unlock_display(void)
   1.151 -{
   1.152 -#if 0
   1.153 -	/* Make sure any X11 transactions are completed */
   1.154 -	SDL_VideoDevice *this = current_video;
   1.155 -	XSync(SDL_Display, False);
   1.156 -#endif
   1.157 -	SDL_Unlock_EventThread();
   1.158 -}
   1.159  int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
   1.160  {
   1.161 -#if 0
   1.162 -	if ( info->version.major <= SDL_MAJOR_VERSION ) {
   1.163 -		info->subsystem = SDL_SYSWM_X11;
   1.164 -		info->info.x11.display = SDL_Display;
   1.165 -		info->info.x11.window = SDL_Window;
   1.166 -		if ( SDL_VERSIONNUM(info->version.major,
   1.167 -		                    info->version.minor,
   1.168 -		                    info->version.patch) >= 1002 ) {
   1.169 -			info->info.x11.fswindow = FSwindow;
   1.170 -			info->info.x11.wmwindow = WMwindow;
   1.171 -		}
   1.172 -		info->info.x11.lock_func = lock_display;
   1.173 -		info->info.x11.unlock_func = unlock_display;
   1.174 -		return(1);
   1.175 -	} else {
   1.176 -		SDL_SetError("Application not compiled with SDL %d.%d\n",
   1.177 -					SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
   1.178 -		return(-1);
   1.179 -	}
   1.180 -#endif
   1.181 -   return -1; // for now ...
   1.182 +   if (info->version.major <= SDL_MAJOR_VERSION)
   1.183 +   {
   1.184 +      return 1;
   1.185 +   }
   1.186 +   else
   1.187 +   {
   1.188 +      SDL_SetError("Application not compiled with SDL %d.%d\n",
   1.189 +                    SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
   1.190 +      return -1;
   1.191 +   }
   1.192  }
   1.193 -
   1.194 -