comparison src/video/x11/SDL_x11modes.c @ 98:8a5aff5c1294

Fixed some problems with the fullscreen code. Wooo. :)
author Sam Lantinga <slouken@lokigames.com>
date Mon, 09 Jul 2001 22:36:16 +0000
parents e85e03f195b4
children a1c973c35fef
comparison
equal deleted inserted replaced
97:c7bcdece4845 98:8a5aff5c1294
394 /* Switch resolution and cover it with the FSwindow */ 394 /* Switch resolution and cover it with the FSwindow */
395 move_cursor_to(this, 0, 0); 395 move_cursor_to(this, 0, 0);
396 set_best_resolution(this, current_w, current_h); 396 set_best_resolution(this, current_w, current_h);
397 move_cursor_to(this, 0, 0); 397 move_cursor_to(this, 0, 0);
398 get_real_resolution(this, &real_w, &real_h); 398 get_real_resolution(this, &real_w, &real_h);
399 XResizeWindow(SDL_Display, FSwindow, real_w, real_h); 399 XMoveResizeWindow(SDL_Display, FSwindow, 0, 0, real_w, real_h);
400 move_cursor_to(this, real_w/2, real_h/2); 400 move_cursor_to(this, real_w/2, real_h/2);
401 401
402 /* Center and reparent the drawing window */ 402 /* Center and reparent the drawing window */
403 x = (real_w - current_w)/2; 403 x = (real_w - current_w)/2;
404 y = (real_h - current_h)/2; 404 y = (real_h - current_h)/2;
423 int okay; 423 int okay;
424 #if 0 424 #if 0
425 Window tmpwin, *windows; 425 Window tmpwin, *windows;
426 int i, nwindows; 426 int i, nwindows;
427 #endif 427 #endif
428 int real_w, real_h;
428 429
429 okay = 1; 430 okay = 1;
430 if ( ! currently_fullscreen ) { 431 if ( currently_fullscreen ) {
431 int real_w, real_h; 432 return(okay);
432 433 }
433 /* Map the fullscreen window to blank the screen */ 434
434 get_real_resolution(this, &real_w, &real_h); 435 /* Ungrab the input so that we can move the mouse around */
435 XResizeWindow(SDL_Display, FSwindow, real_w, real_h); 436 X11_GrabInputNoLock(this, SDL_GRAB_OFF);
436 XMapRaised(SDL_Display, FSwindow); 437
437 X11_WaitMapped(this, FSwindow); 438 /* Map the fullscreen window to blank the screen */
439 get_real_resolution(this, &real_w, &real_h);
440 XMoveResizeWindow(SDL_Display, FSwindow, 0, 0, real_w, real_h);
441 XMapRaised(SDL_Display, FSwindow);
442 X11_WaitMapped(this, FSwindow);
438 443
439 #if 0 /* This seems to break WindowMaker in focus-follows-mouse mode */ 444 #if 0 /* This seems to break WindowMaker in focus-follows-mouse mode */
440 /* Make sure we got to the top of the window stack */ 445 /* Make sure we got to the top of the window stack */
441 if ( XQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin, 446 if ( XQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin,
442 &windows, &nwindows) && windows ) { 447 &windows, &nwindows) && windows ) {
443 /* If not, try to put us there - if fail... oh well */ 448 /* If not, try to put us there - if fail... oh well */
444 if ( windows[nwindows-1] != FSwindow ) { 449 if ( windows[nwindows-1] != FSwindow ) {
445 tmpwin = windows[nwindows-1]; 450 tmpwin = windows[nwindows-1];
446 for ( i=0; i<nwindows; ++i ) { 451 for ( i=0; i<nwindows; ++i ) {
447 if ( windows[i] == FSwindow ) { 452 if ( windows[i] == FSwindow ) {
448 memcpy(&windows[i], &windows[i+1], 453 memcpy(&windows[i], &windows[i+1],
449 (nwindows-i-1)*sizeof(windows[i])); 454 (nwindows-i-1)*sizeof(windows[i]));
450 break; 455 break;
451 }
452 } 456 }
453 windows[nwindows-1] = FSwindow;
454 XRestackWindows(SDL_Display, windows, nwindows);
455 XSync(SDL_Display, False);
456 } 457 }
457 XFree(windows); 458 windows[nwindows-1] = FSwindow;
458 } 459 XRestackWindows(SDL_Display, windows, nwindows);
460 XSync(SDL_Display, False);
461 }
462 XFree(windows);
463 }
459 #else 464 #else
460 XRaiseWindow(SDL_Display, FSwindow); 465 XRaiseWindow(SDL_Display, FSwindow);
461 #endif 466 #endif
462 467
463 #ifdef XFREE86_VM 468 #ifdef XFREE86_VM
464 /* Save the current video mode */ 469 /* Save the current video mode */
465 if ( use_vidmode ) { 470 if ( use_vidmode ) {
466 XVidMode(LockModeSwitch, (SDL_Display, SDL_Screen, True)); 471 XVidMode(LockModeSwitch, (SDL_Display, SDL_Screen, True));
467 } 472 }
468 #endif 473 #endif
469 currently_fullscreen = 1; 474 currently_fullscreen = 1;
470 475
471 /* Set the new resolution */ 476 /* Set the new resolution */
472 okay = X11_ResizeFullScreen(this); 477 okay = X11_ResizeFullScreen(this);
473 if ( ! okay ) { 478 if ( ! okay ) {
474 X11_LeaveFullScreen(this); 479 X11_LeaveFullScreen(this);
475 } 480 }
476 /* Set the colormap */ 481 /* Set the colormap */
477 if ( SDL_XColorMap ) { 482 if ( SDL_XColorMap ) {
478 XInstallColormap(SDL_Display, SDL_XColorMap); 483 XInstallColormap(SDL_Display, SDL_XColorMap);
479 }
480 } 484 }
481 if ( okay ) 485 if ( okay )
482 X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN); 486 X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN);
483 487
484 /* We may need to refresh the screen at this point (no backing store) 488 /* We may need to refresh the screen at this point (no backing store)