]> Pileus Git - ~andy/gtk/blob - gdk/gdkinternals.h
Add gdk_event_[gs]et_source_device().
[~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 _GdkInputWindow GdkInputWindow;
180 typedef struct _GdkWindowPaint GdkWindowPaint;
181
182 typedef void (* GdkDisplayPointerInfoForeach) (GdkDisplay           *display,
183                                                GdkDevice            *device,
184                                                GdkPointerWindowInfo *device_info,
185                                                gpointer              user_data);
186
187 struct _GdkWindow
188 {
189   GObject parent_instance;
190
191   GdkWindowImpl *impl; /* window-system-specific delegate object */  
192   
193   GdkWindow *parent;
194   GdkVisual *visual;
195
196   gpointer user_data;
197
198   gint x;
199   gint y;
200   
201   gint extension_events;
202
203   GList *filters;
204   GList *children;
205
206   cairo_pattern_t *background;
207   
208   GSList *paint_stack;
209   
210   cairo_region_t *update_area;
211   guint update_freeze_count;
212   
213   guint8 window_type;
214   guint8 depth;
215   guint8 resize_count;
216
217   GdkWindowState state;
218   
219   guint guffaw_gravity : 1;
220   guint input_only : 1;
221   guint modal_hint : 1;
222   guint composited : 1;
223   
224   guint destroyed : 2;
225
226   guint accept_focus : 1;
227   guint focus_on_map : 1;
228   guint shaped : 1;
229   guint support_multidevice : 1;
230   
231   GdkEventMask event_mask;
232
233   guint update_and_descendants_freeze_count;
234
235   /* The GdkWindow that has the impl, ref:ed if another window.
236    * This ref is required to keep the wrapper of the impl window alive
237    * for as long as any GdkWindow references the impl. */
238   GdkWindow *impl_window; 
239   int abs_x, abs_y; /* Absolute offset in impl */
240   gint width, height;
241   guint32 clip_tag;
242   cairo_region_t *clip_region; /* Clip region (wrt toplevel) in window coords */
243   cairo_region_t *clip_region_with_children; /* Clip region in window coords */
244   GdkCursor *cursor;
245   GHashTable *device_cursor;
246   gint8 toplevel_window_type;
247   guint synthesize_crossing_event_queued : 1;
248   guint effective_visibility : 2;
249   guint visibility : 2; /* The visibility wrt the toplevel (i.e. based on clip_region) */
250   guint native_visibility : 2; /* the native visibility of a impl windows */
251   guint viewable : 1; /* mapped and all parents mapped */
252   guint applied_shape : 1;
253
254   guint num_offscreen_children;
255   GdkWindowPaint *implicit_paint;
256   GdkInputWindow *input_window; /* only set for impl windows */
257
258   GList *outstanding_moves;
259
260   cairo_region_t *shape;
261   cairo_region_t *input_shape;
262   
263   cairo_surface_t *cairo_surface;
264
265   GList *devices_inside;
266   GHashTable *device_events;
267 };
268
269 #define GDK_WINDOW_TYPE(d) (((GDK_WINDOW (d)))->window_type)
270 #define GDK_WINDOW_DESTROYED(d) (GDK_WINDOW (d)->destroyed)
271
272 extern GSList    *_gdk_displays;
273 extern gchar     *_gdk_display_name;
274 extern gint       _gdk_screen_number;
275 extern gchar     *_gdk_display_arg_name;
276 extern gboolean   _gdk_disable_multidevice;
277
278 void      _gdk_events_queue  (GdkDisplay *display);
279 GdkEvent* _gdk_event_unqueue (GdkDisplay *display);
280
281 void   _gdk_event_emit               (GdkEvent   *event);
282 GList* _gdk_event_queue_find_first   (GdkDisplay *display);
283 void   _gdk_event_queue_remove_link  (GdkDisplay *display,
284                                       GList      *node);
285 GList* _gdk_event_queue_prepend      (GdkDisplay *display,
286                                       GdkEvent   *event);
287 GList* _gdk_event_queue_append       (GdkDisplay *display,
288                                       GdkEvent   *event);
289 GList* _gdk_event_queue_insert_after (GdkDisplay *display,
290                                       GdkEvent   *after_event,
291                                       GdkEvent   *event);
292 GList* _gdk_event_queue_insert_before(GdkDisplay *display,
293                                       GdkEvent   *after_event,
294                                       GdkEvent   *event);
295 void   _gdk_event_button_generate    (GdkDisplay *display,
296                                       GdkEvent   *event);
297
298 void _gdk_windowing_event_data_copy (const GdkEvent *src,
299                                      GdkEvent       *dst);
300 void _gdk_windowing_event_data_free (GdkEvent       *event);
301
302 void gdk_synthesize_window_state (GdkWindow     *window,
303                                   GdkWindowState unset_flags,
304                                   GdkWindowState set_flags);
305
306 GdkDeviceManager * _gdk_device_manager_new (GdkDisplay *display);
307
308 gboolean _gdk_cairo_surface_extents (cairo_surface_t *surface,
309                                      GdkRectangle *extents);
310
311 /*************************************
312  * Interfaces used by windowing code *
313  *************************************/
314
315 cairo_surface_t *
316            _gdk_window_ref_cairo_surface (GdkWindow *window);
317
318 void       _gdk_window_impl_new          (GdkWindow      *window,
319                                           GdkWindow      *real_parent,
320                                           GdkScreen      *screen,
321                                           GdkEventMask    event_mask,
322                                           GdkWindowAttr  *attributes,
323                                           gint            attributes_mask);
324 void       _gdk_window_destroy           (GdkWindow      *window,
325                                           gboolean        foreign_destroy);
326 void       _gdk_window_clear_update_area (GdkWindow      *window);
327 void       _gdk_window_update_size       (GdkWindow      *window);
328 gboolean   _gdk_window_update_viewable   (GdkWindow      *window);
329
330 void       _gdk_window_process_updates_recurse (GdkWindow *window,
331                                                 cairo_region_t *expose_region);
332
333 void       _gdk_screen_close             (GdkScreen      *screen);
334
335 const char *_gdk_get_sm_client_id (void);
336
337 /*****************************************
338  * Interfaces provided by windowing code *
339  *****************************************/
340
341 /* Font/string functions implemented in module-specific code */
342
343 void _gdk_cursor_destroy (GdkCursor *cursor);
344
345 void     _gdk_windowing_init                    (void);
346
347 extern const GOptionEntry _gdk_windowing_args[];
348 void     _gdk_windowing_set_default_display     (GdkDisplay *display);
349
350 gchar *_gdk_windowing_substitute_screen_number (const gchar *display_name,
351                                                 gint         screen_number);
352
353 gulong   _gdk_windowing_window_get_next_serial  (GdkDisplay *display);
354 void     _gdk_windowing_window_get_offsets      (GdkWindow  *window,
355                                                  gint       *x_offset,
356                                                  gint       *y_offset);
357
358
359 void       _gdk_windowing_get_device_state   (GdkDisplay       *display,
360                                               GdkDevice        *device,
361                                               GdkScreen       **screen,
362                                               gint             *x,
363                                               gint             *y,
364                                               GdkModifierType  *mask);
365 GdkWindow* _gdk_windowing_window_at_device_position  (GdkDisplay       *display,
366                                                       GdkDevice        *device,
367                                                       gint             *win_x,
368                                                       gint             *win_y,
369                                                       GdkModifierType  *mask,
370                                                       gboolean          get_toplevel);
371 GdkGrabStatus _gdk_windowing_device_grab     (GdkDevice        *device,
372                                               GdkWindow        *window,
373                                               GdkWindow        *native,
374                                               gboolean          owner_events,
375                                               GdkEventMask      event_mask,
376                                               GdkWindow        *confine_to,
377                                               GdkCursor        *cursor,
378                                               guint32           time);
379 void _gdk_windowing_got_event                (GdkDisplay       *display,
380                                               GList            *event_link,
381                                               GdkEvent         *event,
382                                               gulong            serial);
383
384 void _gdk_windowing_window_process_updates_recurse (GdkWindow *window,
385                                                     cairo_region_t *expose_region);
386 void _gdk_windowing_before_process_all_updates     (void);
387 void _gdk_windowing_after_process_all_updates      (void);
388
389
390 #define GDK_WINDOW_IS_MAPPED(window) (((window)->state & GDK_WINDOW_STATE_WITHDRAWN) == 0)
391
392
393 /* Called when gdk_window_destroy() is called on a foreign window
394  * or an ancestor of the foreign window. It should generally reparent
395  * the window out of it's current heirarchy, hide it, and then
396  * send a message to the owner requesting that the window be destroyed.
397  */
398 void _gdk_windowing_window_destroy_foreign (GdkWindow *window);
399
400 void _gdk_windowing_display_set_sm_client_id (GdkDisplay  *display,
401                                               const gchar *sm_client_id);
402
403 void _gdk_windowing_window_set_composited (GdkWindow *window,
404                                            gboolean composited);
405
406 #define GDK_TYPE_PAINTABLE            (_gdk_paintable_get_type ())
407 #define GDK_PAINTABLE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_PAINTABLE, GdkPaintable))
408 #define GDK_IS_PAINTABLE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_PAINTABLE))
409 #define GDK_PAINTABLE_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GDK_TYPE_PAINTABLE, GdkPaintableIface))
410
411 typedef struct _GdkPaintable        GdkPaintable;
412 typedef struct _GdkPaintableIface   GdkPaintableIface;
413
414 struct _GdkPaintableIface
415 {
416   GTypeInterface g_iface;
417   
418   void (* begin_paint_region)       (GdkPaintable    *paintable,
419                                      GdkWindow       *window,
420                                      const cairo_region_t *region);
421   void (* end_paint)                (GdkPaintable    *paintable);
422 };
423
424 GType _gdk_paintable_get_type (void) G_GNUC_CONST;
425
426 struct GdkAppLaunchContextPrivate
427 {
428   GdkDisplay *display;
429   GdkScreen *screen;
430   gint workspace;
431   guint32 timestamp;
432   GIcon *icon;
433   char *icon_name;
434 };
435
436 char *_gdk_windowing_get_startup_notify_id (GAppLaunchContext *context,
437                                             GAppInfo          *info, 
438                                             GList             *files);
439 void  _gdk_windowing_launch_failed         (GAppLaunchContext *context, 
440                                             const char        *startup_notify_id);
441
442 void _gdk_display_device_grab_update                     (GdkDisplay *display,
443                                                           GdkDevice  *device,
444                                                           GdkDevice  *source_device,
445                                                           gulong      current_serial);
446 GdkDeviceGrabInfo  *_gdk_display_get_last_device_grab  (GdkDisplay *display,
447                                                         GdkDevice  *device);
448 GdkDeviceGrabInfo  *_gdk_display_add_device_grab   (GdkDisplay       *display,
449                                                     GdkDevice        *device,
450                                                     GdkWindow        *window,
451                                                     GdkWindow        *native_window,
452                                                     GdkGrabOwnership  grab_ownership,
453                                                     gboolean          owner_events,
454                                                     GdkEventMask      event_mask,
455                                                     unsigned long     serial_start,
456                                                     guint32           time,
457                                                     gboolean          implicit);
458 GdkDeviceGrabInfo  * _gdk_display_has_device_grab  (GdkDisplay *display,
459                                                     GdkDevice  *device,
460                                                     gulong      serial);
461 gboolean _gdk_display_end_device_grab  (GdkDisplay *display,
462                                         GdkDevice  *device,
463                                         gulong      serial,
464                                         GdkWindow  *if_child,
465                                         gboolean    implicit);
466 gboolean _gdk_display_check_grab_ownership (GdkDisplay *display,
467                                             GdkDevice  *device,
468                                             gulong      serial);
469 void _gdk_display_enable_motion_hints     (GdkDisplay *display,
470                                            GdkDevice  *device);
471
472 GdkPointerWindowInfo * _gdk_display_get_pointer_info (GdkDisplay *display,
473                                                       GdkDevice  *device);
474
475 void _gdk_display_pointer_info_foreach (GdkDisplay                   *display,
476                                         GdkDisplayPointerInfoForeach  func,
477                                         gpointer                      user_data);
478
479 void _gdk_window_invalidate_for_expose (GdkWindow       *window,
480                                         cairo_region_t       *region);
481
482 GdkWindow * _gdk_window_find_child_at (GdkWindow *window,
483                                        int x, int y);
484 GdkWindow * _gdk_window_find_descendant_at (GdkWindow *toplevel,
485                                             double x, double y,
486                                             double *found_x,
487                                             double *found_y);
488
489 void _gdk_window_add_damage (GdkWindow *toplevel,
490                              cairo_region_t *damaged_region);
491
492 GdkEvent * _gdk_make_event (GdkWindow    *window,
493                             GdkEventType  type,
494                             GdkEvent     *event_in_queue,
495                             gboolean      before_event);
496 gboolean _gdk_window_event_parent_of (GdkWindow *parent,
497                                       GdkWindow *child);
498
499 void _gdk_synthesize_crossing_events (GdkDisplay                 *display,
500                                       GdkWindow                  *src,
501                                       GdkWindow                  *dest,
502                                       GdkDevice                  *device,
503                                       GdkDevice                  *source_device,
504                                       GdkCrossingMode             mode,
505                                       gint                        toplevel_x,
506                                       gint                        toplevel_y,
507                                       GdkModifierType             mask,
508                                       guint32                     time_,
509                                       GdkEvent                   *event_in_queue,
510                                       gulong                      serial,
511                                       gboolean                    non_linear);
512 void _gdk_display_set_window_under_pointer (GdkDisplay *display,
513                                             GdkDevice  *device,
514                                             GdkWindow  *window);
515
516
517 void _gdk_synthesize_crossing_events_for_geometry_change (GdkWindow *changed_window);
518
519 cairo_region_t *_gdk_window_calculate_full_clip_region    (GdkWindow     *window,
520                                                       GdkWindow     *base_window,
521                                                       gboolean       do_children,
522                                                       gint          *base_x_offset,
523                                                       gint          *base_y_offset);
524 gboolean    _gdk_window_has_impl (GdkWindow *window);
525 GdkWindow * _gdk_window_get_impl_window (GdkWindow *window);
526 GdkWindow *_gdk_window_get_input_window_for_event (GdkWindow *native_window,
527                                                    GdkEventType event_type,
528                                                    int x, int y,
529                                                    gulong serial);
530
531 /*****************************
532  * offscreen window routines *
533  *****************************/
534 GType gdk_offscreen_window_get_type (void);
535 void       _gdk_offscreen_window_new                 (GdkWindow     *window,
536                                                       GdkWindowAttr *attributes,
537                                                       gint           attributes_mask);
538 cairo_surface_t * _gdk_offscreen_window_create_surface (GdkWindow *window,
539                                                         gint       width,
540                                                         gint       height);
541
542
543 /************************************
544  * Initialization and exit routines *
545  ************************************/
546
547 void _gdk_windowing_exit (void);
548
549 G_END_DECLS
550
551 #endif /* __GDK_INTERNALS_H__ */