]> Pileus Git - ~andy/gtk/blob - gdk/gdkprivate.h
Destroy widgets _after_ propagating unrealize signals through the widget
[~andy/gtk] / gdk / gdkprivate.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 Library 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  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library 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 #ifndef __GDK_PRIVATE_H__
20 #define __GDK_PRIVATE_H__
21
22
23 #include <X11/Xlib.h>
24 #include <X11/Xutil.h>
25 #include <gdk/gdktypes.h>
26
27 #define gdk_window_lookup(xid)     ((GdkWindow*) gdk_xid_table_lookup (xid))
28 #define gdk_pixmap_lookup(xid)     ((GdkPixmap*) gdk_xid_table_lookup (xid))
29 #define gdk_font_lookup(xid)       ((GdkFont*) gdk_xid_table_lookup (xid))
30
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif /* __cplusplus */
35
36
37 typedef struct _GdkWindowPrivate       GdkWindowPrivate;
38 typedef struct _GdkWindowPrivate       GdkPixmapPrivate;
39 typedef struct _GdkImagePrivate        GdkImagePrivate;
40 typedef struct _GdkGCPrivate           GdkGCPrivate;
41 typedef struct _GdkColormapPrivate     GdkColormapPrivate;
42 typedef struct _GdkColorInfo           GdkColorInfo;
43 typedef struct _GdkVisualPrivate       GdkVisualPrivate;
44 typedef struct _GdkFontPrivate         GdkFontPrivate;
45 typedef struct _GdkCursorPrivate       GdkCursorPrivate;
46 typedef struct _GdkEventFilter         GdkEventFilter;
47 typedef struct _GdkClientFilter        GdkClientFilter;
48 typedef struct _GdkColorContextPrivate GdkColorContextPrivate;
49 typedef struct _GdkRegionPrivate       GdkRegionPrivate;
50
51
52 struct _GdkWindowPrivate
53 {
54   GdkWindow window;
55   GdkWindow *parent;
56   Window xwindow;
57   Display *xdisplay;
58   gint16 x;
59   gint16 y;
60   guint16 width;
61   guint16 height;
62   guint8 resize_count;
63   guint8 window_type;
64   guint ref_count;
65   guint destroyed : 2;
66
67   gint extension_events;
68
69   GList *filters;
70   GdkColormap *colormap;
71   GList *children;
72 };
73
74 struct _GdkImagePrivate
75 {
76   GdkImage image;
77   XImage *ximage;
78   Display *xdisplay;
79   gpointer x_shm_info;
80
81   void (*image_put) (GdkDrawable *window,
82                      GdkGC       *gc,
83                      GdkImage    *image,
84                      gint         xsrc,
85                      gint         ysrc,
86                      gint         xdest,
87                      gint         ydest,
88                      gint         width,
89                      gint         height);
90 };
91
92 struct _GdkGCPrivate
93 {
94   GdkGC gc;
95   GC xgc;
96   Display *xdisplay;
97   guint ref_count;
98 };
99
100 typedef enum {
101   GDK_COLOR_WRITEABLE = 1 << 0
102 } GdkColorInfoFlags;
103
104 struct _GdkColorInfo
105 {
106   GdkColorInfoFlags flags;
107   guint ref_count;
108 };
109
110 struct _GdkColormapPrivate
111 {
112   GdkColormap colormap;
113   Colormap xcolormap;
114   Display *xdisplay;
115   GdkVisual *visual;
116   gint private_val;
117
118   GHashTable *hash;
119   GdkColorInfo *info;
120   time_t last_sync_time;
121   
122   guint ref_count;
123 };
124
125 struct _GdkVisualPrivate
126 {
127   GdkVisual visual;
128   Visual *xvisual;
129 };
130
131 struct _GdkFontPrivate
132 {
133   GdkFont font;
134   /* XFontStruct *xfont; */
135   /* generic pointer point to XFontStruct or XFontSet */
136   gpointer xfont;
137   Display *xdisplay;
138   guint ref_count;
139 };
140
141 struct _GdkCursorPrivate
142 {
143   GdkCursor cursor;
144   Cursor xcursor;
145   Display *xdisplay;
146 };
147
148 struct _GdkDndCursorInfo {
149   Cursor          gdk_cursor_dragdefault, gdk_cursor_dragok;
150   GdkWindow      *drag_pm_default, *drag_pm_ok;
151   GdkPoint        default_hotspot, ok_hotspot;
152   GList *xids;
153 };
154 typedef struct _GdkDndCursorInfo GdkDndCursorInfo;
155
156 struct _GdkDndGlobals {
157   GdkAtom            gdk_XdeEnter, gdk_XdeLeave, gdk_XdeRequest;
158   GdkAtom            gdk_XdeDataAvailable, gdk_XdeDataShow, gdk_XdeCancel;
159   GdkAtom            gdk_XdeTypelist;
160
161   GdkDndCursorInfo  *c;
162   GdkWindow     **drag_startwindows;
163   guint           drag_numwindows;
164   gboolean        drag_really, drag_perhaps, dnd_grabbed;
165   Window          dnd_drag_target;
166   GdkPoint        drag_dropcoords;
167
168   GdkPoint dnd_drag_start, dnd_drag_oldpos;
169   GdkRectangle dnd_drag_dropzone;
170   GdkWindowPrivate *real_sw;
171   Window dnd_drag_curwin;
172   Time last_drop_time; /* An incredible hack, sosumi miguel */
173 };
174 typedef struct _GdkDndGlobals GdkDndGlobals;
175
176 struct _GdkEventFilter {
177   GdkFilterFunc function;
178   gpointer data;
179 };
180
181 struct _GdkClientFilter {
182   GdkAtom       type;
183   GdkFilterFunc function;
184   gpointer      data;
185 };
186
187 #ifdef USE_XIM
188
189 typedef struct _GdkICPrivate GdkICPrivate;
190
191 struct _GdkICPrivate
192 {
193   XIC xic;
194   GdkICAttr *attr;
195   GdkICAttributesType mask;
196 };
197
198 #endif /* USE_XIM */
199
200 struct _GdkColorContextPrivate
201 {
202   GdkColorContext color_context;
203   Display *xdisplay;
204   XStandardColormap std_cmap;
205 };
206
207 struct _GdkRegionPrivate
208 {
209   GdkRegion region;
210   Region xregion;
211 };
212
213 typedef enum {
214   GDK_DEBUG_MISC          = 1 << 0,
215   GDK_DEBUG_EVENTS        = 1 << 1,
216   GDK_DEBUG_DND           = 1 << 2,
217   GDK_DEBUG_COLOR_CONTEXT = 1 << 3,
218   GDK_DEBUG_XIM           = 1 << 4
219 } GdkDebugFlag;
220
221 void gdk_window_init (void);
222 void gdk_visual_init (void);
223 void gdk_dnd_init    (void);
224
225 void gdk_image_init  (void);
226 void gdk_image_exit (void);
227
228 GdkColormap* gdk_colormap_lookup (Colormap  xcolormap);
229 GdkVisual*   gdk_visual_lookup   (Visual   *xvisual);
230
231 void gdk_window_add_colormap_windows (GdkWindow *window);
232 void gdk_window_destroy_notify       (GdkWindow *window);
233
234 void     gdk_xid_table_insert (XID      *xid,
235                                gpointer  data);
236 void     gdk_xid_table_remove (XID       xid);
237 gpointer gdk_xid_table_lookup (XID       xid);
238
239 gint gdk_send_xevent (Window window, gboolean propagate, glong event_mask,
240                       XEvent *event_send);
241
242 /* If you pass x = y = -1, it queries the pointer
243    to find out where it currently is.
244    If you pass x = y = -2, it does anything necessary
245    to know that the drag is ending.
246 */
247 void gdk_dnd_display_drag_cursor(gint x,
248                                  gint y,
249                                  gboolean drag_ok,
250                                  gboolean change_made);
251
252 /* Please see gdkwindow.c for comments on how to use */ 
253 Window gdk_window_xid_at(Window base, gint bx, gint by, gint x, gint y, GList *excludes, gboolean excl_child);
254 Window gdk_window_xid_at_coords(gint x, gint y, GList *excludes, gboolean excl_child);
255
256 extern gint              gdk_debug_level;
257 extern gint              gdk_show_events;
258 extern gint              gdk_use_xshm;
259 extern gint              gdk_stack_trace;
260 extern gchar            *gdk_display_name;
261 extern Display          *gdk_display;
262 extern gint              gdk_screen;
263 extern Window            gdk_root_window;
264 extern Window            gdk_leader_window;
265 extern GdkWindowPrivate  gdk_root_parent;
266 extern Atom              gdk_wm_delete_window;
267 extern Atom              gdk_wm_take_focus;
268 extern Atom              gdk_wm_protocols;
269 extern Atom              gdk_wm_window_protocols[];
270 extern Atom              gdk_selection_property;
271 extern GdkDndGlobals     gdk_dnd;
272 extern GdkWindow        *selection_owner[];
273 extern gchar            *gdk_progclass;
274 extern gint              gdk_error_code;
275 extern gint              gdk_error_warnings;
276 extern gint              gdk_null_window_warnings;
277 extern GList            *gdk_default_filters;
278 extern gboolean          gdk_using_threads;
279
280 /* Threading stuff */
281 #ifdef USE_PTHREADS
282 extern gint              gdk_threads_pipe[2];
283 extern gboolean          gdk_select_waiting;
284 #endif
285
286 #ifdef USE_XIM
287 /* XIM support */
288 gint   gdk_im_open               (void);
289 void   gdk_im_close              (void);
290 void   gdk_ic_cleanup            (void);
291
292 extern GdkICPrivate *gdk_xim_ic;                /* currently using IC */
293 extern GdkWindow *gdk_xim_window;               /* currently using Window */
294 #endif USE_XIM
295
296 /* Debugging support */
297
298 #ifdef G_ENABLE_DEBUG
299
300 #define GDK_NOTE(type,action)                G_STMT_START { \
301     if (gdk_debug_flags & GDK_DEBUG_##type)                 \
302        { action; };                          } G_STMT_END
303
304 #else /* !G_ENABLE_DEBUG */
305
306 #define GDK_NOTE(type,action)
307       
308 #endif /* G_ENABLE_DEBUG */
309
310 extern guint gdk_debug_flags;
311
312
313 #ifdef __cplusplus
314 }
315 #endif /* __cplusplus */
316
317
318 #endif /* __GDK_PRIVATE_H__ */