]> Pileus Git - ~andy/gtk/blob - gdk/gdkinternals.h
gdk: Remove colormap debug category
[~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 "gdkwindowimpl.h"
34 #include "gdkdisplay.h"
35 #include "gdkprivate.h"
36
37 G_BEGIN_DECLS
38
39 /**********************
40  * General Facilities * 
41  **********************/
42
43 /* Debugging support */
44
45 typedef struct _GdkColorInfo           GdkColorInfo;
46 typedef struct _GdkEventFilter         GdkEventFilter;
47 typedef struct _GdkClientFilter        GdkClientFilter;
48
49 typedef enum {
50   GDK_COLOR_WRITEABLE = 1 << 0
51 } GdkColorInfoFlags;
52
53 struct _GdkColorInfo
54 {
55   GdkColorInfoFlags flags;
56   guint ref_count;
57 };
58
59 typedef enum {
60   GDK_EVENT_FILTER_REMOVED = 1 << 0
61 } GdkEventFilterFlags;
62
63 struct _GdkEventFilter {
64   GdkFilterFunc function;
65   gpointer data;
66   GdkEventFilterFlags flags;
67   guint ref_count;
68 };
69
70 struct _GdkClientFilter {
71   GdkAtom       type;
72   GdkFilterFunc function;
73   gpointer      data;
74 };
75
76 typedef enum {
77   GDK_DEBUG_MISC          = 1 <<  0,
78   GDK_DEBUG_EVENTS        = 1 <<  1,
79   GDK_DEBUG_DND           = 1 <<  2,
80   GDK_DEBUG_XIM           = 1 <<  3,
81   GDK_DEBUG_NOGRABS       = 1 <<  4,
82   GDK_DEBUG_INPUT         = 1 <<  5,
83   GDK_DEBUG_CURSOR        = 1 <<  6,
84   GDK_DEBUG_MULTIHEAD     = 1 <<  7,
85   GDK_DEBUG_XINERAMA      = 1 <<  8,
86   GDK_DEBUG_DRAW          = 1 <<  9,
87   GDK_DEBUG_EVENTLOOP     = 1 << 10
88 } GdkDebugFlag;
89
90 extern GList            *_gdk_default_filters;
91 extern GdkWindow        *_gdk_parent_root;
92
93 extern guint _gdk_debug_flags;
94 extern gboolean _gdk_native_windows;
95
96 #ifdef G_ENABLE_DEBUG
97
98 #define GDK_NOTE(type,action)                G_STMT_START { \
99     if (_gdk_debug_flags & GDK_DEBUG_##type)                \
100        { action; };                          } G_STMT_END
101
102 #else /* !G_ENABLE_DEBUG */
103
104 #define GDK_NOTE(type,action)
105
106 #endif /* G_ENABLE_DEBUG */
107
108 /* Arg parsing */
109
110 typedef enum 
111 {
112   GDK_ARG_STRING,
113   GDK_ARG_INT,
114   GDK_ARG_BOOL,
115   GDK_ARG_NOBOOL,
116   GDK_ARG_CALLBACK
117 } GdkArgType;
118
119 typedef struct _GdkArgContext GdkArgContext;
120 typedef struct _GdkArgDesc GdkArgDesc;
121
122 typedef void (*GdkArgFunc) (const char *name, const char *arg, gpointer data);
123
124 struct _GdkArgContext
125 {
126   GPtrArray *tables;
127   gpointer cb_data;
128 };
129
130 struct _GdkArgDesc
131 {
132   const char *name;
133   GdkArgType type;
134   gpointer location;
135   GdkArgFunc callback;
136 };
137
138 /* Event handling */
139
140 typedef struct _GdkEventPrivate GdkEventPrivate;
141
142 typedef enum
143 {
144   /* Following flag is set for events on the event queue during
145    * translation and cleared afterwards.
146    */
147   GDK_EVENT_PENDING = 1 << 0
148 } GdkEventFlags;
149
150 struct _GdkEventPrivate
151 {
152   GdkEvent   event;
153   guint      flags;
154   GdkScreen *screen;
155   gpointer   windowing_data;
156   GdkDevice *device;
157   GdkDevice *source_device;
158 };
159
160 typedef struct _GdkWindowPaint GdkWindowPaint;
161
162 struct _GdkWindow
163 {
164   GObject parent_instance;
165
166   GdkWindowImpl *impl; /* window-system-specific delegate object */  
167   
168   GdkWindow *parent;
169   GdkVisual *visual;
170
171   gpointer user_data;
172
173   gint x;
174   gint y;
175   
176   gint extension_events;
177
178   GList *filters;
179   GList *children;
180
181   cairo_pattern_t *background;
182   
183   GSList *paint_stack;
184   
185   cairo_region_t *update_area;
186   guint update_freeze_count;
187   
188   guint8 window_type;
189   guint8 depth;
190   guint8 resize_count;
191
192   GdkWindowState state;
193   
194   guint guffaw_gravity : 1;
195   guint input_only : 1;
196   guint modal_hint : 1;
197   guint composited : 1;
198   
199   guint destroyed : 2;
200
201   guint accept_focus : 1;
202   guint focus_on_map : 1;
203   guint shaped : 1;
204   guint support_multidevice : 1;
205   
206   GdkEventMask event_mask;
207
208   guint update_and_descendants_freeze_count;
209
210   /* The GdkWindow that has the impl, ref:ed if another window.
211    * This ref is required to keep the wrapper of the impl window alive
212    * for as long as any GdkWindow references the impl. */
213   GdkWindow *impl_window; 
214   int abs_x, abs_y; /* Absolute offset in impl */
215   gint width, height;
216   guint32 clip_tag;
217   cairo_region_t *clip_region; /* Clip region (wrt toplevel) in window coords */
218   cairo_region_t *clip_region_with_children; /* Clip region in window coords */
219   GdkCursor *cursor;
220   GHashTable *device_cursor;
221   gint8 toplevel_window_type;
222   guint synthesize_crossing_event_queued : 1;
223   guint effective_visibility : 2;
224   guint visibility : 2; /* The visibility wrt the toplevel (i.e. based on clip_region) */
225   guint native_visibility : 2; /* the native visibility of a impl windows */
226   guint viewable : 1; /* mapped and all parents mapped */
227   guint applied_shape : 1;
228
229   guint num_offscreen_children;
230   GdkWindowPaint *implicit_paint;
231
232   GList *outstanding_moves;
233
234   cairo_region_t *shape;
235   cairo_region_t *input_shape;
236   
237   cairo_surface_t *cairo_surface;
238
239   GList *devices_inside;
240   GHashTable *device_events;
241
242   GHashTable *source_event_masks;
243   gulong device_added_handler_id;
244   gulong device_changed_handler_id;
245 };
246
247 #define GDK_WINDOW_TYPE(d) (((GDK_WINDOW (d)))->window_type)
248 #define GDK_WINDOW_DESTROYED(d) (GDK_WINDOW (d)->destroyed)
249
250 extern gchar     *_gdk_display_name;
251 extern gint       _gdk_screen_number;
252 extern gchar     *_gdk_display_arg_name;
253 extern gboolean   _gdk_disable_multidevice;
254
255 GdkEvent* _gdk_event_unqueue (GdkDisplay *display);
256
257 void _gdk_event_filter_unref        (GdkWindow      *window,
258                                      GdkEventFilter *filter);
259
260 void   _gdk_event_emit               (GdkEvent   *event);
261 GList* _gdk_event_queue_find_first   (GdkDisplay *display);
262 void   _gdk_event_queue_remove_link  (GdkDisplay *display,
263                                       GList      *node);
264 GList* _gdk_event_queue_prepend      (GdkDisplay *display,
265                                       GdkEvent   *event);
266 GList* _gdk_event_queue_append       (GdkDisplay *display,
267                                       GdkEvent   *event);
268 GList* _gdk_event_queue_insert_after (GdkDisplay *display,
269                                       GdkEvent   *after_event,
270                                       GdkEvent   *event);
271 GList* _gdk_event_queue_insert_before(GdkDisplay *display,
272                                       GdkEvent   *after_event,
273                                       GdkEvent   *event);
274 void   _gdk_event_button_generate    (GdkDisplay *display,
275                                       GdkEvent   *event);
276
277 void _gdk_windowing_event_data_copy (const GdkEvent *src,
278                                      GdkEvent       *dst);
279 void _gdk_windowing_event_data_free (GdkEvent       *event);
280
281 void gdk_synthesize_window_state (GdkWindow     *window,
282                                   GdkWindowState unset_flags,
283                                   GdkWindowState set_flags);
284
285 gboolean _gdk_cairo_surface_extents (cairo_surface_t *surface,
286                                      GdkRectangle *extents);
287
288 /*************************************
289  * Interfaces used by windowing code *
290  *************************************/
291
292 cairo_surface_t *
293            _gdk_window_ref_cairo_surface (GdkWindow *window);
294
295 void       _gdk_window_destroy           (GdkWindow      *window,
296                                           gboolean        foreign_destroy);
297 void       _gdk_window_clear_update_area (GdkWindow      *window);
298 void       _gdk_window_update_size       (GdkWindow      *window);
299 gboolean   _gdk_window_update_viewable   (GdkWindow      *window);
300
301 void       _gdk_window_process_updates_recurse (GdkWindow *window,
302                                                 cairo_region_t *expose_region);
303
304 void       _gdk_screen_close             (GdkScreen      *screen);
305
306 /*****************************************
307  * Interfaces provided by windowing code *
308  *****************************************/
309
310 /* Font/string functions implemented in module-specific code */
311
312 void _gdk_cursor_destroy (GdkCursor *cursor);
313
314 extern const GOptionEntry _gdk_windowing_args[];
315 gchar *_gdk_windowing_substitute_screen_number (const gchar *display_name,
316                                                 gint         screen_number);
317
318 void _gdk_windowing_got_event                (GdkDisplay       *display,
319                                               GList            *event_link,
320                                               GdkEvent         *event,
321                                               gulong            serial);
322
323 #define GDK_WINDOW_IS_MAPPED(window) (((window)->state & GDK_WINDOW_STATE_WITHDRAWN) == 0)
324
325 #define GDK_TYPE_PAINTABLE            (_gdk_paintable_get_type ())
326 #define GDK_PAINTABLE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_PAINTABLE, GdkPaintable))
327 #define GDK_IS_PAINTABLE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_PAINTABLE))
328 #define GDK_PAINTABLE_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GDK_TYPE_PAINTABLE, GdkPaintableIface))
329
330 typedef struct _GdkPaintable        GdkPaintable;
331 typedef struct _GdkPaintableIface   GdkPaintableIface;
332
333 struct _GdkPaintableIface
334 {
335   GTypeInterface g_iface;
336   
337   void (* begin_paint_region)       (GdkPaintable    *paintable,
338                                      GdkWindow       *window,
339                                      const cairo_region_t *region);
340   void (* end_paint)                (GdkPaintable    *paintable);
341 };
342
343 GType _gdk_paintable_get_type (void) G_GNUC_CONST;
344
345 void _gdk_window_invalidate_for_expose (GdkWindow       *window,
346                                         cairo_region_t       *region);
347
348 GdkWindow * _gdk_window_find_child_at (GdkWindow *window,
349                                        int x, int y);
350 GdkWindow * _gdk_window_find_descendant_at (GdkWindow *toplevel,
351                                             double x, double y,
352                                             double *found_x,
353                                             double *found_y);
354
355 void _gdk_window_add_damage (GdkWindow *toplevel,
356                              cairo_region_t *damaged_region);
357
358 GdkEvent * _gdk_make_event (GdkWindow    *window,
359                             GdkEventType  type,
360                             GdkEvent     *event_in_queue,
361                             gboolean      before_event);
362 gboolean _gdk_window_event_parent_of (GdkWindow *parent,
363                                       GdkWindow *child);
364
365 void _gdk_synthesize_crossing_events (GdkDisplay                 *display,
366                                       GdkWindow                  *src,
367                                       GdkWindow                  *dest,
368                                       GdkDevice                  *device,
369                                       GdkDevice                  *source_device,
370                                       GdkCrossingMode             mode,
371                                       gint                        toplevel_x,
372                                       gint                        toplevel_y,
373                                       GdkModifierType             mask,
374                                       guint32                     time_,
375                                       GdkEvent                   *event_in_queue,
376                                       gulong                      serial,
377                                       gboolean                    non_linear);
378 void _gdk_display_set_window_under_pointer (GdkDisplay *display,
379                                             GdkDevice  *device,
380                                             GdkWindow  *window);
381
382
383 void _gdk_synthesize_crossing_events_for_geometry_change (GdkWindow *changed_window);
384
385 cairo_region_t *_gdk_window_calculate_full_clip_region    (GdkWindow     *window,
386                                                       GdkWindow     *base_window,
387                                                       gboolean       do_children,
388                                                       gint          *base_x_offset,
389                                                       gint          *base_y_offset);
390 gboolean    _gdk_window_has_impl (GdkWindow *window);
391 GdkWindow * _gdk_window_get_impl_window (GdkWindow *window);
392
393 /*****************************
394  * offscreen window routines *
395  *****************************/
396 GType gdk_offscreen_window_get_type (void);
397 void       _gdk_offscreen_window_new                 (GdkWindow     *window,
398                                                       GdkWindowAttr *attributes,
399                                                       gint           attributes_mask);
400 cairo_surface_t * _gdk_offscreen_window_create_surface (GdkWindow *window,
401                                                         gint       width,
402                                                         gint       height);
403
404
405 G_END_DECLS
406
407 #endif /* __GDK_INTERNALS_H__ */