Mercurial > sdl-ios-xcode
comparison src/video/qtopia/SDL_sysvideo.cc @ 1895:c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 10 Jul 2006 21:04:37 +0000 |
parents | 8d9bb0cf2c2a |
children | 8a9b367a80f3 |
comparison
equal
deleted
inserted
replaced
1894:c69cee13dd76 | 1895:c121d94672cb |
---|---|
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, Uint32 flags) |
277 { | 283 { |
278 | 284 |
279 QImage *qimage; | 285 QImage *qimage; |
280 QSize desktop_size = qApp->desktop()->size(); | 286 QSize desktop_size = qApp->desktop()->size(); |
281 | 287 |
282 | 288 |
283 current->flags = 0; //SDL_FULLSCREEN; // We always run fullscreen. | 289 current->flags = 0; //SDL_FULLSCREEN; // We always run fullscreen. |
284 | 290 |
285 if(width <= desktop_size.width() | 291 if (width <= desktop_size.width() |
286 && height <= desktop_size.height()) { | 292 && height <= desktop_size.height()) { |
287 current->w = desktop_size.width(); | 293 current->w = desktop_size.width(); |
288 current->h = desktop_size.height(); | 294 current->h = desktop_size.height(); |
289 } else if(width <= desktop_size.height() && height <= desktop_size.width()) { | 295 } else if (width <= desktop_size.height() |
290 // Landscape mode | 296 && height <= desktop_size.width()) { |
291 char * envString = SDL_getenv(SDL_QT_ROTATION_ENV_NAME); | 297 // Landscape mode |
292 int envValue = envString ? atoi(envString) : 0; | 298 char *envString = SDL_getenv(SDL_QT_ROTATION_ENV_NAME); |
293 screenRotation = envValue ? SDL_QT_ROTATION_270 : SDL_QT_ROTATION_90; | 299 int envValue = envString ? atoi(envString) : 0; |
294 current->h = desktop_size.width(); | 300 screenRotation = |
295 current->w = desktop_size.height(); | 301 envValue ? SDL_QT_ROTATION_270 : SDL_QT_ROTATION_90; |
296 } else { | 302 current->h = desktop_size.width(); |
297 SDL_SetError("Unsupported resolution, %dx%d\n", width, height); | 303 current->w = desktop_size.height(); |
298 } | 304 } else { |
299 if ( flags & SDL_OPENGL ) { | 305 SDL_SetError("Unsupported resolution, %dx%d\n", width, height); |
300 SDL_SetError("OpenGL not supported"); | 306 } |
301 return(NULL); | 307 if (flags & SDL_INTERNALOPENGL) { |
302 } | 308 SDL_SetError("OpenGL not supported"); |
303 /* Create the QImage framebuffer */ | 309 return (NULL); |
304 qimage = new QImage(current->w, current->h, bpp); | 310 } |
305 if (qimage->isNull()) { | 311 /* Create the QImage framebuffer */ |
306 SDL_SetError("Couldn't create screen bitmap"); | 312 qimage = new QImage(current->w, current->h, bpp); |
307 delete qimage; | 313 if (qimage->isNull()) { |
308 return(NULL); | 314 SDL_SetError("Couldn't create screen bitmap"); |
309 } | 315 delete qimage; |
310 current->pitch = qimage->bytesPerLine(); | 316 return (NULL); |
311 current->pixels = (void *)qimage->bits(); | 317 } |
312 SDL_Win->setImage(qimage); | 318 current->pitch = qimage->bytesPerLine(); |
313 _this->UpdateRects = QT_NormalUpdate; | 319 current->pixels = (void *) qimage->bits(); |
314 SDL_Win->setFullscreen(true); | 320 SDL_Win->setImage(qimage); |
315 /* We're done */ | 321 _this->UpdateRects = QT_NormalUpdate; |
316 return(current); | 322 SDL_Win->setFullscreen(true); |
317 } | 323 /* We're done */ |
318 | 324 return (current); |
319 /* Update the current mouse state and position */ | 325 } |
320 void QT_UpdateMouse(_THIS) | 326 |
321 { | 327 /* Update the current mouse state and position */ |
322 QPoint point(-1, -1); | 328 void QT_UpdateMouse(_THIS) |
323 if ( SDL_Win->isActiveWindow() ) { | 329 { |
324 point = SDL_Win->mousePos(); | 330 QPoint point(-1, -1); |
325 } | 331 if (SDL_Win->isActiveWindow()) { |
326 | 332 point = SDL_Win->mousePos(); |
327 if ( (point.x() >= 0) && (point.x() < SDL_VideoSurface->w) && | 333 } |
328 (point.y() >= 0) && (point.y() < SDL_VideoSurface->h) ) { | 334 |
329 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); | 335 if ((point.x() >= 0) && (point.x() < SDL_VideoSurface->w) && |
330 SDL_PrivateMouseMotion(0, 0, | 336 (point.y() >= 0) && (point.y() < SDL_VideoSurface->h)) { |
331 (Sint16)point.x(), (Sint16)point.y()); | 337 SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); |
332 } else { | 338 SDL_PrivateMouseMotion(0, 0, |
333 SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); | 339 (Sint16) point.x(), (Sint16) point.y()); |
334 } | 340 } else { |
335 } | 341 SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); |
336 | 342 } |
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 /* We don't actually allow hardware surfaces other than the main one */ |
340 return(-1); | 346 static int QT_AllocHWSurface(_THIS, SDL_Surface * surface) |
341 } | 347 { |
342 static void QT_FreeHWSurface(_THIS, SDL_Surface *surface) | 348 return (-1); |
343 { | 349 } |
344 return; | 350 static void QT_FreeHWSurface(_THIS, SDL_Surface * surface) |
345 } | 351 { |
346 static int QT_LockHWSurface(_THIS, SDL_Surface *surface) | 352 return; |
347 { | 353 } |
348 return(0); | 354 static int QT_LockHWSurface(_THIS, SDL_Surface * surface) |
349 } | 355 { |
350 static void QT_UnlockHWSurface(_THIS, SDL_Surface *surface) | 356 return (0); |
351 { | 357 } |
352 return; | 358 static void QT_UnlockHWSurface(_THIS, SDL_Surface * surface) |
353 } | 359 { |
354 | 360 return; |
355 static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) | 361 } |
356 { | 362 |
357 if(SDL_Win->lockScreen()) { | 363 static void QT_NormalUpdate(_THIS, int numrects, SDL_Rect * rects) |
358 for(int i=0; i<numrects; ++i ) { | 364 { |
359 QRect rect(rects[i].x, rects[i].y, | 365 if (SDL_Win->lockScreen()) { |
360 rects[i].w, rects[i].h); | 366 for (int i = 0; i < numrects; ++i) { |
361 SDL_Win->repaintRect(rect); | 367 QRect rect(rects[i].x, rects[i].y, rects[i].w, rects[i].h); |
362 } | 368 SDL_Win->repaintRect(rect); |
363 SDL_Win->unlockScreen(); | 369 } |
364 } | 370 SDL_Win->unlockScreen(); |
365 } | 371 } |
366 /* Is the system palette settable? */ | 372 } |
367 int QT_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | 373 /* Is the system palette settable? */ |
368 { | 374 int QT_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) |
369 return -1; | 375 { |
370 } | 376 return -1; |
371 | 377 } |
372 void QT_VideoQuit(_THIS) | 378 |
373 { | 379 void QT_VideoQuit(_THIS) |
374 // This is dumb, but if I free this, the app doesn't exit correctly. | 380 { |
375 // Of course, this will leak memory if init video is done more than once. | 381 // This is dumb, but if I free this, the app doesn't exit correctly. |
376 // Sucks but such is life. | 382 // Of course, this will leak memory if init video is done more than once. |
377 | 383 // Sucks but such is life. |
378 // -- David Hedbor | 384 |
379 // delete SDL_Win; | 385 // -- David Hedbor |
380 // SDL_Win = 0; | 386 // delete SDL_Win; |
381 _this->screen->pixels = NULL; | 387 // SDL_Win = 0; |
382 QT_GrabInput(_this, SDL_GRAB_OFF); | 388 _this->screen->pixels = NULL; |
383 } | 389 QT_GrabInput(_this, SDL_GRAB_OFF); |
384 | 390 } |
385 static int QT_IconifyWindow(_THIS) { | 391 |
386 SDL_Win->hide(); | 392 static int QT_IconifyWindow(_THIS) |
387 | 393 { |
388 return true; | 394 SDL_Win->hide(); |
389 } | 395 |
390 | 396 return true; |
391 static SDL_GrabMode QT_GrabInput(_THIS, SDL_GrabMode mode) { | 397 } |
392 if(mode == SDL_GRAB_OFF) { | 398 |
393 QPEApplication::grabKeyboard(); | 399 static SDL_GrabMode QT_GrabInput(_THIS, SDL_GrabMode mode) |
394 qApp->processEvents(); | 400 { |
395 QPEApplication::ungrabKeyboard(); | 401 if (mode == SDL_GRAB_OFF) { |
396 } else { | 402 QPEApplication::grabKeyboard(); |
397 QPEApplication::grabKeyboard(); | 403 qApp->processEvents(); |
398 } | 404 QPEApplication::ungrabKeyboard(); |
399 qApp->processEvents(); | 405 } else { |
400 return mode; | 406 QPEApplication::grabKeyboard(); |
401 } | 407 } |
402 | 408 qApp->processEvents(); |
403 }; /* Extern C */ | 409 return mode; |
410 } | |
411 | |
412 }; /* Extern C */ | |
413 | |
414 /* vi: set ts=4 sw=4 expandtab: */ |