/*
 * ButtonBox - a program launcher
 *
 * Copyright (C) 2000 Paul Collins
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 *
 */

#ifndef DISPATCHER_H
#define DISPATCHER_H

#include <X11/Xlib.h>



/* Types: */



typedef struct Dispatcher Dispatcher;
typedef struct WindowInformation WindowInformation;

typedef Bool (*WindowProcedure) (Dispatcher*, XEvent*, void*);

struct Dispatcher 
{
	Display* display;
	int num_windows;
	int num_windows_allocated;
	WindowInformation* windows;
	WindowProcedure default_procedure;
	Bool loop_running;
	Bool reap_zombies;
};

struct WindowInformation 
{
	Window wi_window;
	WindowProcedure wi_procedure;
	void* wi_data;
};



Dispatcher* dispatcher_new (Display*);

void dispatcher_register (Dispatcher*, Window, WindowProcedure, void*);

Display* dispatcher_get_display (Dispatcher*);

void dispatcher_run_loop (Dispatcher*);

void dispatcher_reap_zombies (Dispatcher* dispatcher, Bool reap_p);

void dispatcher_request_loop_exit (Dispatcher*);


#endif /* DISPATCHER_H */
