src/video/qtopia/SDL_QWin.cc
branchSDL-1.3
changeset 1662 782fd950bd46
parent 1403 376665398b25
child 1663 11775724e3fe
     1.1 --- a/src/video/qtopia/SDL_QWin.cc	Sun May 21 17:27:13 2006 +0000
     1.2 +++ b/src/video/qtopia/SDL_QWin.cc	Sun May 28 13:04:16 2006 +0000
     1.3 @@ -27,501 +27,683 @@
     1.4  
     1.5  screenRotationT screenRotation = SDL_QT_NO_ROTATION;
     1.6  
     1.7 -SDL_QWin::SDL_QWin(const QSize& size)
     1.8 -  : QWidget(0, "SDL_main"), my_painter(0), my_image(0),
     1.9 -    my_inhibit_resize(false), my_mouse_pos(-1,-1), my_flags(0),
    1.10 -    my_has_fullscreen(false), my_locked(0)
    1.11 +SDL_QWin::SDL_QWin (const QSize & size):
    1.12 +QWidget (0, "SDL_main"),
    1.13 +my_painter (0),
    1.14 +my_image (0),
    1.15 +my_inhibit_resize (false),
    1.16 +my_mouse_pos (-1, -1),
    1.17 +my_flags (0),
    1.18 +my_has_fullscreen (false),
    1.19 +my_locked (0)
    1.20  {
    1.21 -  setBackgroundMode(NoBackground);
    1.22 +    setBackgroundMode (NoBackground);
    1.23  }
    1.24  
    1.25 -SDL_QWin::~SDL_QWin() {
    1.26 -  // Nothing to do yet.
    1.27 -  if(my_image) {
    1.28 -    delete my_image;
    1.29 -  }
    1.30 +SDL_QWin::~SDL_QWin ()
    1.31 +{
    1.32 +    // Nothing to do yet.
    1.33 +    if (my_image) {
    1.34 +        delete my_image;
    1.35 +    }
    1.36  }
    1.37  
    1.38 -void SDL_QWin::setImage(QImage *image) {
    1.39 -  if ( my_image ) {
    1.40 -    delete my_image;
    1.41 -  }
    1.42 -  my_image = image;
    1.43 -  //  setFixedSize(image->size());
    1.44 +void
    1.45 +SDL_QWin::setImage (QImage * image)
    1.46 +{
    1.47 +    if (my_image) {
    1.48 +        delete my_image;
    1.49 +    }
    1.50 +    my_image = image;
    1.51 +    //  setFixedSize(image->size());
    1.52  }
    1.53  
    1.54 -void SDL_QWin::resizeEvent(QResizeEvent *e) {
    1.55 -  if(size() != qApp->desktop()->size()) {
    1.56 -    // Widget is not the correct size, so do the fullscreen magic
    1.57 -    my_has_fullscreen = false;
    1.58 -    enableFullscreen();
    1.59 -  }
    1.60 -  if(my_inhibit_resize) {
    1.61 -    my_inhibit_resize = false;
    1.62 -  } else {
    1.63 -    SDL_PrivateResize(e->size().width(), e->size().height());
    1.64 -  }
    1.65 +void
    1.66 +SDL_QWin::resizeEvent (QResizeEvent * e)
    1.67 +{
    1.68 +    if (size () != qApp->desktop ()->size ()) {
    1.69 +        // Widget is not the correct size, so do the fullscreen magic
    1.70 +        my_has_fullscreen = false;
    1.71 +        enableFullscreen ();
    1.72 +    }
    1.73 +    if (my_inhibit_resize) {
    1.74 +        my_inhibit_resize = false;
    1.75 +    } else {
    1.76 +        SDL_PrivateResize (e->size ().width (), e->size ().height ());
    1.77 +    }
    1.78  }
    1.79  
    1.80 -void SDL_QWin::focusInEvent(QFocusEvent *) {
    1.81 -  // Always do it here, no matter the size.
    1.82 -  enableFullscreen();
    1.83 -  SDL_PrivateAppActive(true, SDL_APPINPUTFOCUS);
    1.84 +void
    1.85 +SDL_QWin::focusInEvent (QFocusEvent *)
    1.86 +{
    1.87 +    // Always do it here, no matter the size.
    1.88 +    enableFullscreen ();
    1.89 +    SDL_PrivateAppActive (true, SDL_APPINPUTFOCUS);
    1.90  }
    1.91  
    1.92 -void SDL_QWin::focusOutEvent(QFocusEvent *) {
    1.93 -  my_has_fullscreen = false;
    1.94 -  SDL_PrivateAppActive(false, SDL_APPINPUTFOCUS);
    1.95 +void
    1.96 +SDL_QWin::focusOutEvent (QFocusEvent *)
    1.97 +{
    1.98 +    my_has_fullscreen = false;
    1.99 +    SDL_PrivateAppActive (false, SDL_APPINPUTFOCUS);
   1.100  }
   1.101  
   1.102 -void SDL_QWin::closeEvent(QCloseEvent *e) {
   1.103 -  SDL_PrivateQuit();
   1.104 -  e->ignore();
   1.105 +void
   1.106 +SDL_QWin::closeEvent (QCloseEvent * e)
   1.107 +{
   1.108 +    SDL_PrivateQuit ();
   1.109 +    e->ignore ();
   1.110  }
   1.111  
   1.112 -void SDL_QWin::setMousePos(const QPoint &pos) {
   1.113 -  if(my_image->width() == height()) {
   1.114 -    if (screenRotation == SDL_QT_ROTATION_90)
   1.115 -      my_mouse_pos = QPoint(height()-pos.y(), pos.x());
   1.116 -    else if (screenRotation == SDL_QT_ROTATION_270)
   1.117 -      my_mouse_pos = QPoint(pos.y(), width()-pos.x());
   1.118 -  } else {
   1.119 -    my_mouse_pos = pos;
   1.120 -  }
   1.121 +void
   1.122 +SDL_QWin::setMousePos (const QPoint & pos)
   1.123 +{
   1.124 +    if (my_image->width () == height ()) {
   1.125 +        if (screenRotation == SDL_QT_ROTATION_90)
   1.126 +            my_mouse_pos = QPoint (height () - pos.y (), pos.x ());
   1.127 +        else if (screenRotation == SDL_QT_ROTATION_270)
   1.128 +            my_mouse_pos = QPoint (pos.y (), width () - pos.x ());
   1.129 +    } else {
   1.130 +        my_mouse_pos = pos;
   1.131 +    }
   1.132  }
   1.133  
   1.134 -void SDL_QWin::mouseMoveEvent(QMouseEvent *e) {
   1.135 -  Qt::ButtonState button = e->button();
   1.136 -  int sdlstate = 0;
   1.137 -  if( (button & Qt::LeftButton)) {
   1.138 -    sdlstate |= SDL_BUTTON_LMASK;
   1.139 -  }
   1.140 -  if( (button & Qt::RightButton)) {
   1.141 -    sdlstate |= SDL_BUTTON_RMASK;
   1.142 -  }
   1.143 -  if( (button & Qt::MidButton)) {
   1.144 -    sdlstate |= SDL_BUTTON_MMASK;
   1.145 -  }
   1.146 -  setMousePos(e->pos());
   1.147 -  SDL_PrivateMouseMotion(sdlstate, 0, my_mouse_pos.x(), my_mouse_pos.y());
   1.148 +void
   1.149 +SDL_QWin::mouseMoveEvent (QMouseEvent * e)
   1.150 +{
   1.151 +    Qt::ButtonState button = e->button ();
   1.152 +    int sdlstate = 0;
   1.153 +    if ((button & Qt::LeftButton)) {
   1.154 +        sdlstate |= SDL_BUTTON_LMASK;
   1.155 +    }
   1.156 +    if ((button & Qt::RightButton)) {
   1.157 +        sdlstate |= SDL_BUTTON_RMASK;
   1.158 +    }
   1.159 +    if ((button & Qt::MidButton)) {
   1.160 +        sdlstate |= SDL_BUTTON_MMASK;
   1.161 +    }
   1.162 +    setMousePos (e->pos ());
   1.163 +    SDL_PrivateMouseMotion (sdlstate, 0, my_mouse_pos.x (),
   1.164 +                            my_mouse_pos.y ());
   1.165  }
   1.166  
   1.167 -void SDL_QWin::mousePressEvent(QMouseEvent *e) {
   1.168 -  mouseMoveEvent(e);
   1.169 -  Qt::ButtonState button = e->button();
   1.170 -  SDL_PrivateMouseButton(SDL_PRESSED,
   1.171 -			 (button & Qt::LeftButton) ? 1 :
   1.172 -			 ((button & Qt::RightButton) ? 2 : 3),
   1.173 -			 my_mouse_pos.x(), my_mouse_pos.y());
   1.174 +void
   1.175 +SDL_QWin::mousePressEvent (QMouseEvent * e)
   1.176 +{
   1.177 +    mouseMoveEvent (e);
   1.178 +    Qt::ButtonState button = e->button ();
   1.179 +    SDL_PrivateMouseButton (SDL_PRESSED,
   1.180 +                            (button & Qt::LeftButton) ? 1 :
   1.181 +                            ((button & Qt::RightButton) ? 2 : 3),
   1.182 +                            my_mouse_pos.x (), my_mouse_pos.y ());
   1.183  }
   1.184  
   1.185 -void SDL_QWin::mouseReleaseEvent(QMouseEvent *e) {
   1.186 -  setMousePos(e->pos());
   1.187 -  Qt::ButtonState button = e->button();
   1.188 -  SDL_PrivateMouseButton(SDL_RELEASED,
   1.189 -			 (button & Qt::LeftButton) ? 1 :
   1.190 -			 ((button & Qt::RightButton) ? 2 : 3),
   1.191 -			 my_mouse_pos.x(), my_mouse_pos.y());
   1.192 -  my_mouse_pos = QPoint(-1, -1);
   1.193 +void
   1.194 +SDL_QWin::mouseReleaseEvent (QMouseEvent * e)
   1.195 +{
   1.196 +    setMousePos (e->pos ());
   1.197 +    Qt::ButtonState button = e->button ();
   1.198 +    SDL_PrivateMouseButton (SDL_RELEASED,
   1.199 +                            (button & Qt::LeftButton) ? 1 :
   1.200 +                            ((button & Qt::RightButton) ? 2 : 3),
   1.201 +                            my_mouse_pos.x (), my_mouse_pos.y ());
   1.202 +    my_mouse_pos = QPoint (-1, -1);
   1.203  }
   1.204  
   1.205  static inline void
   1.206 -gs_fastRotateBlit_3 ( unsigned short *fb,
   1.207 -		      unsigned short *bits,
   1.208 -		      const QRect& rect )
   1.209 +gs_fastRotateBlit_3 (unsigned short *fb,
   1.210 +                     unsigned short *bits, const QRect & rect)
   1.211  {
   1.212 -  // FIXME: this only works correctly for 240x320 displays
   1.213 -  int startx, starty;
   1.214 -  int width, height;
   1.215 -  
   1.216 -  startx = rect.left() >> 1;
   1.217 -  starty = rect.top() >> 1;
   1.218 -  width  = ((rect.right() - rect.left()) >> 1) + 2;
   1.219 -  height = ((rect.bottom() - rect.top()) >> 1) + 2;
   1.220 +    // FIXME: this only works correctly for 240x320 displays
   1.221 +    int startx, starty;
   1.222 +    int width, height;
   1.223  
   1.224 -  if((startx+width) > 120) {
   1.225 -    width = 120 - startx; // avoid horizontal overflow
   1.226 -  }
   1.227 -  if((starty+height) > 160) { 
   1.228 -    height = 160 - starty; // avoid vertical overflow
   1.229 -  }
   1.230 +    startx = rect.left () >> 1;
   1.231 +    starty = rect.top () >> 1;
   1.232 +    width = ((rect.right () - rect.left ()) >> 1) + 2;
   1.233 +    height = ((rect.bottom () - rect.top ()) >> 1) + 2;
   1.234  
   1.235 -  ulong *sp1, *sp2, *dp1, *dp2;
   1.236 -  ulong stop, sbot, dtop, dbot;    
   1.237 -  
   1.238 -  sp1 = (ulong*)bits + startx + starty*240;
   1.239 -  sp2 = sp1 + 120;
   1.240 -  dp1 = (ulong *)fb + (159 - starty) + startx*320;
   1.241 -  dp2 = dp1 + 160;
   1.242 -  int rowadd = (-320*width) - 1;
   1.243 -  int rowadd2 = 240 - width;
   1.244 -  // transfer in cells of 2x2 pixels in words
   1.245 -  for (int y=0; y<height; y++) {
   1.246 -    for (int x=0; x<width; x++) {
   1.247 -      // read source pixels
   1.248 -      stop = *sp1;
   1.249 -      sbot = *sp2;
   1.250 -      // rotate pixels
   1.251 -      dtop = (sbot & 0xffff) + ((stop & 0xffff)<<16);
   1.252 -      dbot = ((sbot & 0xffff0000)>>16) + (stop & 0xffff0000);
   1.253 -      // write to framebuffer
   1.254 -      *dp1 = dtop;
   1.255 -      *dp2 = dbot;
   1.256 -      // update source ptrs
   1.257 -      sp1++; sp2++;
   1.258 -      // update dest ptrs - 2 pix at a time
   1.259 -      dp1 += 320;
   1.260 -      dp2 += 320;
   1.261 +    if ((startx + width) > 120) {
   1.262 +        width = 120 - startx;   // avoid horizontal overflow
   1.263      }
   1.264 -    // adjust src ptrs - skip a row as we work in pairs
   1.265 -    sp1 += rowadd2;
   1.266 -    sp2 += rowadd2;
   1.267 -    // adjust dest ptrs for rotation
   1.268 -    dp1 += rowadd;
   1.269 -    dp2 += rowadd;
   1.270 -  }
   1.271 +    if ((starty + height) > 160) {
   1.272 +        height = 160 - starty;  // avoid vertical overflow
   1.273 +    }
   1.274 +
   1.275 +    ulong *sp1, *sp2, *dp1, *dp2;
   1.276 +    ulong stop, sbot, dtop, dbot;
   1.277 +
   1.278 +    sp1 = (ulong *) bits + startx + starty * 240;
   1.279 +    sp2 = sp1 + 120;
   1.280 +    dp1 = (ulong *) fb + (159 - starty) + startx * 320;
   1.281 +    dp2 = dp1 + 160;
   1.282 +    int rowadd = (-320 * width) - 1;
   1.283 +    int rowadd2 = 240 - width;
   1.284 +    // transfer in cells of 2x2 pixels in words
   1.285 +    for (int y = 0; y < height; y++) {
   1.286 +        for (int x = 0; x < width; x++) {
   1.287 +            // read source pixels
   1.288 +            stop = *sp1;
   1.289 +            sbot = *sp2;
   1.290 +            // rotate pixels
   1.291 +            dtop = (sbot & 0xffff) + ((stop & 0xffff) << 16);
   1.292 +            dbot = ((sbot & 0xffff0000) >> 16) + (stop & 0xffff0000);
   1.293 +            // write to framebuffer
   1.294 +            *dp1 = dtop;
   1.295 +            *dp2 = dbot;
   1.296 +            // update source ptrs
   1.297 +            sp1++;
   1.298 +            sp2++;
   1.299 +            // update dest ptrs - 2 pix at a time
   1.300 +            dp1 += 320;
   1.301 +            dp2 += 320;
   1.302 +        }
   1.303 +        // adjust src ptrs - skip a row as we work in pairs
   1.304 +        sp1 += rowadd2;
   1.305 +        sp2 += rowadd2;
   1.306 +        // adjust dest ptrs for rotation
   1.307 +        dp1 += rowadd;
   1.308 +        dp2 += rowadd;
   1.309 +    }
   1.310  }
   1.311  
   1.312  static inline void
   1.313 -gs_fastRotateBlit_1 ( unsigned short *fb,
   1.314 -		      unsigned short *bits,
   1.315 -		      const QRect& rect ) {
   1.316 -  // FIXME: this only works correctly for 240x320 displays
   1.317 -  int startx, starty;
   1.318 -  int width, height;
   1.319 +gs_fastRotateBlit_1 (unsigned short *fb,
   1.320 +                     unsigned short *bits, const QRect & rect)
   1.321 +{
   1.322 +    // FIXME: this only works correctly for 240x320 displays
   1.323 +    int startx, starty;
   1.324 +    int width, height;
   1.325  
   1.326 -  startx = rect.left() >> 1;
   1.327 -  starty = rect.top() >> 1;
   1.328 -  width  = ((rect.right() - rect.left()) >> 1) + 2;
   1.329 -  height = ((rect.bottom() - rect.top()) >> 1) + 2;
   1.330 +    startx = rect.left () >> 1;
   1.331 +    starty = rect.top () >> 1;
   1.332 +    width = ((rect.right () - rect.left ()) >> 1) + 2;
   1.333 +    height = ((rect.bottom () - rect.top ()) >> 1) + 2;
   1.334  
   1.335 -  if((startx+width) > 120) {
   1.336 -    width = 120 - startx; // avoid horizontal overflow
   1.337 -  }
   1.338 -  if((starty+height) > 160) { 
   1.339 -    height = 160 - starty; // avoid vertical overflow
   1.340 -  }
   1.341 +    if ((startx + width) > 120) {
   1.342 +        width = 120 - startx;   // avoid horizontal overflow
   1.343 +    }
   1.344 +    if ((starty + height) > 160) {
   1.345 +        height = 160 - starty;  // avoid vertical overflow
   1.346 +    }
   1.347  
   1.348 -  ulong *sp1, *sp2, *dp1, *dp2;
   1.349 -  ulong stop, sbot, dtop, dbot;    
   1.350 -  fb += 320*239; // Move "fb" to top left corner
   1.351 -  sp1 = (ulong*)bits + startx + starty*240;
   1.352 -  sp2 = sp1 + 120;
   1.353 -  dp1 = (ulong*)fb - startx * 320 - starty;
   1.354 -  dp2 = dp1 - 160;
   1.355 -  int rowadd = (320*width) + 1;
   1.356 -  int rowadd2 = 240 - width;
   1.357 -  // transfer in cells of 2x2 pixels in words
   1.358 -  for (int y=0; y<height; y++) {
   1.359 -    for (int x=0; x<width; x++) {
   1.360 -      // read
   1.361 -      stop = *sp1;
   1.362 -      sbot = *sp2;
   1.363 -      // rotate
   1.364 -      dtop = (stop & 0xffff) + ((sbot & 0xffff)<<16);
   1.365 -      dbot = ((stop & 0xffff0000)>>16) + (sbot & 0xffff0000);
   1.366 -      // write
   1.367 -      *dp1 = dtop;
   1.368 -      *dp2 = dbot;
   1.369 -      // update source ptrs
   1.370 -      sp1++; sp2++;
   1.371 -      // update dest ptrs - 2 pix at a time
   1.372 -      dp1 -= 320;
   1.373 -      dp2 -= 320;
   1.374 +    ulong *sp1, *sp2, *dp1, *dp2;
   1.375 +    ulong stop, sbot, dtop, dbot;
   1.376 +    fb += 320 * 239;            // Move "fb" to top left corner
   1.377 +    sp1 = (ulong *) bits + startx + starty * 240;
   1.378 +    sp2 = sp1 + 120;
   1.379 +    dp1 = (ulong *) fb - startx * 320 - starty;
   1.380 +    dp2 = dp1 - 160;
   1.381 +    int rowadd = (320 * width) + 1;
   1.382 +    int rowadd2 = 240 - width;
   1.383 +    // transfer in cells of 2x2 pixels in words
   1.384 +    for (int y = 0; y < height; y++) {
   1.385 +        for (int x = 0; x < width; x++) {
   1.386 +            // read
   1.387 +            stop = *sp1;
   1.388 +            sbot = *sp2;
   1.389 +            // rotate
   1.390 +            dtop = (stop & 0xffff) + ((sbot & 0xffff) << 16);
   1.391 +            dbot = ((stop & 0xffff0000) >> 16) + (sbot & 0xffff0000);
   1.392 +            // write
   1.393 +            *dp1 = dtop;
   1.394 +            *dp2 = dbot;
   1.395 +            // update source ptrs
   1.396 +            sp1++;
   1.397 +            sp2++;
   1.398 +            // update dest ptrs - 2 pix at a time
   1.399 +            dp1 -= 320;
   1.400 +            dp2 -= 320;
   1.401 +        }
   1.402 +        // adjust src ptrs - skip a row as we work in pairs
   1.403 +        sp1 += rowadd2;
   1.404 +        sp2 += rowadd2;
   1.405 +        // adjust dest ptrs for rotation
   1.406 +        dp1 += rowadd;
   1.407 +        dp2 += rowadd;
   1.408      }
   1.409 -    // adjust src ptrs - skip a row as we work in pairs
   1.410 -    sp1 += rowadd2;
   1.411 -    sp2 += rowadd2;
   1.412 -    // adjust dest ptrs for rotation
   1.413 -    dp1 += rowadd;
   1.414 -    dp2 += rowadd;
   1.415 -  }
   1.416  }
   1.417  
   1.418  // desktop, SL-A300 etc
   1.419 -bool SDL_QWin::repaintRotation0(const QRect& rect) {
   1.420 -  if(my_image->width() == width()) {
   1.421 -    uchar *fb = (uchar*)my_painter->frameBuffer();
   1.422 -    uchar *buf = (uchar*)my_image->bits();
   1.423 -    if(rect == my_image->rect()) {
   1.424 -      SDL_memcpy(fb, buf, width()*height()*2);
   1.425 +bool SDL_QWin::repaintRotation0 (const QRect & rect)
   1.426 +{
   1.427 +    if (my_image->width () == width ()) {
   1.428 +        uchar *
   1.429 +            fb = (uchar *) my_painter->frameBuffer ();
   1.430 +        uchar *
   1.431 +            buf = (uchar *) my_image->bits ();
   1.432 +        if (rect == my_image->rect ()) {
   1.433 +            SDL_memcpy (fb, buf, width () * height () * 2);
   1.434 +        } else {
   1.435 +            int
   1.436 +                h = rect.height ();
   1.437 +            int
   1.438 +                wd = rect.width () << 1;
   1.439 +            int
   1.440 +                fblineadd = my_painter->lineStep ();
   1.441 +            int
   1.442 +                buflineadd = my_image->bytesPerLine ();
   1.443 +            fb += (rect.left () << 1) + rect.top () * my_painter->lineStep ();
   1.444 +            buf +=
   1.445 +                (rect.left () << 1) + rect.top () * my_image->bytesPerLine ();
   1.446 +            while (h--) {
   1.447 +                SDL_memcpy (fb, buf, wd);
   1.448 +                fb += fblineadd;
   1.449 +                buf += buflineadd;
   1.450 +            }
   1.451 +        }
   1.452      } else {
   1.453 -      int h = rect.height();
   1.454 -      int wd = rect.width()<<1;
   1.455 -      int fblineadd = my_painter->lineStep();
   1.456 -      int buflineadd = my_image->bytesPerLine();
   1.457 -      fb  += (rect.left()<<1) + rect.top() * my_painter->lineStep();
   1.458 -      buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine();
   1.459 -      while(h--) {
   1.460 -	SDL_memcpy(fb, buf, wd);
   1.461 -	fb += fblineadd;
   1.462 -	buf += buflineadd;
   1.463 -      }
   1.464 +        return false;           // FIXME: Landscape
   1.465      }
   1.466 -  } else {
   1.467 -    return false; // FIXME: Landscape
   1.468 -  }
   1.469  #ifdef __i386__
   1.470 -  my_painter->fillRect( rect, QBrush( Qt::NoBrush ) );
   1.471 +    my_painter->fillRect (rect, QBrush (Qt::NoBrush));
   1.472  #endif
   1.473 -  return true;
   1.474 +    return true;
   1.475  }
   1.476  
   1.477 -  
   1.478 +
   1.479  // Sharp Zaurus SL-5500 etc 
   1.480 -bool SDL_QWin::repaintRotation3(const QRect& rect) {
   1.481 -  if(my_image->width() == width()) {
   1.482 -    ushort *fb = (ushort*)my_painter->frameBuffer();
   1.483 -    ushort *buf = (ushort*)my_image->bits();
   1.484 -    gs_fastRotateBlit_3(fb, buf, rect);
   1.485 -  } else {
   1.486 -    // landscape mode
   1.487 -    if (screenRotation == SDL_QT_ROTATION_90) {
   1.488 -      uchar *fb = (uchar*)my_painter->frameBuffer();
   1.489 -      uchar *buf = (uchar*)my_image->bits();
   1.490 -      if(rect == my_image->rect()) {
   1.491 -	SDL_memcpy(fb, buf, width()*height()*2);
   1.492 -      } else {
   1.493 -	int h = rect.height();
   1.494 -	int wd = rect.width()<<1;
   1.495 -	int fblineadd = my_painter->lineStep();
   1.496 -	int buflineadd = my_image->bytesPerLine();
   1.497 -	fb  += (rect.left()<<1) + rect.top() * my_painter->lineStep();
   1.498 -	buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine();
   1.499 -	while(h--) {
   1.500 -	  SDL_memcpy(fb, buf, wd);
   1.501 -	  fb += fblineadd;
   1.502 -	  buf += buflineadd;
   1.503 -	}
   1.504 -      }
   1.505 -    } else if (screenRotation == SDL_QT_ROTATION_270) {
   1.506 -      int h = rect.height();
   1.507 -      int wd = rect.width();
   1.508 -      int fblineadd = my_painter->lineStep() - (rect.width() << 1);
   1.509 -      int buflineadd = my_image->bytesPerLine() - (rect.width() << 1);
   1.510 -      int w;
   1.511 +bool SDL_QWin::repaintRotation3 (const QRect & rect)
   1.512 +{
   1.513 +    if (my_image->width () == width ()) {
   1.514 +        ushort *
   1.515 +            fb = (ushort *) my_painter->frameBuffer ();
   1.516 +        ushort *
   1.517 +            buf = (ushort *) my_image->bits ();
   1.518 +        gs_fastRotateBlit_3 (fb, buf, rect);
   1.519 +    } else {
   1.520 +        // landscape mode
   1.521 +        if (screenRotation == SDL_QT_ROTATION_90) {
   1.522 +            uchar *
   1.523 +                fb = (uchar *) my_painter->frameBuffer ();
   1.524 +            uchar *
   1.525 +                buf = (uchar *) my_image->bits ();
   1.526 +            if (rect == my_image->rect ()) {
   1.527 +                SDL_memcpy (fb, buf, width () * height () * 2);
   1.528 +            } else {
   1.529 +                int
   1.530 +                    h = rect.height ();
   1.531 +                int
   1.532 +                    wd = rect.width () << 1;
   1.533 +                int
   1.534 +                    fblineadd = my_painter->lineStep ();
   1.535 +                int
   1.536 +                    buflineadd = my_image->bytesPerLine ();
   1.537 +                fb +=
   1.538 +                    (rect.left () << 1) +
   1.539 +                    rect.top () * my_painter->lineStep ();
   1.540 +                buf +=
   1.541 +                    (rect.left () << 1) +
   1.542 +                    rect.top () * my_image->bytesPerLine ();
   1.543 +                while (h--) {
   1.544 +                    SDL_memcpy (fb, buf, wd);
   1.545 +                    fb += fblineadd;
   1.546 +                    buf += buflineadd;
   1.547 +                }
   1.548 +            }
   1.549 +        } else if (screenRotation == SDL_QT_ROTATION_270) {
   1.550 +            int
   1.551 +                h = rect.height ();
   1.552 +            int
   1.553 +                wd = rect.width ();
   1.554 +            int
   1.555 +                fblineadd = my_painter->lineStep () - (rect.width () << 1);
   1.556 +            int
   1.557 +                buflineadd = my_image->bytesPerLine () - (rect.width () << 1);
   1.558 +            int
   1.559 +                w;
   1.560  
   1.561 -      uchar *fb = (uchar*)my_painter->frameBuffer();
   1.562 -      uchar *buf = (uchar*)my_image->bits();
   1.563 -        
   1.564 -      fb += ((my_painter->width() - (rect.top() + rect.height())) * 
   1.565 -	     my_painter->lineStep()) + ((my_painter->height() - ((rect.left() + 
   1.566 -								  rect.width()))) << 1);
   1.567 +            uchar *
   1.568 +                fb = (uchar *) my_painter->frameBuffer ();
   1.569 +            uchar *
   1.570 +                buf = (uchar *) my_image->bits ();
   1.571  
   1.572 -      buf += my_image->bytesPerLine() * (rect.top() + rect.height()) -
   1.573 -	(((my_image->width() - (rect.left() + rect.width())) << 1) + 2);
   1.574 +            fb +=
   1.575 +                ((my_painter->width () -
   1.576 +                  (rect.top () +
   1.577 +                   rect.height ())) * my_painter->lineStep ()) +
   1.578 +                ((my_painter->height () -
   1.579 +                  ((rect.left () + rect.width ()))) << 1);
   1.580  
   1.581 -      while(h--) {
   1.582 -	w = wd;
   1.583 -	while(w--) *((unsigned short*)fb)++ = *((unsigned short*)buf)--;
   1.584 -	fb += fblineadd;
   1.585 -	buf -= buflineadd;
   1.586 -      }
   1.587 +            buf +=
   1.588 +                my_image->bytesPerLine () * (rect.top () +
   1.589 +                                             rect.height ()) -
   1.590 +                (((my_image->width () -
   1.591 +                   (rect.left () + rect.width ())) << 1) + 2);
   1.592 +
   1.593 +            while (h--) {
   1.594 +                w = wd;
   1.595 +                while (w--)
   1.596 +                    *((unsigned short *) fb)++ = *((unsigned short *) buf)--;
   1.597 +                fb += fblineadd;
   1.598 +                buf -= buflineadd;
   1.599 +            }
   1.600 +        }
   1.601      }
   1.602 -  }
   1.603 -  return true;
   1.604 +    return true;
   1.605  }
   1.606  
   1.607  // ipaq 3800...
   1.608 -bool SDL_QWin::repaintRotation1(const QRect& rect) {
   1.609 -  if(my_image->width() == width()) {
   1.610 -    ushort *fb = (ushort*)my_painter->frameBuffer();
   1.611 -    ushort *buf = (ushort*)my_image->bits();
   1.612 -    gs_fastRotateBlit_1(fb, buf, rect);
   1.613 -  } else {
   1.614 -    return false; // FIXME: landscape mode
   1.615 -  }
   1.616 -  return true;
   1.617 +bool SDL_QWin::repaintRotation1 (const QRect & rect)
   1.618 +{
   1.619 +    if (my_image->width () == width ()) {
   1.620 +        ushort *
   1.621 +            fb = (ushort *) my_painter->frameBuffer ();
   1.622 +        ushort *
   1.623 +            buf = (ushort *) my_image->bits ();
   1.624 +        gs_fastRotateBlit_1 (fb, buf, rect);
   1.625 +    } else {
   1.626 +        return false;           // FIXME: landscape mode
   1.627 +    }
   1.628 +    return true;
   1.629  }
   1.630  
   1.631 -void SDL_QWin::repaintRect(const QRect& rect) {
   1.632 -  if(!my_painter || !rect.width() || !rect.height()) {
   1.633 -    return;
   1.634 -  }
   1.635 -  
   1.636 -  if(QPixmap::defaultDepth() == 16) {
   1.637 -    switch(my_painter->transformOrientation()) {
   1.638 -    case 3:
   1.639 -      if(repaintRotation3(rect)) { return;  }
   1.640 -      break;
   1.641 -    case 1:
   1.642 -      if(repaintRotation1(rect)) { return;  }
   1.643 -      break;
   1.644 -    case 0:
   1.645 -      if(repaintRotation0(rect)) { return;  }
   1.646 -      break;
   1.647 +void
   1.648 +SDL_QWin::repaintRect (const QRect & rect)
   1.649 +{
   1.650 +    if (!my_painter || !rect.width () || !rect.height ()) {
   1.651 +        return;
   1.652      }
   1.653 -  } 
   1.654 -  my_painter->drawImage(rect.topLeft(), *my_image, rect);
   1.655 +
   1.656 +    if (QPixmap::defaultDepth () == 16) {
   1.657 +        switch (my_painter->transformOrientation ()) {
   1.658 +        case 3:
   1.659 +            if (repaintRotation3 (rect)) {
   1.660 +                return;
   1.661 +            }
   1.662 +            break;
   1.663 +        case 1:
   1.664 +            if (repaintRotation1 (rect)) {
   1.665 +                return;
   1.666 +            }
   1.667 +            break;
   1.668 +        case 0:
   1.669 +            if (repaintRotation0 (rect)) {
   1.670 +                return;
   1.671 +            }
   1.672 +            break;
   1.673 +        }
   1.674 +    }
   1.675 +    my_painter->drawImage (rect.topLeft (), *my_image, rect);
   1.676  }
   1.677  
   1.678  // This paints the current buffer to the screen, when desired. 
   1.679 -void SDL_QWin::paintEvent(QPaintEvent *ev) {  
   1.680 -  if(my_image) {
   1.681 -    lockScreen(true);
   1.682 -    repaintRect(ev->rect());
   1.683 -    unlockScreen();
   1.684 -  }
   1.685 -}  
   1.686 +void
   1.687 +SDL_QWin::paintEvent (QPaintEvent * ev)
   1.688 +{
   1.689 +    if (my_image) {
   1.690 +        lockScreen (true);
   1.691 +        repaintRect (ev->rect ());
   1.692 +        unlockScreen ();
   1.693 +    }
   1.694 +}
   1.695  
   1.696  /* Function to translate a keyboard transition and queue the key event
   1.697   * This should probably be a table although this method isn't exactly
   1.698   * slow.
   1.699   */
   1.700 -void SDL_QWin::QueueKey(QKeyEvent *e, int pressed)
   1.701 -{  
   1.702 -  SDL_keysym keysym;
   1.703 -  int scancode = e->key();
   1.704 -  /* Set the keysym information */
   1.705 -  if(scancode >= 'A' && scancode <= 'Z') {
   1.706 -    // Qt sends uppercase, SDL wants lowercase
   1.707 -    keysym.sym = static_cast<SDLKey>(scancode + 32);
   1.708 -  } else if(scancode  >= 0x1000) {
   1.709 -    // Special keys
   1.710 -    switch(scancode) {
   1.711 -    case Qt::Key_Escape: scancode = SDLK_ESCAPE; break;
   1.712 -    case Qt::Key_Tab: scancode = SDLK_TAB; break;
   1.713 -    case Qt::Key_Backspace: scancode = SDLK_BACKSPACE; break;
   1.714 -    case Qt::Key_Return: scancode = SDLK_RETURN; break;
   1.715 -    case Qt::Key_Enter: scancode = SDLK_KP_ENTER; break;
   1.716 -    case Qt::Key_Insert: scancode = SDLK_INSERT; break;
   1.717 -    case Qt::Key_Delete: scancode = SDLK_DELETE; break;
   1.718 -    case Qt::Key_Pause: scancode = SDLK_PAUSE; break;
   1.719 -    case Qt::Key_Print: scancode = SDLK_PRINT; break;
   1.720 -    case Qt::Key_SysReq: scancode = SDLK_SYSREQ; break;
   1.721 -    case Qt::Key_Home: scancode = SDLK_HOME; break;
   1.722 -    case Qt::Key_End: scancode = SDLK_END; break;
   1.723 -    // We want the control keys to rotate with the screen
   1.724 -    case Qt::Key_Left: 
   1.725 -        if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_UP;
   1.726 -        else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_DOWN;
   1.727 -        else scancode = SDLK_LEFT;
   1.728 -        break;
   1.729 -    case Qt::Key_Up: 
   1.730 -        if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_RIGHT;
   1.731 -        else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_LEFT;
   1.732 -        else scancode = SDLK_UP;
   1.733 -        break;
   1.734 -    case Qt::Key_Right: 
   1.735 -        if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_DOWN;
   1.736 -        else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_UP;
   1.737 -        else scancode = SDLK_RIGHT;
   1.738 -        break;
   1.739 -    case Qt::Key_Down:
   1.740 -        if (screenRotation == SDL_QT_ROTATION_90) scancode = SDLK_LEFT;
   1.741 -        else if (screenRotation == SDL_QT_ROTATION_270) scancode = SDLK_RIGHT;
   1.742 -        else scancode = SDLK_DOWN;
   1.743 -        break;
   1.744 -    case Qt::Key_Prior: scancode = SDLK_PAGEUP; break;
   1.745 -    case Qt::Key_Next: scancode = SDLK_PAGEDOWN; break;
   1.746 -    case Qt::Key_Shift: scancode = SDLK_LSHIFT; break;
   1.747 -    case Qt::Key_Control: scancode = SDLK_LCTRL; break;
   1.748 -    case Qt::Key_Meta: scancode = SDLK_LMETA; break;
   1.749 -    case Qt::Key_Alt: scancode = SDLK_LALT; break;
   1.750 -    case Qt::Key_CapsLock: scancode = SDLK_CAPSLOCK; break;
   1.751 -    case Qt::Key_NumLock: scancode = SDLK_NUMLOCK; break;
   1.752 -    case Qt::Key_ScrollLock: scancode = SDLK_SCROLLOCK; break;
   1.753 -    case Qt::Key_F1: scancode = SDLK_F1; break;
   1.754 -    case Qt::Key_F2: scancode = SDLK_F2; break;
   1.755 -    case Qt::Key_F3: scancode = SDLK_F3; break;
   1.756 -    case Qt::Key_F4: scancode = SDLK_F4; break;
   1.757 -    case Qt::Key_F5: scancode = SDLK_F5; break;
   1.758 -    case Qt::Key_F6: scancode = SDLK_F6; break;
   1.759 -    case Qt::Key_F7: scancode = SDLK_F7; break;
   1.760 -    case Qt::Key_F8: scancode = SDLK_F8; break;
   1.761 -    case Qt::Key_F9: scancode = SDLK_F9; break;
   1.762 -    case Qt::Key_F10: scancode = SDLK_F10; break;
   1.763 -    case Qt::Key_F11: scancode = SDLK_F11; break;
   1.764 -    case Qt::Key_F12: scancode = SDLK_F12; break;
   1.765 -    case Qt::Key_F13: scancode = SDLK_F13; break;
   1.766 -    case Qt::Key_F14: scancode = SDLK_F14; break;
   1.767 -    case Qt::Key_F15: scancode = SDLK_F15; break;
   1.768 -    case Qt::Key_Super_L: scancode = SDLK_LSUPER; break;
   1.769 -    case Qt::Key_Super_R: scancode = SDLK_RSUPER; break;
   1.770 -    case Qt::Key_Menu: scancode = SDLK_MENU; break;
   1.771 -    case Qt::Key_Help: scancode = SDLK_HELP; break;
   1.772 +void
   1.773 +SDL_QWin::QueueKey (QKeyEvent * e, int pressed)
   1.774 +{
   1.775 +    SDL_keysym keysym;
   1.776 +    int scancode = e->key ();
   1.777 +    /* Set the keysym information */
   1.778 +    if (scancode >= 'A' && scancode <= 'Z') {
   1.779 +        // Qt sends uppercase, SDL wants lowercase
   1.780 +        keysym.sym = static_cast < SDLKey > (scancode + 32);
   1.781 +    } else if (scancode >= 0x1000) {
   1.782 +        // Special keys
   1.783 +        switch (scancode) {
   1.784 +        case Qt::Key_Escape:
   1.785 +            scancode = SDLK_ESCAPE;
   1.786 +            break;
   1.787 +        case Qt::Key_Tab:
   1.788 +            scancode = SDLK_TAB;
   1.789 +            break;
   1.790 +        case Qt::Key_Backspace:
   1.791 +            scancode = SDLK_BACKSPACE;
   1.792 +            break;
   1.793 +        case Qt::Key_Return:
   1.794 +            scancode = SDLK_RETURN;
   1.795 +            break;
   1.796 +        case Qt::Key_Enter:
   1.797 +            scancode = SDLK_KP_ENTER;
   1.798 +            break;
   1.799 +        case Qt::Key_Insert:
   1.800 +            scancode = SDLK_INSERT;
   1.801 +            break;
   1.802 +        case Qt::Key_Delete:
   1.803 +            scancode = SDLK_DELETE;
   1.804 +            break;
   1.805 +        case Qt::Key_Pause:
   1.806 +            scancode = SDLK_PAUSE;
   1.807 +            break;
   1.808 +        case Qt::Key_Print:
   1.809 +            scancode = SDLK_PRINT;
   1.810 +            break;
   1.811 +        case Qt::Key_SysReq:
   1.812 +            scancode = SDLK_SYSREQ;
   1.813 +            break;
   1.814 +        case Qt::Key_Home:
   1.815 +            scancode = SDLK_HOME;
   1.816 +            break;
   1.817 +        case Qt::Key_End:
   1.818 +            scancode = SDLK_END;
   1.819 +            break;
   1.820 +            // We want the control keys to rotate with the screen
   1.821 +        case Qt::Key_Left:
   1.822 +            if (screenRotation == SDL_QT_ROTATION_90)
   1.823 +                scancode = SDLK_UP;
   1.824 +            else if (screenRotation == SDL_QT_ROTATION_270)
   1.825 +                scancode = SDLK_DOWN;
   1.826 +            else
   1.827 +                scancode = SDLK_LEFT;
   1.828 +            break;
   1.829 +        case Qt::Key_Up:
   1.830 +            if (screenRotation == SDL_QT_ROTATION_90)
   1.831 +                scancode = SDLK_RIGHT;
   1.832 +            else if (screenRotation == SDL_QT_ROTATION_270)
   1.833 +                scancode = SDLK_LEFT;
   1.834 +            else
   1.835 +                scancode = SDLK_UP;
   1.836 +            break;
   1.837 +        case Qt::Key_Right:
   1.838 +            if (screenRotation == SDL_QT_ROTATION_90)
   1.839 +                scancode = SDLK_DOWN;
   1.840 +            else if (screenRotation == SDL_QT_ROTATION_270)
   1.841 +                scancode = SDLK_UP;
   1.842 +            else
   1.843 +                scancode = SDLK_RIGHT;
   1.844 +            break;
   1.845 +        case Qt::Key_Down:
   1.846 +            if (screenRotation == SDL_QT_ROTATION_90)
   1.847 +                scancode = SDLK_LEFT;
   1.848 +            else if (screenRotation == SDL_QT_ROTATION_270)
   1.849 +                scancode = SDLK_RIGHT;
   1.850 +            else
   1.851 +                scancode = SDLK_DOWN;
   1.852 +            break;
   1.853 +        case Qt::Key_Prior:
   1.854 +            scancode = SDLK_PAGEUP;
   1.855 +            break;
   1.856 +        case Qt::Key_Next:
   1.857 +            scancode = SDLK_PAGEDOWN;
   1.858 +            break;
   1.859 +        case Qt::Key_Shift:
   1.860 +            scancode = SDLK_LSHIFT;
   1.861 +            break;
   1.862 +        case Qt::Key_Control:
   1.863 +            scancode = SDLK_LCTRL;
   1.864 +            break;
   1.865 +        case Qt::Key_Meta:
   1.866 +            scancode = SDLK_LMETA;
   1.867 +            break;
   1.868 +        case Qt::Key_Alt:
   1.869 +            scancode = SDLK_LALT;
   1.870 +            break;
   1.871 +        case Qt::Key_CapsLock:
   1.872 +            scancode = SDLK_CAPSLOCK;
   1.873 +            break;
   1.874 +        case Qt::Key_NumLock:
   1.875 +            scancode = SDLK_NUMLOCK;
   1.876 +            break;
   1.877 +        case Qt::Key_ScrollLock:
   1.878 +            scancode = SDLK_SCROLLOCK;
   1.879 +            break;
   1.880 +        case Qt::Key_F1:
   1.881 +            scancode = SDLK_F1;
   1.882 +            break;
   1.883 +        case Qt::Key_F2:
   1.884 +            scancode = SDLK_F2;
   1.885 +            break;
   1.886 +        case Qt::Key_F3:
   1.887 +            scancode = SDLK_F3;
   1.888 +            break;
   1.889 +        case Qt::Key_F4:
   1.890 +            scancode = SDLK_F4;
   1.891 +            break;
   1.892 +        case Qt::Key_F5:
   1.893 +            scancode = SDLK_F5;
   1.894 +            break;
   1.895 +        case Qt::Key_F6:
   1.896 +            scancode = SDLK_F6;
   1.897 +            break;
   1.898 +        case Qt::Key_F7:
   1.899 +            scancode = SDLK_F7;
   1.900 +            break;
   1.901 +        case Qt::Key_F8:
   1.902 +            scancode = SDLK_F8;
   1.903 +            break;
   1.904 +        case Qt::Key_F9:
   1.905 +            scancode = SDLK_F9;
   1.906 +            break;
   1.907 +        case Qt::Key_F10:
   1.908 +            scancode = SDLK_F10;
   1.909 +            break;
   1.910 +        case Qt::Key_F11:
   1.911 +            scancode = SDLK_F11;
   1.912 +            break;
   1.913 +        case Qt::Key_F12:
   1.914 +            scancode = SDLK_F12;
   1.915 +            break;
   1.916 +        case Qt::Key_F13:
   1.917 +            scancode = SDLK_F13;
   1.918 +            break;
   1.919 +        case Qt::Key_F14:
   1.920 +            scancode = SDLK_F14;
   1.921 +            break;
   1.922 +        case Qt::Key_F15:
   1.923 +            scancode = SDLK_F15;
   1.924 +            break;
   1.925 +        case Qt::Key_Super_L:
   1.926 +            scancode = SDLK_LSUPER;
   1.927 +            break;
   1.928 +        case Qt::Key_Super_R:
   1.929 +            scancode = SDLK_RSUPER;
   1.930 +            break;
   1.931 +        case Qt::Key_Menu:
   1.932 +            scancode = SDLK_MENU;
   1.933 +            break;
   1.934 +        case Qt::Key_Help:
   1.935 +            scancode = SDLK_HELP;
   1.936 +            break;
   1.937  
   1.938 -    case Qt::Key_F33:
   1.939 -      // FIXME: This is a hack to enable the OK key on
   1.940 -      // Zaurii devices. SDLK_RETURN is a suitable key to use
   1.941 -      // since it often is used as such.
   1.942 -      //     david@hedbor.org
   1.943 -      scancode = SDLK_RETURN;
   1.944 -      break;
   1.945 -    default:
   1.946 -      scancode = SDLK_UNKNOWN;
   1.947 -      break;
   1.948 +        case Qt::Key_F33:
   1.949 +            // FIXME: This is a hack to enable the OK key on
   1.950 +            // Zaurii devices. SDLK_RETURN is a suitable key to use
   1.951 +            // since it often is used as such.
   1.952 +            //     david@hedbor.org
   1.953 +            scancode = SDLK_RETURN;
   1.954 +            break;
   1.955 +        default:
   1.956 +            scancode = SDLK_UNKNOWN;
   1.957 +            break;
   1.958 +        }
   1.959 +        keysym.sym = static_cast < SDLKey > (scancode);
   1.960 +    } else {
   1.961 +        keysym.sym = static_cast < SDLKey > (scancode);
   1.962      }
   1.963 -    keysym.sym = static_cast<SDLKey>(scancode);    
   1.964 -  } else {
   1.965 -    keysym.sym = static_cast<SDLKey>(scancode);    
   1.966 -  }
   1.967 -  keysym.scancode = scancode;
   1.968 -  keysym.mod = KMOD_NONE;
   1.969 -  ButtonState st = e->state();
   1.970 -  if( (st & ShiftButton) )   { keysym.mod = static_cast<SDLMod>(keysym.mod | KMOD_LSHIFT);  }
   1.971 -  if( (st & ControlButton) ) { keysym.mod = static_cast<SDLMod>(keysym.mod | KMOD_LCTRL);  }
   1.972 -  if( (st & AltButton) )     { keysym.mod = static_cast<SDLMod>(keysym.mod | KMOD_LALT);  }
   1.973 -  if ( SDL_TranslateUNICODE ) {
   1.974 -    QChar qchar = e->text()[0];
   1.975 -    keysym.unicode = qchar.unicode();
   1.976 -  } else {
   1.977 -    keysym.unicode = 0;
   1.978 -  }
   1.979 +    keysym.scancode = scancode;
   1.980 +    keysym.mod = KMOD_NONE;
   1.981 +    ButtonState st = e->state ();
   1.982 +    if ((st & ShiftButton)) {
   1.983 +        keysym.mod = static_cast < SDLMod > (keysym.mod | KMOD_LSHIFT);
   1.984 +    }
   1.985 +    if ((st & ControlButton)) {
   1.986 +        keysym.mod = static_cast < SDLMod > (keysym.mod | KMOD_LCTRL);
   1.987 +    }
   1.988 +    if ((st & AltButton)) {
   1.989 +        keysym.mod = static_cast < SDLMod > (keysym.mod | KMOD_LALT);
   1.990 +    }
   1.991 +    if (SDL_TranslateUNICODE) {
   1.992 +        QChar qchar = e->text ()[0];
   1.993 +        keysym.unicode = qchar.unicode ();
   1.994 +    } else {
   1.995 +        keysym.unicode = 0;
   1.996 +    }
   1.997  
   1.998 -  /* NUMLOCK and CAPSLOCK are implemented as double-presses in reality */
   1.999 -  //	if ( (keysym.sym == SDLK_NUMLOCK) || (keysym.sym == SDLK_CAPSLOCK) ) {
  1.1000 -  //		pressed = 1;
  1.1001 -  //	}
  1.1002 +    /* NUMLOCK and CAPSLOCK are implemented as double-presses in reality */
  1.1003 +    //    if ( (keysym.sym == SDLK_NUMLOCK) || (keysym.sym == SDLK_CAPSLOCK) ) {
  1.1004 +    //            pressed = 1;
  1.1005 +    //    }
  1.1006  
  1.1007 -  /* Queue the key event */
  1.1008 -  if ( pressed ) {
  1.1009 -    SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
  1.1010 -  } else {
  1.1011 -    SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
  1.1012 -  }
  1.1013 +    /* Queue the key event */
  1.1014 +    if (pressed) {
  1.1015 +        SDL_PrivateKeyboard (SDL_PRESSED, &keysym);
  1.1016 +    } else {
  1.1017 +        SDL_PrivateKeyboard (SDL_RELEASED, &keysym);
  1.1018 +    }
  1.1019  }
  1.1020  
  1.1021 -void SDL_QWin::setFullscreen(bool fs_on) {
  1.1022 -  my_has_fullscreen = false;
  1.1023 -  enableFullscreen();
  1.1024 +void
  1.1025 +SDL_QWin::setFullscreen (bool fs_on)
  1.1026 +{
  1.1027 +    my_has_fullscreen = false;
  1.1028 +    enableFullscreen ();
  1.1029  }
  1.1030  
  1.1031 -void SDL_QWin::enableFullscreen() {
  1.1032 -  // Make sure size is correct
  1.1033 -  if(!my_has_fullscreen) {
  1.1034 -    setFixedSize(qApp->desktop()->size());
  1.1035 -    // This call is needed because showFullScreen won't work
  1.1036 -    // correctly if the widget already considers itself to be fullscreen.
  1.1037 -    showNormal();
  1.1038 -    // This is needed because showNormal() forcefully changes the window
  1.1039 -    // style to WSTyle_TopLevel.
  1.1040 -    setWFlags(WStyle_Customize | WStyle_NoBorder);
  1.1041 -    // Enable fullscreen.
  1.1042 -    showFullScreen();
  1.1043 -    my_has_fullscreen = true;
  1.1044 -  }
  1.1045 +void
  1.1046 +SDL_QWin::enableFullscreen ()
  1.1047 +{
  1.1048 +    // Make sure size is correct
  1.1049 +    if (!my_has_fullscreen) {
  1.1050 +        setFixedSize (qApp->desktop ()->size ());
  1.1051 +        // This call is needed because showFullScreen won't work
  1.1052 +        // correctly if the widget already considers itself to be fullscreen.
  1.1053 +        showNormal ();
  1.1054 +        // This is needed because showNormal() forcefully changes the window
  1.1055 +        // style to WSTyle_TopLevel.
  1.1056 +        setWFlags (WStyle_Customize | WStyle_NoBorder);
  1.1057 +        // Enable fullscreen.
  1.1058 +        showFullScreen ();
  1.1059 +        my_has_fullscreen = true;
  1.1060 +    }
  1.1061  }
  1.1062  
  1.1063 -bool SDL_QWin::lockScreen(bool force) {
  1.1064 -  if(!my_painter) {
  1.1065 -    if(force || (isVisible() && isActiveWindow())) {
  1.1066 -      my_painter = new QDirectPainter(this);
  1.1067 -    } else {
  1.1068 -      return false;
  1.1069 +bool SDL_QWin::lockScreen (bool force)
  1.1070 +{
  1.1071 +    if (!my_painter) {
  1.1072 +        if (force || (isVisible () && isActiveWindow ())) {
  1.1073 +            my_painter = new QDirectPainter (this);
  1.1074 +        } else {
  1.1075 +            return false;
  1.1076 +        }
  1.1077      }
  1.1078 -  }
  1.1079 -  my_locked++; // Increate lock refcount
  1.1080 -  return true;
  1.1081 +    my_locked++;                // Increate lock refcount
  1.1082 +    return true;
  1.1083  }
  1.1084  
  1.1085 -void SDL_QWin::unlockScreen() {
  1.1086 -  if(my_locked > 0) {
  1.1087 -    my_locked--; // decrease lock refcount;
  1.1088 -  }
  1.1089 -  if(!my_locked && my_painter) {
  1.1090 -    my_painter->end();
  1.1091 -    delete my_painter;
  1.1092 -    my_painter = 0;
  1.1093 -  }
  1.1094 +void
  1.1095 +SDL_QWin::unlockScreen ()
  1.1096 +{
  1.1097 +    if (my_locked > 0) {
  1.1098 +        my_locked--;            // decrease lock refcount;
  1.1099 +    }
  1.1100 +    if (!my_locked && my_painter) {
  1.1101 +        my_painter->end ();
  1.1102 +        delete my_painter;
  1.1103 +        my_painter = 0;
  1.1104 +    }
  1.1105  }
  1.1106 +
  1.1107 +/* vi: set ts=4 sw=4 expandtab: */