Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Oct 1998 09:44:35 +0000 (GMT)
From:      Doug Rabson <dfr@nlsystems.com>
To:        Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
Cc:        John Hay <jhay@mikom.csir.co.za>, FreeBSD-hackers <hackers@FreeBSD.ORG>
Subject:   Re: kld screensavers 
Message-ID:  <Pine.BSF.4.01.9810300936140.366-100000@herring.nlsystems.com>
In-Reply-To: <199810291457.XAA12116@zodiac.mech.utsunomiya-u.ac.jp>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 29 Oct 1998, Kazutaka YOKOTA wrote:

> 
> >It looks about right and SI_SUB_PSEUDO is sufficiently late that it
> >shouldn't disturb anything.  Any time after SI_SUB_CONFIGURE should work I
> >think.
> >
> >It would be nice if the add_scrn_saver/remove_scrn_saver goop was factored
> >into a generic module event handler which can be used by all screen
> >savers.  Have a look at the CDEV_MODULE #define in sys/conf.h for a
> >possible way of doing this.
> >
> >If the generic module handler chains onto an optional user-supplied
> >handler, then extra initialisation (allocating message in this case) can
> >be done by each saver without repeating the registration code.
> 
> You mean something like this?
> 
> 1. Define generic_screen_saver_module_handler() in syscons.c or somewhere.
> 2. Each screen saver module define its own event handler.  It will call
>    the generic handler first and then do its own extra house keeping.

Thats more or less what I was suggesting.  Simple screen savers wouldn't
even need an event handler.  Maybe something like:

struct saver_module_data {
	modeventhand_t 	chainevh;
	void*		chainarg;
	void 	      	(*saver)(int);
};

#defined SAVER_MODULE(name, fn, evh, arg)		\
static struct saver_module_data name##_saver_mod = {	\
	evh, arg, fn					\
};							\
							\
static moduledata_t name##_mod = {			\
	#name,						\
	saver_module_handler,				\
	&name##_saver_mod				\
};							\
DECLARE_MODULE(name, name##_mod, SI_SUB_PSEUDO, SI_ORDER_MIDDLE)

static int
saver_module_handler(module_t mod, modeventtype_t type, void *arg)
{
	struct saver_module_data *data = arg;
        switch (type) {
        case MOD_LOAD:
                return add_scrn_saver(data->saver);
        case MOD_UNLOAD:
                return remove_scrn_saver(data->saver);
        default:
                printf("star_saver module unknown event: 0x%x\n", type);
        }

	if (data->chainevh)
		return data->chainevh(mod, what, data->chainarg);
	else
	        return 0;
}

--
Doug Rabson				Mail:  dfr@nlsystems.com
Nonlinear Systems Ltd.			Phone: +44 181 951 1891
					Fax:   +44 181 381 1039



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.01.9810300936140.366-100000>