View Full Version : Cpw visibility function - not seeing Hide or Show event.

02-25-2002, 10:29 AM
I am trying out various functions in Cpw. Currently working with the Visibility Event. Everything works as expected except the "Hide" and "Show" events.

I have included my example below. Nothing special, just a printf statement.

/************************************************** ******/
/* Window Visibility Event callback */
/* State Constants: 0 CPW_HIDE */
/* 1 CPW_SHOW */
/* 4 CPW_ICONIC x */
/* 5 CPW_RESTORED x */
/************************************************** ******/
void visibility( pCpw cpw, uint_32 winid, uint_32 state )
printf("Visibility Event: State = %d\n", state ); /* JP - Print Vars */

02-25-2002, 06:35 PM
Hey John,

The only way you'll get a CPW_HIDE is if you call cpwHideWindow on a window. You will get a show the first time a window shows after it is created. I did a little test in a demo:

switch ( state ) {
case CPW_SHOW:
printf( "Show Visibility Event" );
cpwHideWindow( cpw, id );

case CPW_HIDE:
printf( "Hide Visibility Event" );
cpwShowWindow( cpw, id );

Which resulted in a window that flashed on and off. So I think this is working. Let me know if helps.


02-26-2002, 04:46 AM
Hi Jim,

It seems that I did not understand what "Hide" meant.

GLUT has a function called "glutVisibilityFunc" that would determine when a window was completely obscured by other windows (it was hidden behind other windows). I guess this could be used to stop an animation or other processing and free up system resources when a window was not viewable.

I assumed that this was the same functionality in Cpw.


02-27-2002, 08:08 AM
Yeah it's not the same in Cpw. I prefer the way Cpw works as it is, but I'd welcome anybody elses feedback. Apps usually don't "turn off" when they are obscured by other windows (from my experience.) But you do need to know when the window is minimized or looses focus - which Cpw supports.

It would be possible to add this type of functionality if people think it's needed however. I could add a new set of constants to the visibility callback which communicate when the window is obscured.

As it stands now, Cpw communicates the following via the visibility callback:

1) iconic (minimized) / restored events.
2) focus changes - forground / not in the foreground changes.
3) hidden / shown changes.

from the source:

( http://www.mathies.com/cpw/srctohtml/cpw_event.h.html )

#define CPW_HIDE 0 /* if visible, now hidden */
#define CPW_SHOW 1 /* if hidden, now shown */
#define CPW_GAINEDFOCUS 2 /* now the foreground window */
#define CPW_LOSTFOCUS 3 /* lost foreground status */
#define CPW_ICONIC 4 /* was iconified */
#define CPW_RESTORED 5 /* was restored */

I could add a CPW_FULLYOBSCURED event maybe, but i'm not sure it's needed. This also might be tought to calculate on all platforms. I would suggest turning off animation on the focus lost event instead.


[This message has been edited by jmathies (edited 02-27-2002).]