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