wdvi

network DVI viewer
Log | Files | Refs

events.h (4012B)


      1 #include <X11/Intrinsic.h>
      2 
      3 #include <poll.h>		/* struct pollfd */
      4 
      5 #include "data.h"		/* struct rgb */
      6 
      7 
      8 struct xdvi_action {
      9 	struct xdvi_action *next;
     10 	XtActionProc	proc;
     11 	Cardinal	num_params;
     12 	String		param;
     13 };
     14 
     15 struct wheel_acts {
     16 	struct wheel_acts *next;
     17 	Modifiers	mask;
     18 	Modifiers	value;
     19 	struct _LateBindings *late_bindings;
     20 	unsigned int	button;
     21 	struct xdvi_action *action;
     22 };
     23 
     24 struct wheel_acts	*wheel_actions;
     25 
     26 struct	xio {
     27 	struct xio	*next;		/* link to next in list */
     28 	int		fd;		/* file descriptor */
     29 	int		xio_events;	/* same as in struct pollfd (can't call
     30 					   it events because poll.h on AIX
     31 					   defines events to something else) */
     32 	struct pollfd	*pfd;
     33 	void	(*read_proc)(void);	/* call to read */
     34 	void	(*write_proc)(void);	/* call to write */
     35 };
     36 
     37 struct	xchild {
     38 	struct xchild	*next;		/* link to next in list */
     39 	pid_t		pid;		/* pid of process, or 0 */
     40 	Boolean		killable;	/* if can be killed with SIGKILL */
     41 	void	(*proc)(int);	/* procedure to call */
     42 };
     43 
     44 struct	WindowRec {
     45 	Window		win;
     46 	int		shrinkfactor;
     47 	int		base_x, base_y;
     48 	unsigned int	width, height;
     49 	int	min_x, max_x, min_y, max_y;	/* for pending expose events */
     50 };
     51 
     52 extern struct	 WindowRec mane, alt, currwin;
     53 #define	shrink_factor	currwin.shrinkfactor
     54 
     55 
     56 /*
     57  * Default magnifier sizes
     58  */
     59 struct	mg_size_rec {
     60 	int		w;
     61 	int		h;
     62 }  mg_size[] = {
     63 	{ 200, 150 },
     64 	{ 400, 250 },
     65 	{ 700, 500 },
     66 	{ 1000, 800 },
     67 	{ 1200, 1200 }
     68 };
     69 
     70 
     71 /*
     72  * For each (foreground, background) color pair, we keep information (depending
     73  * on the color model).  It is organized as a linked list of linked lists,
     74  * with background color more significant.
     75  */
     76 
     77 struct bgrec {
     78 	struct bgrec	*next;
     79 	struct rgb	color;
     80 	struct fgrec	*fg_head;
     81 	Boolean		pixel_good;	/* if the pixel entry is valid */
     82 	Pixel		pixel;
     83 };
     84 
     85 struct fgrec {
     86 	struct fgrec	*next;
     87 	struct rgb	color;
     88 	Boolean		pixel_good;	/* if the pixel entry is valid */
     89 	Pixel		pixel;
     90 };
     91 
     92 struct bgrec	*bg_head	= NULL;	/* head of list */
     93 struct bgrec	*bg_current	= NULL;	/* current bg value */
     94 struct fgrec	*fg_current;		/* current fg value */
     95 struct fgrec	*fg_active	= NULL;	/* where the GCs are */
     96 
     97 
     98 /*
     99  *	Flag values and masks for event_flags
    100  */
    101 
    102 #define	EV_IDLE		(1<<0)	/* non-event */
    103 #define	EV_CURSOR	(1<<1)	/* cursor needs to revert back to ready */
    104 #define	EV_EXPOSE	(1<<2)	/* expose occurred somewhere */
    105 #define	EV_MAG_MOVE	(1<<3)	/* magnifier moved */
    106 #define	EV_MAG_GONE	(1<<4)	/* magnifier gone while being drawn */
    107 #define	EV_ACK		(1<<5)	/* used internally */
    108 #define	EV_NEWPAGE	(1<<7)	/* new page requested */
    109 #define	EV_PS_TOGGLE	(1<<8)	/* PostScript toggled on or off */
    110 #define	EV_NEWDOC	(1<<9)	/* new dvi file requested */
    111 #define	EV_TERM		(1<<10)	/* quit */
    112 #define	EV_MAXPLUS1	(1<<11)
    113 
    114 #define	EV_GE_IDLE		(EV_MAXPLUS1 - EV_IDLE)
    115 #define	EV_GT_IDLE		(EV_MAXPLUS1 - EV_CURSOR)
    116 #define	EV_GE_CURSOR		(EV_MAXPLUS1 - EV_CURSOR)
    117 #define	EV_GE_EXPOSE		(EV_MAXPLUS1 - EV_EXPOSE)
    118 #define	EV_GE_MAG_MOVE		(EV_MAXPLUS1 - EV_MAG_MOVE)
    119 #define	EV_GE_MAG_GONE		(EV_MAXPLUS1 - EV_MAG_GONE)
    120 #define	EV_GE_ACK		(EV_MAXPLUS1 - EV_ACK)
    121 #define	EV_GE_NEWPAGE		(EV_MAXPLUS1 - EV_NEWPAGE)
    122 #define	EV_GE_PS_TOGGLE		(EV_MAXPLUS1 - EV_PS_TOGGLE)
    123 #define	EV_GE_NEWDOC		(EV_MAXPLUS1 - EV_NEWDOC)
    124 #define	EV_GE_TERM		(EV_MAXPLUS1 - EV_TERM)
    125 
    126 #define	EV_NOWAIT		EV_GE_IDLE
    127 
    128 unsigned int	ev_flags	= EV_IDLE;
    129 
    130 extern	XtActionsRec	Actions[];
    131 extern	Cardinal	num_actions;
    132 GC		ruleGC;
    133 GC		foreGC;
    134 GC		foreGC2;
    135 GC		copyGC;
    136 GC		linkGC;
    137 
    138 Pixel		*pixeltbl;
    139 Pixel		*pixeltbl_t;
    140 
    141 int		min_x, max_x, min_y, max_y;
    142 
    143 
    144 Bool	 compile_action(const char *, struct xdvi_action **);
    145 void	 do_color_change(void);
    146 void	 do_pages(void);
    147 void	 enable_intr(void);
    148 void	 handle_expose(Widget, XtPointer, XEvent *, Boolean *);
    149 void	 handle_resize(Widget, XtPointer, XEvent *, Boolean *);
    150 void	 handle_messages(Widget, XtPointer, XEvent *, Boolean *);
    151 unsigned int read_events(unsigned int);
    152 
    153 void	 set_io(struct xio *);
    154 void	 clear_io(struct xio *);
    155 
    156 void	 set_chld(struct xchild *);
    157 void	 clear_chld(struct xchild *);