# HG changeset patch # User Sam Lantinga # Date 1071059756 0 # Node ID b14fdadd8311835f1accb5647c3322a715aa3117 # Parent 4bb432a0f6e09f1bf6203a60308e96fb5894fd5d Date: Thu, 4 Dec 2003 07:48:40 +0200 From: "Mike Gorchak" Subject: SDL/QNX6 new patch Here in attachment my patch for the SDL/QNX6 again :) It contain non-crtitical/cosmetic fixes: 1. Fixed window centering at other than the first consoles. 2. Fixed window centering algorithm in case when window height or width are greater than the desktop resolution. 3. Fixed window positioning on other than the first consoles. 4. Fixed occasional input focus lost when switching to fullscreen. 5. Removed the Photon's default chroma color for the overlays, added RGB(12, 6, 12) color instead (very dark pink). 6. Added more checks to the YUV overlay code (fixed crashes during resolution mode switches). 7. Added support for Enter/Backspace keys in unicode mode (used by Maelstrom and by other games). 8. Fixed window restore/maximize function. It works, finally. diff -r 4bb432a0f6e0 -r b14fdadd8311 README.QNX --- a/README.QNX Wed Dec 10 12:32:38 2003 +0000 +++ b/README.QNX Wed Dec 10 12:35:56 2003 +0000 @@ -1,5 +1,16 @@ README by Mike Gorchak , -Last changed at 12 Aug 2003. +Last changed at 30 Sep 2003. + +====================================================================== +Table of Contents: + +1. OpenGL. +2. Wheel and multi-button mouses. +3. CDROM handling issues. +4. Hardware video overlays. +5. Shared library building. +6. Some building issues. +7. Environment variables. ====================================================================== OpenGL: @@ -14,7 +25,7 @@ cially selected (QSSL made acceleration only for Voodoo boards in fullscreen mode, sorry but I don't have this board to test OpenGL - maybe it works or maybe not :)). If you want acceleration - you can -remove one line in the source code: find the file SDL_ph_video.c and +remove one line in the source code: find the file SDL_ph_image.c and remove the following OGLAttrib[OGLargc++]=PHOGL_ATTRIB_FORCE_SW; @@ -50,7 +61,7 @@ root:root rights. ====================================================================== -Video Overlays: +Hardware video overlays: Overlays can flicker during window movement, resizing, etc. It happens because the photon driver updates the real window contents be- @@ -77,8 +88,11 @@ script you must manually delete the libtool.m4 stuff from the acinclu- de.m4 file (it comes after the ESD detection code up to the end of the file), because the libtool stuff in the acinclude.m4 file is very old -and doesn't know anything about QNX. Just remove it, then run -"libtoolize --force --copy" and after that run the autogen.sh script. +in SDL distribution before the version 1.2.7 and doesn't know anything +about QNX. SDL 1.2.7 distribution contain the new libtool.m4 script, +but anyway it is broken :), Just remove it, then run "libtoolize +--force --copy", delete the file aclocal.m4 and after that run the +autogen.sh script. ====================================================================== Some building issues: @@ -107,3 +121,24 @@ ./configure --with-sdl-prefix=/usr \ --with-sdl-exec-prefix=/usr \ --prefix=/usr --without-x + +====================================================================== +Environment variables: + + Please note that the photon driver is sensible to the following +environmental variables: + + * SDL_VIDEO_WINDOW_POS - can be set in the "X,Y" format. If X and Y +coordinates are bigger than the current desktop resolution, then win- +dow positioning across virtual consoles is activated. If X and Y are +smaller than the desktop resolution then window positioning in the +current console is activated. The word "center" can be used instead of +coordinates, it produces the same behavior as SDL_VIDEO_CENTERED +environmental variable. + + * SDL_VIDEO_CENTERED - if this environmental variable exists then the +window centering is perfomed in the current virtual console. + + The SDL_VIDEO_CENTERED enviromental variable has greater priority +than the SDL_VIDEO_WINDOW_POS in case if both variables are supplied +to the application. diff -r 4bb432a0f6e0 -r b14fdadd8311 SDL.qpg.in --- a/SDL.qpg.in Wed Dec 10 12:32:38 2003 +0000 +++ b/SDL.qpg.in Wed Dec 10 12:35:56 2003 +0000 @@ -62,7 +62,7 @@ - SDL + Simple DirectMedia Layer (SDL) SDL slouken@libsdl.org public @@ -95,10 +95,11 @@ Software Development/Libraries and Extensions/C Libraries - SDL, audio, graphics, demos, games, emulators, media, layer + SDL, audio, graphics, demos, games, emulators, direct, media, layer qnx6 none Photon + Console Developer User diff -r 4bb432a0f6e0 -r b14fdadd8311 configure.in --- a/configure.in Wed Dec 10 12:32:38 2003 +0000 +++ b/configure.in Wed Dec 10 12:35:56 2003 +0000 @@ -1582,7 +1582,9 @@ if test x$use_dlopen = xyes; then CFLAGS="$CFLAGS -DUSE_DLOPEN" - AC_CHECK_LIB(dl, dlopen, SYSTEM_LIBS="$SYSTEM_LIBS -ldl", AC_CHECK_LIB(ltdl, dlopen, SYSTEM_LIBS="$SYSTEM_LIBS -lltdl")) + AC_CHECK_LIB(c, dlopen, SYSTEM_LIBS="$SYSTEM_LIBS", + AC_CHECK_LIB(dl, dlopen, SYSTEM_LIBS="$SYSTEM_LIBS -ldl", + AC_CHECK_LIB(ltdl, dlopen, SYSTEM_LIBS="$SYSTEM_LIBS -lltdl"))) fi fi } diff -r 4bb432a0f6e0 -r b14fdadd8311 src/video/photon/SDL_ph_events.c --- a/src/video/photon/SDL_ph_events.c Wed Dec 10 12:32:38 2003 +0000 +++ b/src/video/photon/SDL_ph_events.c Wed Dec 10 12:35:56 2003 +0000 @@ -217,12 +217,12 @@ set_motion_sensitivity(this, -1); posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); } - /* request to quit */ + /* quit request */ else if (winEvent->event_f==Ph_WM_CLOSE) { posted = SDL_PrivateQuit(); } - /* request to hide/unhide */ + /* hide/unhide request */ else if (winEvent->event_f==Ph_WM_HIDE) { if (currently_hided) @@ -241,7 +241,7 @@ /* request to resize */ else if (winEvent->event_f==Ph_WM_RESIZE) { - SDL_PrivateResize(winEvent->size.w, winEvent->size.h); + SDL_PrivateResize(winEvent->size.w+1, winEvent->size.h+1); } /* request to move */ else if (winEvent->event_f==Ph_WM_MOVE) @@ -250,6 +250,7 @@ { int lockedstate=current_overlay->hwdata->locked; int chromastate=current_overlay->hwdata->ischromakey; + int error; SDL_Rect target; current_overlay->hwdata->locked=1; @@ -258,20 +259,25 @@ target.w=current_overlay->hwdata->CurrentViewPort.size.w; target.h=current_overlay->hwdata->CurrentViewPort.size.h; current_overlay->hwdata->ischromakey=0; - ph_DisplayYUVOverlay(this, current_overlay, &target); - current_overlay->hwdata->ischromakey=chromastate; - current_overlay->hwdata->locked=lockedstate; + error=ph_DisplayYUVOverlay(this, current_overlay, &target); + if (!error) + { + current_overlay->hwdata->ischromakey=chromastate; + current_overlay->hwdata->locked=lockedstate; + } } } - /* request to maximize */ + /* maximize request */ else if (winEvent->event_f==Ph_WM_MAX) { /* window already moved and resized here */ - SDL_PrivateResize(winEvent->size.w-winEvent->pos.x, winEvent->size.h-winEvent->pos.y); + currently_maximized=1; } - /* request to restore */ + /* restore request */ else if (winEvent->event_f==Ph_WM_RESTORE) { + /* window already moved and resized here */ + currently_maximized=0; } } break; @@ -285,7 +291,7 @@ { rect = PhGetRects(event); - for(i=0;inum_rects;i++) + for(i=0; inum_rects; i++) { sdlrects[i].x = rect[i].ul.x; sdlrects[i].y = rect[i].ul.y; @@ -298,6 +304,7 @@ if (current_overlay!=NULL) { int lockedstate=current_overlay->hwdata->locked; + int error; SDL_Rect target; current_overlay->hwdata->locked=1; @@ -306,9 +313,12 @@ target.w=current_overlay->hwdata->CurrentViewPort.size.w; target.h=current_overlay->hwdata->CurrentViewPort.size.h; current_overlay->hwdata->forcedredraw=1; - ph_DisplayYUVOverlay(this, current_overlay, &target); - current_overlay->hwdata->forcedredraw=0; - current_overlay->hwdata->locked=lockedstate; + error=ph_DisplayYUVOverlay(this, current_overlay, &target); + if (!error) + { + current_overlay->hwdata->forcedredraw=0; + current_overlay->hwdata->locked=lockedstate; + } } } } @@ -355,6 +365,11 @@ } } break; + + case Ph_EV_INFO: + { + } + break; } return(posted); @@ -542,13 +557,20 @@ switch (keysym->scancode) { + /* Esc key */ case 0x01: keysym->unicode = 27; break; + /* BackSpace key */ + case 0x0E: keysym->unicode = 127; + break; + /* Enter key */ + case 0x1C: keysym->unicode = 10; + break; default: utf8len = PhKeyToMb(utf8, key); if (utf8len > 0) { - utf8len = mbtowc(&unicode, utf8, utf8len); + utf8len = mbtowc(&unicode, utf8, utf8len); if (utf8len > 0) { keysym->unicode = unicode; diff -r 4bb432a0f6e0 -r b14fdadd8311 src/video/photon/SDL_ph_video.c --- a/src/video/photon/SDL_ph_video.c Wed Dec 10 12:32:38 2003 +0000 +++ b/src/video/photon/SDL_ph_video.c Wed Dec 10 12:35:56 2003 +0000 @@ -186,7 +186,7 @@ { PtWidget_t *widget; - widget = PtCreateWidget(PtWindow, NULL, 0, 0); + widget = PtCreateWidget(PtWindow, NULL, 0, NULL); return widget; } @@ -195,20 +195,28 @@ { PtArg_t args[32]; PhPoint_t pos = {0, 0}; + PhDim_t* olddim; PhDim_t dim = {w, h}; + PhRect_t desktopextent; int nargs = 0; const char* windowpos; const char* iscentered; int x, y; - PtSetArg(&args[nargs++], Pt_ARG_DIM, &dim, 0); + /* check if window size has been changed by Window Manager */ + PtGetResource(window, Pt_ARG_DIM, &olddim, 0); + if ((olddim->w!=w) || (olddim->h!=h)) + { + PtSetArg(&args[nargs++], Pt_ARG_DIM, &dim, 0); + } if ((flags & SDL_RESIZABLE) == SDL_RESIZABLE) { - PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_CLOSE); - PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_MAX | Ph_WM_RESTORE); - PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_RESIZE | Ph_WM_MOVE | Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_CLOSE); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_RESIZE); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_RESIZE | Ph_WM_MOVE | Ph_WM_CLOSE | Ph_WM_MAX | Ph_WM_RESTORE); PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN); + PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, Pt_RESIZE_XY_AS_REQUIRED); } else { @@ -216,6 +224,7 @@ PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE); PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_MOVE | Ph_WM_CLOSE); PtSetArg(&args[nargs++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX | Ph_WM_RENDER_COLLAPSE | Ph_WM_RENDER_RETURN); + PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED); } if (((flags & SDL_NOFRAME)==SDL_NOFRAME) || ((flags & SDL_FULLSCREEN)==SDL_FULLSCREEN)) @@ -240,39 +249,71 @@ { PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0); PtSetArg(&args[nargs++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, Pt_BASIC_PREVENT_FILL); - PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_FFRONT | Ph_WM_MAX); + PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_FFRONT | Ph_WM_MAX | Ph_WM_TOFRONT | Ph_WM_CONSWITCH); PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS | Ph_WM_STATE_ISALTKEY); } else { - windowpos = getenv("SDL_VIDEO_WINDOW_POS"); - iscentered = getenv("SDL_VIDEO_CENTERED"); - - if ((iscentered) || ((windowpos) && (strcmp(windowpos, "center")==0))) + if (!currently_maximized) { - pos.x = (desktop_mode.width - w)/2; - pos.y = (desktop_mode.height - h)/2; - PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0); - } + windowpos = getenv("SDL_VIDEO_WINDOW_POS"); + iscentered = getenv("SDL_VIDEO_CENTERED"); + + if ((iscentered) || ((windowpos) && (strcmp(windowpos, "center")==0))) + { + PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, 0, &desktopextent); + if (desktop_mode.width>w) + { + pos.x = (desktop_mode.width - w)/2; + } + if (desktop_mode.height>h) + { + pos.y = (desktop_mode.height - h)/2; + } + + pos.x+=desktopextent.ul.x; + pos.y+=desktopextent.ul.y; + PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0); + } + else + { + if (windowpos) + { + if (sscanf(windowpos, "%d,%d", &x, &y) == 2) + { + if ((xinfo.wm_available = 1; diff -r 4bb432a0f6e0 -r b14fdadd8311 src/video/photon/SDL_ph_video.h --- a/src/video/photon/SDL_ph_video.h Wed Dec 10 12:32:38 2003 +0000 +++ b/src/video/photon/SDL_ph_video.h Wed Dec 10 12:35:56 2003 +0000 @@ -62,7 +62,8 @@ }; /* Private display data */ -struct SDL_PrivateVideoData { +struct SDL_PrivateVideoData +{ PgDisplaySettings_t mode_settings; PtWidget_t *Window; /* used to handle input events */ PhImage_t *image; /* used to display image */ @@ -96,12 +97,13 @@ int mouse_relative; WMcursor* BlankCursor; - Uint32 depth; /* current visual depth (not bpp) */ - Uint32 desktopbpp; /* bpp of desktop at the moment of start */ - Uint32 desktoppal; /* palette mode emulation or system */ + Uint32 depth; /* current visual depth (not bpp) */ + Uint32 desktopbpp; /* bpp of desktop at the moment of start */ + Uint32 desktoppal; /* palette mode emulation or system */ int currently_fullscreen; - int currently_hided; /* 1 - window hided (minimazed), 0 - normal */ + int currently_hided; /* 1 - window hided (minimazed), 0 - normal */ + int currently_maximized; /* 1 - window hided (minimazed), 0 - normal */ PhEvent_t* event; SDL_Overlay* overlay; @@ -120,6 +122,7 @@ #define syspalph (this->hidden->syspalph) #define currently_fullscreen (this->hidden->currently_fullscreen) #define currently_hided (this->hidden->currently_hided) +#define currently_maximized (this->hidden->currently_maximized) #define event (this->hidden->event) #define current_overlay (this->hidden->overlay) #define desktop_mode (this->hidden->desktop_mode) diff -r 4bb432a0f6e0 -r b14fdadd8311 src/video/photon/SDL_ph_wm.c --- a/src/video/photon/SDL_ph_wm.c Wed Dec 10 12:32:38 2003 +0000 +++ b/src/video/photon/SDL_ph_wm.c Wed Dec 10 12:35:56 2003 +0000 @@ -43,9 +43,6 @@ #include "SDL_ph_modes_c.h" #include "SDL_ph_wm_c.h" -/* This is necessary for working properly with Enlightenment, etc. */ -#define USE_ICON_WINDOW - void ph_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) { return; diff -r 4bb432a0f6e0 -r b14fdadd8311 src/video/photon/SDL_phyuv.c --- a/src/video/photon/SDL_phyuv.c Wed Dec 10 12:32:38 2003 +0000 +++ b/src/video/photon/SDL_phyuv.c Wed Dec 10 12:35:56 2003 +0000 @@ -182,7 +182,9 @@ overlay->hwdata->props.src_dim.w = width; overlay->hwdata->props.src_dim.h = height; - overlay->hwdata->chromakey = PgGetOverlayChromaColor(); + /* overlay->hwdata->chromakey = PgGetOverlayChromaColor(); */ + overlay->hwdata->chromakey = PgRGB(12, 6, 12); /* very dark pink color */ + overlay->hwdata->props.color_key = overlay->hwdata->chromakey; PhAreaToRect(&overlay->hwdata->CurrentViewPort, &overlay->hwdata->props.viewport); @@ -191,6 +193,7 @@ if ((overlay->hwdata->ischromakey)&&(overlay->hwdata->chromakey)) { overlay->hwdata->props.flags |= Pg_SCALER_PROP_CHROMA_ENABLE; + overlay->hwdata->props.flags |= Pg_SCALER_PROP_CHROMA_SPECIFY_KEY_MASK; } else { @@ -286,7 +289,7 @@ { if (overlay == NULL) { - return 0; + return -1; } overlay->hwdata->locked = 1; @@ -332,7 +335,7 @@ { if (overlay == NULL) { - return; + return; } overlay->hwdata->locked = 0; @@ -406,9 +409,9 @@ switch(rtncode) { case -1: - SDL_SetError("PgConfigScalerChannel failed\n"); + SDL_SetError("PgConfigScalerChannel() function failed\n"); SDL_FreeYUVOverlay(overlay); - return (0); + return -1; case 1: grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1); break; diff -r 4bb432a0f6e0 -r b14fdadd8311 test/testoverlay2.c --- a/test/testoverlay2.c Wed Dec 10 12:32:38 2003 +0000 +++ b/test/testoverlay2.c Wed Dec 10 12:35:56 2003 +0000 @@ -275,6 +275,7 @@ SDL_Event event; Uint32 lastftick; int paused=0; + int resized=0; int i; int fps=12; int fpsdelay; @@ -505,6 +506,10 @@ screen=SDL_SetVideoMode(event.resize.w, event.resize.h, 0, SDL_RESIZABLE | SDL_SWSURFACE); overlayrect.w=event.resize.w; overlayrect.h=event.resize.h; + if (paused) + { + resized=1; + } break; case SDL_KEYDOWN: if (event.key.keysym.sym == SDLK_SPACE) @@ -526,9 +531,9 @@ } } - if (!paused) + if ((!paused)||(resized)) { - if ((SDL_GetTicks()-lastftick)>fpsdelay) + if (((SDL_GetTicks()-lastftick)>fpsdelay)||(resized)) { lastftick=SDL_GetTicks(); @@ -552,10 +557,17 @@ } SDL_DisplayYUVOverlay(overlay, &overlayrect); - i++; - if (i==10) + if (!resized) { - i=0; + i++; + if (i==10) + { + i=0; + } + } + else + { + resized=0; } } } diff -r 4bb432a0f6e0 -r b14fdadd8311 test/testsprite.c --- a/test/testsprite.c Wed Dec 10 12:32:38 2003 +0000 +++ b/test/testsprite.c Wed Dec 10 12:35:56 2003 +0000 @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "SDL.h"