1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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.
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.
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.
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/.
27 /* Uninstalled header defining types and functions internal to GDK */
29 #ifndef __GDK_INTERNALS_H__
30 #define __GDK_INTERNALS_H__
33 #include <gdk/gdktypes.h>
34 #include <gdk/gdkwindow.h>
35 #include <gdk/gdkprivate.h>
37 #include <gdk/gdkmedialib.h>
42 /**********************
43 * General Facilities *
44 **********************/
46 /* Debugging support */
48 typedef struct _GdkColorInfo GdkColorInfo;
49 typedef struct _GdkEventFilter GdkEventFilter;
50 typedef struct _GdkClientFilter GdkClientFilter;
53 GDK_COLOR_WRITEABLE = 1 << 0
58 GdkColorInfoFlags flags;
62 struct _GdkEventFilter {
63 GdkFilterFunc function;
67 struct _GdkClientFilter {
69 GdkFilterFunc function;
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_GDKRGB = 1 << 6,
81 GDK_DEBUG_GC = 1 << 7,
82 GDK_DEBUG_PIXMAP = 1 << 8,
83 GDK_DEBUG_IMAGE = 1 << 9,
84 GDK_DEBUG_INPUT = 1 <<10,
85 GDK_DEBUG_CURSOR = 1 <<11,
86 GDK_DEBUG_MULTIHEAD = 1 <<12,
87 GDK_DEBUG_XINERAMA = 1 <<13,
88 GDK_DEBUG_DRAW = 1 <<14,
89 GDK_DEBUG_EVENTLOOP = 1 <<15
92 extern GList *_gdk_default_filters;
93 extern GdkWindow *_gdk_parent_root;
94 extern gint _gdk_error_code;
95 extern gint _gdk_error_warnings;
97 extern guint _gdk_debug_flags;
98 extern gboolean _gdk_native_windows;
100 #ifdef G_ENABLE_DEBUG
102 #define GDK_NOTE(type,action) G_STMT_START { \
103 if (_gdk_debug_flags & GDK_DEBUG_##type) \
104 { action; }; } G_STMT_END
106 #else /* !G_ENABLE_DEBUG */
108 #define GDK_NOTE(type,action)
110 #endif /* G_ENABLE_DEBUG */
123 typedef struct _GdkArgContext GdkArgContext;
124 typedef struct _GdkArgDesc GdkArgDesc;
126 typedef void (*GdkArgFunc) (const char *name, const char *arg, gpointer data);
128 struct _GdkArgContext
144 typedef struct _GdkEventPrivate GdkEventPrivate;
148 /* Following flag is set for events on the event queue during
149 * translation and cleared afterwards.
151 GDK_EVENT_PENDING = 1 << 0
154 struct _GdkEventPrivate
159 gpointer windowing_data;
163 /* Tracks information about the pointer grab on this display */
167 GdkWindow *native_window;
169 gulong serial_end; /* exclusive, i.e. not active on serial_end */
170 gboolean owner_events;
174 GdkGrabOwnership ownership;
177 guint implicit_ungrab : 1;
180 typedef struct _GdkInputWindow GdkInputWindow;
182 typedef void (* GdkDisplayPointerInfoForeach) (GdkDisplay *display,
184 GdkPointerWindowInfo *device_info,
187 /* Private version of GdkWindowObject. The initial part of this strucuture
188 is public for historical reasons. Don't change that part */
189 typedef struct _GdkWindowPaint GdkWindowPaint;
191 struct _GdkWindowObject
193 /* vvvvvvv THIS PART IS PUBLIC. DON'T CHANGE vvvvvvvvvvvvvv */
194 GdkDrawable parent_instance;
196 GdkDrawable *impl; /* window-system-specific delegate object */
198 GdkWindowObject *parent;
205 gint extension_events;
211 GdkPixmap *bg_pixmap;
215 GdkRegion *update_area;
216 guint update_freeze_count;
222 GdkWindowState state;
224 guint guffaw_gravity : 1;
225 guint input_only : 1;
226 guint modal_hint : 1;
227 guint composited : 1;
231 guint accept_focus : 1;
232 guint focus_on_map : 1;
234 guint support_multidevice : 1;
236 GdkEventMask event_mask;
238 guint update_and_descendants_freeze_count;
240 GdkWindowRedirect *redirect;
242 /* ^^^^^^^^^^ THIS PART IS PUBLIC. DON'T CHANGE ^^^^^^^^^^ */
244 /* The GdkWindowObject that has the impl, ref:ed if another window.
245 * This ref is required to keep the wrapper of the impl window alive
246 * for as long as any GdkWindow references the impl. */
247 GdkWindowObject *impl_window;
248 int abs_x, abs_y; /* Absolute offset in impl */
251 GdkRegion *clip_region; /* Clip region (wrt toplevel) in window coords */
252 GdkRegion *clip_region_with_children; /* Clip region in window coords */
254 GHashTable *device_cursor;
255 gint8 toplevel_window_type;
256 guint synthesize_crossing_event_queued : 1;
257 guint effective_visibility : 2;
258 guint visibility : 2; /* The visibility wrt the toplevel (i.e. based on clip_region) */
259 guint native_visibility : 2; /* the native visibility of a impl windows */
260 guint viewable : 1; /* mapped and all parents mapped */
261 guint applied_shape : 1;
263 guint num_offscreen_children;
264 GdkWindowPaint *implicit_paint;
265 GdkInputWindow *input_window; /* only set for impl windows */
267 GList *outstanding_moves;
270 GdkRegion *input_shape;
272 cairo_surface_t *cairo_surface;
273 guint outstanding_surfaces; /* only set on impl window */
275 GList *devices_inside;
276 GHashTable *device_events;
279 #define GDK_WINDOW_TYPE(d) (((GdkWindowObject*)(GDK_WINDOW (d)))->window_type)
280 #define GDK_WINDOW_DESTROYED(d) (((GdkWindowObject*)(GDK_WINDOW (d)))->destroyed)
282 extern GdkEventFunc _gdk_event_func; /* Callback for events */
283 extern gpointer _gdk_event_data;
284 extern GDestroyNotify _gdk_event_notify;
286 extern GSList *_gdk_displays;
287 extern gchar *_gdk_display_name;
288 extern gint _gdk_screen_number;
289 extern gchar *_gdk_display_arg_name;
290 extern gboolean _gdk_enable_multidevice;
292 void _gdk_events_queue (GdkDisplay *display);
293 GdkEvent* _gdk_event_unqueue (GdkDisplay *display);
295 GList* _gdk_event_queue_find_first (GdkDisplay *display);
296 void _gdk_event_queue_remove_link (GdkDisplay *display,
298 GList* _gdk_event_queue_prepend (GdkDisplay *display,
300 GList* _gdk_event_queue_append (GdkDisplay *display,
302 GList* _gdk_event_queue_insert_after (GdkDisplay *display,
303 GdkEvent *after_event,
305 GList* _gdk_event_queue_insert_before(GdkDisplay *display,
306 GdkEvent *after_event,
308 void _gdk_event_button_generate (GdkDisplay *display,
311 void _gdk_windowing_event_data_copy (const GdkEvent *src,
313 void _gdk_windowing_event_data_free (GdkEvent *event);
315 void gdk_synthesize_window_state (GdkWindow *window,
316 GdkWindowState unset_flags,
317 GdkWindowState set_flags);
319 GdkDeviceManager * _gdk_device_manager_new (GdkDisplay *display);
322 #define GDK_SCRATCH_IMAGE_WIDTH 256
323 #define GDK_SCRATCH_IMAGE_HEIGHT 64
325 GdkImage* _gdk_image_new_for_depth (GdkScreen *screen,
331 GdkImage *_gdk_image_get_scratch (GdkScreen *screen,
338 GdkImage *_gdk_drawable_copy_to_image (GdkDrawable *drawable,
347 cairo_surface_t *_gdk_drawable_ref_cairo_surface (GdkDrawable *drawable);
349 GdkDrawable *_gdk_drawable_get_source_drawable (GdkDrawable *drawable);
350 cairo_surface_t * _gdk_drawable_create_cairo_surface (GdkDrawable *drawable,
355 GdkGC *_gdk_drawable_get_scratch_gc (GdkDrawable *drawable,
356 gboolean graphics_exposures);
357 GdkGC *_gdk_drawable_get_subwindow_scratch_gc (GdkDrawable *drawable);
359 void _gdk_gc_update_context (GdkGC *gc,
361 const GdkColor *override_foreground,
362 GdkBitmap *override_stipple,
364 GdkDrawable *target_drawable);
366 /*************************************
367 * Interfaces used by windowing code *
368 *************************************/
370 GdkPixmap *_gdk_pixmap_new (GdkDrawable *drawable,
374 GdkPixmap *_gdk_pixmap_create_from_data (GdkDrawable *drawable,
381 GdkPixmap *_gdk_bitmap_create_from_data (GdkDrawable *drawable,
386 void _gdk_window_impl_new (GdkWindow *window,
387 GdkWindow *real_parent,
390 GdkEventMask event_mask,
391 GdkWindowAttr *attributes,
392 gint attributes_mask);
393 void _gdk_window_destroy (GdkWindow *window,
394 gboolean foreign_destroy);
395 void _gdk_window_clear_update_area (GdkWindow *window);
396 void _gdk_window_update_size (GdkWindow *window);
397 gboolean _gdk_window_update_viewable (GdkWindow *window);
399 void _gdk_window_process_updates_recurse (GdkWindow *window,
400 GdkRegion *expose_region);
402 void _gdk_screen_close (GdkScreen *screen);
404 const char *_gdk_get_sm_client_id (void);
406 void _gdk_gc_init (GdkGC *gc,
407 GdkDrawable *drawable,
409 GdkGCValuesMask values_mask);
411 GdkRegion *_gdk_gc_get_clip_region (GdkGC *gc);
412 GdkBitmap *_gdk_gc_get_clip_mask (GdkGC *gc);
413 gboolean _gdk_gc_get_exposures (GdkGC *gc);
414 GdkFill _gdk_gc_get_fill (GdkGC *gc);
415 GdkPixmap *_gdk_gc_get_tile (GdkGC *gc);
416 GdkBitmap *_gdk_gc_get_stipple (GdkGC *gc);
417 guint32 _gdk_gc_get_fg_pixel (GdkGC *gc);
418 guint32 _gdk_gc_get_bg_pixel (GdkGC *gc);
419 void _gdk_gc_add_drawable_clip (GdkGC *gc,
424 void _gdk_gc_remove_drawable_clip (GdkGC *gc);
425 void _gdk_gc_set_clip_region_internal (GdkGC *gc,
427 gboolean reset_origin);
428 GdkSubwindowMode _gdk_gc_get_subwindow (GdkGC *gc);
430 GdkDrawable *_gdk_drawable_begin_direct_draw (GdkDrawable *drawable,
435 void _gdk_drawable_end_direct_draw (gpointer priv_data);
438 /*****************************************
439 * Interfaces provided by windowing code *
440 *****************************************/
442 /* Font/string functions implemented in module-specific code */
444 void _gdk_colormap_real_destroy (GdkColormap *colormap);
446 void _gdk_cursor_destroy (GdkCursor *cursor);
448 void _gdk_windowing_init (void);
450 extern const GOptionEntry _gdk_windowing_args[];
451 void _gdk_windowing_set_default_display (GdkDisplay *display);
453 gchar *_gdk_windowing_substitute_screen_number (const gchar *display_name,
456 gulong _gdk_windowing_window_get_next_serial (GdkDisplay *display);
457 void _gdk_windowing_window_get_offsets (GdkWindow *window,
460 GdkRegion *_gdk_windowing_window_get_shape (GdkWindow *window);
461 GdkRegion *_gdk_windowing_window_get_input_shape(GdkWindow *window);
462 GdkRegion *_gdk_windowing_get_shape_for_mask (GdkBitmap *mask);
463 void _gdk_windowing_window_beep (GdkWindow *window);
466 void _gdk_windowing_get_device_state (GdkDisplay *display,
471 GdkModifierType *mask);
472 GdkWindow* _gdk_windowing_window_at_device_position (GdkDisplay *display,
476 GdkModifierType *mask,
477 gboolean get_toplevel);
478 GdkGrabStatus _gdk_windowing_device_grab (GdkDevice *device,
481 gboolean owner_events,
482 GdkEventMask event_mask,
483 GdkWindow *confine_to,
486 void _gdk_windowing_got_event (GdkDisplay *display,
491 void _gdk_windowing_window_process_updates_recurse (GdkWindow *window,
492 GdkRegion *expose_region);
493 void _gdk_windowing_before_process_all_updates (void);
494 void _gdk_windowing_after_process_all_updates (void);
496 /* Return the number of bits-per-pixel for images of the specified depth. */
497 gint _gdk_windowing_get_bits_for_depth (GdkDisplay *display,
501 #define GDK_WINDOW_IS_MAPPED(window) ((((GdkWindowObject*)window)->state & GDK_WINDOW_STATE_WITHDRAWN) == 0)
504 /* Called when gdk_window_destroy() is called on a foreign window
505 * or an ancestor of the foreign window. It should generally reparent
506 * the window out of it's current heirarchy, hide it, and then
507 * send a message to the owner requesting that the window be destroyed.
509 void _gdk_windowing_window_destroy_foreign (GdkWindow *window);
511 void _gdk_windowing_display_set_sm_client_id (GdkDisplay *display,
512 const gchar *sm_client_id);
514 void _gdk_windowing_window_set_composited (GdkWindow *window,
515 gboolean composited);
517 #define GDK_TYPE_PAINTABLE (_gdk_paintable_get_type ())
518 #define GDK_PAINTABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_PAINTABLE, GdkPaintable))
519 #define GDK_IS_PAINTABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_PAINTABLE))
520 #define GDK_PAINTABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GDK_TYPE_PAINTABLE, GdkPaintableIface))
522 typedef struct _GdkPaintable GdkPaintable;
523 typedef struct _GdkPaintableIface GdkPaintableIface;
525 struct _GdkPaintableIface
527 GTypeInterface g_iface;
529 void (* begin_paint_region) (GdkPaintable *paintable,
531 const GdkRegion *region);
532 void (* end_paint) (GdkPaintable *paintable);
535 GType _gdk_paintable_get_type (void) G_GNUC_CONST;
537 /* Implementation types */
538 GType _gdk_window_impl_get_type (void) G_GNUC_CONST;
539 GType _gdk_pixmap_impl_get_type (void) G_GNUC_CONST;
543 * _gdk_windowing_gc_set_clip_region:
545 * @region: the new clip region
546 * @reset_origin: if TRUE, reset the clip_x/y_origin values to 0
548 * Do any window-system specific processing necessary
549 * for a change in clip region. Since the clip origin
550 * will likely change before the GC is used with the
551 * new clip, frequently this function will only set a flag and
552 * do the real processing later.
554 * When this function is called, _gdk_gc_get_clip_region
555 * will already return the new region.
557 void _gdk_windowing_gc_set_clip_region (GdkGC *gc,
558 const GdkRegion *region,
559 gboolean reset_origin);
562 * _gdk_windowing_gc_copy:
563 * @dst_gc: a #GdkGC from the GDK backend
564 * @src_gc: a #GdkGC from the GDK backend
566 * Copies backend specific state from @src_gc to @dst_gc.
567 * This is called before the generic state is copied, so
568 * the old generic state is still available from @dst_gc
570 void _gdk_windowing_gc_copy (GdkGC *dst_gc,
573 /* Queries the current foreground color of a GdkGC */
574 void _gdk_windowing_gc_get_foreground (GdkGC *gc,
576 /* Queries the current background color of a GdkGC */
577 void _gdk_windowing_gc_get_background (GdkGC *gc,
580 struct GdkAppLaunchContextPrivate
590 char *_gdk_windowing_get_startup_notify_id (GAppLaunchContext *context,
593 void _gdk_windowing_launch_failed (GAppLaunchContext *context,
594 const char *startup_notify_id);
596 void _gdk_display_device_grab_update (GdkDisplay *display,
598 gulong current_serial);
599 GdkDeviceGrabInfo *_gdk_display_get_last_device_grab (GdkDisplay *display,
601 GdkDeviceGrabInfo *_gdk_display_add_device_grab (GdkDisplay *display,
604 GdkWindow *native_window,
605 GdkGrabOwnership grab_ownership,
606 gboolean owner_events,
607 GdkEventMask event_mask,
608 unsigned long serial_start,
611 GdkDeviceGrabInfo * _gdk_display_has_device_grab (GdkDisplay *display,
614 gboolean _gdk_display_end_device_grab (GdkDisplay *display,
619 gboolean _gdk_display_check_grab_ownership (GdkDisplay *display,
622 void _gdk_display_enable_motion_hints (GdkDisplay *display,
625 GdkPointerWindowInfo * _gdk_display_get_pointer_info (GdkDisplay *display,
628 void _gdk_display_pointer_info_foreach (GdkDisplay *display,
629 GdkDisplayPointerInfoForeach func,
632 void _gdk_window_invalidate_for_expose (GdkWindow *window,
635 void _gdk_windowing_set_cairo_surface_size (cairo_surface_t *surface,
639 cairo_surface_t * _gdk_windowing_create_cairo_surface (GdkDrawable *drawable,
642 GdkWindow * _gdk_window_find_child_at (GdkWindow *window,
644 GdkWindow * _gdk_window_find_descendant_at (GdkWindow *toplevel,
649 void _gdk_window_add_damage (GdkWindow *toplevel,
650 GdkRegion *damaged_region);
652 GdkEvent * _gdk_make_event (GdkWindow *window,
654 GdkEvent *event_in_queue,
655 gboolean before_event);
656 gboolean _gdk_window_event_parent_of (GdkWindow *parent,
659 void _gdk_synthesize_crossing_events (GdkDisplay *display,
663 GdkCrossingMode mode,
666 GdkModifierType mask,
668 GdkEvent *event_in_queue,
670 gboolean non_linear);
671 void _gdk_display_set_window_under_pointer (GdkDisplay *display,
676 void _gdk_synthesize_crossing_events_for_geometry_change (GdkWindow *changed_window);
678 GdkRegion *_gdk_window_calculate_full_clip_region (GdkWindow *window,
679 GdkWindow *base_window,
680 gboolean do_children,
682 gint *base_y_offset);
683 gboolean _gdk_window_has_impl (GdkWindow *window);
684 GdkWindow * _gdk_window_get_impl_window (GdkWindow *window);
685 GdkWindow *_gdk_window_get_input_window_for_event (GdkWindow *native_window,
686 GdkEventType event_type,
690 /*****************************
691 * offscreen window routines *
692 *****************************/
693 GType gdk_offscreen_window_get_type (void);
694 void _gdk_offscreen_window_new (GdkWindow *window,
697 GdkWindowAttr *attributes,
698 gint attributes_mask);
701 /************************************
702 * Initialization and exit routines *
703 ************************************/
705 void _gdk_image_exit (void);
706 void _gdk_windowing_exit (void);
710 #endif /* __GDK_INTERNALS_H__ */