Date: Thu, 28 Mar 2002 09:20:03 +0200
authorSam Lantinga <slouken@libsdl.org>
Thu, 28 Mar 2002 16:20:10 +0000
changeset 32066f815c147ed
parent 319 189a6a3416c7
child 321 af42e7c4c860
Date: Thu, 28 Mar 2002 09:20:03 +0200
From: "Mike Gorchak" <mike@malva.ua>
Subject: New QNX patch.

Hi !

1. Removed warning (possible bug) with invalid type, passing to the function
in ph_WarpedMotion.
2. Rewritten handler of Ph_WM_RESIZE message, now works, but buggy (old
handler doesn't work at all).
3. Added stub handler for Ph_WM_MAX (maximize) message.
4. Added more #ifdef HAVE_OPENGL to disable OpenGL stuff when it not needed.
5. Added support for SDL_NOFRAME and SDL_RESIZABLE flags (in OpenGL windows
too).
6. Added cosmetic changes, if no SDL_RESIZABLE flag defined, disable resize
handlers in window border and maximize button at caption.
7. Fixed my bug with invalid arguments count passed to PtCreateWidget call.
8. Fixed some palette problems.
9. Updated README.QNX file.

And I changed testgl.c test application:

10. Added in testgl.c application support for SDL_NOFRAME flag and
option -noframe.
README.QNX
src/video/photon/SDL_ph_events.c
src/video/photon/SDL_ph_video.c
test/testgl.c
     1.1 --- a/README.QNX	Tue Mar 26 17:37:31 2002 +0000
     1.2 +++ b/README.QNX	Thu Mar 28 16:20:10 2002 +0000
     1.3 @@ -7,10 +7,11 @@
     1.4  of OS before 6.1.0 are not supported.
     1.5  
     1.6  Problems:
     1.7 -1. While creating OpenGL context artificially  selected  software
     1.8 -   renderer mode (QSSL made acceleration only for  Voodoo  boards
     1.9 -   in fullscreen mode, sorry but I don't have this board, if  you
    1.10 -   want acceleration - you may remove some line in source).
    1.11 +1. While  creating  OpenGL  context  software  renderer  mode  is
    1.12 +   artificially selected (QSSL made acceleration only for  Voodoo
    1.13 +   boards in fullscreen mode, sorry but I don't have  this board,
    1.14 +   if you want acceleration - you may remove some line  in source
    1.15 +   code).
    1.16  2. Photon has some errors in detecting  how  much bits  per pixel
    1.17     videomode has.
    1.18  3. No  shared  libraries  yet.  We  need  manually  set  flag  to
    1.19 @@ -31,7 +32,8 @@
    1.20                  --disable-shared    \
    1.21                  --disable-video-opengl
    1.22  
    1.23 -    In test directory also run ./configure script without x11 support, e.g.:
    1.24 +    In test directory  also run  ./configure  script  without x11
    1.25 +support, e.g.:
    1.26  
    1.27      ./configure  --with-sdl-prefix=/usr/local      \
    1.28                   --with-sdl-exec-prefix=/usr/local \
     2.1 --- a/src/video/photon/SDL_ph_events.c	Tue Mar 26 17:37:31 2002 +0000
     2.2 +++ b/src/video/photon/SDL_ph_events.c	Thu Mar 28 16:20:10 2002 +0000
     2.3 @@ -74,7 +74,7 @@
     2.4  					(peekevent->timestamp == event->timestamp)	
     2.5  				) {
     2.6  					repeated = 1;
     2.7 -					 //PhEventNext( peekevent, EVENT_SIZE );  
     2.8 +					 /* PhEventNext( peekevent, EVENT_SIZE ); */
     2.9  				}				
    2.10  			}
    2.11  		}
    2.12 @@ -85,7 +85,7 @@
    2.13  		}
    2.14  		break;
    2.15  
    2.16 -		default: // no events pending
    2.17 +		default: /* no events pending */
    2.18  	}
    2.19  	return(repeated);
    2.20  }
    2.21 @@ -93,11 +93,12 @@
    2.22  
    2.23  static int ph_WarpedMotion(_THIS, PhEvent_t *winEvent)
    2.24  {
    2.25 -	PhPointerEvent_t *pointer = PhGetData( winEvent );
    2.26 +/*	PhPointerEvent_t *pointer = PhGetData( winEvent ); */
    2.27  	PhRect_t *rect = PhGetRects( winEvent );
    2.28  
    2.29  	int centre_x, centre_y;
    2.30 -	int dx, dy, abs_x, abs_y;
    2.31 +	int dx, dy;
    2.32 +        short abs_x, abs_y;
    2.33  	int posted;
    2.34  
    2.35  	centre_x = SDL_VideoSurface->w / 2;
    2.36 @@ -155,177 +156,168 @@
    2.37  
    2.38  static int ph_DispatchEvent(_THIS)
    2.39  {
    2.40 -	int posted;
    2.41 -	PhRect_t* rect;
    2.42 -	PhPointerEvent_t* pointerEvent;
    2.43 -	PhKeyEvent_t* keyEvent;
    2.44 -	PhWindowEvent_t* winEvent;
    2.45 -	int i, buttons;
    2.46 -	SDL_Rect sdlrects[50]; 
    2.47 +    int posted;
    2.48 +    PhRect_t* rect;
    2.49 +    PhPointerEvent_t* pointerEvent;
    2.50 +    PhKeyEvent_t* keyEvent;
    2.51 +    PhWindowEvent_t* winEvent;
    2.52 +    int i, buttons;
    2.53 +    SDL_Rect sdlrects[50]; 
    2.54  	
    2.55 -	posted = 0;
    2.56 +    posted = 0;
    2.57  	
    2.58 -	switch (event->type) {
    2.59 -		case Ph_EV_BOUNDARY:
    2.60 +    switch (event->type)
    2.61 +    {
    2.62 +        case Ph_EV_BOUNDARY:
    2.63 +        {
    2.64 +            if (event->subtype == Ph_EV_PTR_ENTER)
    2.65 +            {
    2.66 +                posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
    2.67 +            }
    2.68 +            else if (event->subtype ==Ph_EV_PTR_LEAVE)
    2.69 +            {
    2.70 +                posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);	
    2.71 +            }
    2.72 +        }
    2.73 +        break;
    2.74 +
    2.75 +        case Ph_EV_PTR_MOTION_BUTTON:
    2.76 +        case Ph_EV_PTR_MOTION_NOBUTTON:
    2.77 +        {
    2.78 +            if (SDL_VideoSurface)
    2.79 +            {
    2.80 +                pointerEvent = PhGetData(event);
    2.81 +                rect = PhGetRects(event);
    2.82 +
    2.83 +                if (mouse_relative)
    2.84 +                {
    2.85 +                    posted = ph_WarpedMotion(this, event);
    2.86 +                }
    2.87 +                else
    2.88 +                {
    2.89 +                    posted = SDL_PrivateMouseMotion(0, 0, rect->ul.x, rect->ul.y);
    2.90 +                }
    2.91 +            }
    2.92 +        }
    2.93 +        break;
    2.94 +
    2.95 +        case Ph_EV_BUT_PRESS:
    2.96 +        {
    2.97 +            pointerEvent = PhGetData( event );
    2.98 +            buttons = ph2sdl_mousebutton( pointerEvent->buttons );
    2.99 +            if (buttons != 0)
   2.100 +            {
   2.101 +                posted = SDL_PrivateMouseButton(SDL_PRESSED, buttons, 0, 0);
   2.102 +            }
   2.103 +        }
   2.104 +        break;
   2.105 +
   2.106 +        case Ph_EV_BUT_RELEASE:
   2.107 +        {
   2.108 +            pointerEvent = PhGetData(event);
   2.109 +            buttons = ph2sdl_mousebutton(pointerEvent->buttons);
   2.110 +            if (event->subtype == Ph_EV_RELEASE_REAL && buttons != 0)
   2.111 +            {
   2.112 +                posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0);
   2.113 +            }
   2.114 +            else if(event->subtype == Ph_EV_RELEASE_PHANTOM)
   2.115 +            {
   2.116 +                /* If the mouse is outside the window,
   2.117 +                 * only a phantom release event is sent, so
   2.118 +                 * check if the window doesn't have mouse focus.
   2.119 +                 * Not perfect, maybe checking the mouse button
   2.120 +                 * state for Ph_EV_BOUNDARY events would be
   2.121 +                 * better. */
   2.122 +                if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) == 0)
   2.123  		{
   2.124 -			if (event->subtype == Ph_EV_PTR_ENTER)
   2.125 -				posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
   2.126 -			else if (event->subtype ==Ph_EV_PTR_LEAVE)
   2.127 -				posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);	
   2.128 -		}
   2.129 -		break;
   2.130 +                    posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0);
   2.131 +                }
   2.132 +            }
   2.133 +        }
   2.134 +        break;
   2.135  
   2.136 -		case Ph_EV_PTR_MOTION_BUTTON:
   2.137 -		case Ph_EV_PTR_MOTION_NOBUTTON:
   2.138 -		{
   2.139 -			if ( SDL_VideoSurface ) {
   2.140 -				pointerEvent = PhGetData( event );
   2.141 -				rect = PhGetRects( event );
   2.142 -				if( mouse_relative )
   2.143 -				{
   2.144 -					posted = ph_WarpedMotion(this, event);
   2.145 -				}
   2.146 -				else
   2.147 -					posted = SDL_PrivateMouseMotion(0, 0,
   2.148 -							rect->ul.x, rect->ul.y);
   2.149 -			}
   2.150 -		}
   2.151 -		break;
   2.152 +        case Ph_EV_WM:
   2.153 +        {
   2.154 +            winEvent = PhGetData(event);
   2.155  
   2.156 -		case Ph_EV_BUT_PRESS:
   2.157 -		{
   2.158 -			pointerEvent = PhGetData( event );
   2.159 -			buttons = ph2sdl_mousebutton( pointerEvent->buttons );
   2.160 -			if( buttons != 0 )
   2.161 -			posted = SDL_PrivateMouseButton( SDL_PRESSED, buttons,
   2.162 -					0, 0 );
   2.163 -		}
   2.164 -		break;
   2.165 +            /* losing focus */
   2.166 +            if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUSLOST))
   2.167 +            {
   2.168 +                set_motion_sensitivity(this, Ph_EV_PTR_MOTION_BUTTON);
   2.169 +                posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);	
   2.170  
   2.171 -		case Ph_EV_BUT_RELEASE:
   2.172 -		{
   2.173 -			pointerEvent = PhGetData(event);
   2.174 -			buttons = ph2sdl_mousebutton(pointerEvent->buttons);
   2.175 -			if( event->subtype == Ph_EV_RELEASE_REAL && 
   2.176 -					buttons != 0 )
   2.177 -			{
   2.178 -				posted = SDL_PrivateMouseButton( SDL_RELEASED,
   2.179 -						buttons, 0, 0 );
   2.180 -			}
   2.181 -			else if( event->subtype == Ph_EV_RELEASE_PHANTOM )
   2.182 -			{
   2.183 -				/* If the mouse is outside the window,
   2.184 -				 * only a phantom release event is sent, so
   2.185 -				 * check if the window doesn't have mouse focus.
   2.186 -				 * Not perfect, maybe checking the mouse button
   2.187 -				 * state for Ph_EV_BOUNDARY events would be
   2.188 -				 * better. */
   2.189 -				if( ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) == 0 )
   2.190 -				{
   2.191 -					posted = SDL_PrivateMouseButton( SDL_RELEASED,
   2.192 -						buttons, 0, 0 );
   2.193 -				}
   2.194 -			}
   2.195 -		}
   2.196 -		break;
   2.197 +                /* Queue leaving fullscreen mode */
   2.198 +                switch_waiting = 0x01;
   2.199 +                switch_time = SDL_GetTicks() + 200;
   2.200 +            }
   2.201 +            /* gaining focus */
   2.202 +            else if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUS))
   2.203 +            {
   2.204 +                set_motion_sensitivity(this, -1);
   2.205 +                posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
   2.206 +            }
   2.207 +            /* request to quit */
   2.208 +            else if (winEvent->event_f==Ph_WM_CLOSE)
   2.209 +            {
   2.210 +                posted = SDL_PrivateQuit();
   2.211 +            }
   2.212 +            /* request to resize */
   2.213 +            else if (winEvent->event_f==Ph_WM_RESIZE)
   2.214 +            {
   2.215 +                SDL_PrivateResize(winEvent->size.w, winEvent->size.h);
   2.216 +            }
   2.217 +            /* request to maximize */
   2.218 +            else if (winEvent->event_f==Ph_WM_MAX)
   2.219 +            {
   2.220 +                /* TODO: get screen resolution, set window pos to 0, 0 and resize it ! */
   2.221 +            }
   2.222 +        }
   2.223 +        break;
   2.224  
   2.225 -		case Ph_EV_WM:
   2.226 -		{
   2.227 -			winEvent = PhGetData( event );
   2.228 -			
   2.229 -			/* losing focus */
   2.230 -			if ((winEvent->event_f==Ph_WM_FOCUS)&&
   2.231 -				(winEvent->event_state==Ph_WM_EVSTATE_FOCUSLOST))
   2.232 -			{
   2.233 -				set_motion_sensitivity(this, Ph_EV_PTR_MOTION_BUTTON);
   2.234 -				posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);	
   2.235 +        /* window has been resized, moved or removed */
   2.236 +        case Ph_EV_EXPOSE:
   2.237 +        {
   2.238 +            if (SDL_VideoSurface)
   2.239 +            {
   2.240 +                rect = PhGetRects(event);
   2.241  
   2.242 -				/* Queue leaving fullscreen mode */
   2.243 -				switch_waiting = 0x01;
   2.244 -				switch_time = SDL_GetTicks() + 200;
   2.245 -			}
   2.246 +                for(i=0;i<event->num_rects;i++)
   2.247 +                {
   2.248 +                    sdlrects[i].x = rect[i].ul.x;
   2.249 +                    sdlrects[i].y = rect[i].ul.y;
   2.250 +                    sdlrects[i].w = rect[i].lr.x - rect[i].ul.x + 1;
   2.251 +                    sdlrects[i].h = rect[i].lr.y - rect[i].ul.y + 1;
   2.252 +                }
   2.253  
   2.254 -			/* gaining focus */
   2.255 -			else if ((winEvent->event_f==Ph_WM_FOCUS)&&
   2.256 -					(winEvent->event_state==Ph_WM_EVSTATE_FOCUS))
   2.257 -			{
   2.258 -				set_motion_sensitivity(this, -1);
   2.259 -				posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
   2.260 -#if 0
   2.261 -				/* Queue entry into fullscreen mode */
   2.262 -				switch_waiting = 0x01 | SDL_FULLSCREEN;
   2.263 -				switch_time = SDL_GetTicks() + 1500;
   2.264 -#endif
   2.265 -			}
   2.266 +                this->UpdateRects(this, event->num_rects, sdlrects);
   2.267 +            }
   2.268 +        }
   2.269 +	break;
   2.270  
   2.271 -			/* request to quit */
   2.272 -			else if (winEvent->event_f==Ph_WM_CLOSE)
   2.273 -			{
   2.274 -				posted = SDL_PrivateQuit();
   2.275 -			}
   2.276 -			else if (winEvent->event_f==Ph_WM_RESIZE)
   2.277 -			{
   2.278 -				PhDim_t *size;
   2.279 +        case Ph_EV_KEY:
   2.280 +        {
   2.281 +            SDL_keysym keysym;
   2.282  
   2.283 -				PtGetResource( window, Pt_ARG_DIM, &size, 0 );
   2.284 -				SDL_PrivateResize(size->w,size->h);
   2.285 -			}
   2.286 -		}
   2.287 -		break;
   2.288 -		
   2.289 -		/* window has been resized, moved or removed */
   2.290 -		case Ph_EV_EXPOSE:
   2.291 -		{
   2.292 -			if (SDL_VideoSurface)
   2.293 -			{
   2.294 -				rect = PhGetRects( event );
   2.295 +            posted = 0;
   2.296  
   2.297 -				//PgSetClipping(1, rect );
   2.298 -				for(i=0;i<event->num_rects;i++)
   2.299 -				{
   2.300 -					sdlrects[i].x = rect[i].ul.x;
   2.301 -					sdlrects[i].y = rect[i].ul.y;
   2.302 -					sdlrects[i].w = rect[i].lr.x - rect[i].ul.x + 1;
   2.303 -					sdlrects[i].h = rect[i].lr.y - rect[i].ul.y + 1;
   2.304 -				}
   2.305 +            keyEvent = PhGetData( event );
   2.306  
   2.307 -				this->UpdateRects(this, event->num_rects, sdlrects);
   2.308 +            if (Pk_KF_Key_Down & keyEvent->key_flags)
   2.309 +            {
   2.310 +                posted = SDL_PrivateKeyboard(SDL_PRESSED, ph_TranslateKey(keyEvent, &keysym));
   2.311 +            }
   2.312 +            else /* must be key release */
   2.313 +            {
   2.314 +                 /* Ignore repeated key release events */
   2.315 +                 /* if (! Pk_KF_Key_Repeat & keyEvent->key_flags ) */
   2.316  
   2.317 -			}
   2.318 -		}
   2.319 -		break;
   2.320 +                posted = SDL_PrivateKeyboard(SDL_RELEASED, ph_TranslateKey( keyEvent, &keysym));
   2.321 +            }
   2.322 +        }
   2.323 +        break;
   2.324 +    }
   2.325  
   2.326 -		case Ph_EV_KEY:
   2.327 -		{
   2.328 -	
   2.329 -			SDL_keysym keysym;
   2.330 -			
   2.331 -			posted = 0;
   2.332 -			
   2.333 -			keyEvent = PhGetData( event );
   2.334 -
   2.335 -			if (Pk_KF_Key_Down & keyEvent->key_flags)
   2.336 -			{
   2.337 -				
   2.338 -				posted = SDL_PrivateKeyboard(SDL_PRESSED,
   2.339 -                			ph_TranslateKey( keyEvent, &keysym));
   2.340 -			}
   2.341 -			else /* must be key release */
   2.342 - 			{
   2.343 - 				/* Ignore repeated key release events */
   2.344 -				/*if (! Pk_KF_Key_Repeat & keyEvent->key_flags )*/
   2.345 -				
   2.346 -					posted = SDL_PrivateKeyboard(SDL_RELEASED,
   2.347 -        					ph_TranslateKey( keyEvent, &keysym));
   2.348 -				/*}*/
   2.349 -			}
   2.350 -		}
   2.351 -		break;
   2.352 -	}
   2.353 -	
   2.354 -		
   2.355 -	
   2.356 -	return(posted);
   2.357 +    return(posted);
   2.358  }
   2.359  
   2.360  /* perform a blocking read if no events available */
     3.1 --- a/src/video/photon/SDL_ph_video.c	Tue Mar 26 17:37:31 2002 +0000
     3.2 +++ b/src/video/photon/SDL_ph_video.c	Thu Mar 28 16:20:10 2002 +0000
     3.3 @@ -175,15 +175,14 @@
     3.4  
     3.5  static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)
     3.6  {
     3.7 -    int i;
     3.8 -    unsigned long *tempptr;
     3.9 -    int rtnval;
    3.10      PgVideoModeInfo_t my_mode_info;
    3.11      PgHWCaps_t my_hwcaps;
    3.12  
    3.13      window=NULL;
    3.14 +    desktoppal=SDLPH_PAL_NONE;
    3.15 +#ifdef HAVE_OPENGL
    3.16      oglctx=NULL;
    3.17 -    desktoppal=SDLPH_PAL_NONE;
    3.18 +#endif /* HAVE_OPENGL */
    3.19      
    3.20      captionflag=0;
    3.21      old_video_mode=-1;
    3.22 @@ -218,31 +217,13 @@
    3.23      vformat->BitsPerPixel = my_mode_info.bits_per_pixel;
    3.24      vformat->BytesPerPixel = my_mode_info.bytes_per_scanline/my_mode_info.width;
    3.25      desktopbpp = my_mode_info.bits_per_pixel;
    3.26 +    
    3.27 +    /* save current palette */
    3.28 +    if (desktopbpp==8)
    3.29 +    {
    3.30 +        PgGetPalette(ph_palette);
    3.31 +    }
    3.32           
    3.33 -    /* return a palette if we are in 256 color mode */
    3.34 -    if (vformat->BitsPerPixel == 8)
    3.35 -    {
    3.36 -        vformat->palette = malloc(sizeof(SDL_Palette));
    3.37 -        memset(vformat->palette, 0, sizeof(SDL_Palette));
    3.38 -        vformat->palette->ncolors = 256;
    3.39 -        vformat->palette->colors = (SDL_Color *)malloc(256 *sizeof(SDL_Color));
    3.40 -
    3.41 -        /* fill the palette */
    3.42 -        rtnval = PgGetPalette(ph_palette);
    3.43 -        if (rtnval < 0)
    3.44 -        {
    3.45 -	    fprintf(stderr, "ph_VideoInit: PgGetPalette failed\n");
    3.46 -        }
    3.47 -
    3.48 -        tempptr = (unsigned long *)vformat->palette->colors;
    3.49 -
    3.50 -        for(i=0;i<256; i++)
    3.51 -        {
    3.52 -            *tempptr = (((unsigned long)ph_palette[i]) << 8);
    3.53 -            tempptr++;
    3.54 -        }		
    3.55 -    }
    3.56 -
    3.57      currently_fullscreen = 0;
    3.58      
    3.59      this->info.wm_available = 1;
    3.60 @@ -268,6 +249,8 @@
    3.61      /* Lock the event thread, in multi-threading environments */
    3.62      SDL_Lock_EventThread();
    3.63  
    3.64 +    current->flags = flags;
    3.65 +
    3.66      /* create window if no OpenGL support selected */
    3.67      if ((flags & SDL_OPENGL)!=SDL_OPENGL)
    3.68      {
    3.69 @@ -276,6 +259,34 @@
    3.70          PtSetArg(&arg[pargc++], Pt_ARG_DIM, &dim, 0);
    3.71          PtSetArg(&arg[pargc++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED);
    3.72  
    3.73 +        /* enable window minimizing */
    3.74 +        PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_HIDE);
    3.75 +
    3.76 +        /* remove border and caption if no frame flag selected */
    3.77 +        if ((flags & SDL_NOFRAME) == SDL_NOFRAME)
    3.78 +        {
    3.79 +            PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Ph_WM_RENDER_TITLE | Ph_WM_RENDER_BORDER);
    3.80 +        }
    3.81 +        else
    3.82 +        {
    3.83 +            PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_TITLE | Ph_WM_RENDER_BORDER);
    3.84 +        }
    3.85 +
    3.86 +        /* if window is not resizable then remove resize handles and maximize button */
    3.87 +        if ((flags & SDL_RESIZABLE) != SDL_RESIZABLE)
    3.88 +        {
    3.89 +            PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX);
    3.90 +            PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX);
    3.91 +            PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX);
    3.92 +        }
    3.93 +        else
    3.94 +        {
    3.95 +            PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX);
    3.96 +            /* it is need to be Pt_FALSE to allow the application to process the resize callback */
    3.97 +            PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX);
    3.98 +            PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_RESIZE | Ph_WM_MAX);
    3.99 +        }
   3.100 +
   3.101          if (window!=NULL)
   3.102          {
   3.103              PtUnrealizeWidget(window);
   3.104 @@ -283,7 +294,7 @@
   3.105              window=NULL;
   3.106          }
   3.107  
   3.108 -        window=PtCreateWidget(PtWindow, NULL, pargc-1, arg);
   3.109 +        window=PtCreateWidget(PtWindow, NULL, pargc, arg);
   3.110          PtRealizeWidget(window);
   3.111          
   3.112          PtFlush();
   3.113 @@ -295,7 +306,6 @@
   3.114          /* ph_SetupOpenGLContext creates also window as need */
   3.115          if (ph_SetupOpenGLContext(this, width, height, bpp, flags)==0)
   3.116          {
   3.117 -            current->flags=flags;
   3.118              /* setup OGL update function ... ugly method */
   3.119              ph_ResizeImage(this, current, flags); 
   3.120          }
   3.121 @@ -363,15 +373,13 @@
   3.122          } /* end fullscreen flag */
   3.123          else
   3.124          {
   3.125 -            if (flags & SDL_HWSURFACE)  /* Use offscreen memory iff SDL_HWSURFACE flag is set */
   3.126 +            /* Use offscreen memory iff SDL_HWSURFACE flag is set */
   3.127 +            if (flags & SDL_HWSURFACE)
   3.128              {
   3.129 -                /* Hardware surface is Offsceen Context.  ph_ResizeImage handles the switch */
   3.130 -                current->flags = (flags & (~SDL_RESIZABLE)); /* no stretch blit in offscreen context */
   3.131 +                /* no stretch blit in offscreen context */
   3.132 +                current->flags = (flags & (~SDL_RESIZABLE));
   3.133              }
   3.134 -            else /* must be SDL_SWSURFACE */
   3.135 -            {
   3.136 -                current->flags = (flags | SDL_RESIZABLE); /* yes we can resize as this is a software surface */
   3.137 -            }
   3.138 +
   3.139              /* using palette emulation code in window mode */
   3.140              if (bpp==8)
   3.141              {
   3.142 @@ -425,6 +433,9 @@
   3.143          ph_SetCaption(this, this->wm_title, NULL);
   3.144      }
   3.145  
   3.146 +    /* finish window drawing */
   3.147 +    PtFlush();
   3.148 +
   3.149      SDL_Unlock_EventThread();
   3.150  
   3.151      /* We're done! */
   3.152 @@ -433,7 +444,9 @@
   3.153  
   3.154  static void ph_VideoQuit(_THIS)
   3.155  {
   3.156 +#ifdef HAVE_OPENGL
   3.157      PhRegion_t region_info;
   3.158 +#endif /* HAVE_OPENGL */
   3.159  
   3.160      ph_DestroyImage(this, SDL_VideoSurface); 
   3.161  
   3.162 @@ -443,7 +456,7 @@
   3.163      }
   3.164  
   3.165  #ifdef HAVE_OPENGL
   3.166 -    /* prevent double SEGFAULT with parachute mode */
   3.167 +    /* prevent double SEGFAULT during parachute mode */
   3.168      if (this->screen)
   3.169      {
   3.170          if (((this->screen->flags & SDL_FULLSCREEN)==SDL_FULLSCREEN) &&
   3.171 @@ -518,14 +531,14 @@
   3.172              if ((this->screen->flags & SDL_FULLSCREEN) != SDL_FULLSCREEN)
   3.173              {
   3.174                  /* window mode must use soft palette */
   3.175 -                PgSetPalette((PgColor_t*)&syspalph, 0, firstcolor, ncolors, Pg_PALSET_SOFT, 0);
   3.176 +                PgSetPalette((PgColor_t*)&syspalph[firstcolor], 0, firstcolor, ncolors, Pg_PALSET_SOFT, 0);
   3.177                  /* image needs to be redrawed, very slow method */
   3.178                  PgDrawPhImage(&point, SDL_Image, 0);
   3.179              }
   3.180              else
   3.181              {
   3.182                  /* fullscreen mode must use hardware palette */
   3.183 -                PgSetPalette((PgColor_t*)&syspalph, 0, firstcolor, ncolors, Pg_PALSET_GLOBAL, 0);
   3.184 +                PgSetPalette((PgColor_t*)&syspalph[firstcolor], 0, firstcolor, ncolors, Pg_PALSET_GLOBAL, 0);
   3.185              }
   3.186          }
   3.187          else
   3.188 @@ -586,9 +599,10 @@
   3.189      {
   3.190          oglctx=PdCreateOpenGLContext(1, &dim, 0, OGLAttrib);
   3.191      }
   3.192 +
   3.193      if (oglctx==NULL)
   3.194      {
   3.195 -        fprintf(stderr,"error: cannot create OpenGL context.\n");
   3.196 +        fprintf(stderr,"ph_SetupOpenGLContext: cannot create OpenGL context.\n");
   3.197          return (-1);
   3.198      }
   3.199  
   3.200 @@ -608,10 +622,26 @@
   3.201          pos.y=0;
   3.202  
   3.203          PtSetArg(&args[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, ~0);
   3.204 -        PtSetArg(&args[pargc++], Pt_ARG_WINDOW_MANAGED_FLAGS,Pt_TRUE, Ph_WM_FFRONT | Ph_WM_CLOSE | Ph_WM_TOFRONT | Ph_WM_CONSWITCH);
   3.205 +        PtSetArg(&args[pargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_FFRONT | Ph_WM_CLOSE | Ph_WM_TOFRONT | Ph_WM_CONSWITCH);
   3.206          PtSetArg(&args[pargc++], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS);
   3.207          PtSetArg(&args[pargc++], Pt_ARG_POS, &pos, 0);
   3.208      }
   3.209 +    else
   3.210 +    {
   3.211 +        /* remove border and caption if no frame flag selected */
   3.212 +        if ((flags & SDL_NOFRAME) == SDL_NOFRAME)
   3.213 +        {
   3.214 +            PtSetArg(&args[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, 0, Ph_WM_RENDER_TITLE | Ph_WM_RENDER_BORDER);
   3.215 +        }
   3.216 +        else
   3.217 +        {
   3.218 +           /* if window is not resizable then remove resize handles */
   3.219 +           if ((flags & SDL_RESIZABLE) != SDL_RESIZABLE)
   3.220 +           {
   3.221 +               PtSetArg(&args[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, 0, Ph_WM_RENDER_RESIZE);
   3.222 +           }
   3.223 +        }
   3.224 +    }
   3.225  
   3.226      if (window!=NULL)
   3.227      {
   3.228 @@ -620,7 +650,7 @@
   3.229          window=NULL;
   3.230      }
   3.231  
   3.232 -    window=PtCreateWidget(PtWindow, NULL, pargc-1, args);
   3.233 +    window=PtCreateWidget(PtWindow, NULL, pargc, args);
   3.234      PtRealizeWidget(window);
   3.235  
   3.236      /* disable mouse for fullscreen */
     4.1 --- a/test/testgl.c	Tue Mar 26 17:37:31 2002 +0000
     4.2 +++ b/test/testgl.c	Thu Mar 28 16:20:10 2002 +0000
     4.3 @@ -393,7 +393,7 @@
     4.4  }
     4.5  
     4.6  int RunGLTest( int argc, char* argv[],
     4.7 -               int logo, int slowly, int bpp, float gamma )
     4.8 +               int logo, int slowly, int bpp, float gamma, int noframe )
     4.9  {
    4.10  	int i;
    4.11  	int rgb_size[3];
    4.12 @@ -447,6 +447,10 @@
    4.13  		}
    4.14  	}
    4.15  
    4.16 +        if (noframe) {
    4.17 +           video_flags |= SDL_NOFRAME;
    4.18 +        }
    4.19 +
    4.20  	/* Initialize the display */
    4.21  	switch (bpp) {
    4.22  	    case 8:
    4.23 @@ -686,6 +690,7 @@
    4.24  	int bpp = 0;
    4.25  	int slowly;
    4.26  	float gamma = 0.0;
    4.27 +        int noframe = 0;
    4.28  
    4.29  	logo = 0;
    4.30  	slowly = 0;
    4.31 @@ -711,15 +716,18 @@
    4.32  		if ( strcmp(argv[i], "-gamma") == 0 ) {
    4.33   		       gamma = (float)atof(argv[++i]);
    4.34  		}
    4.35 +		if ( strcmp(argv[i], "-noframe") == 0 ) {
    4.36 + 		       noframe = 1;
    4.37 +		}
    4.38  		if ( strncmp(argv[i], "-h", 2) == 0 ) {
    4.39   		       printf(
    4.40 -"Usage: %s [-twice] [-logo] [-slow] [-bpp n] [-gamma n]\n",
    4.41 +"Usage: %s [-twice] [-logo] [-slow] [-bpp n] [-gamma n] [-noframe]\n",
    4.42   			      argv[0]);
    4.43  			exit(0);
    4.44  		}
    4.45  	}
    4.46  	for ( i=0; i<numtests; ++i ) {
    4.47 - 	       RunGLTest(argc, argv, logo, slowly, bpp, gamma);
    4.48 + 	       RunGLTest(argc, argv, logo, slowly, bpp, gamma, noframe);
    4.49  	}
    4.50  	return 0;
    4.51  }