]> Pileus Git - ~andy/gtk/blob - gdk/gdkinternals.h
API: Add gdk_window_get_background_pattern()
[~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 <gdk/gdktypes.h>
34 #include <gdk/gdkwindow.h>
35 #include <gdk/gdkprivate.h>
36 #ifdef USE_MEDIALIB
37 #include <gdk/gdkmedialib.h>
38 #endif
39
40 G_BEGIN_DECLS
41
42 /**********************
43  * General Facilities * 
44  **********************/
45
46 /* Debugging support */
47
48 typedef struct _GdkColorInfo           GdkColorInfo;
49 typedef struct _GdkEventFilter         GdkEventFilter;
50 typedef struct _GdkClientFilter        GdkClientFilter;
51
52 typedef enum {
53   GDK_COLOR_WRITEABLE = 1 << 0
54 } GdkColorInfoFlags;
55
56 struct _GdkColorInfo
57 {
58   GdkColorInfoFlags flags;
59   guint ref_count;
60 };
61
62 struct _GdkEventFilter {
63   GdkFilterFunc function;
64   gpointer data;
65 };
66
67 struct _GdkClientFilter {
68   GdkAtom       type;
69   GdkFilterFunc function;
70   gpointer      data;
71 };
72
73 typedef enum {
74   GDK_DEBUG_MISC          = 1 << 0,
75   GDK_DEBUG_EVENTS        = 1 << 1,
76   GDK_DEBUG_DND           = 1 << 2,
77   GDK_DEBUG_XIM           = 1 << 3,
78   GDK_DEBUG_NOGRABS       = 1 << 4,
79   GDK_DEBUG_COLORMAP      = 1 << 5,
80   GDK_DEBUG_GC            = 1 << 6,
81   GDK_DEBUG_PIXMAP        = 1 << 7,
82   GDK_DEBUG_IMAGE         = 1 << 8,
83   GDK_DEBUG_INPUT         = 1 << 9,
84   GDK_DEBUG_CURSOR        = 1 <<10,
85   GDK_DEBUG_MULTIHEAD     = 1 <<11,
86   GDK_DEBUG_XINERAMA      = 1 <<12,
87   GDK_DEBUG_DRAW          = 1 <<13,
88   GDK_DEBUG_EVENTLOOP     = 1 <<14
89 } GdkDebugFlag;
90
91 extern GList            *_gdk_default_filters;
92 extern GdkWindow        *_gdk_parent_root;
93 extern gint              _gdk_error_code;
94 extern gint              _gdk_error_warnings;
95
96 extern guint _gdk_debug_flags;
97 extern gboolean _gdk_native_windows;
98
99 #ifdef G_ENABLE_DEBUG
100
101 #define GDK_NOTE(type,action)                G_STMT_START { \
102     if (_gdk_debug_flags & GDK_DEBUG_##type)                \
103        { action; };                          } G_STMT_END
104
105 #else /* !G_ENABLE_DEBUG */
106
107 #define GDK_NOTE(type,action)
108
109 #endif /* G_ENABLE_DEBUG */
110
111 /* Arg parsing */
112
113 typedef enum 
114 {
115   GDK_ARG_STRING,
116   GDK_ARG_INT,
117   GDK_ARG_BOOL,
118   GDK_ARG_NOBOOL,
119   GDK_ARG_CALLBACK
120 } GdkArgType;
121
122 typedef struct _GdkArgContext GdkArgContext;
123 typedef struct _GdkArgDesc GdkArgDesc;
124
125 typedef void (*GdkArgFunc) (const char *name, const char *arg, gpointer data);
126
127 struct _GdkArgContext
128 {
129   GPtrArray *tables;
130   gpointer cb_data;
131 };
132
133 struct _GdkArgDesc
134 {
135   const char *name;
136   GdkArgType type;
137   gpointer location;
138   GdkArgFunc callback;
139 };
140
141 /* Event handling */
142
143 typedef struct _GdkEventPrivate GdkEventPrivate;
144
145 typedef enum
146 {
147   /* Following flag is set for events on the event queue during
148    * translation and cleared afterwards.
149    */
150   GDK_EVENT_PENDING = 1 << 0
151 } GdkEventFlags;
152
153 struct _GdkEventPrivate
154 {
155   GdkEvent   event;
156   guint      flags;
157   GdkScreen *screen;
158   gpointer   windowing_data;
159   GdkDevice *device;
160 };
161
162 /* Tracks information about the pointer grab on this display */
163 typedef struct
164 {
165   GdkWindow *window;
166   GdkWindow *native_window;
167   gulong serial_start;
168   gulong serial_end; /* exclusive, i.e. not active on serial_end */
169   gboolean owner_events;
170   guint event_mask;
171   gboolean implicit;
172   guint32 time;
173   GdkGrabOwnership ownership;
174
175   guint activated : 1;
176   guint implicit_ungrab : 1;
177 } GdkDeviceGrabInfo;
178
179 typedef struct _GdkInputWindow GdkInputWindow;
180
181 typedef void (* GdkDisplayPointerInfoForeach) (GdkDisplay           *display,
182                                                GdkDevice            *device,
183                                                GdkPointerWindowInfo *device_info,
184                                                gpointer              user_data);
185
186 /* Private version of GdkWindowObject. The initial part of this strucuture
187    is public for historical reasons. Don't change that part */
188 typedef struct _GdkWindowPaint             GdkWindowPaint;
189
190 #define GDK_WINDOW_OBJECT(object)    ((GdkWindowObject *) GDK_WINDOW (object))
191
192 struct _GdkWindowObject
193 {
194   GdkDrawable parent_instance;
195
196   GdkDrawable *impl; /* window-system-specific delegate object */  
197   
198   GdkWindowObject *parent;
199
200   gpointer user_data;
201
202   gint x;
203   gint y;
204   
205   gint extension_events;
206
207   GList *filters;
208   GList *children;
209
210   GdkColor bg_color;
211   GdkPixmap *bg_pixmap;
212   cairo_pattern_t *background;
213   
214   GSList *paint_stack;
215   
216   cairo_region_t *update_area;
217   guint update_freeze_count;
218   
219   guint8 window_type;
220   guint8 depth;
221   guint8 resize_count;
222
223   GdkWindowState state;
224   
225   guint guffaw_gravity : 1;
226   guint input_only : 1;
227   guint modal_hint : 1;
228   guint composited : 1;
229   
230   guint destroyed : 2;
231
232   guint accept_focus : 1;
233   guint focus_on_map : 1;
234   guint shaped : 1;
235   guint support_multidevice : 1;
236   
237   GdkEventMask event_mask;
238
239   guint update_and_descendants_freeze_count;
240
241   GdkWindowRedirect *redirect;
242
243   /* The GdkWindowObject that has the impl, ref:ed if another window.
244    * This ref is required to keep the wrapper of the impl window alive
245    * for as long as any GdkWindow references the impl. */
246   GdkWindowObject *impl_window; 
247   int abs_x, abs_y; /* Absolute offset in impl */
248   gint width, height;
249   guint32 clip_tag;
250   cairo_region_t *clip_region; /* Clip region (wrt toplevel) in window coords */
251   cairo_region_t *clip_region_with_children; /* Clip region in window coords */
252   GdkCursor *cursor;
253   GHashTable *device_cursor;
254   gint8 toplevel_window_type;
255   guint synthesize_crossing_event_queued : 1;
256   guint effective_visibility : 2;
257   guint visibility : 2; /* The visibility wrt the toplevel (i.e. based on clip_region) */
258   guint native_visibility : 2; /* the native visibility of a impl windows */
259   guint viewable : 1; /* mapped and all parents mapped */
260   guint applied_shape : 1;
261
262   guint num_offscreen_children;
263   GdkWindowPaint *implicit_paint;
264   GdkInputWindow *input_window; /* only set for impl windows */
265
266   GList *outstanding_moves;
267
268   cairo_region_t *shape;
269   cairo_region_t *input_shape;
270   
271   cairo_surface_t *cairo_surface;
272   guint outstanding_surfaces; /* only set on impl window */
273
274   GList *devices_inside;
275   GHashTable *device_events;
276 };
277
278 #define GDK_WINDOW_TYPE(d) (((GdkWindowObject*)(GDK_WINDOW (d)))->window_type)
279 #define GDK_WINDOW_DESTROYED(d) (((GdkWindowObject*)(GDK_WINDOW (d)))->destroyed)
280
281 extern GdkEventFunc   _gdk_event_func;    /* Callback for events */
282 extern gpointer       _gdk_event_data;
283 extern GDestroyNotify _gdk_event_notify;
284
285 extern GSList    *_gdk_displays;
286 extern gchar     *_gdk_display_name;
287 extern gint       _gdk_screen_number;
288 extern gchar     *_gdk_display_arg_name;
289 extern gboolean   _gdk_enable_multidevice;
290
291 void      _gdk_events_queue  (GdkDisplay *display);
292 GdkEvent* _gdk_event_unqueue (GdkDisplay *display);
293
294 GList* _gdk_event_queue_find_first   (GdkDisplay *display);
295 void   _gdk_event_queue_remove_link  (GdkDisplay *display,
296                                       GList      *node);
297 GList* _gdk_event_queue_prepend      (GdkDisplay *display,
298                                       GdkEvent   *event);
299 GList* _gdk_event_queue_append       (GdkDisplay *display,
300                                       GdkEvent   *event);
301 GList* _gdk_event_queue_insert_after (GdkDisplay *display,
302                                       GdkEvent   *after_event,
303                                       GdkEvent   *event);
304 GList* _gdk_event_queue_insert_before(GdkDisplay *display,
305                                       GdkEvent   *after_event,
306                                       GdkEvent   *event);
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 GdkDeviceManager * _gdk_device_manager_new (GdkDisplay *display);
319
320
321 cairo_surface_t *_gdk_drawable_ref_cairo_surface (GdkDrawable *drawable);
322
323 GdkDrawable *_gdk_drawable_get_source_drawable (GdkDrawable *drawable);
324 cairo_surface_t * _gdk_drawable_create_cairo_surface (GdkDrawable *drawable,
325                                                       int width,
326                                                       int height);
327
328 /*************************************
329  * Interfaces used by windowing code *
330  *************************************/
331
332 GdkPixmap *_gdk_pixmap_new               (GdkDrawable    *drawable,
333                                           gint            width,
334                                           gint            height,
335                                           gint            depth);
336
337 void       _gdk_window_impl_new          (GdkWindow      *window,
338                                           GdkWindow      *real_parent,
339                                           GdkScreen      *screen,
340                                           GdkVisual      *visual,
341                                           GdkEventMask    event_mask,
342                                           GdkWindowAttr  *attributes,
343                                           gint            attributes_mask);
344 void       _gdk_window_destroy           (GdkWindow      *window,
345                                           gboolean        foreign_destroy);
346 void       _gdk_window_clear_update_area (GdkWindow      *window);
347 void       _gdk_window_update_size       (GdkWindow      *window);
348 gboolean   _gdk_window_update_viewable   (GdkWindow      *window);
349
350 void       _gdk_window_process_updates_recurse (GdkWindow *window,
351                                                 cairo_region_t *expose_region);
352
353 void       _gdk_screen_close             (GdkScreen      *screen);
354
355 const char *_gdk_get_sm_client_id (void);
356
357 /*****************************************
358  * Interfaces provided by windowing code *
359  *****************************************/
360
361 /* Font/string functions implemented in module-specific code */
362
363 void _gdk_colormap_real_destroy (GdkColormap *colormap);
364
365 void _gdk_cursor_destroy (GdkCursor *cursor);
366
367 void     _gdk_windowing_init                    (void);
368
369 extern const GOptionEntry _gdk_windowing_args[];
370 void     _gdk_windowing_set_default_display     (GdkDisplay *display);
371
372 gchar *_gdk_windowing_substitute_screen_number (const gchar *display_name,
373                                                 gint         screen_number);
374
375 gulong   _gdk_windowing_window_get_next_serial  (GdkDisplay *display);
376 void     _gdk_windowing_window_get_offsets      (GdkWindow  *window,
377                                                  gint       *x_offset,
378                                                  gint       *y_offset);
379 cairo_region_t *_gdk_windowing_window_get_shape      (GdkWindow  *window);
380 cairo_region_t *_gdk_windowing_window_get_input_shape(GdkWindow  *window);
381 cairo_region_t *_gdk_windowing_get_shape_for_mask    (GdkBitmap *mask);
382 void     _gdk_windowing_window_beep             (GdkWindow *window);
383
384
385 void       _gdk_windowing_get_device_state   (GdkDisplay       *display,
386                                               GdkDevice        *device,
387                                               GdkScreen       **screen,
388                                               gint             *x,
389                                               gint             *y,
390                                               GdkModifierType  *mask);
391 GdkWindow* _gdk_windowing_window_at_device_position  (GdkDisplay       *display,
392                                                       GdkDevice        *device,
393                                                       gint             *win_x,
394                                                       gint             *win_y,
395                                                       GdkModifierType  *mask,
396                                                       gboolean          get_toplevel);
397 GdkGrabStatus _gdk_windowing_device_grab     (GdkDevice        *device,
398                                               GdkWindow        *window,
399                                               GdkWindow        *native,
400                                               gboolean          owner_events,
401                                               GdkEventMask      event_mask,
402                                               GdkWindow        *confine_to,
403                                               GdkCursor        *cursor,
404                                               guint32           time);
405 void _gdk_windowing_got_event                (GdkDisplay       *display,
406                                               GList            *event_link,
407                                               GdkEvent         *event,
408                                               gulong            serial);
409
410 void _gdk_windowing_window_process_updates_recurse (GdkWindow *window,
411                                                     cairo_region_t *expose_region);
412 void _gdk_windowing_before_process_all_updates     (void);
413 void _gdk_windowing_after_process_all_updates      (void);
414
415 /* Return the number of bits-per-pixel for images of the specified depth. */
416 gint _gdk_windowing_get_bits_for_depth (GdkDisplay *display,
417                                         gint        depth);
418
419
420 #define GDK_WINDOW_IS_MAPPED(window) ((((GdkWindowObject*)window)->state & GDK_WINDOW_STATE_WITHDRAWN) == 0)
421
422
423 /* Called when gdk_window_destroy() is called on a foreign window
424  * or an ancestor of the foreign window. It should generally reparent
425  * the window out of it's current heirarchy, hide it, and then
426  * send a message to the owner requesting that the window be destroyed.
427  */
428 void _gdk_windowing_window_destroy_foreign (GdkWindow *window);
429
430 void _gdk_windowing_display_set_sm_client_id (GdkDisplay  *display,
431                                               const gchar *sm_client_id);
432
433 void _gdk_windowing_window_set_composited (GdkWindow *window,
434                                            gboolean composited);
435
436 #define GDK_TYPE_PAINTABLE            (_gdk_paintable_get_type ())
437 #define GDK_PAINTABLE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_PAINTABLE, GdkPaintable))
438 #define GDK_IS_PAINTABLE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_PAINTABLE))
439 #define GDK_PAINTABLE_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GDK_TYPE_PAINTABLE, GdkPaintableIface))
440
441 typedef struct _GdkPaintable        GdkPaintable;
442 typedef struct _GdkPaintableIface   GdkPaintableIface;
443
444 struct _GdkPaintableIface
445 {
446   GTypeInterface g_iface;
447   
448   void (* begin_paint_region)       (GdkPaintable    *paintable,
449                                      GdkWindow       *window,
450                                      const cairo_region_t *region);
451   void (* end_paint)                (GdkPaintable    *paintable);
452 };
453
454 GType _gdk_paintable_get_type (void) G_GNUC_CONST;
455
456 /* Implementation types */
457 GType _gdk_window_impl_get_type (void) G_GNUC_CONST;
458 GType _gdk_pixmap_impl_get_type (void) G_GNUC_CONST;
459
460 struct GdkAppLaunchContextPrivate
461 {
462   GdkDisplay *display;
463   GdkScreen *screen;
464   gint workspace;
465   guint32 timestamp;
466   GIcon *icon;
467   char *icon_name;
468 };
469
470 char *_gdk_windowing_get_startup_notify_id (GAppLaunchContext *context,
471                                             GAppInfo          *info, 
472                                             GList             *files);
473 void  _gdk_windowing_launch_failed         (GAppLaunchContext *context, 
474                                             const char        *startup_notify_id);
475
476 void _gdk_display_device_grab_update                     (GdkDisplay *display,
477                                                           GdkDevice  *device,
478                                                           gulong      current_serial);
479 GdkDeviceGrabInfo  *_gdk_display_get_last_device_grab  (GdkDisplay *display,
480                                                         GdkDevice  *device);
481 GdkDeviceGrabInfo  *_gdk_display_add_device_grab   (GdkDisplay       *display,
482                                                     GdkDevice        *device,
483                                                     GdkWindow        *window,
484                                                     GdkWindow        *native_window,
485                                                     GdkGrabOwnership  grab_ownership,
486                                                     gboolean          owner_events,
487                                                     GdkEventMask      event_mask,
488                                                     unsigned long     serial_start,
489                                                     guint32           time,
490                                                     gboolean          implicit);
491 GdkDeviceGrabInfo  * _gdk_display_has_device_grab  (GdkDisplay *display,
492                                                     GdkDevice  *device,
493                                                     gulong      serial);
494 gboolean _gdk_display_end_device_grab  (GdkDisplay *display,
495                                         GdkDevice  *device,
496                                         gulong      serial,
497                                         GdkWindow  *if_child,
498                                         gboolean    implicit);
499 gboolean _gdk_display_check_grab_ownership (GdkDisplay *display,
500                                             GdkDevice  *device,
501                                             gulong      serial);
502 void _gdk_display_enable_motion_hints     (GdkDisplay *display,
503                                            GdkDevice  *device);
504
505 GdkPointerWindowInfo * _gdk_display_get_pointer_info (GdkDisplay *display,
506                                                       GdkDevice  *device);
507
508 void _gdk_display_pointer_info_foreach (GdkDisplay                   *display,
509                                         GdkDisplayPointerInfoForeach  func,
510                                         gpointer                      user_data);
511
512 void _gdk_window_invalidate_for_expose (GdkWindow       *window,
513                                         cairo_region_t       *region);
514
515 gboolean _gdk_windowing_set_cairo_surface_size (cairo_surface_t *surface,
516                                                 int width,
517                                                 int height);
518
519 cairo_surface_t * _gdk_windowing_create_cairo_surface (GdkDrawable *drawable,
520                                                        int width,
521                                                        int height);
522 GdkWindow * _gdk_window_find_child_at (GdkWindow *window,
523                                        int x, int y);
524 GdkWindow * _gdk_window_find_descendant_at (GdkWindow *toplevel,
525                                             double x, double y,
526                                             double *found_x,
527                                             double *found_y);
528
529 void _gdk_window_add_damage (GdkWindow *toplevel,
530                              cairo_region_t *damaged_region);
531
532 GdkEvent * _gdk_make_event (GdkWindow    *window,
533                             GdkEventType  type,
534                             GdkEvent     *event_in_queue,
535                             gboolean      before_event);
536 gboolean _gdk_window_event_parent_of (GdkWindow *parent,
537                                       GdkWindow *child);
538
539 void _gdk_synthesize_crossing_events (GdkDisplay                 *display,
540                                       GdkWindow                  *src,
541                                       GdkWindow                  *dest,
542                                       GdkDevice                  *device,
543                                       GdkCrossingMode             mode,
544                                       gint                        toplevel_x,
545                                       gint                        toplevel_y,
546                                       GdkModifierType             mask,
547                                       guint32                     time_,
548                                       GdkEvent                   *event_in_queue,
549                                       gulong                      serial,
550                                       gboolean                    non_linear);
551 void _gdk_display_set_window_under_pointer (GdkDisplay *display,
552                                             GdkDevice  *device,
553                                             GdkWindow  *window);
554
555
556 void _gdk_synthesize_crossing_events_for_geometry_change (GdkWindow *changed_window);
557
558 cairo_region_t *_gdk_window_calculate_full_clip_region    (GdkWindow     *window,
559                                                       GdkWindow     *base_window,
560                                                       gboolean       do_children,
561                                                       gint          *base_x_offset,
562                                                       gint          *base_y_offset);
563 gboolean    _gdk_window_has_impl (GdkWindow *window);
564 GdkWindow * _gdk_window_get_impl_window (GdkWindow *window);
565 GdkWindow *_gdk_window_get_input_window_for_event (GdkWindow *native_window,
566                                                    GdkEventType event_type,
567                                                    int x, int y,
568                                                    gulong serial);
569
570 /*****************************
571  * offscreen window routines *
572  *****************************/
573 GType gdk_offscreen_window_get_type (void);
574 void       _gdk_offscreen_window_new                 (GdkWindow     *window,
575                                                       GdkScreen     *screen,
576                                                       GdkVisual     *visual,
577                                                       GdkWindowAttr *attributes,
578                                                       gint           attributes_mask);
579
580
581 /************************************
582  * Initialization and exit routines *
583  ************************************/
584
585 void _gdk_windowing_exit (void);
586
587 G_END_DECLS
588
589 #endif /* __GDK_INTERNALS_H__ */