nanogui: GR_EVENT_SCREENSAVER never emitted
Subject:
Re: GR_EVENT_SCREENSAVER never emitted
From:
"hongouyang" ####@####.####
Date:
5 May 2001 08:54:33 -0000
Message-Id: <002b01c0d540$fabd3120$557e9684@sttri.com>
Thank you very much for your reply.
> I think you should add this line instead:
> GrSelectEvents(GR_ROOT_WINDOW_ID, GR_EVENT_MASK_SCREENSAVER);
>
> In other words, you need to select for screensaver events on the root
> window rather than on an application window.
Yes, I modified the nxkbd.c file to add this line as you say, and it does work. Now I want make the nano-x server do the work instead of a appliation, because I am only intersted in the srvutil.c:GsActivateScreenSaver( ) call. I add these lines in the srvmain.c:main( ) right after the GsInitialize( ) call:
GrSetScreenSaverTimeout(10); /* I think the nano-X Libary API doc has error in the description of this function's argument. It is not in miniseconds , but in seconds*/
GrSelectEvents(GR_ROOT_WINDOW_ID, GR_EVENT_MASK_SCREENSAVER);
I compiled all then. When I run the nano-X, a segmentation fault occured after some time and the nano-X exit.
When I modifed the srvmain.c:main() as this, it works:
.....
if(GsInitialize() < 0)
exit(1);
GrSetScreenSaverTimeout(10); /*added*/
while(1){
GsSelect(10*1000L); /*modified the parameter from 0L to 10000L */
}
.....
Does this two method has much difference? How does it work?
Thanks.
> > line 340: case GR_EVENT_TYPE_SCREENSAVER: /*added by me in the for(;;) */
> > printf("Screensaver event got\n");
> > break;
>
> Note that you will probably also want to test whether
> event.screensaver.activate is true or not to find out whether to activate
> or deactivate the screensaver.