From: David Hedbor
authorSam Lantinga <slouken@libsdl.org>
Mon, 20 Jan 2003 01:08:20 +0000
changeset 567969fbd4dcd4e
parent 566 d6e7d7006062
child 568 0cd6b268193b
From: David Hedbor
Subject: Qtopia patches (input grabbing and iconify)

Ok, here's a patch that adds support for SDL_WM_GrabInput (default
state is "ungrabbed") and SDL_WM_IconifyWindow. Also has some other
tweaks such as taking additional steps to clean up when exiting
(bypassing certain bugs in some versions of Qtopia and/or OPIE) and it
also maps Key_F33 to Key_Return (this is the Zaurus 'ok' key).
configure.in
src/main/linux/SDL_Qtopia_main.cc
src/video/SDL_video.c
src/video/qtopia/SDL_QWin.cc
src/video/qtopia/SDL_QWin.h
src/video/qtopia/SDL_sysvideo.cc
     1.1 --- a/configure.in	Mon Jan 20 00:25:28 2003 +0000
     1.2 +++ b/configure.in	Mon Jan 20 01:08:20 2003 +0000
     1.3 @@ -1459,8 +1459,13 @@
     1.4          if test x$video_qtopia = xyes; then
     1.5              CFLAGS="$CFLAGS -DENABLE_QTOPIA -DQT_QWS_EBX -DQT_QWS_CUSTOM -DQWS -I${QPEDIR}/include -I${QTDIR}/include/ -DNO_DEBUG -fno-rtti -fno-exceptions"
     1.6              SDL_LIBS="$SDL_LIBS -L${QPEDIR}/lib -L${QTDIR}/lib/ -lqpe -lqte"
     1.7 +            SDL_CFLAGS="$SDL_CFLAGS -DQWS"	  
     1.8              VIDEO_SUBDIRS="$VIDEO_SUBDIRS qtopia"
     1.9              VIDEO_DRIVERS="$VIDEO_DRIVERS qtopia/libvideo_qtopia.la"
    1.10 +        else
    1.11 +	AC_MSG_ERROR([
    1.12 +*** Failed to find Qtopia includes. Make sure that the QTDIR and QPEDIR
    1.13 +*** environment variables are set correctly.])
    1.14          fi
    1.15          AC_LANG_C
    1.16      fi
     2.1 --- a/src/main/linux/SDL_Qtopia_main.cc	Mon Jan 20 00:25:28 2003 +0000
     2.2 +++ b/src/main/linux/SDL_Qtopia_main.cc	Mon Jan 20 01:08:20 2003 +0000
     2.3 @@ -1,11 +1,32 @@
     2.4  
     2.5  /* Include the SDL main definition header */
     2.6  #include "SDL_main.h"
     2.7 +#include <stdlib.h>
     2.8 +#include <unistd.h>
     2.9  #ifdef main
    2.10  #undef main
    2.11  #endif
    2.12  #ifdef QWS
    2.13  #include <qpe/qpeapplication.h>
    2.14 +#include <qapplication.h>
    2.15 +#include <qpe/qpeapplication.h>
    2.16 +#include <stdlib.h>
    2.17 +
    2.18 +// Workaround for OPIE to remove taskbar icon. Also fixes
    2.19 +// some issues in Qtopia where there are left-over qcop files in /tmp/.
    2.20 +// I'm guessing this will also clean up the taskbar in the Sharp version
    2.21 +// of Qtopia.
    2.22 +static inline void cleanupQCop() {
    2.23 +  QString appname(qApp->argv()[0]);
    2.24 +  int slash = appname.findRev("/");
    2.25 +  if(slash != -1) {  appname = appname.mid(slash+1); }
    2.26 +  QString cmd = QPEApplication::qpeDir() + "bin/qcop QPE/System 'closing(QString)' '"+appname+"'";
    2.27 +  system(cmd.latin1());
    2.28 +  cmd = "/tmp/qcop-msg-"+appname;
    2.29 +  unlink(cmd.latin1());
    2.30 +}
    2.31 +
    2.32 +static QPEApplication *app;
    2.33  #endif
    2.34  
    2.35  extern int SDL_main(int argc, char *argv[]);
    2.36 @@ -15,9 +36,10 @@
    2.37  #ifdef QWS
    2.38    // This initializes the Qtopia application. It needs to be done here
    2.39    // because it parses command line options.
    2.40 -  QPEApplication app(argc, argv);
    2.41    QWidget dummy;
    2.42 -  app.showMainWidget(&dummy);
    2.43 +  app = new QPEApplication(argc, argv);
    2.44 +  app->showMainWidget(&dummy);
    2.45 +  atexit(cleanupQCop);
    2.46  #endif
    2.47    // Exit here because if return is used, the application
    2.48    // doesn't seem to quit correctly.
     3.1 --- a/src/video/SDL_video.c	Mon Jan 20 00:25:28 2003 +0000
     3.2 +++ b/src/video/SDL_video.c	Mon Jan 20 01:08:20 2003 +0000
     3.3 @@ -54,6 +54,9 @@
     3.4  #ifdef ENABLE_NANOX
     3.5  	&NX_bootstrap,
     3.6  #endif
     3.7 +#ifdef ENABLE_QTOPIA
     3.8 +	&Qtopia_bootstrap,
     3.9 +#endif
    3.10  #ifdef ENABLE_FBCON
    3.11  	&FBCON_bootstrap,
    3.12  #endif
    3.13 @@ -111,9 +114,6 @@
    3.14  #ifdef ENABLE_GEM
    3.15  	&GEM_bootstrap,
    3.16  #endif
    3.17 -#ifdef ENABLE_QTOPIA
    3.18 -	&Qtopia_bootstrap,
    3.19 -#endif
    3.20  #ifdef ENABLE_PICOGUI
    3.21  	&PG_bootstrap,
    3.22  #endif
     4.1 --- a/src/video/qtopia/SDL_QWin.cc	Mon Jan 20 00:25:28 2003 +0000
     4.2 +++ b/src/video/qtopia/SDL_QWin.cc	Mon Jan 20 01:08:20 2003 +0000
     4.3 @@ -129,14 +129,12 @@
     4.4    my_mouse_pos = QPoint(-1, -1);
     4.5  }
     4.6  
     4.7 -#define USE_DIRECTPAINTER
     4.8 -
     4.9 -
    4.10 -#ifndef __i386__
    4.11 -static inline void gs_fastRotateBlit_3 ( unsigned short *fb,
    4.12 -					 unsigned short *bits,
    4.13 -					 const QRect& rect )
    4.14 +static inline void
    4.15 +gs_fastRotateBlit_3 ( unsigned short *fb,
    4.16 +		      unsigned short *bits,
    4.17 +		      const QRect& rect )
    4.18  {
    4.19 +  // FIXME: this only works correctly for 240x320 displays
    4.20    int startx, starty;
    4.21    int width, height;
    4.22    
    4.23 @@ -187,87 +185,193 @@
    4.24      dp2 += rowadd;
    4.25    }
    4.26  }
    4.27 +
    4.28 +static inline void
    4.29 +gs_fastRotateBlit_1 ( unsigned short *fb,
    4.30 +		      unsigned short *bits,
    4.31 +		      const QRect& rect ) {
    4.32 +  // FIXME: this only works correctly for 240x320 displays
    4.33 +  int startx, starty;
    4.34 +  int width, height;
    4.35 +
    4.36 +  startx = rect.left() >> 1;
    4.37 +  starty = rect.top() >> 1;
    4.38 +  width  = ((rect.right() - rect.left()) >> 1) + 2;
    4.39 +  height = ((rect.bottom() - rect.top()) >> 1) + 2;
    4.40 +
    4.41 +  if((startx+width) > 120) {
    4.42 +    width = 120 - startx; // avoid horizontal overflow
    4.43 +  }
    4.44 +  if((starty+height) > 160) { 
    4.45 +    height = 160 - starty; // avoid vertical overflow
    4.46 +  }
    4.47 +
    4.48 +  ulong *sp1, *sp2, *dp1, *dp2;
    4.49 +  ulong stop, sbot, dtop, dbot;    
    4.50 +  fb += 320*239; // Move "fb" to top left corner
    4.51 +  sp1 = (ulong*)bits + startx + starty*240;
    4.52 +  sp2 = sp1 + 120;
    4.53 +  dp1 = (ulong*)fb - startx * 320 - starty;
    4.54 +  dp2 = dp1 - 160;
    4.55 +  int rowadd = (320*width) + 1;
    4.56 +  int rowadd2 = 240 - width;
    4.57 +  // transfer in cells of 2x2 pixels in words
    4.58 +  for (int y=0; y<height; y++) {
    4.59 +    for (int x=0; x<width; x++) {
    4.60 +      // read
    4.61 +      stop = *sp1;
    4.62 +      sbot = *sp2;
    4.63 +      // rotate
    4.64 +      dtop = (stop & 0xffff) + ((sbot & 0xffff)<<16);
    4.65 +      dbot = ((stop & 0xffff0000)>>16) + (sbot & 0xffff0000);
    4.66 +      // write
    4.67 +      *dp1 = dtop;
    4.68 +      *dp2 = dbot;
    4.69 +      // update source ptrs
    4.70 +      sp1++; sp2++;
    4.71 +      // update dest ptrs - 2 pix at a time
    4.72 +      dp1 -= 320;
    4.73 +      dp2 -= 320;
    4.74 +    }
    4.75 +    // adjust src ptrs - skip a row as we work in pairs
    4.76 +    sp1 += rowadd2;
    4.77 +    sp2 += rowadd2;
    4.78 +    // adjust dest ptrs for rotation
    4.79 +    dp1 += rowadd;
    4.80 +    dp2 += rowadd;
    4.81 +  }
    4.82 +}
    4.83 +
    4.84 +// desktop, SL-A300 etc
    4.85 +bool SDL_QWin::repaintRotation0(const QRect& rect) {
    4.86 +  if(my_image->width() == width()) {
    4.87 +    uchar *fb = (uchar*)my_painter->frameBuffer();
    4.88 +    uchar *buf = (uchar*)my_image->bits();
    4.89 +    if(rect == my_image->rect()) {
    4.90 +      memcpy(fb, buf, width()*height()*2);
    4.91 +    } else {
    4.92 +      int h = rect.height();
    4.93 +      int wd = rect.width()<<1;
    4.94 +      int fblineadd = my_painter->lineStep();
    4.95 +      int buflineadd = my_image->bytesPerLine();
    4.96 +      fb  += (rect.left()<<1) + rect.top() * my_painter->lineStep();
    4.97 +      buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine();
    4.98 +      while(h--) {
    4.99 +	memcpy(fb, buf, wd);
   4.100 +	fb += fblineadd;
   4.101 +	buf += buflineadd;
   4.102 +      }
   4.103 +    }
   4.104 +  } else {
   4.105 +    return false; // FIXME: Landscape
   4.106 +  }
   4.107 +#ifdef __i386__
   4.108 +  my_painter->fillRect( rect, QBrush( Qt::NoBrush ) );
   4.109  #endif
   4.110 +  return true;
   4.111 +}
   4.112 +
   4.113 +  
   4.114 +// Sharp Zaurus SL-5500 etc 
   4.115 +bool SDL_QWin::repaintRotation3(const QRect& rect) {
   4.116 +  if(my_image->width() == width()) {
   4.117 +    ushort *fb = (ushort*)my_painter->frameBuffer();
   4.118 +    ushort *buf = (ushort*)my_image->bits();
   4.119 +    gs_fastRotateBlit_3(fb, buf, rect);
   4.120 +  } else {
   4.121 +    // landscape mode
   4.122 +    if (screenRotation == SDL_QT_ROTATION_90) {
   4.123 +      uchar *fb = (uchar*)my_painter->frameBuffer();
   4.124 +      uchar *buf = (uchar*)my_image->bits();
   4.125 +      if(rect == my_image->rect()) {
   4.126 +	memcpy(fb, buf, width()*height()*2);
   4.127 +      } else {
   4.128 +	int h = rect.height();
   4.129 +	int wd = rect.width()<<1;
   4.130 +	int fblineadd = my_painter->lineStep();
   4.131 +	int buflineadd = my_image->bytesPerLine();
   4.132 +	fb  += (rect.left()<<1) + rect.top() * my_painter->lineStep();
   4.133 +	buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine();
   4.134 +	while(h--) {
   4.135 +	  memcpy(fb, buf, wd);
   4.136 +	  fb += fblineadd;
   4.137 +	  buf += buflineadd;
   4.138 +	}
   4.139 +      }
   4.140 +    } else if (screenRotation == SDL_QT_ROTATION_270) {
   4.141 +      int h = rect.height();
   4.142 +      int wd = rect.width();
   4.143 +      int fblineadd = my_painter->lineStep() - (rect.width() << 1);
   4.144 +      int buflineadd = my_image->bytesPerLine() - (rect.width() << 1);
   4.145 +      int w;
   4.146 +
   4.147 +      uchar *fb = (uchar*)my_painter->frameBuffer();
   4.148 +      uchar *buf = (uchar*)my_image->bits();
   4.149 +        
   4.150 +      fb += ((my_painter->width() - (rect.top() + rect.height())) * 
   4.151 +	     my_painter->lineStep()) + ((my_painter->height() - ((rect.left() + 
   4.152 +								  rect.width()))) << 1);
   4.153 +
   4.154 +      buf += my_image->bytesPerLine() * (rect.top() + rect.height()) -
   4.155 +	(((my_image->width() - (rect.left() + rect.width())) << 1) + 2);
   4.156 +
   4.157 +      while(h--) {
   4.158 +	w = wd;
   4.159 +	while(w--) *((unsigned short*)fb)++ = *((unsigned short*)buf)--;
   4.160 +	fb += fblineadd;
   4.161 +	buf -= buflineadd;
   4.162 +      }
   4.163 +    }
   4.164 +  }
   4.165 +  return true;
   4.166 +}
   4.167 +
   4.168 +// ipaq 3800...
   4.169 +bool SDL_QWin::repaintRotation1(const QRect& rect) {
   4.170 +  if(my_image->width() == width()) {
   4.171 +    ushort *fb = (ushort*)my_painter->frameBuffer();
   4.172 +    ushort *buf = (ushort*)my_image->bits();
   4.173 +    gs_fastRotateBlit_1(fb, buf, rect);
   4.174 +  } else {
   4.175 +    return false; // FIXME: landscape mode
   4.176 +  }
   4.177 +  return true;
   4.178 +}
   4.179  
   4.180  void SDL_QWin::repaintRect(const QRect& rect) {
   4.181    if(!my_painter || !rect.width() || !rect.height()) {
   4.182      return;
   4.183    }
   4.184 -#ifndef __i386__
   4.185 -
   4.186 -  if(QPixmap::defaultDepth() == 16 &&
   4.187 -     my_painter->transformOrientation() == 3 &&
   4.188 -     my_painter->numRects() >= 0) {
   4.189 -    if(my_image->width() == width()) {
   4.190 -      ushort *fb = (ushort*)my_painter->frameBuffer();
   4.191 -      ushort *buf = (ushort*)my_image->bits();
   4.192 -      gs_fastRotateBlit_3(fb, buf, rect);
   4.193 -    } else {
   4.194 -      // landscape mode
   4.195 -      if (screenRotation == SDL_QT_ROTATION_90) {
   4.196 -        uchar *fb = (uchar*)my_painter->frameBuffer();
   4.197 -        uchar *buf = (uchar*)my_image->bits();
   4.198 -        if(rect == my_image->rect()) {
   4.199 -          memcpy(fb, buf, width()*height()*2);
   4.200 -        } else {
   4.201 -          int h = rect.height();
   4.202 -          int wd = rect.width()<<1;
   4.203 -          int fblineadd = my_painter->lineStep();
   4.204 -          int buflineadd = my_image->bytesPerLine();
   4.205 -          fb  += (rect.left()<<1) + rect.top() * my_painter->lineStep();
   4.206 -          buf += (rect.left()<<1) + rect.top() * my_image->bytesPerLine();
   4.207 -          while(h--) {
   4.208 -            memcpy(fb, buf, wd);
   4.209 -            fb += fblineadd;
   4.210 -            buf += buflineadd;
   4.211 -          }
   4.212 -        }
   4.213 -      }
   4.214 -      else if (screenRotation == SDL_QT_ROTATION_270) {
   4.215 -        int h = rect.height();
   4.216 -        int wd = rect.width();
   4.217 -        int fblineadd = my_painter->lineStep() - (rect.width() << 1);
   4.218 -        int buflineadd = my_image->bytesPerLine() - (rect.width() << 1);
   4.219 -        int w;
   4.220 -
   4.221 -        uchar *fb = (uchar*)my_painter->frameBuffer();
   4.222 -        uchar *buf = (uchar*)my_image->bits();
   4.223 -        
   4.224 -        fb += ((my_painter->width() - (rect.top() + rect.height())) * 
   4.225 -            my_painter->lineStep()) + ((my_painter->height() - ((rect.left() + 
   4.226 -                                                                 rect.width()))) << 1);
   4.227 -
   4.228 -        buf += my_image->bytesPerLine() * (rect.top() + rect.height()) -
   4.229 -            (((my_image->width() - (rect.left() + rect.width())) << 1) + 2);
   4.230 -
   4.231 -        while(h--) {
   4.232 -          w = wd;
   4.233 -          while(w--) *((unsigned short*)fb)++ = *((unsigned short*)buf)--;
   4.234 -          fb += fblineadd;
   4.235 -          buf -= buflineadd;
   4.236 -          }
   4.237 -        }
   4.238 +  
   4.239 +  if(QPixmap::defaultDepth() == 16) {
   4.240 +    switch(my_painter->transformOrientation()) {
   4.241 +    case 3:
   4.242 +      if(repaintRotation3(rect)) { return;  }
   4.243 +      break;
   4.244 +    case 1:
   4.245 +      if(repaintRotation1(rect)) { return;  }
   4.246 +      break;
   4.247 +    case 0:
   4.248 +      if(repaintRotation0(rect)) { return;  }
   4.249 +      break;
   4.250      }
   4.251 -  } else {
   4.252 -#endif
   4.253 -    QPainter pp(this);
   4.254 -    pp.drawImage(rect.topLeft(), *my_image, rect);
   4.255 -    pp.end();
   4.256 -#ifndef __i386__
   4.257 -  }
   4.258 -#endif
   4.259 +  } 
   4.260 +  my_painter->drawImage(rect.topLeft(), *my_image, rect);
   4.261  }
   4.262  
   4.263  // This paints the current buffer to the screen, when desired. 
   4.264  void SDL_QWin::paintEvent(QPaintEvent *ev) {  
   4.265 -  if(my_image && isVisible() && isActiveWindow()) {
   4.266 -    lockScreen();
   4.267 +  if(my_image) {
   4.268 +    lockScreen(true);
   4.269      repaintRect(ev->rect());
   4.270      unlockScreen();
   4.271    }
   4.272  }  
   4.273  
   4.274 -/* Function to translate a keyboard transition and queue the key event */
   4.275 +/* Function to translate a keyboard transition and queue the key event
   4.276 + * This should probably be a table although this method isn't exactly
   4.277 + * slow.
   4.278 + */
   4.279  void SDL_QWin::QueueKey(QKeyEvent *e, int pressed)
   4.280  {  
   4.281    SDL_keysym keysym;
   4.282 @@ -340,6 +444,14 @@
   4.283      case Qt::Key_Super_R: scancode = SDLK_RSUPER; break;
   4.284      case Qt::Key_Menu: scancode = SDLK_MENU; break;
   4.285      case Qt::Key_Help: scancode = SDLK_HELP; break;
   4.286 +
   4.287 +    case Qt::Key_F33:
   4.288 +      // FIXME: This is a hack to enable the OK key on
   4.289 +      // Zaurii devices. SDLK_RETURN is a suitable key to use
   4.290 +      // since it often is used as such.
   4.291 +      //     david@hedbor.org
   4.292 +      scancode = SDLK_RETURN;
   4.293 +      break;
   4.294      default:
   4.295        scancode = SDLK_UNKNOWN;
   4.296        break;
   4.297 @@ -394,3 +506,26 @@
   4.298      my_has_fullscreen = true;
   4.299    }
   4.300  }
   4.301 +
   4.302 +bool SDL_QWin::lockScreen(bool force) {
   4.303 +  if(!my_painter) {
   4.304 +    if(force || (isVisible() && isActiveWindow())) {
   4.305 +      my_painter = new QDirectPainter(this);
   4.306 +    } else {
   4.307 +      return false;
   4.308 +    }
   4.309 +  }
   4.310 +  my_locked++; // Increate lock refcount
   4.311 +  return true;
   4.312 +}
   4.313 +
   4.314 +void SDL_QWin::unlockScreen() {
   4.315 +  if(my_locked > 0) {
   4.316 +    my_locked--; // decrease lock refcount;
   4.317 +  }
   4.318 +  if(!my_locked && my_painter) {
   4.319 +    my_painter->end();
   4.320 +    delete my_painter;
   4.321 +    my_painter = 0;
   4.322 +  }
   4.323 +}
     5.1 --- a/src/video/qtopia/SDL_QWin.h	Mon Jan 20 00:25:28 2003 +0000
     5.2 +++ b/src/video/qtopia/SDL_QWin.h	Mon Jan 20 01:08:20 2003 +0000
     5.3 @@ -70,14 +70,7 @@
     5.4      x = my_offset.x();
     5.5      y = my_offset.y();
     5.6    }
     5.7 -  bool beginDraw(void) {
     5.8 -    return true;
     5.9 -  }
    5.10 -  void endDraw(void) {
    5.11 -  }
    5.12 -  QImage *image(void) {
    5.13 -    return my_image;
    5.14 -  }
    5.15 +  QImage *image(void) { return my_image; }
    5.16    
    5.17    void setWFlags(WFlags flags) {
    5.18      QWidget::setWFlags(flags);
    5.19 @@ -87,22 +80,8 @@
    5.20    void setMousePos(const QPoint& newpos);
    5.21    void setFullscreen(bool);
    5.22  
    5.23 -  void lockScreen() {
    5.24 -    if(!my_painter) {
    5.25 -      my_painter = new QDirectPainter(this);
    5.26 -    }
    5.27 -    my_locked++; // Increate lock refcount
    5.28 -  }
    5.29 -  void unlockScreen() {
    5.30 -    if(my_locked > 0) {
    5.31 -      my_locked--; // decrease lock refcount;
    5.32 -    }
    5.33 -    if(!my_locked && my_painter) {
    5.34 -      my_painter->end();
    5.35 -      delete my_painter;
    5.36 -      my_painter = 0;
    5.37 -    }
    5.38 -  }
    5.39 +  bool lockScreen(bool force=false);
    5.40 +  void unlockScreen();
    5.41    void repaintRect(const QRect& rect);
    5.42   protected:
    5.43    /* Handle resizing of the window */
    5.44 @@ -114,13 +93,12 @@
    5.45    void mousePressEvent(QMouseEvent *e);
    5.46    void mouseReleaseEvent(QMouseEvent *e);
    5.47    void paintEvent(QPaintEvent *ev);
    5.48 -  void keyPressEvent(QKeyEvent *e) {
    5.49 -    QueueKey(e, 1);
    5.50 -  }
    5.51 -  void keyReleaseEvent(QKeyEvent *e) {
    5.52 -    QueueKey(e, 0);
    5.53 -  }
    5.54 +  void keyPressEvent(QKeyEvent *e)   { QueueKey(e, 1); }
    5.55 +  void keyReleaseEvent(QKeyEvent *e) { QueueKey(e, 0); }
    5.56   private:
    5.57 +  bool repaintRotation0(const QRect& rect);
    5.58 +  bool repaintRotation1(const QRect& rect);
    5.59 +  bool repaintRotation3(const QRect& rect);
    5.60    void enableFullscreen();
    5.61    QDirectPainter *my_painter;
    5.62    QImage *my_image;
     6.1 --- a/src/video/qtopia/SDL_sysvideo.cc	Mon Jan 20 00:25:28 2003 +0000
     6.2 +++ b/src/video/qtopia/SDL_sysvideo.cc	Mon Jan 20 01:08:20 2003 +0000
     6.3 @@ -53,12 +53,12 @@
     6.4    //#define QTOPIA_DEBUG
     6.5  #define QT_HIDDEN_SIZE	32	/* starting hidden window size */
     6.6  
     6.7 -/* Name of the environment variable used to invert the screen rotation or not:
     6.8 -   Possible values:
     6.9 -   !=0 : Screen is 270 rotated
    6.10 -   0: Screen is 90 rotated*/
    6.11 +  /* Name of the environment variable used to invert the screen rotation or not:
    6.12 +     Possible values:
    6.13 +     !=0 : Screen is 270 rotated
    6.14 +     0: Screen is 90 rotated*/
    6.15  #define SDL_QT_ROTATION_ENV_NAME "SDL_QT_INVERT_ROTATION"
    6.16 -
    6.17 +  
    6.18    /* Initialization/Query functions */
    6.19    static int QT_VideoInit(_THIS, SDL_PixelFormat *vformat);
    6.20    static SDL_Rect **QT_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
    6.21 @@ -75,6 +75,8 @@
    6.22  
    6.23    static int QT_ToggleFullScreen(_THIS, int fullscreen);
    6.24  
    6.25 +  static int QT_IconifyWindow(_THIS);
    6.26 +  static SDL_GrabMode QT_GrabInput(_THIS, SDL_GrabMode mode);
    6.27  
    6.28    /* FB driver bootstrap functions */
    6.29  
    6.30 @@ -128,6 +130,8 @@
    6.31      device->FreeHWSurface = QT_FreeHWSurface;
    6.32      device->SetIcon = NULL;
    6.33      device->SetCaption = QT_SetWMCaption;
    6.34 +    device->IconifyWindow = QT_IconifyWindow;
    6.35 +    device->GrabInput = QT_GrabInput;
    6.36      device->GetWMInfo = NULL;
    6.37      device->FreeWMCursor = QT_FreeWMCursor;
    6.38      device->CreateWMCursor = QT_CreateWMCursor;
    6.39 @@ -281,7 +285,7 @@
    6.40      QSize desktop_size = qApp->desktop()->size();
    6.41  
    6.42      
    6.43 -    current->flags = SDL_FULLSCREEN; // We always run fullscreen.
    6.44 +    current->flags = 0; //SDL_FULLSCREEN; // We always run fullscreen.
    6.45  
    6.46      if(width <= desktop_size.width()
    6.47  	      && height <= desktop_size.height()) {
    6.48 @@ -355,14 +359,14 @@
    6.49  
    6.50    static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
    6.51    {
    6.52 -    int i;
    6.53 -    SDL_Win->lockScreen(); 
    6.54 -    for ( i=0; i<numrects; ++i ) {
    6.55 -      QRect rect(rects[i].x, rects[i].y,
    6.56 -		 rects[i].w, rects[i].h);
    6.57 -      SDL_Win->repaintRect(rect);
    6.58 +    if(SDL_Win->lockScreen()) {
    6.59 +      for(int i=0; i<numrects; ++i ) {
    6.60 +	QRect rect(rects[i].x, rects[i].y,
    6.61 +		   rects[i].w, rects[i].h);
    6.62 +	SDL_Win->repaintRect(rect);
    6.63 +      }
    6.64 +      SDL_Win->unlockScreen();
    6.65      }
    6.66 -    SDL_Win->unlockScreen(); 
    6.67    }
    6.68    /* Is the system palette settable? */
    6.69    int QT_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
    6.70 @@ -380,6 +384,25 @@
    6.71      //    delete SDL_Win; 
    6.72      //    SDL_Win = 0;
    6.73      _this->screen->pixels = NULL;
    6.74 +    QT_GrabInput(_this, SDL_GRAB_OFF);
    6.75    }
    6.76  
    6.77 +  static int QT_IconifyWindow(_THIS) {
    6.78 +    SDL_Win->hide();
    6.79 +    
    6.80 +    return true;
    6.81 +  }
    6.82 +
    6.83 +  static SDL_GrabMode QT_GrabInput(_THIS, SDL_GrabMode mode) {
    6.84 +    if(mode == SDL_GRAB_OFF) {
    6.85 +      QPEApplication::grabKeyboard();
    6.86 +      qApp->processEvents();
    6.87 +      QPEApplication::ungrabKeyboard();
    6.88 +    } else {
    6.89 +      QPEApplication::grabKeyboard();
    6.90 +    }
    6.91 +    qApp->processEvents();
    6.92 +    return mode;
    6.93 +  }
    6.94 +  
    6.95  }; /* Extern C */