]> Pileus Git - ~andy/gtk/blob - gdk/gdkinternals.h
Add check for GNU extensions to ftw()/nftw().
[~andy/gtk] / gdk / gdkinternals.h
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 /* Uninstalled header defining types and functions internal to GDK */
28
29 #include <gdk/gdktypes.h>
30 #include <gdk/gdkwindow.h>
31 #include <gdk/gdkprivate.h>
32
33 #ifndef __GDK_INTERNALS_H__
34 #define __GDK_INTERNALS_H__
35
36 /**********************
37  * General Facilities * 
38  **********************/
39
40 /* Debugging support */
41
42 typedef struct _GdkColorInfo           GdkColorInfo;
43 typedef struct _GdkEventFilter         GdkEventFilter;
44 typedef struct _GdkClientFilter        GdkClientFilter;
45
46 typedef enum {
47   GDK_COLOR_WRITEABLE = 1 << 0
48 } GdkColorInfoFlags;
49
50 struct _GdkColorInfo
51 {
52   GdkColorInfoFlags flags;
53   guint ref_count;
54 };
55
56 struct _GdkEventFilter {
57   GdkFilterFunc function;
58   gpointer data;
59 };
60
61 struct _GdkClientFilter {
62   GdkAtom       type;
63   GdkFilterFunc function;
64   gpointer      data;
65 };
66
67 typedef enum {
68   GDK_DEBUG_MISC          = 1 << 0,
69   GDK_DEBUG_EVENTS        = 1 << 1,
70   GDK_DEBUG_DND           = 1 << 2,
71   GDK_DEBUG_XIM           = 1 << 3,
72   GDK_DEBUG_NOGRABS       = 1 << 4,
73   GDK_DEBUG_COLORMAP      = 1 << 5,
74   GDK_DEBUG_GDKRGB        = 1 << 6,
75   GDK_DEBUG_GC            = 1 << 7,
76   GDK_DEBUG_PIXMAP        = 1 << 8,
77   GDK_DEBUG_IMAGE         = 1 << 9,
78   GDK_DEBUG_INPUT         = 1 <<10,
79   GDK_DEBUG_CURSOR        = 1 <<11,
80   GDK_DEBUG_MULTIHEAD     = 1 <<12,
81   GDK_DEBUG_XINERAMA      = 1 <<13,
82   GDK_DEBUG_DRAW          = 1 <<14
83 } GdkDebugFlag;
84
85 #ifndef GDK_DISABLE_DEPRECATED
86
87 typedef struct _GdkFontPrivate         GdkFontPrivate;
88
89 struct _GdkFontPrivate
90 {
91   GdkFont font;
92   guint ref_count;
93 };
94
95 #endif /* GDK_DISABLE_DEPRECATED */
96
97 extern GList            *_gdk_default_filters;
98 extern GdkWindow        *_gdk_parent_root;
99 extern gint              _gdk_error_code;
100 extern gint              _gdk_error_warnings;
101
102 extern guint _gdk_debug_flags;
103
104 #ifdef G_ENABLE_DEBUG
105
106 #define GDK_NOTE(type,action)                G_STMT_START { \
107     if (_gdk_debug_flags & GDK_DEBUG_##type)                \
108        { action; };                          } G_STMT_END
109
110 #else /* !G_ENABLE_DEBUG */
111
112 #define GDK_NOTE(type,action)
113
114 #endif /* G_ENABLE_DEBUG */
115
116 /* Arg parsing */
117
118 typedef enum 
119 {
120   GDK_ARG_STRING,
121   GDK_ARG_INT,
122   GDK_ARG_BOOL,
123   GDK_ARG_NOBOOL,
124   GDK_ARG_CALLBACK
125 } GdkArgType;
126
127 typedef struct _GdkArgContext GdkArgContext;
128 typedef struct _GdkArgDesc GdkArgDesc;
129
130 typedef void (*GdkArgFunc) (const char *name, const char *arg, gpointer data);
131
132 struct _GdkArgContext
133 {
134   GPtrArray *tables;
135   gpointer cb_data;
136 };
137
138 struct _GdkArgDesc
139 {
140   const char *name;
141   GdkArgType type;
142   gpointer location;
143   GdkArgFunc callback;
144 };
145
146 /* Event handling */
147
148 typedef struct _GdkEventPrivate GdkEventPrivate;
149
150 typedef enum
151 {
152   /* Following flag is set for events on the event queue during
153    * translation and cleared afterwards.
154    */
155   GDK_EVENT_PENDING = 1 << 0
156 } GdkEventFlags;
157
158 struct _GdkEventPrivate
159 {
160   GdkEvent   event;
161   guint      flags;
162   GdkScreen *screen;
163 };
164
165 extern GdkEventFunc   _gdk_event_func;    /* Callback for events */
166 extern gpointer       _gdk_event_data;
167 extern GDestroyNotify _gdk_event_notify;
168
169 extern GSList    *_gdk_displays;
170 extern gchar     *_gdk_display_name;
171 extern gint       _gdk_screen_number;
172 extern gchar     *_gdk_display_arg_name;
173
174 void      _gdk_events_queue  (GdkDisplay *display);
175 GdkEvent* _gdk_event_unqueue (GdkDisplay *display);
176
177 GList* _gdk_event_queue_find_first  (GdkDisplay *display);
178 void   _gdk_event_queue_remove_link (GdkDisplay *display,
179                                      GList      *node);
180 GList*  _gdk_event_queue_append     (GdkDisplay *display,
181                                      GdkEvent   *event);
182 void _gdk_event_button_generate     (GdkDisplay *display,
183                                      GdkEvent   *event);
184
185 void gdk_synthesize_window_state (GdkWindow     *window,
186                                   GdkWindowState unset_flags,
187                                   GdkWindowState set_flags);
188
189 #define GDK_SCRATCH_IMAGE_WIDTH 256
190 #define GDK_SCRATCH_IMAGE_HEIGHT 64
191
192 GdkImage* _gdk_image_new_for_depth (GdkScreen    *screen,
193                                     GdkImageType  type,
194                                     GdkVisual    *visual,
195                                     gint          width,
196                                     gint          height,
197                                     gint          depth);
198 GdkImage *_gdk_image_get_scratch (GdkScreen *screen,
199                                   gint       width,
200                                   gint       height,
201                                   gint       depth,
202                                   gint      *x,
203                                   gint      *y);
204
205 GdkImage *_gdk_drawable_copy_to_image (GdkDrawable  *drawable,
206                                        GdkImage     *image,
207                                        gint          src_x,
208                                        gint          src_y,
209                                        gint          dest_x,
210                                        gint          dest_y,
211                                        gint          width,
212                                        gint          height);
213
214 cairo_surface_t *_gdk_drawable_ref_cairo_surface (GdkDrawable *drawable);
215
216 /* GC caching */
217 GdkGC *_gdk_drawable_get_scratch_gc (GdkDrawable *drawable,
218                                      gboolean     graphics_exposures);
219
220 void _gdk_gc_update_context (GdkGC     *gc,
221                              cairo_t   *cr,
222                              GdkColor  *override_foreground,
223                              GdkBitmap *override_stipple,
224                              gboolean   gc_changed);
225
226 /*************************************
227  * Interfaces used by windowing code *
228  *************************************/
229
230 void       _gdk_window_destroy           (GdkWindow   *window,
231                                           gboolean     foreign_destroy);
232 void       _gdk_window_clear_update_area (GdkWindow   *window);
233
234 void       _gdk_screen_close             (GdkScreen   *screen);
235
236 const char *_gdk_get_sm_client_id (void);
237
238 void _gdk_gc_init (GdkGC           *gc,
239                    GdkDrawable     *drawable,
240                    GdkGCValues     *values,
241                    GdkGCValuesMask  values_mask);
242
243 GdkRegion *_gdk_gc_get_clip_region (GdkGC *gc);
244 GdkFill    _gdk_gc_get_fill        (GdkGC *gc);
245 GdkPixmap *_gdk_gc_get_tile        (GdkGC *gc);
246 GdkBitmap *_gdk_gc_get_stipple     (GdkGC *gc);
247 guint32    _gdk_gc_get_fg_pixel    (GdkGC *gc);
248 guint32    _gdk_gc_get_bg_pixel    (GdkGC *gc);
249
250 /*****************************************
251  * Interfaces provided by windowing code *
252  *****************************************/
253
254 /* Font/string functions implemented in module-specific code */
255 gint _gdk_font_strlen (GdkFont *font, const char *str);
256 void _gdk_font_destroy (GdkFont *font);
257
258 void _gdk_colormap_real_destroy (GdkColormap *colormap);
259
260 void _gdk_cursor_destroy (GdkCursor *cursor);
261
262 void     _gdk_windowing_init                    (void);
263
264 extern const GOptionEntry _gdk_windowing_args[];
265 void     _gdk_windowing_set_default_display     (GdkDisplay *display);
266
267 gchar *_gdk_windowing_substitute_screen_number (const gchar *display_name,
268                                                 gint         screen_number);
269
270 void     _gdk_windowing_window_get_offsets      (GdkWindow  *window,
271                                                  gint       *x_offset,
272                                                  gint       *y_offset);
273 void     _gdk_windowing_window_clear_area       (GdkWindow  *window,
274                                                  gint        x,
275                                                  gint        y,
276                                                  gint        width,
277                                                  gint        height);
278 void     _gdk_windowing_window_clear_area_e     (GdkWindow  *window,
279                                                  gint        x,
280                                                  gint        y,
281                                                  gint        width,
282                                                  gint        height);
283
284 void       _gdk_windowing_get_pointer        (GdkDisplay       *display,
285                                               GdkScreen       **screen,
286                                               gint             *x,
287                                               gint             *y,
288                                               GdkModifierType  *mask);
289 GdkWindow* _gdk_windowing_window_get_pointer (GdkDisplay       *display,
290                                               GdkWindow        *window,
291                                               gint             *x,
292                                               gint             *y,
293                                               GdkModifierType  *mask);
294 GdkWindow* _gdk_windowing_window_at_pointer  (GdkDisplay       *display,
295                                               gint             *win_x,
296                                               gint             *win_y);
297
298 /* Return the number of bits-per-pixel for images of the specified depth. */
299 gint _gdk_windowing_get_bits_for_depth (GdkDisplay *display,
300                                         gint        depth);
301
302 #define GDK_WINDOW_IS_MAPPED(window) ((((GdkWindowObject*)window)->state & GDK_WINDOW_STATE_WITHDRAWN) == 0)
303
304 /* Called before processing updates for a window. This gives the windowing
305  * layer a chance to save the region for later use in avoiding duplicate
306  * exposes. The return value indicates whether the function has a saved
307  * the region; if the result is TRUE, then the windowing layer is responsible
308  * for destroying the region later.
309  */
310 gboolean _gdk_windowing_window_queue_antiexpose (GdkWindow  *window,
311                                                  GdkRegion  *area);
312
313 /* Called to do the windowing system specific part of gdk_window_destroy(),
314  *
315  * window: The window being destroyed
316  * recursing: If TRUE, then this is being called because a parent
317  *            was destroyed. This generally means that the call to the windowing system
318  *            to destroy the window can be omitted, since it will be destroyed as a result
319  *            of the parent being destroyed. Unless @foreign_destroy
320  *            
321  * foreign_destroy: If TRUE, the window or a parent was destroyed by some external 
322  *            agency. The window has already been destroyed and no windowing
323  *            system calls should be made. (This may never happen for some
324  *            windowing systems.)
325  */
326 void _gdk_windowing_window_destroy (GdkWindow *window,
327                                     gboolean   recursing,
328                                     gboolean   foreign_destroy);
329
330 /* Called when gdk_window_destroy() is called on a foreign window
331  * or an ancestor of the foreign window. It should generally reparent
332  * the window out of it's current heirarchy, hide it, and then
333  * send a message to the owner requesting that the window be destroyed.
334  */
335 void _gdk_windowing_window_destroy_foreign (GdkWindow *window);
336
337 void _gdk_windowing_display_set_sm_client_id (GdkDisplay  *display,
338                                               const gchar *sm_client_id);
339
340 #define GDK_TYPE_PAINTABLE            (_gdk_paintable_get_type ())
341 #define GDK_PAINTABLE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_PAINTABLE, GdkPaintable))
342 #define GDK_IS_PAINTABLE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_PAINTABLE))
343 #define GDK_PAINTABLE_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GDK_TYPE_PAINTABLE, GdkPaintableIface))
344
345 typedef struct _GdkPaintable        GdkPaintable;
346 typedef struct _GdkPaintableIface   GdkPaintableIface;
347
348 struct _GdkPaintableIface
349 {
350   GTypeInterface g_iface;
351   
352   void (* begin_paint_region) (GdkPaintable *paintable,
353                                GdkRegion    *region);
354   void (* end_paint)          (GdkPaintable *paintable);
355
356   void (* invalidate_maybe_recurse) (GdkPaintable *paintable,
357                                      GdkRegion    *region,
358                                      gboolean    (*child_func) (GdkWindow *, gpointer),
359                                      gpointer      user_data);
360   void (* process_updates)          (GdkPaintable *paintable,
361                                      gboolean      update_children);
362 };
363
364 GType _gdk_paintable_get_type (void) G_GNUC_CONST;
365
366 /* Implementation types */
367 GType _gdk_window_impl_get_type (void) G_GNUC_CONST;
368 GType _gdk_pixmap_impl_get_type (void) G_GNUC_CONST;
369
370
371 /**
372  * _gdk_windowing_gc_set_clip_region:
373  * @gc: a #GdkGC
374  * @region: the new clip region
375  * 
376  * Do any window-system specific processing necessary
377  * for a change in clip region. Since the clip origin
378  * will likely change before the GC is used with the
379  * new clip, frequently this function will only set a flag and
380  * do the real processing later.
381  *
382  * When this function is called, _gdk_gc_get_clip_region
383  * will already return the new region.
384  **/
385 void _gdk_windowing_gc_set_clip_region (GdkGC     *gc,
386                                         GdkRegion *region);
387
388 /**
389  * _gdk_windowing_gc_copy:
390  * @dst_gc: a #GdkGC from the GDK backend
391  * @src_gc: a #GdkGC from the GDK backend
392  * 
393  * Copies backend specific state from @src_gc to @dst_gc.
394  * This is called before the generic state is copied, so
395  * the old generic state is still available from @dst_gc
396  **/
397 void _gdk_windowing_gc_copy (GdkGC *dst_gc,
398                              GdkGC *src_gc);
399      
400 /* Queries the current foreground color of a GdkGC */
401 void _gdk_windowing_gc_get_foreground (GdkGC    *gc,
402                                        GdkColor *color);
403 /* Queries the current background color of a GdkGC */
404 void _gdk_windowing_gc_get_background (GdkGC    *gc,
405                                        GdkColor *color);
406
407 /************************************
408  * Initialization and exit routines *
409  ************************************/
410
411 void _gdk_image_exit  (void);
412 void _gdk_windowing_exit (void);
413
414 G_END_DECLS
415
416 #endif /* __GDK_INTERNALS_H__ */