Skip to content

Commit

Permalink
Date: Thu, 4 Dec 2003 07:48:40 +0200
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
slouken committed Dec 10, 2003
1 parent ede9eb3 commit d39649a
Show file tree
Hide file tree
Showing 10 changed files with 183 additions and 66 deletions.
45 changes: 40 additions & 5 deletions README.QNX
@@ -1,5 +1,16 @@
README by Mike Gorchak <mike@malva.ua>, <lestat@i.com.ua>
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:
Expand All @@ -14,7 +25,7 @@ below 6.1.0 are not supported.
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;
Expand Down Expand Up @@ -50,7 +61,7 @@ can't do anything about that, /dev/cd0 has brw------- permissions and
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-
Expand All @@ -77,8 +88,11 @@ Shared library building:
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:
Expand Down Expand Up @@ -107,3 +121,24 @@ x11 support, e.g.:
./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.
5 changes: 3 additions & 2 deletions SDL.qpg.in
Expand Up @@ -62,7 +62,7 @@
</QPM:PackageDescription>

<QPM:ProductDescription>
<QPM:ProductName>SDL</QPM:ProductName>
<QPM:ProductName>Simple DirectMedia Layer (SDL)</QPM:ProductName>
<QPM:ProductIdentifier>SDL</QPM:ProductIdentifier>
<QPM:ProductEmail>slouken@libsdl.org</QPM:ProductEmail>
<QPM:VendorName>public</QPM:VendorName>
Expand Down Expand Up @@ -95,10 +95,11 @@

<QPM:ContentDescription>
<QPM:ContentTopic xmlmultiple="true">Software Development/Libraries and Extensions/C Libraries</QPM:ContentTopic>
<QPM:ContentKeyword>SDL, audio, graphics, demos, games, emulators, media, layer</QPM:ContentKeyword>
<QPM:ContentKeyword>SDL, audio, graphics, demos, games, emulators, direct, media, layer</QPM:ContentKeyword>
<QPM:TargetOS>qnx6</QPM:TargetOS>
<QPM:HostOS>none</QPM:HostOS>
<QPM:DisplayEnvironment xmlmultiple="true">Photon</QPM:DisplayEnvironment>
<QPM:DisplayEnvironment xmlmultiple="true">Console</QPM:DisplayEnvironment>
<QPM:TargetAudience xmlmultiple="true">Developer</QPM:TargetAudience>
<QPM:TargetAudience xmlmultiple="true">User</QPM:TargetAudience>
</QPM:ContentDescription>
Expand Down
4 changes: 3 additions & 1 deletion configure.in
Expand Up @@ -1582,7 +1582,9 @@ CheckDLOPEN()

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
}
Expand Down
50 changes: 36 additions & 14 deletions src/video/photon/SDL_ph_events.c
Expand Up @@ -217,12 +217,12 @@ static int ph_DispatchEvent(_THIS)
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)
Expand All @@ -241,7 +241,7 @@ static int ph_DispatchEvent(_THIS)
/* 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)
Expand All @@ -250,6 +250,7 @@ static int ph_DispatchEvent(_THIS)
{
int lockedstate=current_overlay->hwdata->locked;
int chromastate=current_overlay->hwdata->ischromakey;
int error;
SDL_Rect target;

current_overlay->hwdata->locked=1;
Expand All @@ -258,20 +259,25 @@ static int ph_DispatchEvent(_THIS)
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;
Expand All @@ -285,7 +291,7 @@ static int ph_DispatchEvent(_THIS)
{
rect = PhGetRects(event);

for(i=0;i<event->num_rects;i++)
for(i=0; i<event->num_rects; i++)
{
sdlrects[i].x = rect[i].ul.x;
sdlrects[i].y = rect[i].ul.y;
Expand All @@ -298,6 +304,7 @@ static int ph_DispatchEvent(_THIS)
if (current_overlay!=NULL)
{
int lockedstate=current_overlay->hwdata->locked;
int error;
SDL_Rect target;

current_overlay->hwdata->locked=1;
Expand All @@ -306,9 +313,12 @@ static int ph_DispatchEvent(_THIS)
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;
}
}
}
}
Expand Down Expand Up @@ -355,6 +365,11 @@ static int ph_DispatchEvent(_THIS)
}
}
break;

case Ph_EV_INFO:
{
}
break;
}

return(posted);
Expand Down Expand Up @@ -542,13 +557,20 @@ SDL_keysym *ph_TranslateKey(PhKeyEvent_t *key, SDL_keysym *keysym)

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;
Expand Down
93 changes: 67 additions & 26 deletions src/video/photon/SDL_ph_video.c
Expand Up @@ -186,7 +186,7 @@ static PtWidget_t *ph_CreateWindow(_THIS)
{
PtWidget_t *widget;

widget = PtCreateWidget(PtWindow, NULL, 0, 0);
widget = PtCreateWidget(PtWindow, NULL, 0, NULL);

return widget;
}
Expand All @@ -195,27 +195,36 @@ static int ph_SetupWindow(_THIS, int w, int h, int flags)
{
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
{
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_CLOSE);
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))
Expand All @@ -240,39 +249,71 @@ static int ph_SetupWindow(_THIS, int w, int h, int flags)
{
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);
}
else
{
if (windowpos)
windowpos = getenv("SDL_VIDEO_WINDOW_POS");
iscentered = getenv("SDL_VIDEO_CENTERED");

if ((iscentered) || ((windowpos) && (strcmp(windowpos, "center")==0)))
{
if (sscanf(windowpos, "%d,%d", &x, &y) == 2 )
PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, 0, &desktopextent);
if (desktop_mode.width>w)
{
pos.x=x;
pos.y=y;
PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
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 ((x<desktop_mode.width) && (y<desktop_mode.height))
{
PhWindowQueryVisible(Ph_QUERY_CONSOLE, 0, 0, &desktopextent);
pos.x=x+desktopextent.ul.x;
pos.y=y+desktopextent.ul.y;
}
PtSetArg(&args[nargs++], Pt_ARG_POS, &pos, 0);
}
}
}
}

PtSetArg(&args[nargs++], Pt_ARG_FILL_COLOR, Pg_BLACK, 0);
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISMAX | Ph_WM_STATE_ISALTKEY);

/* if window is maximized render it as maximized */
if (currently_maximized)
{
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISMAX);
}
else
{
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISMAX);
}

/* do not grab the keyboard by default */
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_FALSE, Ph_WM_STATE_ISALTKEY);

/* bring the focus to the window */
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFOCUS);

/* allow to catch hide events */
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_HIDE);
PtSetArg(&args[nargs++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_HIDE);
PtSetArg(&args[nargs++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED);
}

PtSetResources(window, nargs, args);
Expand Down Expand Up @@ -386,6 +427,7 @@ static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)

currently_fullscreen = 0;
currently_hided = 0;
currently_maximized = 0;
current_overlay = NULL;

OCImage.direct_context = NULL;
Expand All @@ -395,7 +437,6 @@ static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)
OCImage.CurrentFrameData = NULL;
OCImage.FrameData0 = NULL;
OCImage.FrameData1 = NULL;


this->info.wm_available = 1;

Expand Down

0 comments on commit d39649a

Please sign in to comment.