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