Date: Thu, 28 Mar 2002 09:20:03 +0200
authorSam Lantinga
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 -		{
    2.61 -			if (event->subtype == Ph_EV_PTR_ENTER)
    2.62 -				posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
    2.63 -			else if (event->subtype ==Ph_EV_PTR_LEAVE)
    2.64 -				posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);	
    2.65 -		}
    2.66 -		break;
    2.67 +    switch (event->type)
    2.68 +    {
    2.69 +        case Ph_EV_BOUNDARY:
    2.70 +        {
    2.71 +            if (event->subtype == Ph_EV_PTR_ENTER)
    2.72 +            {
    2.73 +                posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
    2.74 +            }
    2.75 +            else if (event->subtype ==Ph_EV_PTR_LEAVE)
    2.76 +            {
    2.77 +                posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);	
    2.78 +            }
    2.79 +        }
    2.80 +        break;
    2.81 +
    2.82 +        case Ph_EV_PTR_MOTION_BUTTON:
    2.83 +        case Ph_EV_PTR_MOTION_NOBUTTON:
    2.84 +        {
    2.85 +            if (SDL_VideoSurface)
    2.86 +            {
    2.87 +                pointerEvent = PhGetData(event);
    2.88 +                rect = PhGetRects(event);
    2.89  
    2.90 -		case Ph_EV_PTR_MOTION_BUTTON:
    2.91 -		case Ph_EV_PTR_MOTION_NOBUTTON:
    2.92 -		{
    2.93 -			if ( SDL_VideoSurface ) {
    2.94 -				pointerEvent = PhGetData( event );
    2.95 -				rect = PhGetRects( event );
    2.96 -				if( mouse_relative )
    2.97 -				{
    2.98 -					posted = ph_WarpedMotion(this, event);
    2.99 -				}
   2.100 -				else
   2.101 -					posted = SDL_PrivateMouseMotion(0, 0,
   2.102 -							rect->ul.x, rect->ul.y);
   2.103 -			}
   2.104 -		}
   2.105 -		break;
   2.106 +                if (mouse_relative)
   2.107 +                {
   2.108 +                    posted = ph_WarpedMotion(this, event);
   2.109 +                }
   2.110 +                else
   2.111 +                {
   2.112 +                    posted = SDL_PrivateMouseMotion(0, 0, rect->ul.x, rect->ul.y);
   2.113 +                }
   2.114 +            }
   2.115 +        }
   2.116 +        break;
   2.117  
   2.118 -		case Ph_EV_BUT_PRESS:
   2.119 +        case Ph_EV_BUT_PRESS:
   2.120 +        {
   2.121 +            pointerEvent = PhGetData( event );
   2.122 +            buttons = ph2sdl_mousebutton( pointerEvent->buttons );
   2.123 +            if (buttons != 0)
   2.124 +            {
   2.125 +                posted = SDL_PrivateMouseButton(SDL_PRESSED, buttons, 0, 0);
   2.126 +            }
   2.127 +        }
   2.128 +        break;
   2.129 +
   2.130 +        case Ph_EV_BUT_RELEASE:
   2.131 +        {
   2.132 +            pointerEvent = PhGetData(event);
   2.133 +            buttons = ph2sdl_mousebutton(pointerEvent->buttons);
   2.134 +            if (event->subtype == Ph_EV_RELEASE_REAL && buttons != 0)
   2.135 +            {
   2.136 +                posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0);
   2.137 +            }
   2.138 +            else if(event->subtype == Ph_EV_RELEASE_PHANTOM)
   2.139 +            {
   2.140 +                /* If the mouse is outside the window,
   2.141 +                 * only a phantom release event is sent, so
   2.142 +                 * check if the window doesn't have mouse focus.
   2.143 +                 * Not perfect, maybe checking the mouse button
   2.144 +                 * state for Ph_EV_BOUNDARY events would be
   2.145 +                 * better. */
   2.146 +                if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) == 0)
   2.147  		{
   2.148 -			pointerEvent = PhGetData( event );
   2.149 -			buttons = ph2sdl_mousebutton( pointerEvent->buttons );
   2.150 -			if( buttons != 0 )
   2.151 -			posted = SDL_PrivateMouseButton( SDL_PRESSED, buttons,
   2.152 -					0, 0 );
   2.153 -		}
   2.154 -		break;
   2.155 -
   2.156 -		case Ph_EV_BUT_RELEASE:
   2.157 -		{
   2.158 -			pointerEvent = PhGetData(event);
   2.159 -			buttons = ph2sdl_mousebutton(pointerEvent->buttons);
   2.160 -			if( event->subtype == Ph_EV_RELEASE_REAL && 
   2.161 -					buttons != 0 )
   2.162 -			{
   2.163 -				posted = SDL_PrivateMouseButton( SDL_RELEASED,
   2.164 -						buttons, 0, 0 );
   2.165 -			}
   2.166 -			else if( event->subtype == Ph_EV_RELEASE_PHANTOM )
   2.167 -			{
   2.168 -				/* If the mouse is outside the window,
   2.169 -				 * only a phantom release event is sent, so
   2.170 -				 * check if the window doesn't have mouse focus.
   2.171 -				 * Not perfect, maybe checking the mouse button
   2.172 -				 * state for Ph_EV_BOUNDARY events would be
   2.173 -				 * better. */
   2.174 -				if( ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) == 0 )
   2.175 -				{
   2.176 -					posted = SDL_PrivateMouseButton( SDL_RELEASED,
   2.177 -						buttons, 0, 0 );
   2.178 -				}
   2.179 -			}
   2.180 -		}
   2.181 -		break;
   2.182 -
   2.183 -		case Ph_EV_WM:
   2.184 -		{
   2.185 -			winEvent = PhGetData( event );
   2.186 -			
   2.187 -			/* losing focus */
   2.188 -			if ((winEvent->event_f==Ph_WM_FOCUS)&&
   2.189 -				(winEvent->event_state==Ph_WM_EVSTATE_FOCUSLOST))
   2.190 -			{
   2.191 -				set_motion_sensitivity(this, Ph_EV_PTR_MOTION_BUTTON);
   2.192 -				posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);	
   2.193 +                    posted = SDL_PrivateMouseButton(SDL_RELEASED, buttons, 0, 0);
   2.194 +                }
   2.195 +            }
   2.196 +        }
   2.197 +        break;
   2.198  
   2.199 -				/* Queue leaving fullscreen mode */
   2.200 -				switch_waiting = 0x01;
   2.201 -				switch_time = SDL_GetTicks() + 200;
   2.202 -			}
   2.203 +        case Ph_EV_WM:
   2.204 +        {
   2.205 +            winEvent = PhGetData(event);
   2.206  
   2.207 -			/* gaining focus */
   2.208 -			else if ((winEvent->event_f==Ph_WM_FOCUS)&&
   2.209 -					(winEvent->event_state==Ph_WM_EVSTATE_FOCUS))
   2.210 -			{
   2.211 -				set_motion_sensitivity(this, -1);
   2.212 -				posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
   2.213 -#if 0
   2.214 -				/* Queue entry into fullscreen mode */
   2.215 -				switch_waiting = 0x01 | SDL_FULLSCREEN;
   2.216 -				switch_time = SDL_GetTicks() + 1500;
   2.217 -#endif
   2.218 -			}
   2.219 +            /* losing focus */
   2.220 +            if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUSLOST))
   2.221 +            {
   2.222 +                set_motion_sensitivity(this, Ph_EV_PTR_MOTION_BUTTON);
   2.223 +                posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);	
   2.224  
   2.225 -			/* request to quit */
   2.226 -			else if (winEvent->event_f==Ph_WM_CLOSE)
   2.227 -			{
   2.228 -				posted = SDL_PrivateQuit();
   2.229 -			}
   2.230 -			else if (winEvent->event_f==Ph_WM_RESIZE)
   2.231 -			{
   2.232 -				PhDim_t *size;
   2.233 -
   2.234 -				PtGetResource( window, Pt_ARG_DIM, &size, 0 );
   2.235 -				SDL_PrivateResize(size->w,size->h);
   2.236 -			}
   2.237 -		}
   2.238 -		break;
   2.239 -		
   2.240 -		/* window has been resized, moved or removed */
   2.241 -		case Ph_EV_EXPOSE:
   2.242 -		{
   2.243 -			if (SDL_VideoSurface)
   2.244 -			{
   2.245 -				rect = PhGetRects( event );
   2.246 +                /* Queue leaving fullscreen mode */
   2.247 +                switch_waiting = 0x01;
   2.248 +                switch_time = SDL_GetTicks() + 200;
   2.249 +            }
   2.250 +            /* gaining focus */
   2.251 +            else if ((winEvent->event_f==Ph_WM_FOCUS) && (winEvent->event_state==Ph_WM_EVSTATE_FOCUS))
   2.252 +            {
   2.253 +                set_motion_sensitivity(this, -1);
   2.254 +                posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
   2.255 +            }
   2.256 +            /* request to quit */
   2.257 +            else if (winEvent->event_f==Ph_WM_CLOSE)
   2.258 +            {
   2.259 +                posted = SDL_PrivateQuit();
   2.260 +            }
   2.261 +            /* request to resize */
   2.262 +            else if (winEvent->event_f==Ph_WM_RESIZE)
   2.263 +            {
   2.264 +                SDL_PrivateResize(winEvent->size.w, winEvent->size.h);
   2.265 +            }
   2.266 +            /* request to maximize */
   2.267 +            else if (winEvent->event_f==Ph_WM_MAX)
   2.268 +            {
   2.269 +                /* TODO: get screen resolution, set window pos to 0, 0 and resize it ! */
   2.270 +            }
   2.271 +        }
   2.272 +        break;
   2.273  
   2.274 -				//PgSetClipping(1, rect );
   2.275 -				for(i=0;i<event->num_rects;i++)
   2.276 -				{
   2.277 -					sdlrects[i].x = rect[i].ul.x;
   2.278 -					sdlrects[i].y = rect[i].ul.y;
   2.279 -					sdlrects[i].w = rect[i].lr.x - rect[i].ul.x + 1;
   2.280 -					sdlrects[i].h = rect[i].lr.y - rect[i].ul.y + 1;
   2.281 -				}
   2.282 +        /* window has been resized, moved or removed */
   2.283 +        case Ph_EV_EXPOSE:
   2.284 +        {
   2.285 +            if (SDL_VideoSurface)
   2.286 +            {
   2.287 +                rect = PhGetRects(event);
   2.288  
   2.289 -				this->UpdateRects(this, event->num_rects, sdlrects);
   2.290 +                for(i=0;i<event->num_rects;i++)
   2.291 +                {
   2.292 +                    sdlrects[i].x = rect[i].ul.x;
   2.293 +                    sdlrects[i].y = rect[i].ul.y;
   2.294 +                    sdlrects[i].w = rect[i].lr.x - rect[i].ul.x + 1;
   2.295 +                    sdlrects[i].h = rect[i].lr.y - rect[i].ul.y + 1;
   2.296 +                }
   2.297  
   2.298 -			}
   2.299 -		}
   2.300 -		break;
   2.301 +                this->UpdateRects(this, event->num_rects, sdlrects);
   2.302 +            }
   2.303 +        }
   2.304 +	break;
   2.305  
   2.306 -		case Ph_EV_KEY:
   2.307 -		{
   2.308 -	
   2.309 -			SDL_keysym keysym;
   2.310 -			
   2.311 -			posted = 0;
   2.312 -			
   2.313 -			keyEvent = PhGetData( event );
   2.314 +        case Ph_EV_KEY:
   2.315 +        {
   2.316 +            SDL_keysym keysym;
   2.317 +
   2.318 +            posted = 0;
   2.319 +
   2.320 +            keyEvent = PhGetData( event );
   2.321  
   2.322 -			if (Pk_KF_Key_Down & keyEvent->key_flags)
   2.323 -			{
   2.324 -				
   2.325 -				posted = SDL_PrivateKeyboard(SDL_PRESSED,
   2.326 -                			ph_TranslateKey( keyEvent, &keysym));
   2.327 -			}
   2.328 -			else /* must be key release */
   2.329 - 			{
   2.330 - 				/* Ignore repeated key release events */
   2.331 -				/*if (! Pk_KF_Key_Repeat & keyEvent->key_flags )*/
   2.332 -				
   2.333 -					posted = SDL_PrivateKeyboard(SDL_RELEASED,
   2.334 -        					ph_TranslateKey( keyEvent, &keysym));
   2.335 -				/*}*/
   2.336 -			}
   2.337 -		}
   2.338 -		break;
   2.339 -	}
   2.340 -	
   2.341 -		
   2.342 -	
   2.343 -	return(posted);
   2.344 +            if (Pk_KF_Key_Down & keyEvent->key_flags)
   2.345 +            {
   2.346 +                posted = SDL_PrivateKeyboard(SDL_PRESSED, ph_TranslateKey(keyEvent, &keysym));
   2.347 +            }
   2.348 +            else /* must be key release */
   2.349 +            {
   2.350 +                 /* Ignore repeated key release events */
   2.351 +                 /* if (! Pk_KF_Key_Repeat & keyEvent->key_flags ) */
   2.352 +
   2.353 +                posted = SDL_PrivateKeyboard(SDL_RELEASED, ph_TranslateKey( keyEvent, &keysym));
   2.354 +            }
   2.355 +        }
   2.356 +        break;
   2.357 +    }
   2.358 +
   2.359 +    return(posted);
   2.360  }
   2.361  
   2.362  /* 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 -    /* return a palette if we are in 256 color mode */
    3.28 -    if (vformat->BitsPerPixel == 8)
    3.29 +    
    3.30 +    /* save current palette */
    3.31 +    if (desktopbpp==8)
    3.32      {
    3.33 -        vformat->palette = malloc(sizeof(SDL_Palette));
    3.34 -        memset(vformat->palette, 0, sizeof(SDL_Palette));
    3.35 -        vformat->palette->ncolors = 256;
    3.36 -        vformat->palette->colors = (SDL_Color *)malloc(256 *sizeof(SDL_Color));
    3.37 -
    3.38 -        /* fill the palette */
    3.39 -        rtnval = PgGetPalette(ph_palette);
    3.40 -        if (rtnval < 0)
    3.41 -        {
    3.42 -	    fprintf(stderr, "ph_VideoInit: PgGetPalette failed\n");
    3.43 -        }
    3.44 -
    3.45 -        tempptr = (unsigned long *)vformat->palette->colors;
    3.46 -
    3.47 -        for(i=0;i<256; i++)
    3.48 -        {
    3.49 -            *tempptr = (((unsigned long)ph_palette[i]) << 8);
    3.50 -            tempptr++;
    3.51 -        }		
    3.52 +        PgGetPalette(ph_palette);
    3.53      }
    3.54 -
    3.55 +         
    3.56      currently_fullscreen = 0;
    3.57      
    3.58      this->info.wm_available = 1;
    3.59 @@ -268,6 +249,8 @@
    3.60      /* Lock the event thread, in multi-threading environments */
    3.61      SDL_Lock_EventThread();
    3.62  
    3.63 +    current->flags = flags;
    3.64 +
    3.65      /* create window if no OpenGL support selected */
    3.66      if ((flags & SDL_OPENGL)!=SDL_OPENGL)
    3.67      {
    3.68 @@ -276,6 +259,34 @@
    3.69          PtSetArg(&arg[pargc++], Pt_ARG_DIM, &dim, 0);
    3.70          PtSetArg(&arg[pargc++], Pt_ARG_RESIZE_FLAGS, Pt_FALSE, Pt_RESIZE_XY_AS_REQUIRED);
    3.71  
    3.72 +        /* enable window minimizing */
    3.73 +        PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, Ph_WM_HIDE);
    3.74 +
    3.75 +        /* remove border and caption if no frame flag selected */
    3.76 +        if ((flags & SDL_NOFRAME) == SDL_NOFRAME)
    3.77 +        {
    3.78 +            PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Ph_WM_RENDER_TITLE | Ph_WM_RENDER_BORDER);
    3.79 +        }
    3.80 +        else
    3.81 +        {
    3.82 +            PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_TITLE | Ph_WM_RENDER_BORDER);
    3.83 +        }
    3.84 +
    3.85 +        /* if window is not resizable then remove resize handles and maximize button */
    3.86 +        if ((flags & SDL_RESIZABLE) != SDL_RESIZABLE)
    3.87 +        {
    3.88 +            PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX);
    3.89 +            PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX);
    3.90 +            PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX);
    3.91 +        }
    3.92 +        else
    3.93 +        {
    3.94 +            PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX);
    3.95 +            /* it is need to be Pt_FALSE to allow the application to process the resize callback */
    3.96 +            PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_RESIZE | Ph_WM_MAX);
    3.97 +            PtSetArg(&arg[pargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, Ph_WM_RESIZE | Ph_WM_MAX);
    3.98 +        }
    3.99 +
   3.100          if (window!=NULL)
   3.101          {
   3.102              PtUnrealizeWidget(window);
   3.103 @@ -283,7 +294,7 @@
   3.104              window=NULL;
   3.105          }
   3.106  
   3.107 -        window=PtCreateWidget(PtWindow, NULL, pargc-1, arg);
   3.108 +        window=PtCreateWidget(PtWindow, NULL, pargc, arg);
   3.109          PtRealizeWidget(window);
   3.110          
   3.111          PtFlush();
   3.112 @@ -295,7 +306,6 @@
   3.113          /* ph_SetupOpenGLContext creates also window as need */
   3.114          if (ph_SetupOpenGLContext(this, width, height, bpp, flags)==0)
   3.115          {
   3.116 -            current->flags=flags;
   3.117              /* setup OGL update function ... ugly method */
   3.118              ph_ResizeImage(this, current, flags); 
   3.119          }
   3.120 @@ -363,15 +373,13 @@
   3.121          } /* end fullscreen flag */
   3.122          else
   3.123          {
   3.124 -            if (flags & SDL_HWSURFACE)  /* Use offscreen memory iff SDL_HWSURFACE flag is set */
   3.125 +            /* Use offscreen memory iff SDL_HWSURFACE flag is set */
   3.126 +            if (flags & SDL_HWSURFACE)
   3.127              {
   3.128 -                /* Hardware surface is Offsceen Context.  ph_ResizeImage handles the switch */
   3.129 -                current->flags = (flags & (~SDL_RESIZABLE)); /* no stretch blit in offscreen context */
   3.130 +                /* no stretch blit in offscreen context */
   3.131 +                current->flags = (flags & (~SDL_RESIZABLE));
   3.132              }
   3.133 -            else /* must be SDL_SWSURFACE */
   3.134 -            {
   3.135 -                current->flags = (flags | SDL_RESIZABLE); /* yes we can resize as this is a software surface */
   3.136 -            }
   3.137 +
   3.138              /* using palette emulation code in window mode */
   3.139              if (bpp==8)
   3.140              {
   3.141 @@ -425,6 +433,9 @@
   3.142          ph_SetCaption(this, this->wm_title, NULL);
   3.143      }
   3.144  
   3.145 +    /* finish window drawing */
   3.146 +    PtFlush();
   3.147 +
   3.148      SDL_Unlock_EventThread();
   3.149  
   3.150      /* We're done! */
   3.151 @@ -433,7 +444,9 @@
   3.152  
   3.153  static void ph_VideoQuit(_THIS)
   3.154  {
   3.155 +#ifdef HAVE_OPENGL
   3.156      PhRegion_t region_info;
   3.157 +#endif /* HAVE_OPENGL */
   3.158  
   3.159      ph_DestroyImage(this, SDL_VideoSurface); 
   3.160  
   3.161 @@ -443,7 +456,7 @@
   3.162      }
   3.163  
   3.164  #ifdef HAVE_OPENGL
   3.165 -    /* prevent double SEGFAULT with parachute mode */
   3.166 +    /* prevent double SEGFAULT during parachute mode */
   3.167      if (this->screen)
   3.168      {
   3.169          if (((this->screen->flags & SDL_FULLSCREEN)==SDL_FULLSCREEN) &&
   3.170 @@ -518,14 +531,14 @@
   3.171              if ((this->screen->flags & SDL_FULLSCREEN) != SDL_FULLSCREEN)
   3.172              {
   3.173                  /* window mode must use soft palette */
   3.174 -                PgSetPalette((PgColor_t*)&syspalph, 0, firstcolor, ncolors, Pg_PALSET_SOFT, 0);
   3.175 +                PgSetPalette((PgColor_t*)&syspalph[firstcolor], 0, firstcolor, ncolors, Pg_PALSET_SOFT, 0);
   3.176                  /* image needs to be redrawed, very slow method */
   3.177                  PgDrawPhImage(&point, SDL_Image, 0);
   3.178              }
   3.179              else
   3.180              {
   3.181                  /* fullscreen mode must use hardware palette */
   3.182 -                PgSetPalette((PgColor_t*)&syspalph, 0, firstcolor, ncolors, Pg_PALSET_GLOBAL, 0);
   3.183 +                PgSetPalette((PgColor_t*)&syspalph[firstcolor], 0, firstcolor, ncolors, Pg_PALSET_GLOBAL, 0);
   3.184              }
   3.185          }
   3.186          else
   3.187 @@ -586,9 +599,10 @@
   3.188      {
   3.189          oglctx=PdCreateOpenGLContext(1, &dim, 0, OGLAttrib);
   3.190      }
   3.191 +
   3.192      if (oglctx==NULL)
   3.193      {
   3.194 -        fprintf(stderr,"error: cannot create OpenGL context.\n");
   3.195 +        fprintf(stderr,"ph_SetupOpenGLContext: cannot create OpenGL context.\n");
   3.196          return (-1);
   3.197      }
   3.198  
   3.199 @@ -608,10 +622,26 @@
   3.200          pos.y=0;
   3.201  
   3.202          PtSetArg(&args[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, ~0);
   3.203 -        PtSetArg(&args[pargc++], Pt_ARG_WINDOW_MANAGED_FLAGS,Pt_TRUE, Ph_WM_FFRONT | Ph_WM_CLOSE | Ph_WM_TOFRONT | Ph_WM_CONSWITCH);
   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_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT | Ph_WM_STATE_ISFOCUS);
   3.206          PtSetArg(&args[pargc++], Pt_ARG_POS, &pos, 0);
   3.207      }
   3.208 +    else
   3.209 +    {
   3.210 +        /* remove border and caption if no frame flag selected */
   3.211 +        if ((flags & SDL_NOFRAME) == SDL_NOFRAME)
   3.212 +        {
   3.213 +            PtSetArg(&args[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, 0, Ph_WM_RENDER_TITLE | Ph_WM_RENDER_BORDER);
   3.214 +        }
   3.215 +        else
   3.216 +        {
   3.217 +           /* if window is not resizable then remove resize handles */
   3.218 +           if ((flags & SDL_RESIZABLE) != SDL_RESIZABLE)
   3.219 +           {
   3.220 +               PtSetArg(&args[pargc++], Pt_ARG_WINDOW_RENDER_FLAGS, 0, Ph_WM_RENDER_RESIZE);
   3.221 +           }
   3.222 +        }
   3.223 +    }
   3.224  
   3.225      if (window!=NULL)
   3.226      {
   3.227 @@ -620,7 +650,7 @@
   3.228          window=NULL;
   3.229      }
   3.230  
   3.231 -    window=PtCreateWidget(PtWindow, NULL, pargc-1, args);
   3.232 +    window=PtCreateWidget(PtWindow, NULL, pargc, args);
   3.233      PtRealizeWidget(window);
   3.234  
   3.235      /* 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  }