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