~ubuntu-branches/ubuntu/natty/sawfish/natty

« back to all changes in this revision

Viewing changes to src/sawfish.h

  • Committer: Bazaar Package Importer
  • Author(s): Luis Rodrigo Gallardo Cruz
  • Date: 2009-11-23 09:05:20 UTC
  • mfrom: (0.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: james.westby@ubuntu.com-20091123090520-m588qe37wtxzr2b5
Tags: upstream-1.5.3
ImportĀ upstreamĀ versionĀ 1.5.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* sawfish.h -- Main include file, brings in all the rest
 
2
   $Id$
 
3
 
 
4
   Copyright (C) 1999 John Harper <john@dcs.warwick.ac.uk>
 
5
 
 
6
   This file is part of sawfish.
 
7
 
 
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)
 
11
   any later version.
 
12
 
 
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.
 
17
 
 
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. */
 
21
 
 
22
#ifndef SAWFISH_H
 
23
#define SAWFISH_H
 
24
 
 
25
#define _GNU_SOURCE
 
26
 
 
27
#ifdef HAVE_CONFIG_H
 
28
#include <config.h>
 
29
#endif
 
30
 
 
31
#include <rep.h>
 
32
#include <sys/types.h>
 
33
#include <stdio.h>
 
34
#include <stdarg.h>
 
35
#include <X11/Xlib.h>
 
36
 
 
37
#if defined (HAVE_IMLIB)
 
38
# include <Imlib.h>
 
39
#elif defined (HAVE_GDK_PIXBUF)
 
40
# include <gdk-pixbuf-xlib/gdk-pixbuf-xlib.h>
 
41
#else
 
42
# error "Need an image handling library!"
 
43
#endif
 
44
 
 
45
#ifndef rep_INTERFACE
 
46
# define rep_INTERFACE 7                /* rep 0.10 */
 
47
#endif
 
48
 
 
49
typedef int bool;
 
50
 
 
51
#ifdef rep_HAVE_UNIX
 
52
# define HAVE_UNIX 1
 
53
#endif
 
54
 
 
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)
 
58
 
 
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. */
 
62
 
 
63
/* #define DEBUG 1 */
 
64
 
 
65
/* Event masks */
 
66
 
 
67
/* Events selected on client windows */
 
68
#define CLIENT_EVENTS (PropertyChangeMask | StructureNotifyMask \
 
69
                       | ColormapChangeMask | VisibilityChangeMask)
 
70
 
 
71
/* Events selected on the root window */
 
72
#define ROOT_EVENTS (SubstructureRedirectMask | SubstructureNotifyMask \
 
73
                     | ButtonPressMask | ButtonReleaseMask | KeyPressMask \
 
74
                     | ButtonMotionMask | PointerMotionHintMask \
 
75
                     | EnterWindowMask | LeaveWindowMask | StructureNotifyMask)
 
76
 
 
77
/* Events selected on each frame part */
 
78
#define FP_EVENTS (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask \
 
79
                   | PointerMotionHintMask | EnterWindowMask \
 
80
                   | LeaveWindowMask | KeyPressMask | ExposureMask)
 
81
 
 
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)
 
88
 
 
89
/* Events selected in pointer/button grabs */
 
90
#define POINTER_GRAB_EVENTS (ButtonPressMask | ButtonReleaseMask \
 
91
                             | PointerMotionMask | PointerMotionHintMask)
 
92
 
 
93
/* Type defs */
 
94
 
 
95
/* A managed window */
 
96
typedef struct lisp_window {
 
97
    repv car;
 
98
    struct lisp_window *next;
 
99
    Window id, saved_id;
 
100
    repv plist;
 
101
    repv frame_style;
 
102
 
 
103
    /* stacking order */
 
104
    struct lisp_window *above, *below;
 
105
 
 
106
    /* Is the client window mapped? (by its app) */
 
107
    unsigned int mapped : 1;
 
108
 
 
109
    /* Is the frame visible? (not hidden by hide-window) */
 
110
    unsigned int visible : 1;
 
111
 
 
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;
 
115
 
 
116
    /* Is the client window unmapped by us?
 
117
       (because it's !visible or client_hidden) */
 
118
    unsigned int client_unmapped : 1;
 
119
 
 
120
    /* Is the client window reparented to the frame? */
 
121
    unsigned int reparented : 1;
 
122
 
 
123
    /* Is the client window shaped? */
 
124
    unsigned int shaped : 1;
 
125
 
 
126
    /* Have we called the destroy-notify-hook? */
 
127
    unsigned int destroyed : 1;
 
128
 
 
129
    /* The WM protocols understood by the client */
 
130
    unsigned int does_wm_take_focus : 1;
 
131
    unsigned int does_wm_delete_window : 1;
 
132
 
 
133
    /* Do we need to send a synthetic ConfigureNotify to this window? */
 
134
    unsigned int pending_configure : 1;
 
135
 
 
136
    /* Do we need to recalculate the shape mask of the frame? */
 
137
    unsigned int pending_reshape : 1;
 
138
 
 
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;
 
143
    XSizeHints hints;
 
144
    XWMHints *wmhints;
 
145
    Window *cmap_windows;
 
146
    int n_cmap_windows;
 
147
    repv full_name, name, icon_name;
 
148
    repv net_name, net_icon_name;
 
149
    int frame_vis;
 
150
    repv icon_image;
 
151
 
 
152
    /* Frame data */
 
153
    Window frame;
 
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);
 
161
} Lisp_Window;
 
162
 
 
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)
 
166
 
 
167
#define WINDOW_FOCUSED_P(w) (focus_window == w)
 
168
#define WINDOW_IS_GONE_P(w) (w->id == 0)
 
169
 
 
170
typedef struct Lisp_Font_Class_struct Lisp_Font_Class;
 
171
 
 
172
/* An allocated font */
 
173
typedef struct lisp_font {
 
174
    repv car;
 
175
    struct lisp_font *next;
 
176
    const Lisp_Font_Class *class;
 
177
    repv type;
 
178
    repv name;
 
179
    void *font;
 
180
    repv plist;
 
181
    int ascent, descent;
 
182
} Lisp_Font;
 
183
 
 
184
#define FONTP(v)        rep_CELL16_TYPEP(v, font_type)
 
185
#define VFONT(v)        ((Lisp_Font *)rep_PTR(v))
 
186
 
 
187
/* An allocated color */
 
188
typedef struct lisp_color {
 
189
    repv car;
 
190
    struct lisp_color *next;
 
191
    int red, green, blue, alpha;        /* each 16 bits */
 
192
    int pixel;                          /* somewhere in the screen's cmap */
 
193
} Lisp_Color;
 
194
 
 
195
#define COLORP(v)       rep_CELL16_TYPEP(v, color_type)
 
196
#define VCOLOR(v)       ((Lisp_Color *)rep_PTR(v))
 
197
 
 
198
/* An allocated cursor */
 
199
typedef struct lisp_cursor {
 
200
    repv car;
 
201
    struct lisp_cursor *next;
 
202
    repv data;
 
203
    Cursor cursor;
 
204
} Lisp_Cursor;
 
205
 
 
206
#define CURSORP(v)      rep_CELL16_TYPEP(v, cursor_type)
 
207
#define VCURSOR(v)      ((Lisp_Cursor *)rep_PTR(v))
 
208
 
 
209
#if defined (HAVE_IMLIB)
 
210
typedef ImlibImage *image_t;
 
211
#elif defined (HAVE_GDK_PIXBUF)
 
212
typedef GdkPixbuf *image_t;
 
213
#endif
 
214
 
 
215
typedef struct pixmap_cache_node_struct pixmap_cache_node;
 
216
 
 
217
/* A loaded image */
 
218
typedef struct lisp_image {
 
219
    repv car;
 
220
    struct lisp_image *next;
 
221
    image_t image;
 
222
#if !defined (HAVE_IMLIB)
 
223
    int border[4];
 
224
#endif
 
225
#if defined (NEED_PIXMAP_CACHE)
 
226
    pixmap_cache_node *pixmap_first, *pixmap_last;
 
227
#endif
 
228
    repv plist;
 
229
} Lisp_Image;
 
230
 
 
231
#define IMAGEP(v)       rep_CELL16_TYPEP(v, image_type)
 
232
#define VIMAGE(v)       ((Lisp_Image *)rep_PTR(v))
 
233
 
 
234
enum frame_part_states {
 
235
    fps_none = -1,
 
236
    fps_inactive = 0,
 
237
    fps_focused,
 
238
    fps_highlighted,
 
239
    fps_inactive_highlighted,
 
240
    fps_clicked,
 
241
    fps_inactive_clicked,
 
242
    fps_MAX
 
243
};
 
244
 
 
245
/* one component of a frame */
 
246
struct frame_part {
 
247
    repv car;
 
248
    struct frame_part *next, *next_alloc;
 
249
    repv alist;                         /* the generator alist */
 
250
    repv local_alist;
 
251
 
 
252
    Lisp_Window *win;
 
253
    int x, y, width, height;
 
254
    Window id;
 
255
    GC gc;
 
256
 
 
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;
 
262
 
 
263
    repv text;                  /* may be nil, a string, or a function */
 
264
    repv x_justify, y_justify;
 
265
 
 
266
    repv font[fps_MAX];
 
267
    repv fg[fps_MAX];                   /* may be color or image */
 
268
    repv bg[fps_MAX];                   /* may be color or image */
 
269
 
 
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;
 
275
 
 
276
    repv cursor;
 
277
 
 
278
    /* cached state of the window */
 
279
    struct {
 
280
        int width, height;
 
281
        repv font, text;
 
282
        repv x_justify, y_justify;
 
283
        repv fg, bg;
 
284
    } drawn;
 
285
};
 
286
 
 
287
#define PARTP(v)        rep_CELL16_TYPEP(v, frame_part_type)
 
288
#define VPART(v)        ((struct frame_part *) rep_PTR (v))
 
289
 
 
290
/* codes for the clean_exit_jmp_buf */
 
291
enum exit_codes {
 
292
    ec_no_exit = 0,
 
293
    ec_exit,
 
294
    ec_restart,
 
295
    ec_session_died
 
296
};
 
297
 
 
298
/* bring in prototypes */
 
299
 
 
300
#ifndef XlibSpecificationRelease
 
301
# define XlibSpecificationRelease 4
 
302
#endif
 
303
 
 
304
/* Work around for X11R5 and earlier */
 
305
#ifndef XUrgencyHint
 
306
#define XUrgencyHint (1 << 8)
 
307
#endif
 
308
 
 
309
#include "sawfish_subrs.h"
 
310
 
 
311
/* Miscellaneous macro defs */
 
312
 
 
313
/* Maximum/minimum macros. Don't use when X or Y have side-effects! */
 
314
#undef MAX
 
315
#define MAX(x,y) (((x) > (y)) ? (x) : (y))
 
316
#undef MIN
 
317
#define MIN(x,y) (((x) < (y)) ? (x) : (y))
 
318
#undef CLAMP
 
319
#define CLAMP(x,l,h) (((x) > (h)) ? (h) : (((x) < (l)) ? (l) : (x)))
 
320
 
 
321
#undef POS
 
322
#define POS(x)   MAX(x, 0)
 
323
#undef ABS
 
324
#define ABS(x)   (((x) >= 0) ? (x) : -(x))
 
325
 
 
326
#ifndef NULL
 
327
# define NULL 0
 
328
#endif
 
329
 
 
330
#ifndef TRUE
 
331
# define TRUE 1
 
332
#endif
 
333
 
 
334
#ifndef FALSE
 
335
# define FALSE 0
 
336
#endif
 
337
 
 
338
#if !defined (DEBUG)
 
339
# define DB(x) do { ; } while (0)
 
340
#elif DEBUG == 0
 
341
# define DB(x) db_printf x
 
342
#else
 
343
# define DB(x) printf x
 
344
#endif
 
345
 
 
346
#ifndef NDEBUG
 
347
# define return_if_fail(x)                                      \
 
348
    do {                                                        \
 
349
        if (!(x)) {                                             \
 
350
            fprintf (stderr, "%s:%d: assertion failed: %s\n",   \
 
351
                     __FILE__, __LINE__, #x);                   \
 
352
            return;                                             \
 
353
        }                                                       \
 
354
    } while (0)
 
355
 
 
356
# define return_val_if_fail(x, v)                               \
 
357
    do {                                                        \
 
358
        if (!(x)) {                                             \
 
359
            fprintf (stderr, "%s:%d: assertion failed: %s\n",   \
 
360
                     __FILE__, __LINE__, #x);                   \
 
361
            return (v);                                         \
 
362
        }                                                       \
 
363
    } while (0)
 
364
 
 
365
#define nonterminal_assert(x)                                   \
 
366
    do {                                                        \
 
367
        if (!(x)) {                                             \
 
368
            fprintf (stderr, "%s:%d: assertion failed: %s\n",   \
 
369
                     __FILE__, __LINE__, #x);                   \
 
370
        }                                                       \
 
371
    } while (0)
 
372
        
 
373
#else
 
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)
 
377
#endif
 
378
 
 
379
#endif /* SAWFISH_H */