comparison src/video/qtopia/SDL_sysvideo.cc @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents e49147870aac
children 4da1ee79c9af
comparison
equal deleted inserted replaced
1661:281d3f4870e5 1662:782fd950bd46
30 30
31 #include "SDL_timer.h" 31 #include "SDL_timer.h"
32 32
33 #include "SDL_QWin.h" 33 #include "SDL_QWin.h"
34 34
35 extern "C" { 35 extern "C"
36 {
36 37
37 #include "../SDL_sysvideo.h" 38 #include "../SDL_sysvideo.h"
38 #include "../../events/SDL_events_c.h" 39 #include "../../events/SDL_events_c.h"
39 #include "SDL_sysevents_c.h" 40 #include "SDL_sysevents_c.h"
40 #include "SDL_sysmouse_c.h" 41 #include "SDL_sysmouse_c.h"
41 #include "SDL_syswm_c.h" 42 #include "SDL_syswm_c.h"
42 #include "SDL_lowvideo.h" 43 #include "SDL_lowvideo.h"
43 44
44 //#define QTOPIA_DEBUG 45 //#define QTOPIA_DEBUG
45 #define QT_HIDDEN_SIZE 32 /* starting hidden window size */ 46 #define QT_HIDDEN_SIZE 32 /* starting hidden window size */
46 47
47 /* Name of the environment variable used to invert the screen rotation or not: 48 /* Name of the environment variable used to invert the screen rotation or not:
48 Possible values: 49 Possible values:
49 !=0 : Screen is 270° rotated 50 !=0 : Screen is 270° rotated
50 0: Screen is 90° rotated*/ 51 0: Screen is 90° rotated */
51 #define SDL_QT_ROTATION_ENV_NAME "SDL_QT_INVERT_ROTATION" 52 #define SDL_QT_ROTATION_ENV_NAME "SDL_QT_INVERT_ROTATION"
52 53
53 /* Initialization/Query functions */ 54 /* Initialization/Query functions */
54 static int QT_VideoInit(_THIS, SDL_PixelFormat *vformat); 55 static int QT_VideoInit (_THIS, SDL_PixelFormat * vformat);
55 static SDL_Rect **QT_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); 56 static SDL_Rect **QT_ListModes (_THIS, SDL_PixelFormat * format,
56 static SDL_Surface *QT_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); 57 Uint32 flags);
57 static void QT_UpdateMouse(_THIS); 58 static SDL_Surface *QT_SetVideoMode (_THIS, SDL_Surface * current,
58 static int QT_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); 59 int width, int height, int bpp,
59 static void QT_VideoQuit(_THIS); 60 Uint32 flags);
60 61 static void QT_UpdateMouse (_THIS);
61 /* Hardware surface functions */ 62 static int QT_SetColors (_THIS, int firstcolor, int ncolors,
62 static int QT_AllocHWSurface(_THIS, SDL_Surface *surface); 63 SDL_Color * colors);
63 static int QT_LockHWSurface(_THIS, SDL_Surface *surface); 64 static void QT_VideoQuit (_THIS);
64 static void QT_UnlockHWSurface(_THIS, SDL_Surface *surface); 65
65 static void QT_FreeHWSurface(_THIS, SDL_Surface *surface); 66 /* Hardware surface functions */
66 67 static int QT_AllocHWSurface (_THIS, SDL_Surface * surface);
67 static int QT_ToggleFullScreen(_THIS, int fullscreen); 68 static int QT_LockHWSurface (_THIS, SDL_Surface * surface);
68 69 static void QT_UnlockHWSurface (_THIS, SDL_Surface * surface);
69 static int QT_IconifyWindow(_THIS); 70 static void QT_FreeHWSurface (_THIS, SDL_Surface * surface);
70 static SDL_GrabMode QT_GrabInput(_THIS, SDL_GrabMode mode); 71
71 72 static int QT_ToggleFullScreen (_THIS, int fullscreen);
72 /* FB driver bootstrap functions */ 73
73 74 static int QT_IconifyWindow (_THIS);
74 static int QT_Available(void) 75 static SDL_GrabMode QT_GrabInput (_THIS, SDL_GrabMode mode);
75 { 76
76 return(1); 77 /* FB driver bootstrap functions */
77 } 78
78 79 static int QT_Available (void)
79 static void QT_DeleteDevice(SDL_VideoDevice *device) 80 {
80 { 81 return (1);
81 SDL_free(device->hidden); 82 }
82 SDL_free(device); 83
83 } 84 static void QT_DeleteDevice (SDL_VideoDevice * device)
84 85 {
85 static SDL_VideoDevice *QT_CreateDevice(int devindex) 86 SDL_free (device->hidden);
86 { 87 SDL_free (device);
87 SDL_VideoDevice *device; 88 }
88 89
89 /* Initialize all variables that we clean on shutdown */ 90 static SDL_VideoDevice *QT_CreateDevice (int devindex)
90 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); 91 {
91 if ( device ) { 92 SDL_VideoDevice *device;
92 SDL_memset(device, 0, (sizeof *device)); 93
93 device->hidden = (struct SDL_PrivateVideoData *) 94 /* Initialize all variables that we clean on shutdown */
94 SDL_malloc((sizeof *device->hidden)); 95 device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice));
95 } 96 if (device) {
96 if ( (device == NULL) || (device->hidden == NULL) ) { 97 SDL_memset (device, 0, (sizeof *device));
97 SDL_OutOfMemory(); 98 device->hidden = (struct SDL_PrivateVideoData *)
98 if ( device ) { 99 SDL_malloc ((sizeof *device->hidden));
99 SDL_free(device); 100 }
100 } 101 if ((device == NULL) || (device->hidden == NULL)) {
101 return(0); 102 SDL_OutOfMemory ();
102 } 103 if (device) {
103 SDL_memset(device->hidden, 0, (sizeof *device->hidden)); 104 SDL_free (device);
104 105 }
105 /* Set the function pointers */ 106 return (0);
106 device->VideoInit = QT_VideoInit; 107 }
107 device->ListModes = QT_ListModes; 108 SDL_memset (device->hidden, 0, (sizeof *device->hidden));
108 device->SetVideoMode = QT_SetVideoMode; 109
109 device->UpdateMouse = QT_UpdateMouse; 110 /* Set the function pointers */
110 device->SetColors = QT_SetColors; 111 device->VideoInit = QT_VideoInit;
111 device->UpdateRects = NULL; 112 device->ListModes = QT_ListModes;
112 device->VideoQuit = QT_VideoQuit; 113 device->SetVideoMode = QT_SetVideoMode;
113 device->AllocHWSurface = QT_AllocHWSurface; 114 device->UpdateMouse = QT_UpdateMouse;
114 device->CheckHWBlit = NULL; 115 device->SetColors = QT_SetColors;
115 device->FillHWRect = NULL; 116 device->UpdateRects = NULL;
116 device->SetHWColorKey = NULL; 117 device->VideoQuit = QT_VideoQuit;
117 device->SetHWAlpha = NULL; 118 device->AllocHWSurface = QT_AllocHWSurface;
118 device->LockHWSurface = QT_LockHWSurface; 119 device->CheckHWBlit = NULL;
119 device->UnlockHWSurface = QT_UnlockHWSurface; 120 device->FillHWRect = NULL;
120 device->FlipHWSurface = NULL; 121 device->SetHWColorKey = NULL;
121 device->FreeHWSurface = QT_FreeHWSurface; 122 device->SetHWAlpha = NULL;
122 device->SetIcon = NULL; 123 device->LockHWSurface = QT_LockHWSurface;
123 device->SetCaption = QT_SetWMCaption; 124 device->UnlockHWSurface = QT_UnlockHWSurface;
124 device->IconifyWindow = QT_IconifyWindow; 125 device->FlipHWSurface = NULL;
125 device->GrabInput = QT_GrabInput; 126 device->FreeHWSurface = QT_FreeHWSurface;
126 device->GetWMInfo = NULL; 127 device->SetIcon = NULL;
127 device->FreeWMCursor = QT_FreeWMCursor; 128 device->SetCaption = QT_SetWMCaption;
128 device->CreateWMCursor = QT_CreateWMCursor; 129 device->IconifyWindow = QT_IconifyWindow;
129 device->ShowWMCursor = QT_ShowWMCursor; 130 device->GrabInput = QT_GrabInput;
130 device->WarpWMCursor = QT_WarpWMCursor; 131 device->GetWMInfo = NULL;
131 device->InitOSKeymap = QT_InitOSKeymap; 132 device->FreeWMCursor = QT_FreeWMCursor;
132 device->PumpEvents = QT_PumpEvents; 133 device->CreateWMCursor = QT_CreateWMCursor;
133 134 device->ShowWMCursor = QT_ShowWMCursor;
134 device->free = QT_DeleteDevice; 135 device->WarpWMCursor = QT_WarpWMCursor;
135 device->ToggleFullScreen = QT_ToggleFullScreen; 136 device->InitOSKeymap = QT_InitOSKeymap;
136 137 device->PumpEvents = QT_PumpEvents;
137 /* Set the driver flags */ 138
138 device->handles_any_size = 0; 139 device->free = QT_DeleteDevice;
139 140 device->ToggleFullScreen = QT_ToggleFullScreen;
140 return device; 141
141 } 142 /* Set the driver flags */
142 143 device->handles_any_size = 0;
143 VideoBootStrap Qtopia_bootstrap = { 144
144 "qtopia", "Qtopia / QPE graphics", 145 return device;
145 QT_Available, QT_CreateDevice 146 }
146 }; 147
147 148 VideoBootStrap Qtopia_bootstrap = {
148 /* Function to sort the display_list */ 149 "qtopia", "Qtopia / QPE graphics",
149 static int CompareModes(const void *A, const void *B) 150 QT_Available, QT_CreateDevice
150 { 151 };
152
153 /* Function to sort the display_list */
154 static int CompareModes (const void *A, const void *B)
155 {
151 #if 0 156 #if 0
152 const display_mode *a = (display_mode *)A; 157 const display_mode *a = (display_mode *) A;
153 const display_mode *b = (display_mode *)B; 158 const display_mode *b = (display_mode *) B;
154 159
155 if ( a->space == b->space ) { 160 if (a->space == b->space) {
156 return((b->virtual_width*b->virtual_height)- 161 return ((b->virtual_width * b->virtual_height) -
157 (a->virtual_width*a->virtual_height)); 162 (a->virtual_width * a->virtual_height));
158 } else { 163 } else {
159 return(ColorSpaceToBitsPerPixel(b->space)- 164 return (ColorSpaceToBitsPerPixel (b->space) -
160 ColorSpaceToBitsPerPixel(a->space)); 165 ColorSpaceToBitsPerPixel (a->space));
161 } 166 }
162 #endif 167 #endif
163 return 0; 168 return 0;
164 } 169 }
165 170
166 /* Yes, this isn't the fastest it could be, but it works nicely */ 171 /* Yes, this isn't the fastest it could be, but it works nicely */
167 static int QT_AddMode(_THIS, int index, unsigned int w, unsigned int h) 172 static int QT_AddMode (_THIS, int index, unsigned int w, unsigned int h)
168 { 173 {
169 SDL_Rect *mode; 174 SDL_Rect *mode;
170 int i; 175 int i;
171 int next_mode; 176 int next_mode;
172 177
173 /* Check to see if we already have this mode */ 178 /* Check to see if we already have this mode */
174 if ( SDL_nummodes[index] > 0 ) { 179 if (SDL_nummodes[index] > 0) {
175 for ( i=SDL_nummodes[index]-1; i >= 0; --i ) { 180 for (i = SDL_nummodes[index] - 1; i >= 0; --i) {
176 mode = SDL_modelist[index][i]; 181 mode = SDL_modelist[index][i];
177 if ( (mode->w == w) && (mode->h == h) ) { 182 if ((mode->w == w) && (mode->h == h)) {
178 return(0); 183 return (0);
179 } 184 }
180 } 185 }
181 } 186 }
182 187
183 /* Set up the new video mode rectangle */ 188 /* Set up the new video mode rectangle */
184 mode = (SDL_Rect *)SDL_malloc(sizeof *mode); 189 mode = (SDL_Rect *) SDL_malloc (sizeof *mode);
185 if ( mode == NULL ) { 190 if (mode == NULL) {
186 SDL_OutOfMemory(); 191 SDL_OutOfMemory ();
187 return(-1); 192 return (-1);
188 } 193 }
189 mode->x = 0; 194 mode->x = 0;
190 mode->y = 0; 195 mode->y = 0;
191 mode->w = w; 196 mode->w = w;
192 mode->h = h; 197 mode->h = h;
193 #ifdef QTOPIA_DEBUG 198 #ifdef QTOPIA_DEBUG
194 fprintf(stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h, index+1); 199 fprintf (stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h,
200 index + 1);
195 #endif 201 #endif
196 202
197 /* Allocate the new list of modes, and fill in the new mode */ 203 /* Allocate the new list of modes, and fill in the new mode */
198 next_mode = SDL_nummodes[index]; 204 next_mode = SDL_nummodes[index];
199 SDL_modelist[index] = (SDL_Rect **) 205 SDL_modelist[index] = (SDL_Rect **)
200 SDL_realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *)); 206 SDL_realloc (SDL_modelist[index],
201 if ( SDL_modelist[index] == NULL ) { 207 (1 + next_mode + 1) * sizeof (SDL_Rect *));
202 SDL_OutOfMemory(); 208 if (SDL_modelist[index] == NULL) {
203 SDL_nummodes[index] = 0; 209 SDL_OutOfMemory ();
204 SDL_free(mode); 210 SDL_nummodes[index] = 0;
205 return(-1); 211 SDL_free (mode);
206 } 212 return (-1);
207 SDL_modelist[index][next_mode] = mode; 213 }
208 SDL_modelist[index][next_mode+1] = NULL; 214 SDL_modelist[index][next_mode] = mode;
209 SDL_nummodes[index]++; 215 SDL_modelist[index][next_mode + 1] = NULL;
210 216 SDL_nummodes[index]++;
211 return(0); 217
212 } 218 return (0);
213 219 }
214 int QT_VideoInit(_THIS, SDL_PixelFormat *vformat) 220
215 { 221 int QT_VideoInit (_THIS, SDL_PixelFormat * vformat)
216 /* Initialize the QPE Application */ 222 {
217 /* Determine the screen depth */ 223 /* Initialize the QPE Application */
218 vformat->BitsPerPixel = QPixmap::defaultDepth(); 224 /* Determine the screen depth */
219 225 vformat->BitsPerPixel = QPixmap::defaultDepth ();
220 // For now we hardcode the current depth because anything else 226
221 // might as well be emulated by SDL rather than by Qtopia. 227 // For now we hardcode the current depth because anything else
222 228 // might as well be emulated by SDL rather than by Qtopia.
223 QSize desktop_size = qApp->desktop()->size(); 229
224 QT_AddMode(_this, ((vformat->BitsPerPixel+7)/8)-1, 230 QSize desktop_size = qApp->desktop ()->size ();
225 desktop_size.width(), desktop_size.height()); 231 QT_AddMode (_this, ((vformat->BitsPerPixel + 7) / 8) - 1,
226 QT_AddMode(_this, ((vformat->BitsPerPixel+7)/8)-1, 232 desktop_size.width (), desktop_size.height ());
227 desktop_size.height(), desktop_size.width()); 233 QT_AddMode (_this, ((vformat->BitsPerPixel + 7) / 8) - 1,
228 234 desktop_size.height (), desktop_size.width ());
229 /* Determine the current screen size */ 235
230 this->info.current_w = desktop_size.width(); 236 /* Determine the current screen size */
231 this->info.current_h = desktop_size.height(); 237 this->info.current_w = desktop_size.width ();
232 238 this->info.current_h = desktop_size.height ();
233 /* Create the window / widget */ 239
234 SDL_Win = new SDL_QWin(QSize(QT_HIDDEN_SIZE, QT_HIDDEN_SIZE)); 240 /* Create the window / widget */
235 ((QPEApplication*)qApp)->showMainWidget(SDL_Win); 241 SDL_Win = new SDL_QWin (QSize (QT_HIDDEN_SIZE, QT_HIDDEN_SIZE));
236 /* Fill in some window manager capabilities */ 242 ((QPEApplication *) qApp)->showMainWidget (SDL_Win);
237 _this->info.wm_available = 0; 243 /* Fill in some window manager capabilities */
238 244 _this->info.wm_available = 0;
239 /* We're done! */ 245
240 return(0); 246 /* We're done! */
241 } 247 return (0);
242 248 }
243 /* We support any dimension at our bit-depth */ 249
244 SDL_Rect **QT_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) 250 /* We support any dimension at our bit-depth */
245 { 251 SDL_Rect **QT_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags)
246 SDL_Rect **modes; 252 {
247 253 SDL_Rect **modes;
248 modes = ((SDL_Rect **)0); 254
249 if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { 255 modes = ((SDL_Rect **) 0);
250 modes = SDL_modelist[((format->BitsPerPixel+7)/8)-1]; 256 if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) {
251 } else { 257 modes = SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1];
252 if ( format->BitsPerPixel == 258 } else {
253 _this->screen->format->BitsPerPixel ) { 259 if (format->BitsPerPixel == _this->screen->format->BitsPerPixel) {
254 modes = ((SDL_Rect **)-1); 260 modes = ((SDL_Rect **) - 1);
255 } 261 }
256 } 262 }
257 return(modes); 263 return (modes);
258 } 264 }
259 265
260 /* Various screen update functions available */ 266 /* Various screen update functions available */
261 static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect *rects); 267 static void QT_NormalUpdate (_THIS, int numrects, SDL_Rect * rects);
262 268
263 269
264 static int QT_SetFullScreen(_THIS, SDL_Surface *screen, int fullscreen) 270 static int QT_SetFullScreen (_THIS, SDL_Surface * screen, int fullscreen)
265 { 271 {
266 return -1; 272 return -1;
267 } 273 }
268 274
269 static int QT_ToggleFullScreen(_THIS, int fullscreen) 275 static int QT_ToggleFullScreen (_THIS, int fullscreen)
270 { 276 {
271 return -1; 277 return -1;
272 } 278 }
273 279
274 /* FIXME: check return values and cleanup here */ 280 /* FIXME: check return values and cleanup here */
275 SDL_Surface *QT_SetVideoMode(_THIS, SDL_Surface *current, 281 SDL_Surface *QT_SetVideoMode (_THIS, SDL_Surface * current,
276 int width, int height, int bpp, Uint32 flags) 282 int width, int height, int bpp,
277 { 283 Uint32 flags)
278 284 {
279 QImage *qimage; 285
280 QSize desktop_size = qApp->desktop()->size(); 286 QImage *qimage;
281 287 QSize desktop_size = qApp->desktop ()->size ();
282 288
283 current->flags = 0; //SDL_FULLSCREEN; // We always run fullscreen. 289
284 290 current->flags = 0; //SDL_FULLSCREEN; // We always run fullscreen.
285 if(width <= desktop_size.width() 291
286 && height <= desktop_size.height()) { 292 if (width <= desktop_size.width ()
287 current->w = desktop_size.width(); 293 && height <= desktop_size.height ()) {
288 current->h = desktop_size.height(); 294 current->w = desktop_size.width ();
289 } else if(width <= desktop_size.height() && height <= desktop_size.width()) { 295 current->h = desktop_size.height ();
290 // Landscape mode 296 } else if (width <= desktop_size.height ()
291 char * envString = SDL_getenv(SDL_QT_ROTATION_ENV_NAME); 297 && height <= desktop_size.width ()) {
292 int envValue = envString ? atoi(envString) : 0; 298 // Landscape mode
293 screenRotation = envValue ? SDL_QT_ROTATION_270 : SDL_QT_ROTATION_90; 299 char *envString = SDL_getenv (SDL_QT_ROTATION_ENV_NAME);
294 current->h = desktop_size.width(); 300 int envValue = envString ? atoi (envString) : 0;
295 current->w = desktop_size.height(); 301 screenRotation =
296 } else { 302 envValue ? SDL_QT_ROTATION_270 : SDL_QT_ROTATION_90;
297 SDL_SetError("Unsupported resolution, %dx%d\n", width, height); 303 current->h = desktop_size.width ();
298 } 304 current->w = desktop_size.height ();
299 if ( flags & SDL_INTERNALOPENGL ) { 305 } else {
300 SDL_SetError("OpenGL not supported"); 306 SDL_SetError ("Unsupported resolution, %dx%d\n", width, height);
301 return(NULL); 307 }
302 } 308 if (flags & SDL_INTERNALOPENGL) {
303 /* Create the QImage framebuffer */ 309 SDL_SetError ("OpenGL not supported");
304 qimage = new QImage(current->w, current->h, bpp); 310 return (NULL);
305 if (qimage->isNull()) { 311 }
306 SDL_SetError("Couldn't create screen bitmap"); 312 /* Create the QImage framebuffer */
307 delete qimage; 313 qimage = new QImage (current->w, current->h, bpp);
308 return(NULL); 314 if (qimage->isNull ()) {
309 } 315 SDL_SetError ("Couldn't create screen bitmap");
310 current->pitch = qimage->bytesPerLine(); 316 delete qimage;
311 current->pixels = (void *)qimage->bits(); 317 return (NULL);
312 SDL_Win->setImage(qimage); 318 }
313 _this->UpdateRects = QT_NormalUpdate; 319 current->pitch = qimage->bytesPerLine ();
314 SDL_Win->setFullscreen(true); 320 current->pixels = (void *) qimage->bits ();
315 /* We're done */ 321 SDL_Win->setImage (qimage);
316 return(current); 322 _this->UpdateRects = QT_NormalUpdate;
317 } 323 SDL_Win->setFullscreen (true);
318 324 /* We're done */
319 /* Update the current mouse state and position */ 325 return (current);
320 void QT_UpdateMouse(_THIS) 326 }
321 { 327
322 QPoint point(-1, -1); 328 /* Update the current mouse state and position */
323 if ( SDL_Win->isActiveWindow() ) { 329 void QT_UpdateMouse (_THIS)
324 point = SDL_Win->mousePos(); 330 {
325 } 331 QPoint point (-1, -1);
326 332 if (SDL_Win->isActiveWindow ()) {
327 if ( (point.x() >= 0) && (point.x() < SDL_VideoSurface->w) && 333 point = SDL_Win->mousePos ();
328 (point.y() >= 0) && (point.y() < SDL_VideoSurface->h) ) { 334 }
329 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); 335
330 SDL_PrivateMouseMotion(0, 0, 336 if ((point.x () >= 0) && (point.x () < SDL_VideoSurface->w) &&
331 (Sint16)point.x(), (Sint16)point.y()); 337 (point.y () >= 0) && (point.y () < SDL_VideoSurface->h)) {
332 } else { 338 SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
333 SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); 339 SDL_PrivateMouseMotion (0, 0,
334 } 340 (Sint16) point.x (), (Sint16) point.y ());
335 } 341 } else {
336 342 SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS);
337 /* We don't actually allow hardware surfaces other than the main one */ 343 }
338 static int QT_AllocHWSurface(_THIS, SDL_Surface *surface) 344 }
339 { 345
340 return(-1); 346 /* We don't actually allow hardware surfaces other than the main one */
341 } 347 static int QT_AllocHWSurface (_THIS, SDL_Surface * surface)
342 static void QT_FreeHWSurface(_THIS, SDL_Surface *surface) 348 {
343 { 349 return (-1);
344 return; 350 }
345 } 351 static void QT_FreeHWSurface (_THIS, SDL_Surface * surface)
346 static int QT_LockHWSurface(_THIS, SDL_Surface *surface) 352 {
347 { 353 return;
348 return(0); 354 }
349 } 355 static int QT_LockHWSurface (_THIS, SDL_Surface * surface)
350 static void QT_UnlockHWSurface(_THIS, SDL_Surface *surface) 356 {
351 { 357 return (0);
352 return; 358 }
353 } 359 static void QT_UnlockHWSurface (_THIS, SDL_Surface * surface)
354 360 {
355 static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) 361 return;
356 { 362 }
357 if(SDL_Win->lockScreen()) { 363
358 for(int i=0; i<numrects; ++i ) { 364 static void QT_NormalUpdate (_THIS, int numrects, SDL_Rect * rects)
359 QRect rect(rects[i].x, rects[i].y, 365 {
360 rects[i].w, rects[i].h); 366 if (SDL_Win->lockScreen ()) {
361 SDL_Win->repaintRect(rect); 367 for (int i = 0; i < numrects; ++i) {
362 } 368 QRect rect (rects[i].x, rects[i].y, rects[i].w, rects[i].h);
363 SDL_Win->unlockScreen(); 369 SDL_Win->repaintRect (rect);
364 } 370 }
365 } 371 SDL_Win->unlockScreen ();
366 /* Is the system palette settable? */ 372 }
367 int QT_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) 373 }
368 { 374 /* Is the system palette settable? */
369 return -1; 375 int QT_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors)
370 } 376 {
371 377 return -1;
372 void QT_VideoQuit(_THIS) 378 }
373 { 379
374 // This is dumb, but if I free this, the app doesn't exit correctly. 380 void QT_VideoQuit (_THIS)
375 // Of course, this will leak memory if init video is done more than once. 381 {
376 // Sucks but such is life. 382 // This is dumb, but if I free this, the app doesn't exit correctly.
377 383 // Of course, this will leak memory if init video is done more than once.
378 // -- David Hedbor 384 // Sucks but such is life.
379 // delete SDL_Win; 385
380 // SDL_Win = 0; 386 // -- David Hedbor
381 _this->screen->pixels = NULL; 387 // delete SDL_Win;
382 QT_GrabInput(_this, SDL_GRAB_OFF); 388 // SDL_Win = 0;
383 } 389 _this->screen->pixels = NULL;
384 390 QT_GrabInput (_this, SDL_GRAB_OFF);
385 static int QT_IconifyWindow(_THIS) { 391 }
386 SDL_Win->hide(); 392
387 393 static int QT_IconifyWindow (_THIS)
388 return true; 394 {
389 } 395 SDL_Win->hide ();
390 396
391 static SDL_GrabMode QT_GrabInput(_THIS, SDL_GrabMode mode) { 397 return true;
392 if(mode == SDL_GRAB_OFF) { 398 }
393 QPEApplication::grabKeyboard(); 399
394 qApp->processEvents(); 400 static SDL_GrabMode QT_GrabInput (_THIS, SDL_GrabMode mode)
395 QPEApplication::ungrabKeyboard(); 401 {
396 } else { 402 if (mode == SDL_GRAB_OFF) {
397 QPEApplication::grabKeyboard(); 403 QPEApplication::grabKeyboard ();
398 } 404 qApp->processEvents ();
399 qApp->processEvents(); 405 QPEApplication::ungrabKeyboard ();
400 return mode; 406 } else {
401 } 407 QPEApplication::grabKeyboard ();
402 408 }
403 }; /* Extern C */ 409 qApp->processEvents ();
410 return mode;
411 }
412
413 }; /* Extern C */
414
415 /* vi: set ts=4 sw=4 expandtab: */