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 Library 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 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library 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.
19 #ifndef __GDK_TYPES_H__
20 #define __GDK_TYPES_H__
23 /* GDK uses "glib". (And so does GTK).
29 #define GDK_CURRENT_TIME 0L
30 #define GDK_PARENT_RELATIVE 1L
32 /* special deviceid for core pointer events */
33 #define GDK_CORE_POINTER 0xfedc
38 #endif /* __cplusplus */
41 /* Type definitions for the basic structures.
44 typedef gulong GdkAtom;
45 typedef struct _GdkColor GdkColor;
46 typedef struct _GdkColormap GdkColormap;
47 typedef struct _GdkVisual GdkVisual;
48 typedef struct _GdkWindowAttr GdkWindowAttr;
49 typedef struct _GdkWindow GdkWindow;
50 typedef struct _GdkWindow GdkPixmap;
51 typedef struct _GdkWindow GdkBitmap;
52 typedef struct _GdkWindow GdkDrawable;
53 typedef struct _GdkImage GdkImage;
54 typedef struct _GdkGCValues GdkGCValues;
55 typedef struct _GdkGC GdkGC;
56 typedef struct _GdkPoint GdkPoint;
57 typedef struct _GdkRectangle GdkRectangle;
58 typedef struct _GdkSegment GdkSegment;
59 typedef struct _GdkFont GdkFont;
60 typedef struct _GdkCursor GdkCursor;
61 typedef struct _GdkColorContextDither GdkColorContextDither;
62 typedef struct _GdkColorContext GdkColorContext;
63 typedef struct _GdkDragContext GdkDragContext;
65 typedef struct _GdkEventAny GdkEventAny;
66 typedef struct _GdkEventExpose GdkEventExpose;
67 typedef struct _GdkEventNoExpose GdkEventNoExpose;
68 typedef struct _GdkEventVisibility GdkEventVisibility;
69 typedef struct _GdkEventMotion GdkEventMotion;
70 typedef struct _GdkEventButton GdkEventButton;
71 typedef struct _GdkEventKey GdkEventKey;
72 typedef struct _GdkEventFocus GdkEventFocus;
73 typedef struct _GdkEventCrossing GdkEventCrossing;
74 typedef struct _GdkEventConfigure GdkEventConfigure;
75 typedef struct _GdkEventProperty GdkEventProperty;
76 typedef struct _GdkEventSelection GdkEventSelection;
77 typedef struct _GdkEventProximity GdkEventProximity;
78 typedef struct _GdkEventClient GdkEventClient;
80 typedef struct _GdkEventDND GdkEventDND;
82 typedef union _GdkEvent GdkEvent;
84 typedef struct _GdkDeviceKey GdkDeviceKey;
85 typedef struct _GdkDeviceInfo GdkDeviceInfo;
86 typedef struct _GdkTimeCoord GdkTimeCoord;
87 typedef struct _GdkRegion GdkRegion;
88 typedef gint (*GdkEventFunc) (GdkEvent *event,
96 * Root: There is only 1 root window and it is initialized
97 * at startup. Creating a window of type GDK_WINDOW_ROOT
99 * Toplevel: Windows which interact with the window manager.
100 * Child: Windows which are children of some other type of window.
101 * (Any other type of window). Most windows are child windows.
102 * Dialog: A special kind of toplevel window which interacts with
103 * the window manager slightly differently than a regular
104 * toplevel window. Dialog windows should be used for any
106 * Pixmap: Pixmaps are really just another kind of window which
107 * doesn't actually appear on the screen. It can't have
108 * children, either and is really just a convenience so
109 * that the drawing functions can work on both windows
110 * and pixmaps transparently. (ie. You shouldn't pass a
111 * pixmap to any procedure which accepts a window with the
112 * exception of the drawing functions).
113 * Foreign: A window that actually belongs to another application
126 /* Classes of windows.
127 * InputOutput: Almost every window should be of this type. Such windows
128 * receive events and are also displayed on screen.
129 * InputOnly: Used only in special circumstances when events need to be
130 * stolen from another window or windows. Input only windows
131 * have no visible output, so they are handy for placing over
132 * top of a group of windows in order to grab the events (or
133 * filter the events) from those windows.
142 * Normal: Normal X image type. These are slow as they involve passing
143 * the entire image through the X connection each time a draw
144 * request is required.
145 * Shared: Shared memory X image type. These are fast as the X server
146 * and the program actually use the same piece of memory. They
147 * should be used with care though as there is the possibility
148 * for both the X server and the program to be reading/writing
149 * the image simultaneously and producing undesired results.
168 GDK_VISUAL_STATIC_GRAY,
169 GDK_VISUAL_GRAYSCALE,
170 GDK_VISUAL_STATIC_COLOR,
171 GDK_VISUAL_PSEUDO_COLOR,
172 GDK_VISUAL_TRUE_COLOR,
173 GDK_VISUAL_DIRECT_COLOR
177 * GDK_FONT_FONT: the font is an XFontStruct.
178 * GDK_FONT_FONTSET: the font is an XFontSet used for I18N.
186 /* Window attribute mask values.
187 * GDK_WA_TITLE: The "title" field is valid.
188 * GDK_WA_X: The "x" field is valid.
189 * GDK_WA_Y: The "y" field is valid.
190 * GDK_WA_CURSOR: The "cursor" field is valid.
191 * GDK_WA_COLORMAP: The "colormap" field is valid.
192 * GDK_WA_VISUAL: The "visual" field is valid.
196 GDK_WA_TITLE = 1 << 1,
199 GDK_WA_CURSOR = 1 << 4,
200 GDK_WA_COLORMAP = 1 << 5,
201 GDK_WA_VISUAL = 1 << 6,
202 GDK_WA_WMCLASS = 1 << 7,
203 GDK_WA_NOREDIR = 1 << 8
204 } GdkWindowAttributesType;
206 /* Size restriction enumeration.
210 GDK_HINT_POS = 1 << 0,
211 GDK_HINT_MIN_SIZE = 1 << 1,
212 GDK_HINT_MAX_SIZE = 1 << 2
215 /* GC function types.
216 * Copy: Overwrites destination pixels with the source pixels.
217 * Invert: Inverts the destination pixels.
218 * Xor: Xor's the destination pixels with the source pixels.
219 * Clear: set pixels to 0
220 * And: source AND destination
221 * And Reverse: source AND (NOT destination)
222 * And Invert: (NOT source) AND destination
224 * Or: source OR destination
225 * Nor: (NOT source) AND (NOT destination)
226 * Equiv: (NOT source) XOR destination
227 * Xor Reverse: source OR (NOT destination)
228 * Copy Inverted: NOT source
229 * Xor Inverted: (NOT source) OR destination
230 * Nand: (NOT source) OR (NOT destination)
231 * Set: set pixels to 1
266 /* GC fill rule for polygons
284 GDK_LINE_ON_OFF_DASH,
318 #include <gdk/gdkcursors.h>
320 GDK_CURSOR_IS_PIXMAP = -1
324 GDK_FILTER_CONTINUE, /* Event not handled, continue processesing */
325 GDK_FILTER_TRANSLATE, /* Translated event stored */
326 GDK_FILTER_REMOVE /* Terminate processing, removing event */
330 GDK_VISIBILITY_UNOBSCURED,
331 GDK_VISIBILITY_PARTIAL,
332 GDK_VISIBILITY_FULLY_OBSCURED
333 } GdkVisibilityState;
336 * Nothing: No event occurred.
337 * Delete: A window delete event was sent by the window manager.
338 * The specified window should be deleted.
339 * Destroy: A window has been destroyed.
340 * Expose: Part of a window has been uncovered.
341 * NoExpose: Same as expose, but no expose event was generated.
342 * VisibilityNotify: A window has become fully/partially/not obscured.
343 * MotionNotify: The mouse has moved.
344 * ButtonPress: A mouse button was pressed.
345 * ButtonRelease: A mouse button was release.
346 * KeyPress: A key was pressed.
347 * KeyRelease: A key was released.
348 * EnterNotify: A window was entered.
349 * LeaveNotify: A window was exited.
350 * FocusChange: The focus window has changed. (The focus window gets
352 * Resize: A window has been resized.
353 * Map: A window has been mapped. (It is now visible on the screen).
354 * Unmap: A window has been unmapped. (It is no longer visible on
363 GDK_MOTION_NOTIFY = 3,
364 GDK_BUTTON_PRESS = 4,
365 GDK_2BUTTON_PRESS = 5,
366 GDK_3BUTTON_PRESS = 6,
367 GDK_BUTTON_RELEASE = 7,
370 GDK_ENTER_NOTIFY = 10,
371 GDK_LEAVE_NOTIFY = 11,
372 GDK_FOCUS_CHANGE = 12,
376 GDK_PROPERTY_NOTIFY = 16,
377 GDK_SELECTION_CLEAR = 17,
378 GDK_SELECTION_REQUEST = 18,
379 GDK_SELECTION_NOTIFY = 19,
380 GDK_PROXIMITY_IN = 20,
381 GDK_PROXIMITY_OUT = 21,
384 GDK_DRAG_MOTION = 24,
385 GDK_DRAG_STATUS = 25,
387 GDK_DROP_FINISHED = 27,
388 GDK_CLIENT_EVENT = 28,
389 GDK_VISIBILITY_NOTIFY = 29,
393 /* Event masks. (Used to select what types of events a window
398 GDK_EXPOSURE_MASK = 1 << 1,
399 GDK_POINTER_MOTION_MASK = 1 << 2,
400 GDK_POINTER_MOTION_HINT_MASK = 1 << 3,
401 GDK_BUTTON_MOTION_MASK = 1 << 4,
402 GDK_BUTTON1_MOTION_MASK = 1 << 5,
403 GDK_BUTTON2_MOTION_MASK = 1 << 6,
404 GDK_BUTTON3_MOTION_MASK = 1 << 7,
405 GDK_BUTTON_PRESS_MASK = 1 << 8,
406 GDK_BUTTON_RELEASE_MASK = 1 << 9,
407 GDK_KEY_PRESS_MASK = 1 << 10,
408 GDK_KEY_RELEASE_MASK = 1 << 11,
409 GDK_ENTER_NOTIFY_MASK = 1 << 12,
410 GDK_LEAVE_NOTIFY_MASK = 1 << 13,
411 GDK_FOCUS_CHANGE_MASK = 1 << 14,
412 GDK_STRUCTURE_MASK = 1 << 15,
413 GDK_PROPERTY_CHANGE_MASK = 1 << 16,
414 GDK_VISIBILITY_NOTIFY_MASK = 1 << 17,
415 GDK_PROXIMITY_IN_MASK = 1 << 18,
416 GDK_PROXIMITY_OUT_MASK = 1 << 19,
417 GDK_SUBSTRUCTURE_MASK = 1 << 20,
418 GDK_ALL_EVENTS_MASK = 0x0FFFFF
421 /* Types of enter/leave notifications.
427 * Unknown: An unknown type of enter/leave event occurred.
431 GDK_NOTIFY_ANCESTOR = 0,
432 GDK_NOTIFY_VIRTUAL = 1,
433 GDK_NOTIFY_INFERIOR = 2,
434 GDK_NOTIFY_NONLINEAR = 3,
435 GDK_NOTIFY_NONLINEAR_VIRTUAL = 4,
436 GDK_NOTIFY_UNKNOWN = 5
439 /* Enter/leave event modes.
451 /* Types of modifiers.
455 GDK_SHIFT_MASK = 1 << 0,
456 GDK_LOCK_MASK = 1 << 1,
457 GDK_CONTROL_MASK = 1 << 2,
458 GDK_MOD1_MASK = 1 << 3,
459 GDK_MOD2_MASK = 1 << 4,
460 GDK_MOD3_MASK = 1 << 5,
461 GDK_MOD4_MASK = 1 << 6,
462 GDK_MOD5_MASK = 1 << 7,
463 GDK_BUTTON1_MASK = 1 << 8,
464 GDK_BUTTON2_MASK = 1 << 9,
465 GDK_BUTTON3_MASK = 1 << 10,
466 GDK_BUTTON4_MASK = 1 << 11,
467 GDK_BUTTON5_MASK = 1 << 12,
468 GDK_RELEASE_MASK = 1 << 13,
469 GDK_MODIFIER_MASK = 0x3fff
474 GDK_CLIP_BY_CHILDREN = 0,
475 GDK_INCLUDE_INFERIORS = 1
480 GDK_INPUT_READ = 1 << 0,
481 GDK_INPUT_WRITE = 1 << 1,
482 GDK_INPUT_EXCEPTION = 1 << 2
489 GDK_ERROR_PARAM = -2,
502 GDK_GC_FOREGROUND = 1 << 0,
503 GDK_GC_BACKGROUND = 1 << 1,
504 GDK_GC_FONT = 1 << 2,
505 GDK_GC_FUNCTION = 1 << 3,
506 GDK_GC_FILL = 1 << 4,
507 GDK_GC_TILE = 1 << 5,
508 GDK_GC_STIPPLE = 1 << 6,
509 GDK_GC_CLIP_MASK = 1 << 7,
510 GDK_GC_SUBWINDOW = 1 << 8,
511 GDK_GC_TS_X_ORIGIN = 1 << 9,
512 GDK_GC_TS_Y_ORIGIN = 1 << 10,
513 GDK_GC_CLIP_X_ORIGIN = 1 << 11,
514 GDK_GC_CLIP_Y_ORIGIN = 1 << 12,
515 GDK_GC_EXPOSURES = 1 << 13,
516 GDK_GC_LINE_WIDTH = 1 << 14,
517 GDK_GC_LINE_STYLE = 1 << 15,
518 GDK_GC_CAP_STYLE = 1 << 16,
519 GDK_GC_JOIN_STYLE = 1 << 17
524 GDK_SELECTION_PRIMARY = 1,
525 GDK_SELECTION_SECONDARY = 2
530 GDK_PROPERTY_NEW_VALUE,
536 GDK_PROP_MODE_REPLACE,
537 GDK_PROP_MODE_PREPEND,
541 /* Enums for XInput support */
569 /* The next two types define enums for predefined atoms relating
570 to selections. In general, one will need to use gdk_intern_atom */
574 GDK_TARGET_BITMAP = 5,
575 GDK_TARGET_COLORMAP = 7,
576 GDK_TARGET_DRAWABLE = 17,
577 GDK_TARGET_PIXMAP = 20,
578 GDK_TARGET_STRING = 31
583 GDK_SELECTION_TYPE_ATOM = 4,
584 GDK_SELECTION_TYPE_BITMAP = 5,
585 GDK_SELECTION_TYPE_COLORMAP = 7,
586 GDK_SELECTION_TYPE_DRAWABLE = 17,
587 GDK_SELECTION_TYPE_INTEGER = 19,
588 GDK_SELECTION_TYPE_PIXMAP = 20,
589 GDK_SELECTION_TYPE_WINDOW = 33,
590 GDK_SELECTION_TYPE_STRING = 31
595 GDK_EXTENSION_EVENTS_NONE,
596 GDK_EXTENSION_EVENTS_ALL,
597 GDK_EXTENSION_EVENTS_CURSOR
600 typedef enum /*< flags >*/
602 GDK_IM_PREEDIT_AREA = 0x0001,
603 GDK_IM_PREEDIT_CALLBACKS = 0x0002,
604 GDK_IM_PREEDIT_POSITION = 0x0004,
605 GDK_IM_PREEDIT_NOTHING = 0x0008,
606 GDK_IM_PREEDIT_NONE = 0x0010,
607 GDK_IM_PREEDIT_MASK = 0x001f,
609 GDK_IM_STATUS_AREA = 0x0100,
610 GDK_IM_STATUS_CALLBACKS = 0x0200,
611 GDK_IM_STATUS_NOTHING = 0x0400,
612 GDK_IM_STATUS_NONE = 0x0800,
613 GDK_IM_STATUS_MASK = 0x0f00
616 /* The next two enumeration values current match the
617 * Motif constants. If this is changed, the implementation
618 * of gdk_window_set_decorations/gdk_window_set_functions
619 * will need to change as well.
623 GDK_DECOR_ALL = 1 << 0,
624 GDK_DECOR_BORDER = 1 << 1,
625 GDK_DECOR_RESIZEH = 1 << 2,
626 GDK_DECOR_TITLE = 1 << 3,
627 GDK_DECOR_MENU = 1 << 4,
628 GDK_DECOR_MINIMIZE = 1 << 5,
629 GDK_DECOR_MAXIMIZE = 1 << 6
634 GDK_FUNC_ALL = 1 << 0,
635 GDK_FUNC_RESIZE = 1 << 1,
636 GDK_FUNC_MOVE = 1 << 2,
637 GDK_FUNC_MINIMIZE = 1 << 3,
638 GDK_FUNC_MAXIMIZE = 1 << 4,
639 GDK_FUNC_CLOSE = 1 << 5
642 typedef void (*GdkInputFunction) (gpointer data,
644 GdkInputCondition condition);
646 typedef void (*GdkDestroyNotify) (gpointer data);
648 /* Color Context modes.
650 * GDK_CC_MODE_UNDEFINED - unknown
651 * GDK_CC_MODE_BW - default B/W
652 * GDK_CC_MODE_STD_CMAP - has a standard colormap
653 * GDK_CC_MODE_TRUE - is a TrueColor/DirectColor visual
654 * GDK_CC_MODE_MY_GRAY - my grayramp
655 * GDK_CC_MODE_PALETTE - has a pre-allocated palette
660 GDK_CC_MODE_UNDEFINED,
662 GDK_CC_MODE_STD_CMAP,
666 } GdkColorContextMode;
668 /* Types of overlapping between a rectangle and a region
669 * GDK_OVERLAP_RECTANGLE_IN: rectangle is in region
670 * GDK_OVERLAP_RECTANGLE_OUT: rectangle in not in region
671 * GDK_OVERLAP_RECTANGLE_PART: rectangle in partially in region
676 GDK_OVERLAP_RECTANGLE_IN,
677 GDK_OVERLAP_RECTANGLE_OUT,
678 GDK_OVERLAP_RECTANGLE_PART
682 GDK_ACTION_DEFAULT = 1 << 0,
683 GDK_ACTION_COPY = 1 << 1,
684 GDK_ACTION_MOVE = 1 << 2,
685 GDK_ACTION_LINK = 1 << 3,
686 GDK_ACTION_PRIVATE = 1 << 4,
687 GDK_ACTION_ASK = 1 << 5
691 GDK_DRAG_PROTO_MOTIF,
693 GDK_DRAG_PROTO_ROOTWIN /* A root window with nobody claiming
698 * A color consists of red, green and blue values in the
699 * range 0-65535 and a pixel value. The pixel value is highly
700 * dependent on the depth and colormap which this color will
701 * be used to draw into. Therefore, sharing colors between
702 * colormaps is a bad idea.
712 /* The colormap type.
713 * Colormaps consist of 256 colors.
722 * "type" is the type of visual this is (PseudoColor, TrueColor, etc).
723 * "depth" is the bit depth of this visual.
724 * "colormap_size" is the size of a colormap for this visual.
725 * "bits_per_rgb" is the number of significant bits per red, green and blue.
726 * The red, green and blue masks, shifts and precisions refer
727 * to value needed to calculate pixel values in TrueColor and DirectColor
728 * visuals. The "mask" is the significant bits within the pixel. The
729 * "shift" is the number of bits left we must shift a primary for it
730 * to be in position (according to the "mask"). "prec" refers to how
731 * much precision the pixel value contains for a particular primary.
737 GdkByteOrder byte_order;
754 struct _GdkWindowAttr
761 GdkWindowClass wclass;
763 GdkColormap *colormap;
764 GdkWindowType window_type;
767 gchar *wmclass_class;
768 gboolean override_redirect;
779 GdkVisual *visual; /* visual used to create the image */
780 GdkByteOrder byte_order;
784 guint16 bpp; /* bytes per pixel */
785 guint16 bpl; /* bytes per line */
794 GdkFunction function;
798 GdkPixmap *clip_mask;
799 GdkSubwindowMode subwindow_mode;
804 gint graphics_exposures;
806 GdkLineStyle line_style;
807 GdkCapStyle cap_style;
808 GdkJoinStyle join_style;
851 struct _GdkColorContextDither
853 gint fast_rgb[32][32][32]; /* quick look-up table for faster rendering */
854 gint fast_err[32][32][32]; /* internal RGB error information */
855 gint fast_erg[32][32][32];
856 gint fast_erb[32][32][32];
859 struct _GdkColorContext
862 GdkColormap *colormap;
864 gint num_colors; /* available no. of colors in colormap */
865 gint max_colors; /* maximum no. of colors */
866 gint num_allocated; /* no. of allocated colors */
868 GdkColorContextMode mode;
869 gint need_to_free_colormap;
870 GdkAtom std_cmap_atom;
872 gulong *clut; /* color look-up table */
873 GdkColor *cmap; /* colormap */
875 GHashTable *color_hash; /* hash table of allocated colors */
876 GdkColor *palette; /* preallocated palette */
877 gint num_palette; /* size of palette */
879 GdkColorContextDither *fast_dither; /* fast dither matrix */
908 /* Types for XInput support */
913 GdkModifierType modifiers;
916 struct _GdkDeviceInfo
920 GdkInputSource source;
922 gint has_cursor; /* TRUE if the X pointer follows device motion */
924 GdkAxisUse *axes; /* Specifies use for each axis */
939 /* Structure that holds information about a drag in progress.
940 * this is used on both source and destination sides.
942 struct _GdkDragContext {
943 GdkDragProtocol protocol;
947 GdkWindow *source_window;
948 GdkWindow *dest_window;
951 GdkDragAction actions;
952 GdkDragAction suggested_action;
953 GdkDragAction action;
958 /* Event filtering */
960 typedef void GdkXEvent; /* Can be cast to XEvent */
962 typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
973 struct _GdkEventExpose
979 gint count; /* If non-zero, how many more events follow. */
982 struct _GdkEventNoExpose
987 /* XXX: does anyone need the X major_code or minor_code fields? */
990 struct _GdkEventVisibility
995 GdkVisibilityState state;
998 struct _GdkEventMotion
1011 GdkInputSource source;
1013 gdouble x_root, y_root;
1016 struct _GdkEventButton
1029 GdkInputSource source;
1031 gdouble x_root, y_root;
1046 struct _GdkEventCrossing
1051 GdkWindow *subwindow;
1057 GdkCrossingMode mode;
1058 GdkNotifyType detail;
1063 struct _GdkEventFocus
1071 struct _GdkEventConfigure
1081 struct _GdkEventProperty
1091 struct _GdkEventSelection
1103 /* This event type will be used pretty rarely. It only is important
1104 for XInput aware programs that are drawing their own cursor */
1106 struct _GdkEventProximity
1112 GdkInputSource source;
1116 struct _GdkEventClient
1121 GdkAtom message_type;
1122 gushort data_format;
1130 /* Event types for DND */
1132 struct _GdkEventDND {
1136 GdkDragContext *context;
1139 gshort x_root, y_root;
1146 GdkEventExpose expose;
1147 GdkEventNoExpose no_expose;
1148 GdkEventVisibility visibility;
1149 GdkEventMotion motion;
1150 GdkEventButton button;
1152 GdkEventCrossing crossing;
1153 GdkEventFocus focus_change;
1154 GdkEventConfigure configure;
1155 GdkEventProperty property;
1156 GdkEventSelection selection;
1157 GdkEventProximity proximity;
1158 GdkEventClient client;
1171 #endif /* __cplusplus */
1174 #endif /* __GDK_TYPES_H__ */