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