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