diff src/video/qtopia/SDL_sysvideo.cc @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children
line wrap: on
line diff
--- a/src/video/qtopia/SDL_sysvideo.cc	Mon May 29 03:53:21 2006 +0000
+++ b/src/video/qtopia/SDL_sysvideo.cc	Mon May 29 04:04:35 2006 +0000
@@ -52,60 +52,60 @@
 #define SDL_QT_ROTATION_ENV_NAME "SDL_QT_INVERT_ROTATION"
 
     /* Initialization/Query functions */
-    static int QT_VideoInit (_THIS, SDL_PixelFormat * vformat);
-    static SDL_Rect **QT_ListModes (_THIS, SDL_PixelFormat * format,
-                                    Uint32 flags);
-    static SDL_Surface *QT_SetVideoMode (_THIS, SDL_Surface * current,
-                                         int width, int height, int bpp,
-                                         Uint32 flags);
-    static void QT_UpdateMouse (_THIS);
-    static int QT_SetColors (_THIS, int firstcolor, int ncolors,
-                             SDL_Color * colors);
-    static void QT_VideoQuit (_THIS);
+    static int QT_VideoInit(_THIS, SDL_PixelFormat * vformat);
+    static SDL_Rect **QT_ListModes(_THIS, SDL_PixelFormat * format,
+                                   Uint32 flags);
+    static SDL_Surface *QT_SetVideoMode(_THIS, SDL_Surface * current,
+                                        int width, int height, int bpp,
+                                        Uint32 flags);
+    static void QT_UpdateMouse(_THIS);
+    static int QT_SetColors(_THIS, int firstcolor, int ncolors,
+                            SDL_Color * colors);
+    static void QT_VideoQuit(_THIS);
 
     /* Hardware surface functions */
-    static int QT_AllocHWSurface (_THIS, SDL_Surface * surface);
-    static int QT_LockHWSurface (_THIS, SDL_Surface * surface);
-    static void QT_UnlockHWSurface (_THIS, SDL_Surface * surface);
-    static void QT_FreeHWSurface (_THIS, SDL_Surface * surface);
+    static int QT_AllocHWSurface(_THIS, SDL_Surface * surface);
+    static int QT_LockHWSurface(_THIS, SDL_Surface * surface);
+    static void QT_UnlockHWSurface(_THIS, SDL_Surface * surface);
+    static void QT_FreeHWSurface(_THIS, SDL_Surface * surface);
 
-    static int QT_ToggleFullScreen (_THIS, int fullscreen);
+    static int QT_ToggleFullScreen(_THIS, int fullscreen);
 
-    static int QT_IconifyWindow (_THIS);
-    static SDL_GrabMode QT_GrabInput (_THIS, SDL_GrabMode mode);
+    static int QT_IconifyWindow(_THIS);
+    static SDL_GrabMode QT_GrabInput(_THIS, SDL_GrabMode mode);
 
     /* FB driver bootstrap functions */
 
-    static int QT_Available (void)
+    static int QT_Available(void)
     {
         return (1);
     }
 
-    static void QT_DeleteDevice (SDL_VideoDevice * device)
+    static void QT_DeleteDevice(SDL_VideoDevice * device)
     {
-        SDL_free (device->hidden);
-        SDL_free (device);
+        SDL_free(device->hidden);
+        SDL_free(device);
     }
 
-    static SDL_VideoDevice *QT_CreateDevice (int devindex)
+    static SDL_VideoDevice *QT_CreateDevice(int devindex)
     {
         SDL_VideoDevice *device;
 
         /* Initialize all variables that we clean on shutdown */
-        device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice));
+        device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
         if (device) {
-            SDL_memset (device, 0, (sizeof *device));
+            SDL_memset(device, 0, (sizeof *device));
             device->hidden = (struct SDL_PrivateVideoData *)
-                SDL_malloc ((sizeof *device->hidden));
+                SDL_malloc((sizeof *device->hidden));
         }
         if ((device == NULL) || (device->hidden == NULL)) {
-            SDL_OutOfMemory ();
+            SDL_OutOfMemory();
             if (device) {
-                SDL_free (device);
+                SDL_free(device);
             }
             return (0);
         }
-        SDL_memset (device->hidden, 0, (sizeof *device->hidden));
+        SDL_memset(device->hidden, 0, (sizeof *device->hidden));
 
         /* Set the function pointers */
         device->VideoInit = QT_VideoInit;
@@ -151,7 +151,7 @@
     };
 
     /* Function to sort the display_list */
-    static int CompareModes (const void *A, const void *B)
+    static int CompareModes(const void *A, const void *B)
     {
 #if 0
         const display_mode *a = (display_mode *) A;
@@ -161,15 +161,15 @@
             return ((b->virtual_width * b->virtual_height) -
                     (a->virtual_width * a->virtual_height));
         } else {
-            return (ColorSpaceToBitsPerPixel (b->space) -
-                    ColorSpaceToBitsPerPixel (a->space));
+            return (ColorSpaceToBitsPerPixel(b->space) -
+                    ColorSpaceToBitsPerPixel(a->space));
         }
 #endif
         return 0;
     }
 
     /* Yes, this isn't the fastest it could be, but it works nicely */
-    static int QT_AddMode (_THIS, int index, unsigned int w, unsigned int h)
+    static int QT_AddMode(_THIS, int index, unsigned int w, unsigned int h)
     {
         SDL_Rect *mode;
         int i;
@@ -186,9 +186,9 @@
         }
 
         /* Set up the new video mode rectangle */
-        mode = (SDL_Rect *) SDL_malloc (sizeof *mode);
+        mode = (SDL_Rect *) SDL_malloc(sizeof *mode);
         if (mode == NULL) {
-            SDL_OutOfMemory ();
+            SDL_OutOfMemory();
             return (-1);
         }
         mode->x = 0;
@@ -196,19 +196,19 @@
         mode->w = w;
         mode->h = h;
 #ifdef QTOPIA_DEBUG
-        fprintf (stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h,
-                 index + 1);
+        fprintf(stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h,
+                index + 1);
 #endif
 
         /* Allocate the new list of modes, and fill in the new mode */
         next_mode = SDL_nummodes[index];
         SDL_modelist[index] = (SDL_Rect **)
-            SDL_realloc (SDL_modelist[index],
-                         (1 + next_mode + 1) * sizeof (SDL_Rect *));
+            SDL_realloc(SDL_modelist[index],
+                        (1 + next_mode + 1) * sizeof(SDL_Rect *));
         if (SDL_modelist[index] == NULL) {
-            SDL_OutOfMemory ();
+            SDL_OutOfMemory();
             SDL_nummodes[index] = 0;
-            SDL_free (mode);
+            SDL_free(mode);
             return (-1);
         }
         SDL_modelist[index][next_mode] = mode;
@@ -218,28 +218,28 @@
         return (0);
     }
 
-    int QT_VideoInit (_THIS, SDL_PixelFormat * vformat)
+    int QT_VideoInit(_THIS, SDL_PixelFormat * vformat)
     {
         /* Initialize the QPE Application  */
         /* Determine the screen depth */
-        vformat->BitsPerPixel = QPixmap::defaultDepth ();
+        vformat->BitsPerPixel = QPixmap::defaultDepth();
 
         // For now we hardcode the current depth because anything else
         // might as well be emulated by SDL rather than by Qtopia.
 
-        QSize desktop_size = qApp->desktop ()->size ();
-        QT_AddMode (_this, ((vformat->BitsPerPixel + 7) / 8) - 1,
-                    desktop_size.width (), desktop_size.height ());
-        QT_AddMode (_this, ((vformat->BitsPerPixel + 7) / 8) - 1,
-                    desktop_size.height (), desktop_size.width ());
+        QSize desktop_size = qApp->desktop()->size();
+        QT_AddMode(_this, ((vformat->BitsPerPixel + 7) / 8) - 1,
+                   desktop_size.width(), desktop_size.height());
+        QT_AddMode(_this, ((vformat->BitsPerPixel + 7) / 8) - 1,
+                   desktop_size.height(), desktop_size.width());
 
         /* Determine the current screen size */
-        this->info.current_w = desktop_size.width ();
-        this->info.current_h = desktop_size.height ();
+        this->info.current_w = desktop_size.width();
+        this->info.current_h = desktop_size.height();
 
         /* Create the window / widget */
-        SDL_Win = new SDL_QWin (QSize (QT_HIDDEN_SIZE, QT_HIDDEN_SIZE));
-        ((QPEApplication *) qApp)->showMainWidget (SDL_Win);
+        SDL_Win = new SDL_QWin(QSize(QT_HIDDEN_SIZE, QT_HIDDEN_SIZE));
+        ((QPEApplication *) qApp)->showMainWidget(SDL_Win);
         /* Fill in some window manager capabilities */
         _this->info.wm_available = 0;
 
@@ -248,7 +248,7 @@
     }
 
     /* We support any dimension at our bit-depth */
-    SDL_Rect **QT_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags)
+    SDL_Rect **QT_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
     {
         SDL_Rect **modes;
 
@@ -264,120 +264,119 @@
     }
 
     /* Various screen update functions available */
-    static void QT_NormalUpdate (_THIS, int numrects, SDL_Rect * rects);
+    static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect * rects);
 
 
-    static int QT_SetFullScreen (_THIS, SDL_Surface * screen, int fullscreen)
+    static int QT_SetFullScreen(_THIS, SDL_Surface * screen, int fullscreen)
     {
         return -1;
     }
 
-    static int QT_ToggleFullScreen (_THIS, int fullscreen)
+    static int QT_ToggleFullScreen(_THIS, int fullscreen)
     {
         return -1;
     }
 
     /* FIXME: check return values and cleanup here */
-    SDL_Surface *QT_SetVideoMode (_THIS, SDL_Surface * current,
-                                  int width, int height, int bpp,
-                                  Uint32 flags)
+    SDL_Surface *QT_SetVideoMode(_THIS, SDL_Surface * current,
+                                 int width, int height, int bpp, Uint32 flags)
     {
 
         QImage *qimage;
-        QSize desktop_size = qApp->desktop ()->size ();
+        QSize desktop_size = qApp->desktop()->size();
 
 
         current->flags = 0;     //SDL_FULLSCREEN; // We always run fullscreen.
 
-        if (width <= desktop_size.width ()
-            && height <= desktop_size.height ()) {
-            current->w = desktop_size.width ();
-            current->h = desktop_size.height ();
-        } else if (width <= desktop_size.height ()
-                   && height <= desktop_size.width ()) {
+        if (width <= desktop_size.width()
+            && height <= desktop_size.height()) {
+            current->w = desktop_size.width();
+            current->h = desktop_size.height();
+        } else if (width <= desktop_size.height()
+                   && height <= desktop_size.width()) {
             // Landscape mode
-            char *envString = SDL_getenv (SDL_QT_ROTATION_ENV_NAME);
-            int envValue = envString ? atoi (envString) : 0;
+            char *envString = SDL_getenv(SDL_QT_ROTATION_ENV_NAME);
+            int envValue = envString ? atoi(envString) : 0;
             screenRotation =
                 envValue ? SDL_QT_ROTATION_270 : SDL_QT_ROTATION_90;
-            current->h = desktop_size.width ();
-            current->w = desktop_size.height ();
+            current->h = desktop_size.width();
+            current->w = desktop_size.height();
         } else {
-            SDL_SetError ("Unsupported resolution, %dx%d\n", width, height);
+            SDL_SetError("Unsupported resolution, %dx%d\n", width, height);
         }
         if (flags & SDL_INTERNALOPENGL) {
-            SDL_SetError ("OpenGL not supported");
+            SDL_SetError("OpenGL not supported");
             return (NULL);
         }
         /* Create the QImage framebuffer */
-        qimage = new QImage (current->w, current->h, bpp);
-        if (qimage->isNull ()) {
-            SDL_SetError ("Couldn't create screen bitmap");
+        qimage = new QImage(current->w, current->h, bpp);
+        if (qimage->isNull()) {
+            SDL_SetError("Couldn't create screen bitmap");
             delete qimage;
             return (NULL);
         }
-        current->pitch = qimage->bytesPerLine ();
-        current->pixels = (void *) qimage->bits ();
-        SDL_Win->setImage (qimage);
+        current->pitch = qimage->bytesPerLine();
+        current->pixels = (void *) qimage->bits();
+        SDL_Win->setImage(qimage);
         _this->UpdateRects = QT_NormalUpdate;
-        SDL_Win->setFullscreen (true);
+        SDL_Win->setFullscreen(true);
         /* We're done */
         return (current);
     }
 
     /* Update the current mouse state and position */
-    void QT_UpdateMouse (_THIS)
+    void QT_UpdateMouse(_THIS)
     {
-        QPoint point (-1, -1);
-        if (SDL_Win->isActiveWindow ()) {
-            point = SDL_Win->mousePos ();
+        QPoint point(-1, -1);
+        if (SDL_Win->isActiveWindow()) {
+            point = SDL_Win->mousePos();
         }
 
-        if ((point.x () >= 0) && (point.x () < SDL_VideoSurface->w) &&
-            (point.y () >= 0) && (point.y () < SDL_VideoSurface->h)) {
-            SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
-            SDL_PrivateMouseMotion (0, 0,
-                                    (Sint16) point.x (), (Sint16) point.y ());
+        if ((point.x() >= 0) && (point.x() < SDL_VideoSurface->w) &&
+            (point.y() >= 0) && (point.y() < SDL_VideoSurface->h)) {
+            SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
+            SDL_PrivateMouseMotion(0, 0,
+                                   (Sint16) point.x(), (Sint16) point.y());
         } else {
-            SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS);
+            SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
         }
     }
 
     /* We don't actually allow hardware surfaces other than the main one */
-    static int QT_AllocHWSurface (_THIS, SDL_Surface * surface)
+    static int QT_AllocHWSurface(_THIS, SDL_Surface * surface)
     {
         return (-1);
     }
-    static void QT_FreeHWSurface (_THIS, SDL_Surface * surface)
+    static void QT_FreeHWSurface(_THIS, SDL_Surface * surface)
     {
         return;
     }
-    static int QT_LockHWSurface (_THIS, SDL_Surface * surface)
+    static int QT_LockHWSurface(_THIS, SDL_Surface * surface)
     {
         return (0);
     }
-    static void QT_UnlockHWSurface (_THIS, SDL_Surface * surface)
+    static void QT_UnlockHWSurface(_THIS, SDL_Surface * surface)
     {
         return;
     }
 
-    static void QT_NormalUpdate (_THIS, int numrects, SDL_Rect * rects)
+    static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect * rects)
     {
-        if (SDL_Win->lockScreen ()) {
+        if (SDL_Win->lockScreen()) {
             for (int i = 0; i < numrects; ++i) {
-                QRect rect (rects[i].x, rects[i].y, rects[i].w, rects[i].h);
-                SDL_Win->repaintRect (rect);
+                QRect rect(rects[i].x, rects[i].y, rects[i].w, rects[i].h);
+                SDL_Win->repaintRect(rect);
             }
-            SDL_Win->unlockScreen ();
+            SDL_Win->unlockScreen();
         }
     }
     /* Is the system palette settable? */
-    int QT_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors)
+    int QT_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
     {
         return -1;
     }
 
-    void QT_VideoQuit (_THIS)
+    void QT_VideoQuit(_THIS)
     {
         // This is dumb, but if I free this, the app doesn't exit correctly.
         // Of course, this will leak memory if init video is done more than once.
@@ -387,26 +386,26 @@
         //    delete SDL_Win; 
         //    SDL_Win = 0;
         _this->screen->pixels = NULL;
-        QT_GrabInput (_this, SDL_GRAB_OFF);
+        QT_GrabInput(_this, SDL_GRAB_OFF);
     }
 
-    static int QT_IconifyWindow (_THIS)
+    static int QT_IconifyWindow(_THIS)
     {
-        SDL_Win->hide ();
+        SDL_Win->hide();
 
         return true;
     }
 
-    static SDL_GrabMode QT_GrabInput (_THIS, SDL_GrabMode mode)
+    static SDL_GrabMode QT_GrabInput(_THIS, SDL_GrabMode mode)
     {
         if (mode == SDL_GRAB_OFF) {
-            QPEApplication::grabKeyboard ();
-            qApp->processEvents ();
-            QPEApplication::ungrabKeyboard ();
+            QPEApplication::grabKeyboard();
+            qApp->processEvents();
+            QPEApplication::ungrabKeyboard();
         } else {
-            QPEApplication::grabKeyboard ();
+            QPEApplication::grabKeyboard();
         }
-        qApp->processEvents ();
+        qApp->processEvents();
         return mode;
     }