ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/main_unix.cpp
(Generate patch)

Comparing SheepShaver/src/Unix/main_unix.cpp (file contents):
Revision 1.41 by gbeauche, 2004-06-22T17:10:07Z vs.
Revision 1.42 by gbeauche, 2004-06-24T15:37:25Z

# Line 127 | Line 127
127   #include "debug.h"
128  
129  
130 + #ifdef USE_SDL
131 + #include <SDL.h>
132 + #endif
133 +
134 + #ifndef USE_SDL_VIDEO
135   #include <X11/Xlib.h>
136 + #endif
137  
138   #ifdef ENABLE_GTK
139   #include <gtk/gtk.h>
# Line 272 | Line 278 | int64 BusClockSpeed;   // Bus clock speed
278  
279  
280   // Global variables
281 + #ifndef USE_SDL_VIDEO
282   char *x_display_name = NULL;                            // X11 display name
283   Display *x_display = NULL;                                      // X11 display handle
284   #ifdef X11_LOCK_TYPE
285   X11_LOCK_TYPE x_display_lock = X11_LOCK_INIT; // X11 display lock
286   #endif
287 + #endif
288  
289   static int zero_fd = 0;                                         // FD of /dev/zero
290   static bool lm_area_mapped = false;                     // Flag: Low Memory area mmap()ped
# Line 452 | Line 460 | int main(int argc, char **argv)
460          for (int i=1; i<argc; i++) {
461                  if (strcmp(argv[i], "--help") == 0) {
462                          usage(argv[0]);
463 + #ifndef USE_SDL_VIDEO
464                  } else if (strcmp(argv[i], "--display") == 0) {
465                          i++;
466                          if (i < argc)
467                                  x_display_name = strdup(argv[i]);
468 + #endif
469                  } else if (argv[i][0] == '-') {
470                          fprintf(stderr, "Unrecognized option '%s'\n", argv[i]);
471                          usage(argv[0]);
472                  }
473          }
474  
475 + #ifdef USE_SDL
476 +        // Initialize SDL system
477 +        int sdl_flags = 0;
478 + #ifdef USE_SDL_VIDEO
479 +        sdl_flags |= SDL_INIT_VIDEO;
480 + #endif
481 +        assert(sdl_flags != 0);
482 +        if (SDL_Init(sdl_flags) == -1) {
483 +                char str[256];
484 +                sprintf(str, "Could not initialize SDL: %s.\n", SDL_GetError());
485 +                ErrorAlert(str);
486 +                goto quit;
487 +        }
488 +        atexit(SDL_Quit);
489 + #endif
490 +
491 + #ifndef USE_SDL_VIDEO
492          // Open display
493          x_display = XOpenDisplay(x_display_name);
494          if (x_display == NULL) {
# Line 475 | Line 502 | int main(int argc, char **argv)
502          // Fork out, so we can return from fullscreen mode when things get ugly
503          XF86DGAForkApp(DefaultScreen(x_display));
504   #endif
505 + #endif
506  
507   #ifdef ENABLE_MON
508          // Initialize mon
# Line 1121 | Line 1149 | static void Quit(void)
1149   #endif
1150  
1151          // Close X11 server connection
1152 + #ifndef USE_SDL_VIDEO
1153          if (x_display)
1154                  XCloseDisplay(x_display);
1155 + #endif
1156  
1157          exit(0);
1158   }
# Line 1567 | Line 1597 | static void sigusr2_handler(int sig, sig
1597   {
1598          machine_regs *r = MACHINE_REGISTERS(scp);
1599  
1600 + #ifdef USE_SDL_VIDEO
1601 +        // We must fill in the events queue in the same thread that did call SDL_SetVideoMode()
1602 +        SDL_PumpEvents();
1603 + #endif
1604 +
1605          // Do nothing if interrupts are disabled
1606          if (*(int32 *)XLM_IRQ_NEST > 0)
1607                  return;
# Line 2166 | Line 2201 | void display_alert(int title_id, int pre
2201  
2202   void ErrorAlert(const char *text)
2203   {
2204 < #ifdef ENABLE_GTK
2204 > #if defined(ENABLE_GTK) && !defined(USE_SDL_VIDEO)
2205          if (PrefsFindBool("nogui") || x_display == NULL) {
2206                  printf(GetString(STR_SHELL_ERROR_PREFIX), text);
2207                  return;
# Line 2185 | Line 2220 | void ErrorAlert(const char *text)
2220  
2221   void WarningAlert(const char *text)
2222   {
2223 < #ifdef ENABLE_GTK
2223 > #if defined(ENABLE_GTK) && !defined(USE_SDL_VIDEO)
2224          if (PrefsFindBool("nogui") || x_display == NULL) {
2225                  printf(GetString(STR_SHELL_WARNING_PREFIX), text);
2226                  return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines