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