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