1
/* sawfish.h -- Main include file, brings in all the rest
4
Copyright (C) 1999 John Harper <john@dcs.warwick.ac.uk>
6
This file is part of sawfish.
8
sawfish is free software; you can redistribute it and/or modify it
9
under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2, or (at your option)
13
sawfish is distributed in the hope that it will be useful, but
14
WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with sawfish; see the file COPYING. If not, write to
20
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
32
#include <sys/types.h>
37
#if defined (HAVE_IMLIB)
39
#elif defined (HAVE_GDK_PIXBUF)
40
# include <gdk-pixbuf-xlib/gdk-pixbuf-xlib.h>
42
# error "Need an image handling library!"
46
# define rep_INTERFACE 7 /* rep 0.10 */
55
/* Uncomment the following line to get reams of debugging data. But
56
redirect it to a non-X terminal (otherwise we can't printf when
57
the server is grabbed => deadlock)
59
You can also define it to zero to store the debugging output in
60
one of rep's buffers. Send the sawfish process a SIGUSR2 to print
61
the last 4k or so to stderr. */
67
/* Events selected on client windows */
68
#define CLIENT_EVENTS (PropertyChangeMask | StructureNotifyMask \
69
| ColormapChangeMask | VisibilityChangeMask)
71
/* Events selected on the root window */
72
#define ROOT_EVENTS (SubstructureRedirectMask | SubstructureNotifyMask \
73
| ButtonPressMask | ButtonReleaseMask | KeyPressMask \
74
| ButtonMotionMask | PointerMotionHintMask \
75
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask)
77
/* Events selected on each frame part */
78
#define FP_EVENTS (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask \
79
| PointerMotionHintMask | EnterWindowMask \
80
| LeaveWindowMask | KeyPressMask | ExposureMask)
82
/* Events selected on the frame window */
83
#define FRAME_EVENTS (ButtonPressMask | ButtonReleaseMask | KeyPressMask \
84
| ButtonMotionMask | PointerMotionHintMask \
85
| EnterWindowMask | LeaveWindowMask | ExposureMask \
86
| FocusChangeMask | SubstructureRedirectMask \
87
| VisibilityChangeMask)
89
/* Events selected in pointer/button grabs */
90
#define POINTER_GRAB_EVENTS (ButtonPressMask | ButtonReleaseMask \
91
| PointerMotionMask | PointerMotionHintMask)
95
/* A managed window */
96
typedef struct lisp_window {
98
struct lisp_window *next;
104
struct lisp_window *above, *below;
106
/* Is the client window mapped? (by its app) */
107
unsigned int mapped : 1;
109
/* Is the frame visible? (not hidden by hide-window) */
110
unsigned int visible : 1;
112
/* Is the client window hidden by us?
113
(controlled by window's `hide-client' property -- used for shading) */
114
unsigned int client_hidden : 1;
116
/* Is the client window unmapped by us?
117
(because it's !visible or client_hidden) */
118
unsigned int client_unmapped : 1;
120
/* Is the client window reparented to the frame? */
121
unsigned int reparented : 1;
123
/* Is the client window shaped? */
124
unsigned int shaped : 1;
126
/* Have we called the destroy-notify-hook? */
127
unsigned int destroyed : 1;
129
/* The WM protocols understood by the client */
130
unsigned int does_wm_take_focus : 1;
131
unsigned int does_wm_delete_window : 1;
133
/* Do we need to send a synthetic ConfigureNotify to this window? */
134
unsigned int pending_configure : 1;
136
/* Do we need to recalculate the shape mask of the frame? */
137
unsigned int pending_reshape : 1;
139
/* The position and dimensions of `attr' is always maintained.
140
But the position is the position of the frame, while the
141
dimensions are those of the client */
142
XWindowAttributes attr;
145
Window *cmap_windows;
147
repv full_name, name, icon_name;
148
repv net_name, net_icon_name;
154
struct frame_part *frame_parts;
155
int frame_x, frame_y; /* relative to client-window */
156
unsigned int frame_width, frame_height;
157
void (*destroy_frame)(struct lisp_window *w);
158
void (*focus_change)(struct lisp_window *w);
159
void (*rebuild_frame)(struct lisp_window *w);
160
void (*property_change)(struct lisp_window *w);
163
#define VWIN(v) ((Lisp_Window *)rep_PTR(v))
164
#define XWINDOWP(v) rep_CELL16_TYPEP(v, window_type)
165
#define WINDOWP(v) XWINDOWP(v)
167
#define WINDOW_FOCUSED_P(w) (focus_window == w)
168
#define WINDOW_IS_GONE_P(w) (w->id == 0)
170
typedef struct Lisp_Font_Class_struct Lisp_Font_Class;
172
/* An allocated font */
173
typedef struct lisp_font {
175
struct lisp_font *next;
176
const Lisp_Font_Class *class;
184
#define FONTP(v) rep_CELL16_TYPEP(v, font_type)
185
#define VFONT(v) ((Lisp_Font *)rep_PTR(v))
187
/* An allocated color */
188
typedef struct lisp_color {
190
struct lisp_color *next;
191
int red, green, blue, alpha; /* each 16 bits */
192
int pixel; /* somewhere in the screen's cmap */
195
#define COLORP(v) rep_CELL16_TYPEP(v, color_type)
196
#define VCOLOR(v) ((Lisp_Color *)rep_PTR(v))
198
/* An allocated cursor */
199
typedef struct lisp_cursor {
201
struct lisp_cursor *next;
206
#define CURSORP(v) rep_CELL16_TYPEP(v, cursor_type)
207
#define VCURSOR(v) ((Lisp_Cursor *)rep_PTR(v))
209
#if defined (HAVE_IMLIB)
210
typedef ImlibImage *image_t;
211
#elif defined (HAVE_GDK_PIXBUF)
212
typedef GdkPixbuf *image_t;
215
typedef struct pixmap_cache_node_struct pixmap_cache_node;
218
typedef struct lisp_image {
220
struct lisp_image *next;
222
#if !defined (HAVE_IMLIB)
225
#if defined (NEED_PIXMAP_CACHE)
226
pixmap_cache_node *pixmap_first, *pixmap_last;
231
#define IMAGEP(v) rep_CELL16_TYPEP(v, image_type)
232
#define VIMAGE(v) ((Lisp_Image *)rep_PTR(v))
234
enum frame_part_states {
239
fps_inactive_highlighted,
241
fps_inactive_clicked,
245
/* one component of a frame */
248
struct frame_part *next, *next_alloc;
249
repv alist; /* the generator alist */
253
int x, y, width, height;
257
unsigned int clicked : 1;
258
unsigned int highlighted : 1;
259
unsigned int pending_refresh : 1;
260
unsigned int below_client : 1;
261
unsigned int scale_foreground : 1;
263
repv text; /* may be nil, a string, or a function */
264
repv x_justify, y_justify;
267
repv fg[fps_MAX]; /* may be color or image */
268
repv bg[fps_MAX]; /* may be color or image */
270
/* If renderer != Qnil, this overrides the bg array. It's a
271
function to call to render the contents of rendered_image
272
to the current state. */
273
repv renderer, rendered_image;
274
int render_scale, rendered_state;
278
/* cached state of the window */
282
repv x_justify, y_justify;
287
#define PARTP(v) rep_CELL16_TYPEP(v, frame_part_type)
288
#define VPART(v) ((struct frame_part *) rep_PTR (v))
290
/* codes for the clean_exit_jmp_buf */
298
/* bring in prototypes */
300
#ifndef XlibSpecificationRelease
301
# define XlibSpecificationRelease 4
304
/* Work around for X11R5 and earlier */
306
#define XUrgencyHint (1 << 8)
309
#include "sawfish_subrs.h"
311
/* Miscellaneous macro defs */
313
/* Maximum/minimum macros. Don't use when X or Y have side-effects! */
315
#define MAX(x,y) (((x) > (y)) ? (x) : (y))
317
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
319
#define CLAMP(x,l,h) (((x) > (h)) ? (h) : (((x) < (l)) ? (l) : (x)))
322
#define POS(x) MAX(x, 0)
324
#define ABS(x) (((x) >= 0) ? (x) : -(x))
339
# define DB(x) do { ; } while (0)
341
# define DB(x) db_printf x
343
# define DB(x) printf x
347
# define return_if_fail(x) \
350
fprintf (stderr, "%s:%d: assertion failed: %s\n", \
351
__FILE__, __LINE__, #x); \
356
# define return_val_if_fail(x, v) \
359
fprintf (stderr, "%s:%d: assertion failed: %s\n", \
360
__FILE__, __LINE__, #x); \
365
#define nonterminal_assert(x) \
368
fprintf (stderr, "%s:%d: assertion failed: %s\n", \
369
__FILE__, __LINE__, #x); \
374
# define return_if_fail(x) do {} while (0)
375
# define return_val_if_fail(x, v) do {} while (0)
376
# define nonterminal_assert(x) do {} while (0)
379
#endif /* SAWFISH_H */