comparison src/video/photon/SDL_ph_wm.c @ 266:c6abdda2f666

Added QNX cleanups by Mike Gorchak (thanks!)
author Sam Lantinga <slouken@libsdl.org>
date Fri, 18 Jan 2002 18:14:03 +0000
parents e8157fcb3114
children 3d8b6b9f1e18
comparison
equal deleted inserted replaced
265:35d9c8a5aa10 266:c6abdda2f666
228 PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0); 228 PtSetResource(window, Pt_ARG_WINDOW_TITLE, title, 0);
229 } 229 }
230 SDL_Unlock_EventThread(); 230 SDL_Unlock_EventThread();
231 } 231 }
232 232
233 /* Iconify the window (stolen from PhHotKey sources by phearbear ;-) */ 233 /* Iconify current window */
234 int ph_IconifyWindow(_THIS) 234 int ph_IconifyWindow(_THIS)
235 { 235 {
236 #if 1 /* Code submitted by Luca <barbato_luca@yahoo.com> */ 236 WmApiContext_t context=WmCreateContext();
237 WmApiContext_t context=WmCreateContext(); 237 WmWindowDefinition_t **wininfo=malloc(sizeof(WmWindowDefinition_t)*2);
238 WmWindowDefinition_t 238 int num;
239 **wininfo=malloc(sizeof(WmWindowDefinition_t)*2); 239
240 int num; 240 SDL_Lock_EventThread();
241 SDL_Lock_EventThread(); 241 WmGetFocusList(context,2,&num,wininfo);
242 WmGetFocusList(context,2,&num,wininfo); 242 WmPerformFrameAction(context, wininfo[0]->rid,Pt_ACTION_MIN);
243 WmPerformFrameAction(context, wininfo[0]->rid,Pt_ACTION_MIN); 243
244 244 WmDestroyContext (context);
245 WmDestroyContext (context); 245 SDL_Unlock_EventThread();
246 SDL_Unlock_EventThread(); 246 free(wininfo);
247 free(wininfo); 247
248 return (0); 248 return (0);
249 #else
250 int result=0;
251 int myerr;
252 int num;
253 PtConnectionClient_t *Client=0;
254 WmMsg_t* Message=malloc(sizeof(WmMsg_t));
255 WmReply_t *Reply=malloc(sizeof(WmReply_t));
256 WmApiContext_t MsgStruct=malloc(sizeof(WmApiContext_t));
257 WmWindowDefinition_t **WNDDEF=malloc(sizeof(WmWindowDefinition_t)*2);
258
259 SDL_Lock_EventThread();
260
261 PtInit("/dev/photon");
262
263 Client=PtConnectionFindName("pwm",0,0);
264
265 if(!Client)
266 {
267 return result;
268 }
269
270 MsgStruct->input_group=PhInputGroup(0);
271 MsgStruct->connection=PtConnectionFindName("pwm",0,0);
272 myerr=WmGetFocusList(MsgStruct,2,&num,WNDDEF);
273
274 Message->hdr.type=WM_REQUEST_WIN_ACTION;
275 Message->hdr.subtype=Pt_ACTION_MIN;
276 Message->hdr.rid=WNDDEF[0]->rid;
277 myerr=WmSendMessage(Client,Message,Reply,0);
278
279 free(Message);
280 free(Reply);
281
282 SDL_Unlock_EventThread();
283
284 return(result);
285 #endif /* 1 */
286 } 249 }
287 250
288 SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode) 251 SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
289 { 252 {
290 #if 0 /*big*/ 253 return(mode);
291 int numtries, result;
292
293 if ( this->screen == NULL ) {
294 return(SDL_GRAB_OFF);
295 }
296 if ( ! SDL_Window ) {
297 return(mode); /* Will be set later on mode switch */
298 }
299 if ( mode == SDL_GRAB_OFF ) {
300 XUngrabPointer(SDL_Display, CurrentTime);
301 if ( this->screen->flags & SDL_FULLSCREEN ) {
302 /* Rebind the mouse to the fullscreen window */
303 for ( numtries = 0; numtries < 10; ++numtries ) {
304 result = XGrabPointer(SDL_Display, FSwindow,
305 True, 0,
306 GrabModeAsync, GrabModeAsync,
307 FSwindow, None, CurrentTime);
308 if ( result == AlreadyGrabbed ) {
309 break;
310 }
311 SDL_Delay(100);
312 }
313 }
314 #ifdef GRAB_FULLSCREEN
315 if ( !(this->screen->flags & SDL_FULLSCREEN) )
316 #endif
317 XUngrabKeyboard(SDL_Display, CurrentTime);
318 } else {
319 if ( this->screen->flags & SDL_FULLSCREEN ) {
320 /* Unbind the mouse from the fullscreen window */
321 XUngrabPointer(SDL_Display, CurrentTime);
322 }
323 /* Try to grab the mouse */
324 for ( numtries = 0; numtries < 10; ++numtries ) {
325 result = XGrabPointer(SDL_Display, SDL_Window, True, 0,
326 GrabModeAsync, GrabModeAsync,
327 SDL_Window, None, CurrentTime);
328 if ( result != AlreadyGrabbed ) {
329 break;
330 }
331 SDL_Delay(100);
332 }
333 #ifdef GRAB_FULLSCREEN
334 if ( !(this->screen->flags & SDL_FULLSCREEN) )
335 #endif
336 XGrabKeyboard(SDL_Display, WMwindow, True,
337 GrabModeAsync, GrabModeAsync, CurrentTime);
338 }
339 XSync(SDL_Display, False);
340
341
342 #endif /*big*/
343 return(mode);
344 } 254 }
345 255
346 SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode) 256 SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode)
347 { 257 {
348 #if 0 258 return(mode);
349 SDL_Lock_EventThread(); 259 }
350 mode = X11_GrabInputNoLock(this, mode); 260
351 SDL_Unlock_EventThread();
352 #endif
353 return(mode);
354 }
355
356 /* If 'info' is the right version, this function fills it and returns 1.
357 Otherwise, in case of a version mismatch, it returns -1.
358 */
359 static void lock_display(void)
360 {
361 SDL_Lock_EventThread();
362 }
363 static void unlock_display(void)
364 {
365 #if 0
366 /* Make sure any X11 transactions are completed */
367 SDL_VideoDevice *this = current_video;
368 XSync(SDL_Display, False);
369 #endif
370 SDL_Unlock_EventThread();
371 }
372 int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info) 261 int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
373 { 262 {
374 #if 0 263 if (info->version.major <= SDL_MAJOR_VERSION)
375 if ( info->version.major <= SDL_MAJOR_VERSION ) { 264 {
376 info->subsystem = SDL_SYSWM_X11; 265 return 1;
377 info->info.x11.display = SDL_Display; 266 }
378 info->info.x11.window = SDL_Window; 267 else
379 if ( SDL_VERSIONNUM(info->version.major, 268 {
380 info->version.minor, 269 SDL_SetError("Application not compiled with SDL %d.%d\n",
381 info->version.patch) >= 1002 ) { 270 SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
382 info->info.x11.fswindow = FSwindow; 271 return -1;
383 info->info.x11.wmwindow = WMwindow; 272 }
384 } 273 }
385 info->info.x11.lock_func = lock_display;
386 info->info.x11.unlock_func = unlock_display;
387 return(1);
388 } else {
389 SDL_SetError("Application not compiled with SDL %d.%d\n",
390 SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
391 return(-1);
392 }
393 #endif
394 return -1; // for now ...
395 }
396
397