1
/* toon.h - functions for drawing cartoons on the root window
2
* Copyright (C) 1999-2001 Robin Hogan
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
#include <X11/Intrinsic.h>
23
#include <X11/extensions/shape.h>
25
#define TOON_UNASSOCIATED -2
37
#define TOON_PARTIALMOVE 0
38
#define TOON_BLOCKED -1
39
#define TOON_SQUASHED -2
41
/* General configuration options */
42
#define TOON_DEFAULTS 0L
44
#define TOON_NOEDGEBLOCK (1L<<0)
45
#define TOON_EDGEBLOCK (1L<<1)
46
#define TOON_SIDEBOTTOMBLOCK (1L<<2)
47
#define TOON_NOSOLIDPOPUPS (1L<<4)
48
#define TOON_SOLIDPOPUPS (1L<<5)
49
#define TOON_NOSHAPEDWINDOWS (1L<<6)
50
#define TOON_SHAPEDWINDOWS (1L<<7)
52
#define TOON_NOCATCHSIGNALS (1L<<16)
53
#define TOON_CATCHSIGNALS (1L<<17)
54
#define TOON_EXITGRACEFULLY (1L<<18)
56
/* Configuration for individual toon types */
57
#define TOON_NOCYCLE (1L<<0)
58
#define TOON_INVULNERABLE (1L<<1)
59
#define TOON_NOBLOCK (1L<<2)
61
#define TOON_MESSAGE_LENGTH 128
62
#define TOON_DEFAULTMAXRELOCATE 8
66
/* The ToonData structure describes the properties of a type of toon,
67
* such as walker, climber etc. */
69
typedef struct __ToonData ToonData;
72
unsigned long int conf; /* bitmask of toon properties such as cycling etc */
74
char *filename; /* Name of image file name */
75
ToonData *master; /* If pixmap data is duplicated from another toon, this is it */
76
Pixmap pixmap, mask; /* pointers to X structures */
77
unsigned int nframes; /* number of frames in image */
78
unsigned int ndirections; /* number directions in image (1 or 2) */
79
unsigned int width, height; /* width & height of individual frame/dir */
80
unsigned int acceleration, speed, terminal_velocity;
81
int loop; /* Number of times to repeat cycle */
85
/* The Toon structure describes the properties of a particular toon,
86
* such as its location and speed */
89
int x, y, u, v; /* new position and velocity */
90
unsigned int genus, type, frame, direction;
92
unsigned int width_map, height_map;
93
/* properties of the image mapped on the screen */
94
unsigned int associate; /* toon is associated with a window */
95
int xoffset, yoffset; /* location relative to window origin */
96
unsigned int wid; /* window associated with */
97
unsigned int cycle; /* Number of times frame cycle has repeated */
105
/*** INTERNAL STRUCTURES AND FUNCTION PROTOTYPES ***/
111
typedef int __ToonErrorHandler();
112
void __ToonSignalHandler(int sig);
113
int __ToonError(Display *toon_display, XErrorEvent *error);
114
void __ToonExitGracefully(int sig);
116
/* OK, OK, global variables are gross but it makes the interface easier,
117
* and we're unlikely to want to two threads in the same program writing
118
* to two different screens */
119
extern Display *toon_display;
120
extern Window toon_root; /* the window to draw to */
121
extern Window toon_parent; /* the parent window of all the client windows */
122
extern Window toon_root_override; /* override both toon_root and toon_parent */
123
extern int toon_x_offset, toon_y_offset; /* toon_root relative to toon_parent */
124
extern int toon_display_width, toon_display_height;
125
extern GC toon_drawGC;
126
extern Region toon_windows;
127
extern unsigned int toon_nwindows;
128
extern __ToonWindowData *toon_windata;
129
extern ToonData **toon_data;
130
extern int toon_ngenera;
131
extern int toon_ntypes;
132
extern int toon_errno;
133
extern char toon_edge_block;
134
extern char toon_shaped_windows;
135
extern char toon_solid_popups;
136
extern int toon_signal;
137
extern char toon_error_message[TOON_MESSAGE_LENGTH];
138
extern char toon_message[TOON_MESSAGE_LENGTH];
139
extern int toon_max_relocate_up;
140
extern int toon_max_relocate_down;
141
extern int toon_max_relocate_left;
142
extern int toon_max_relocate_right;
144
/*** FUNCTION PROTOTYPES ***/
146
/* HANDLE STRANGE WINDOW MANAGERS (toon_root.c) */
147
Window ToonGetRootWindow(Display *display, int screen,
148
Window *clientparent);
150
/* SIGNAL AND ERROR HANDLING FUNCTIONS (toon_signal.c) */
152
char *ToonErrorMessage();
154
/* STARTUP FUNCTIONS (toon_init.c) */
155
Display *ToonOpenDisplay(char *display_name);
156
int ToonInit(Display *display);
157
int ToonConfigure(unsigned long int code);
158
int ToonInstallData(ToonData **data, int ngenera, int ntypes);
159
#define ToonSetRoot(id) toon_root_override = (Window) id
161
/* FINISHING UP (toon_end.c) */
164
int ToonCloseDisplay();
166
/* DRAWING FUNCTIONS (toon_draw.c) */
167
int ToonDraw(Toon *toon,int n);
168
int ToonErase(Toon *toon,int n);
171
/* QUERY FUNCTIONS (toon_query.c) */
172
#define ToonDisplayWidth() (toon_display_width)
173
#define ToonDisplayHeight() (toon_display_height)
174
int ToonBlocked(Toon *toon, int direction);
175
int ToonOffsetBlocked(Toon *toon, int xoffset, int yoffset);
176
int ToonWindowsMoved();
178
/* ASSIGNMENT FUNCTIONS (toon_set.c) */
179
void ToonMove(Toon *toon, int xoffset, int yoffset);
180
void ToonSetPosition(Toon *toon, int x, int y);
181
void ToonSetGenusAndType(Toon *toon, int genus, int type, int direction,
183
#define ToonSetType(toon, type, direction, gravity) \
184
ToonSetGenusAndType(toon, (toon)->genus, type, direction, gravity)
185
void ToonSetVelocity(Toon *toon, int u, int v);
187
/* CORE FUNCTIONS (toon_core.c) */
188
int ToonAdvance(Toon *toon, int mode);
189
int ToonLocateWindows();
190
int ToonSleep(unsigned long usecs);
192
/* HANDLING TOON ASSOCIATIONS WITH MOVING WINDOWS (toon_associate.c) */
193
void ToonSetAssociation(Toon *toon, int direction);
194
void ToonSetMaximumRelocate(int up, int down, int left, int right);
195
int ToonRelocateAssociated(Toon *toon, int n);
196
int ToonCalculateAssociations(Toon *toon, int n);