]> Pileus Git - ~andy/gtk/blob - gdk/gdkinternals.h
stylecontext: Do invalidation on first resize container
[~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   GDK_DEBUG_SETTINGS      = 1 << 12
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
155   /* The following flag is set for:
156    * 1) touch events emulating pointer events
157    * 2) pointer events being emulated by a touch sequence.
158    */
159   GDK_EVENT_POINTER_EMULATED = 1 << 1
160 } GdkEventFlags;
161
162 struct _GdkEventPrivate
163 {
164   GdkEvent   event;
165   guint      flags;
166   GdkScreen *screen;
167   gpointer   windowing_data;
168   GdkDevice *device;
169   GdkDevice *source_device;
170 };
171
172 typedef struct _GdkWindowPaint GdkWindowPaint;
173
174 struct _GdkWindow
175 {
176   GObject parent_instance;
177
178   GdkWindowImpl *impl; /* window-system-specific delegate object */
179
180   GdkWindow *parent;
181   GdkVisual *visual;
182
183   gpointer user_data;
184
185   gint x;
186   gint y;
187
188   GdkEventMask event_mask;
189
190   GList *filters;
191   GList *children;
192
193   cairo_pattern_t *background;
194
195   GSList *paint_stack;
196
197   cairo_region_t *update_area;
198   guint update_freeze_count;
199
200   guint8 window_type;
201   guint8 depth;
202   guint8 resize_count;
203
204   gint8 toplevel_window_type;
205   guint8 alpha;
206
207   GdkWindowState state;
208
209   guint guffaw_gravity : 1;
210   guint input_only : 1;
211   guint modal_hint : 1;
212   guint composited : 1;
213   guint has_alpha_background : 1;
214
215   guint destroyed : 2;
216
217   guint accept_focus : 1;
218   guint focus_on_map : 1;
219   guint shaped : 1;
220   guint support_multidevice : 1;
221   guint synthesize_crossing_event_queued : 1;
222   guint effective_visibility : 2;
223   guint visibility : 2; /* The visibility wrt the toplevel (i.e. based on clip_region) */
224   guint native_visibility : 2; /* the native visibility of a impl windows */
225   guint viewable : 1; /* mapped and all parents mapped */
226   guint applied_shape : 1;
227   GdkFullscreenMode fullscreen_mode;
228
229   /* The GdkWindow that has the impl, ref:ed if another window.
230    * This ref is required to keep the wrapper of the impl window alive
231    * for as long as any GdkWindow references the impl. */
232   GdkWindow *impl_window;
233
234   guint update_and_descendants_freeze_count;
235
236   gint abs_x, abs_y; /* Absolute offset in impl */
237   gint width, height;
238
239   /* The clip region is the part of the window, in window coordinates
240      that is fully or partially (i.e. semi transparently) visible in
241      the window hierarchy from the toplevel and down */
242   cairo_region_t *clip_region;
243   /* This is the clip region, with additionally all the opaque
244      child windows removed */
245   cairo_region_t *clip_region_with_children;
246   /* The layered region is the subset of clip_region that
247      is covered by non-opaque sibling or ancestor sibling window. */
248   cairo_region_t *layered_region;
249
250   GdkCursor *cursor;
251   GHashTable *device_cursor;
252
253   GSList *implicit_paint;
254
255   GList *outstanding_moves;
256
257   cairo_region_t *shape;
258   cairo_region_t *input_shape;
259
260   cairo_surface_t *cairo_surface;
261
262   GList *devices_inside;
263   GHashTable *device_events;
264
265   GHashTable *source_event_masks;
266   gulong device_added_handler_id;
267   gulong device_changed_handler_id;
268
269   guint num_offscreen_children;
270
271   GdkFrameClock *frame_clock; /* NULL to use from parent or default */
272 };
273
274 #define GDK_WINDOW_TYPE(d) (((GDK_WINDOW (d)))->window_type)
275 #define GDK_WINDOW_DESTROYED(d) (GDK_WINDOW (d)->destroyed)
276
277 extern gchar     *_gdk_display_name;
278 extern gint       _gdk_screen_number;
279 extern gchar     *_gdk_display_arg_name;
280 extern gboolean   _gdk_disable_multidevice;
281
282 GdkEvent* _gdk_event_unqueue (GdkDisplay *display);
283
284 void _gdk_event_filter_unref        (GdkWindow      *window,
285                                      GdkEventFilter *filter);
286
287 void     _gdk_event_set_pointer_emulated (GdkEvent *event,
288                                           gboolean  emulated);
289 gboolean _gdk_event_get_pointer_emulated (GdkEvent *event);
290
291 void   _gdk_event_emit               (GdkEvent   *event);
292 GList* _gdk_event_queue_find_first   (GdkDisplay *display);
293 void   _gdk_event_queue_remove_link  (GdkDisplay *display,
294                                       GList      *node);
295 GList* _gdk_event_queue_prepend      (GdkDisplay *display,
296                                       GdkEvent   *event);
297 GList* _gdk_event_queue_append       (GdkDisplay *display,
298                                       GdkEvent   *event);
299 GList* _gdk_event_queue_insert_after (GdkDisplay *display,
300                                       GdkEvent   *after_event,
301                                       GdkEvent   *event);
302 GList* _gdk_event_queue_insert_before(GdkDisplay *display,
303                                       GdkEvent   *after_event,
304                                       GdkEvent   *event);
305
306 void    _gdk_event_queue_handle_motion_compression (GdkDisplay *display);
307
308 void   _gdk_event_button_generate    (GdkDisplay *display,
309                                       GdkEvent   *event);
310
311 void _gdk_windowing_event_data_copy (const GdkEvent *src,
312                                      GdkEvent       *dst);
313 void _gdk_windowing_event_data_free (GdkEvent       *event);
314
315 void gdk_synthesize_window_state (GdkWindow     *window,
316                                   GdkWindowState unset_flags,
317                                   GdkWindowState set_flags);
318
319 gboolean _gdk_cairo_surface_extents (cairo_surface_t *surface,
320                                      GdkRectangle *extents);
321
322 /*************************************
323  * Interfaces used by windowing code *
324  *************************************/
325
326 cairo_surface_t *
327            _gdk_window_ref_cairo_surface (GdkWindow *window);
328
329 void       _gdk_window_destroy           (GdkWindow      *window,
330                                           gboolean        foreign_destroy);
331 void       _gdk_window_clear_update_area (GdkWindow      *window);
332 void       _gdk_window_update_size       (GdkWindow      *window);
333 gboolean   _gdk_window_update_viewable   (GdkWindow      *window);
334
335 void       _gdk_window_process_updates_recurse (GdkWindow *window,
336                                                 cairo_region_t *expose_region);
337
338 void       _gdk_screen_close             (GdkScreen      *screen);
339
340 /*****************************************
341  * Interfaces provided by windowing code *
342  *****************************************/
343
344 /* Font/string functions implemented in module-specific code */
345
346 void _gdk_cursor_destroy (GdkCursor *cursor);
347
348 extern const GOptionEntry _gdk_windowing_args[];
349 gchar *_gdk_windowing_substitute_screen_number (const gchar *display_name,
350                                                 gint         screen_number);
351
352 void _gdk_windowing_got_event                (GdkDisplay       *display,
353                                               GList            *event_link,
354                                               GdkEvent         *event,
355                                               gulong            serial);
356
357 #define GDK_WINDOW_IS_MAPPED(window) (((window)->state & GDK_WINDOW_STATE_WITHDRAWN) == 0)
358
359 #define GDK_TYPE_PAINTABLE            (_gdk_paintable_get_type ())
360 #define GDK_PAINTABLE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_PAINTABLE, GdkPaintable))
361 #define GDK_IS_PAINTABLE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_PAINTABLE))
362 #define GDK_PAINTABLE_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GDK_TYPE_PAINTABLE, GdkPaintableIface))
363
364 typedef struct _GdkPaintable        GdkPaintable;
365 typedef struct _GdkPaintableIface   GdkPaintableIface;
366
367 struct _GdkPaintableIface
368 {
369   GTypeInterface g_iface;
370   
371   void (* begin_paint_region)       (GdkPaintable    *paintable,
372                                      GdkWindow       *window,
373                                      const cairo_region_t *region);
374   void (* end_paint)                (GdkPaintable    *paintable);
375 };
376
377 GType _gdk_paintable_get_type (void) G_GNUC_CONST;
378
379 void _gdk_window_invalidate_for_expose (GdkWindow       *window,
380                                         cairo_region_t       *region);
381
382 GdkWindow * _gdk_window_find_child_at (GdkWindow *window,
383                                        int x, int y);
384 GdkWindow * _gdk_window_find_descendant_at (GdkWindow *toplevel,
385                                             double x, double y,
386                                             double *found_x,
387                                             double *found_y);
388
389 void _gdk_window_add_damage (GdkWindow *toplevel,
390                              cairo_region_t *damaged_region);
391
392 GdkEvent * _gdk_make_event (GdkWindow    *window,
393                             GdkEventType  type,
394                             GdkEvent     *event_in_queue,
395                             gboolean      before_event);
396 gboolean _gdk_window_event_parent_of (GdkWindow *parent,
397                                       GdkWindow *child);
398
399 void _gdk_synthesize_crossing_events (GdkDisplay                 *display,
400                                       GdkWindow                  *src,
401                                       GdkWindow                  *dest,
402                                       GdkDevice                  *device,
403                                       GdkDevice                  *source_device,
404                                       GdkCrossingMode             mode,
405                                       gint                        toplevel_x,
406                                       gint                        toplevel_y,
407                                       GdkModifierType             mask,
408                                       guint32                     time_,
409                                       GdkEvent                   *event_in_queue,
410                                       gulong                      serial,
411                                       gboolean                    non_linear);
412 void _gdk_display_set_window_under_pointer (GdkDisplay *display,
413                                             GdkDevice  *device,
414                                             GdkWindow  *window);
415
416
417 void _gdk_synthesize_crossing_events_for_geometry_change (GdkWindow *changed_window);
418
419 gboolean    _gdk_window_has_impl (GdkWindow *window);
420 GdkWindow * _gdk_window_get_impl_window (GdkWindow *window);
421
422 /*****************************
423  * offscreen window routines *
424  *****************************/
425 GType gdk_offscreen_window_get_type (void);
426 void       _gdk_offscreen_window_new                 (GdkWindow     *window,
427                                                       GdkWindowAttr *attributes,
428                                                       gint           attributes_mask);
429 cairo_surface_t * _gdk_offscreen_window_create_surface (GdkWindow *window,
430                                                         gint       width,
431                                                         gint       height);
432
433 G_END_DECLS
434
435 #endif /* __GDK_INTERNALS_H__ */