]> Pileus Git - ~andy/gtk/blob - gdk/x11/gdkx.h
applied patch from Andreas Persenius <ndap@swipnet.se> that updates the
[~andy/gtk] / gdk / x11 / gdkx.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 #ifndef __GDK_X_H__
28 #define __GDK_X_H__
29
30 #include <gdk/gdkprivate.h>
31 #include <gdk/gdkcursor.h>
32
33 #include <X11/Xlib.h>
34 #include <X11/Xutil.h>
35
36 #include <gdk/x11/gdkwindow-x11.h>
37 #include <gdk/x11/gdkpixmap-x11.h>
38
39 typedef struct _GdkGCXData             GdkGCXData;
40 typedef struct _GdkColormapPrivateX11 GdkColormapPrivateX11;
41 typedef struct _GdkCursorPrivate       GdkCursorPrivate;
42 typedef struct _GdkFontPrivateX        GdkFontPrivateX;
43 typedef struct _GdkImagePrivateX11    GdkImagePrivateX11;
44 typedef struct _GdkVisualPrivate       GdkVisualPrivate;
45
46 #ifdef USE_XIM
47 typedef struct _GdkICPrivate        GdkICPrivate;
48 #endif /* USE_XIM */
49
50 struct _GdkCursorPrivate
51 {
52   GdkCursor cursor;
53   Cursor xcursor;
54   Display *xdisplay;
55 };
56
57 struct _GdkFontPrivateX
58 {
59   GdkFontPrivate base;
60   /* XFontStruct *xfont; */
61   /* generic pointer point to XFontStruct or XFontSet */
62   gpointer xfont;
63   Display *xdisplay;
64
65   GSList *names;
66 };
67
68 struct _GdkVisualPrivate
69 {
70   GdkVisual visual;
71   Visual *xvisual;
72 };
73
74 struct _GdkColormapPrivateX11
75 {
76   Colormap xcolormap;
77   Display *xdisplay;
78   gint private_val;
79
80   GHashTable *hash;
81   GdkColorInfo *info;
82   time_t last_sync_time;
83 };
84
85 struct _GdkImagePrivateX11
86 {
87   XImage *ximage;
88   Display *xdisplay;
89   gpointer x_shm_info;
90 };
91
92
93 #ifdef USE_XIM
94
95 struct _GdkICPrivate
96 {
97   XIC xic;
98   GdkICAttr *attr;
99   GdkICAttributesType mask;
100 };
101
102 #endif /* USE_XIM */
103
104
105 typedef struct _GdkGCX11      GdkGCX11;
106 typedef struct _GdkGCX11Class GdkGCX11Class;
107
108 #define GDK_TYPE_GC_X11              (gdk_gc_x11_get_type ())
109 #define GDK_GC_X11(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_GC_X11, GdkGCX11))
110 #define GDK_GC_X11_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GC_X11, GdkGCX11Class))
111 #define GDK_IS_GC_X11(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_GC_X11))
112 #define GDK_IS_GC_X11_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GC_X11))
113 #define GDK_GC_X11_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GC_X11, GdkGCX11Class))
114
115 struct _GdkGCX11
116 {
117   GdkGC parent_instance;
118   
119   GC xgc;
120   Display *xdisplay;
121   GdkRegion *clip_region;
122   guint dirty_mask;
123 };
124
125 struct _GdkGCX11Class
126 {
127   GdkGCClass parent_class;
128
129 };
130
131 GType gdk_gc_x11_get_type (void);
132
133 #define GDK_ROOT_WINDOW()             gdk_root_window
134 #define GDK_ROOT_PARENT()             ((GdkWindow *)gdk_parent_root)
135 #define GDK_DISPLAY()                 gdk_display
136 #define GDK_WINDOW_XDISPLAY(win)      (GDK_DRAWABLE_IMPL_X11(((GdkWindowObject *)win)->impl)->xdisplay)
137 #define GDK_WINDOW_XID(win)           (GDK_DRAWABLE_IMPL_X11(((GdkWindowObject *)win)->impl)->xid)
138 #define GDK_PIXMAP_XDISPLAY(win)      (GDK_DRAWABLE_IMPL_X11(((GdkPixmapObject *)win)->impl)->xdisplay)
139 #define GDK_PIXMAP_XID(win)           (GDK_DRAWABLE_IMPL_X11(((GdkPixmapObject *)win)->impl)->xid)
140 #define GDK_DRAWABLE_XDISPLAY(win)    (GDK_IS_WINDOW (win) ? GDK_WINDOW_XDISPLAY (win) : GDK_PIXMAP_XDISPLAY (win))
141 #define GDK_DRAWABLE_XID(win)         (GDK_IS_WINDOW (win) ? GDK_WINDOW_XID (win) : GDK_PIXMAP_XID (win))
142 #define GDK_IMAGE_XDISPLAY(image)     (((GdkImagePrivateX11 *) GDK_IMAGE (image)->windowing_data)->xdisplay)
143 #define GDK_IMAGE_XIMAGE(image)       (((GdkImagePrivateX11 *) GDK_IMAGE (image)->windowing_data)->ximage)
144 #define GDK_GC_XDISPLAY(gc)           (GDK_GC_X11(gc)->xdisplay)
145 #define GDK_COLORMAP_XDISPLAY(cmap)   (((GdkColormapPrivateX11 *)GDK_COLORMAP (cmap)->windowing_data)->xdisplay)
146 #define GDK_COLORMAP_XCOLORMAP(cmap)  (((GdkColormapPrivateX11 *)GDK_COLORMAP (cmap)->windowing_data)->xcolormap)
147 #define GDK_VISUAL_XVISUAL(vis)       (((GdkVisualPrivate *) vis)->xvisual)
148 #define GDK_FONT_XDISPLAY(font)       (((GdkFontPrivate *) font)->xdisplay)
149 #define GDK_FONT_XFONT(font)          (((GdkFontPrivateX *)font)->xfont)
150
151 #define GDK_GC_XGC(gc)       (GDK_GC_X11(gc)->xgc)
152 #define GDK_GC_GET_XGC(gc)   (GDK_GC_X11(gc)->dirty_mask ? _gdk_x11_gc_flush (gc) : GDK_GC_XGC (gc))
153 #define GDK_WINDOW_XWINDOW    GDK_DRAWABLE_XID
154
155 extern Display          *gdk_display;
156 extern Window            gdk_root_window;
157 extern gint              gdk_screen;
158 extern gchar            *gdk_display_name;
159 extern Window            gdk_leader_window;
160
161 extern Atom              gdk_selection_property;
162
163 extern gchar            *gdk_progclass;
164
165 GdkVisual*   gdkx_visual_get   (VisualID xvisualid);
166 /* XXX: Do not use this function until it is fixed. An X Colormap
167  *      is useless unless we also have the visual. */
168 GdkColormap* gdkx_colormap_get (Colormap xcolormap);
169 /* Utility function in gdk.c - not sure where it belongs, but it's
170    needed in more than one place, so make it public */
171 Window        gdk_get_client_window      (Display  *dpy,
172                                           Window    win);
173
174 /* Functions to create pixmaps and windows from their X equivalents */
175 GdkPixmap    *gdk_pixmap_foreign_new (GdkNativeWindow anid);
176 GdkWindow    *gdk_window_foreign_new (GdkNativeWindow anid);
177
178 /* Return the Gdk* for a particular XID */
179 gpointer      gdk_xid_table_lookup     (XID              xid);
180
181 #define gdk_window_lookup(xid)     ((GdkWindow*) gdk_xid_table_lookup (xid))
182 #define gdk_pixmap_lookup(xid)     ((GdkPixmap*) gdk_xid_table_lookup (xid))
183 #define gdk_font_lookup(xid)       ((GdkFont*) gdk_xid_table_lookup (xid))
184
185 GC _gdk_x11_gc_flush (GdkGC *gc);
186
187 #endif /* __GDK_X_H__ */