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