comparison src/video/photon/SDL_ph_video.c @ 692:04dd6c6d7c30

Date: Fri, 15 Aug 2003 09:13:59 +0300 From: "Mike Gorchak" Subject: Patches for tests and QNX6 Here more fixes for the QNX6 in sdlqnx.diff file: - Spellchecked README.QNX (thanks to Julian Kinraid) - Fixed bugs in fullscreen mode: window region wasn't on top by default, so \ it caused some artifacts to be appeared on the screen, prevent window conten\ ts default filler in Photon while in fullscreen mode, it damages the screen. - Added support for the SDL_VIDEO_WINDOW_POS, SDL_VIDEO_CENTERED env variabl\ es. - Some minor code restructurization.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 23 Aug 2003 23:20:21 +0000
parents 8bedd6d61642
children aaf3b8af6616
comparison
equal deleted inserted replaced
691:609543e2b3a1 692:04dd6c6d7c30
192 { 192 {
193 PtArg_t args[32]; 193 PtArg_t args[32];
194 PhPoint_t pos = {0, 0}; 194 PhPoint_t pos = {0, 0};
195 PhDim_t dim = {w, h}; 195 PhDim_t dim = {w, h};
196 int nargs = 0; 196 int nargs = 0;
197 const char* windowpos;
198 const char* iscentered;
199 int x, y;
197 200
198 PtSetArg(&args[nargs++], Pt_ARG_DIM, &dim, 0); 201 PtSetArg(&args[nargs++], Pt_ARG_DIM, &dim, 0);
199 PtSetArg(&args[nargs++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0);
200 202
201 if ((flags & SDL_RESIZABLE) == SDL_RESIZABLE) 203 if ((flags & SDL_RESIZABLE) == SDL_RESIZABLE)
202 { 204 {
203 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_CLOSE); 205 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_CLOSE);
204 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_MAX | Ph_WM_RESTORE); 206 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_MAX | Ph_WM_RESTORE);
232 } 234 }
233 235
234 if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) 236 if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN)
235 { 237 {
236 PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0); 238 PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
239 PtSetArg(&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, Pt_BASIC_PREVENT_FILL);
237 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_FFRONT | Ph_WM_MAX); 240 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_FFRONT | Ph_WM_MAX);
238 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISMAX | 241 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS | Ph_WM_STATE_ISALTKEY);
239 Ph_WM_STATE_ISFOCUS | Ph_WM_STATE_ISALTKEY); 242 }
240 } 243 else
241 else 244 {
242 { 245 windowpos = getenv("SDL_VIDEO_WINDOW_POS");
246 iscentered = getenv("SDL_VIDEO_CENTERED");
247
248 if ((iscentered) || ((windowpos) && (strcmp(windowpos, "center")==0)))
249 {
250 pos.x = (desktop_mode.width - w)/2;
251 pos.y = (desktop_mode.height - h)/2;
252 PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
253 }
254 else
255 {
256 if (windowpos)
257 {
258 if (sscanf(windowpos, "%d,%d", &x, &y) == 2 )
259 {
260 pos.x=x;
261 pos.y=y;
262 PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
263 }
264 }
265 }
266
267
268 PtSetArg(&args[nargs++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0);
243 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISMAX | Ph_WM_STATE_ISALTKEY); 269 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISMAX | Ph_WM_STATE_ISALTKEY);
244 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_HIDE); 270 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_HIDE);
245 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_HIDE); 271 PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_HIDE);
246 PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED); 272 PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED);
247 } 273 }
248 274
249 PtSetResources(window, nargs, args); 275 PtSetResources(window, nargs, args);
250 PtRealizeWidget(window); 276 PtRealizeWidget(window);
277 PtWindowToFront(window);
251 278
252 return 0; 279 return 0;
253 } 280 }
254 281
255 static const struct ColourMasks* ph_GetColourMasks(int bpp) 282 static const struct ColourMasks* ph_GetColourMasks(int bpp)
279 return NULL; 306 return NULL;
280 } 307 }
281 308
282 static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat) 309 static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)
283 { 310 {
284 PgVideoModeInfo_t my_mode_info;
285 PgHWCaps_t my_hwcaps; 311 PgHWCaps_t my_hwcaps;
286 int i; 312 int i;
287 313
288 window=NULL; 314 window=NULL;
289 desktoppal=SDLPH_PAL_NONE; 315 desktoppal=SDLPH_PAL_NONE;
323 SDL_SetError("ph_VideoInit(): GetGraphicsHWCaps function failed !\n"); 349 SDL_SetError("ph_VideoInit(): GetGraphicsHWCaps function failed !\n");
324 this->FreeWMCursor(this, SDL_BlankCursor); 350 this->FreeWMCursor(this, SDL_BlankCursor);
325 return -1; 351 return -1;
326 } 352 }
327 353
328 if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &my_mode_info) < 0) 354 if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &desktop_mode) < 0)
329 { 355 {
330 SDL_SetError("ph_VideoInit(): PgGetVideoModeInfo function failed !\n"); 356 SDL_SetError("ph_VideoInit(): PgGetVideoModeInfo function failed !\n");
331 this->FreeWMCursor(this, SDL_BlankCursor); 357 this->FreeWMCursor(this, SDL_BlankCursor);
332 return -1; 358 return -1;
333 } 359 }
334 360
335 /* We need to return BytesPerPixel as it in used by CreateRGBsurface */ 361 /* We need to return BytesPerPixel as it in used by CreateRGBsurface */
336 vformat->BitsPerPixel = my_mode_info.bits_per_pixel; 362 vformat->BitsPerPixel = desktop_mode.bits_per_pixel;
337 vformat->BytesPerPixel = my_mode_info.bytes_per_scanline/my_mode_info.width; 363 vformat->BytesPerPixel = desktop_mode.bytes_per_scanline/desktop_mode.width;
338 desktopbpp = my_mode_info.bits_per_pixel; 364 desktopbpp = desktop_mode.bits_per_pixel;
339 365
340 /* save current palette */ 366 /* save current palette */
341 if (desktopbpp==8) 367 if (desktopbpp==8)
342 { 368 {
343 PgGetPalette(savedpal); 369 PgGetPalette(savedpal);
432 { 458 {
433 desktoppal=SDLPH_PAL_SYSTEM; 459 desktoppal=SDLPH_PAL_SYSTEM;
434 } 460 }
435 461
436 current->flags &= ~SDL_RESIZABLE; /* no resize for Direct Context */ 462 current->flags &= ~SDL_RESIZABLE; /* no resize for Direct Context */
463 current->flags |= SDL_HWSURFACE;
437 } 464 }
438 else 465 else
439 { 466 {
440 /* remove this if we'll support non-fullscreen sw/hw+doublebuf */ 467 /* remove this if we'll support non-fullscreen sw/hw+doublebuf */
441 current->flags &= ~SDL_DOUBLEBUF; 468 current->flags &= ~SDL_DOUBLEBUF;
485 512
486 /* finish window drawing, if we are not in fullscreen, of course */ 513 /* finish window drawing, if we are not in fullscreen, of course */
487 if ((current->flags & SDL_FULLSCREEN) != SDL_FULLSCREEN) 514 if ((current->flags & SDL_FULLSCREEN) != SDL_FULLSCREEN)
488 { 515 {
489 PtFlush(); 516 PtFlush();
517 }
518 else
519 {
520 PgFlush();
490 } 521 }
491 522
492 SDL_Unlock_EventThread(); 523 SDL_Unlock_EventThread();
493 524
494 /* We're done! */ 525 /* We're done! */