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, see <http://www.gnu.org/licenses/>.
16  */
17 
18 /*
19  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
20  * file for a list of people on the GTK+ Team.  See the ChangeLog
21  * files for a list of changes.  These files are distributed with
22  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
23  */
24 
25 #ifndef __GDK_TYPES_H__
26 #define __GDK_TYPES_H__
27 
28 #if !defined (__GDK_H_INSIDE__) && !defined (GTK_COMPILATION)
29 #error "Only <gdk/gdk.h> can be included directly."
30 #endif
31 
32 /* GDK uses "glib". (And so does GTK).
33  */
34 #include <glib.h>
35 #include <glib-object.h>
36 #include <gio/gio.h>
37 #include <cairo.h>
38 #include <pango/pango.h>
39 
40 /* The system specific file gdkconfig.h contains such configuration
41  * settings that are needed not only when compiling GDK (or GTK)
42  * itself, but also occasionally when compiling programs that use GDK
43  * (or GTK). One such setting is what windowing API backend is in use.
44  */
45 #include <gdk/gdkconfig.h>
46 
47 G_BEGIN_DECLS
48 
49 /**
50  * GDK_CURRENT_TIME:
51  *
52  * Represents the current time, and can be used anywhere a time is expected.
53  */
54 #define GDK_CURRENT_TIME     0L
55 
56 #ifdef __GI_SCANNER__
57 /* The introspection scanner is currently unable to lookup how
58  * cairo_rectangle_int_t is actually defined. This prevents
59  * introspection data for the GdkRectangle type to include fields
60  * descriptions. To workaround this issue, we define it with the same
61  * content as cairo_rectangle_int_t, but only under the introspection
62  * define.
63  */
64 struct _GdkRectangle
65 {
66     int x, y;
67     int width, height;
68 };
69 typedef struct _GdkRectangle          GdkRectangle;
70 #else
71 typedef cairo_rectangle_int_t         GdkRectangle;
72 #endif
73 
74 /* Forward declarations of commonly used types */
75 typedef struct _GdkRGBA               GdkRGBA;
76 typedef struct _GdkContentFormats     GdkContentFormats;
77 typedef struct _GdkContentProvider    GdkContentProvider;
78 typedef struct _GdkCursor             GdkCursor;
79 typedef struct _GdkTexture            GdkTexture;
80 typedef struct _GdkDevice             GdkDevice;
81 typedef struct _GdkDrag               GdkDrag;
82 typedef struct _GdkDrop               GdkDrop;
83 
84 typedef struct _GdkClipboard          GdkClipboard;
85 typedef struct _GdkDisplayManager     GdkDisplayManager;
86 typedef struct _GdkDisplay            GdkDisplay;
87 typedef struct _GdkSurface             GdkSurface;
88 typedef struct _GdkAppLaunchContext   GdkAppLaunchContext;
89 typedef struct _GdkSeat               GdkSeat;
90 typedef struct _GdkSnapshot           GdkSnapshot;
91 
92 typedef struct _GdkDrawContext        GdkDrawContext;
93 typedef struct _GdkCairoContext       GdkCairoContext;
94 typedef struct _GdkGLContext          GdkGLContext;
95 typedef struct _GdkVulkanContext      GdkVulkanContext;
96 
97 /* Currently, these are the same values numerically as in the
98  * X protocol. If you change that, gdksurface-x11.c/gdk_surface_set_geometry_hints()
99  * will need fixing.
100  */
101 /**
102  * GdkGravity:
103  * @GDK_GRAVITY_NORTH_WEST: the reference point is at the top left corner.
104  * @GDK_GRAVITY_NORTH: the reference point is in the middle of the top edge.
105  * @GDK_GRAVITY_NORTH_EAST: the reference point is at the top right corner.
106  * @GDK_GRAVITY_WEST: the reference point is at the middle of the left edge.
107  * @GDK_GRAVITY_CENTER: the reference point is at the center of the surface.
108  * @GDK_GRAVITY_EAST: the reference point is at the middle of the right edge.
109  * @GDK_GRAVITY_SOUTH_WEST: the reference point is at the lower left corner.
110  * @GDK_GRAVITY_SOUTH: the reference point is at the middle of the lower edge.
111  * @GDK_GRAVITY_SOUTH_EAST: the reference point is at the lower right corner.
112  * @GDK_GRAVITY_STATIC: the reference point is at the top left corner of the
113  *  surface itself, ignoring window manager decorations.
114  *
115  * Defines the reference point of a surface and is used in `GdkPopupLayout`.
116  */
117 typedef enum
118 {
119   GDK_GRAVITY_NORTH_WEST = 1,
120   GDK_GRAVITY_NORTH,
121   GDK_GRAVITY_NORTH_EAST,
122   GDK_GRAVITY_WEST,
123   GDK_GRAVITY_CENTER,
124   GDK_GRAVITY_EAST,
125   GDK_GRAVITY_SOUTH_WEST,
126   GDK_GRAVITY_SOUTH,
127   GDK_GRAVITY_SOUTH_EAST,
128   GDK_GRAVITY_STATIC
129 } GdkGravity;
130 
131 /* Types of modifiers.
132  */
133 /**
134  * GdkModifierType:
135  * @GDK_SHIFT_MASK: the Shift key.
136  * @GDK_LOCK_MASK: a Lock key (depending on the modifier mapping of the
137  *  X server this may either be CapsLock or ShiftLock).
138  * @GDK_CONTROL_MASK: the Control key.
139  * @GDK_ALT_MASK: the fourth modifier key (it depends on the modifier
140  *  mapping of the X server which key is interpreted as this modifier, but
141  *  normally it is the Alt key).
142  * @GDK_BUTTON1_MASK: the first mouse button.
143  * @GDK_BUTTON2_MASK: the second mouse button.
144  * @GDK_BUTTON3_MASK: the third mouse button.
145  * @GDK_BUTTON4_MASK: the fourth mouse button.
146  * @GDK_BUTTON5_MASK: the fifth mouse button.
147  * @GDK_SUPER_MASK: the Super modifier
148  * @GDK_HYPER_MASK: the Hyper modifier
149  * @GDK_META_MASK: the Meta modifier
150  *
151  * Flags to indicate the state of modifier keys and mouse buttons
152  * in events.
153  *
154  * Typical modifier keys are Shift, Control, Meta, Super, Hyper, Alt, Compose,
155  * Apple, CapsLock or ShiftLock.
156  *
157  * Note that GDK may add internal values to events which include values outside
158  * of this enumeration. Your code should preserve and ignore them.  You can use
159  * %GDK_MODIFIER_MASK to remove all private values.
160  */
161 typedef enum
162 {
163   GDK_SHIFT_MASK    = 1 << 0,
164   GDK_LOCK_MASK     = 1 << 1,
165   GDK_CONTROL_MASK  = 1 << 2,
166   GDK_ALT_MASK      = 1 << 3,
167 
168   GDK_BUTTON1_MASK  = 1 << 8,
169   GDK_BUTTON2_MASK  = 1 << 9,
170   GDK_BUTTON3_MASK  = 1 << 10,
171   GDK_BUTTON4_MASK  = 1 << 11,
172   GDK_BUTTON5_MASK  = 1 << 12,
173 
174   GDK_SUPER_MASK    = 1 << 26,
175   GDK_HYPER_MASK    = 1 << 27,
176   GDK_META_MASK     = 1 << 28,
177 } GdkModifierType;
178 
179 
180 /**
181  * GDK_MODIFIER_MASK:
182  *
183  * A mask covering all entries in `GdkModifierType`.
184  */
185 #define GDK_MODIFIER_MASK (GDK_SHIFT_MASK|GDK_LOCK_MASK|GDK_CONTROL_MASK| \
186                            GDK_ALT_MASK|GDK_SUPER_MASK|GDK_HYPER_MASK|GDK_META_MASK| \
187                            GDK_BUTTON1_MASK|GDK_BUTTON2_MASK|GDK_BUTTON3_MASK| \
188                            GDK_BUTTON4_MASK|GDK_BUTTON5_MASK)
189 
190 
191 /**
192  * GdkGLError:
193  * @GDK_GL_ERROR_NOT_AVAILABLE: OpenGL support is not available
194  * @GDK_GL_ERROR_UNSUPPORTED_FORMAT: The requested visual format is not supported
195  * @GDK_GL_ERROR_UNSUPPORTED_PROFILE: The requested profile is not supported
196  * @GDK_GL_ERROR_COMPILATION_FAILED: The shader compilation failed
197  * @GDK_GL_ERROR_LINK_FAILED: The shader linking failed
198  *
199  * Error enumeration for `GdkGLContext`.
200  */
201 typedef enum {
202   GDK_GL_ERROR_NOT_AVAILABLE,
203   GDK_GL_ERROR_UNSUPPORTED_FORMAT,
204   GDK_GL_ERROR_UNSUPPORTED_PROFILE,
205   GDK_GL_ERROR_COMPILATION_FAILED,
206   GDK_GL_ERROR_LINK_FAILED
207 } GdkGLError;
208 
209 /**
210  * GdkVulkanError:
211  * @GDK_VULKAN_ERROR_UNSUPPORTED: Vulkan is not supported on this backend or has not been
212  *   compiled in.
213  * @GDK_VULKAN_ERROR_NOT_AVAILABLE: Vulkan support is not available on this Surface
214  *
215  * Error enumeration for `GdkVulkanContext`.
216  */
217 typedef enum {
218   GDK_VULKAN_ERROR_UNSUPPORTED,
219   GDK_VULKAN_ERROR_NOT_AVAILABLE,
220 } GdkVulkanError;
221 
222 /**
223  * GdkAxisUse:
224  * @GDK_AXIS_IGNORE: the axis is ignored.
225  * @GDK_AXIS_X: the axis is used as the x axis.
226  * @GDK_AXIS_Y: the axis is used as the y axis.
227  * @GDK_AXIS_DELTA_X: the axis is used as the scroll x delta
228  * @GDK_AXIS_DELTA_Y: the axis is used as the scroll y delta
229  * @GDK_AXIS_PRESSURE: the axis is used for pressure information.
230  * @GDK_AXIS_XTILT: the axis is used for x tilt information.
231  * @GDK_AXIS_YTILT: the axis is used for y tilt information.
232  * @GDK_AXIS_WHEEL: the axis is used for wheel information.
233  * @GDK_AXIS_DISTANCE: the axis is used for pen/tablet distance information
234  * @GDK_AXIS_ROTATION: the axis is used for pen rotation information
235  * @GDK_AXIS_SLIDER: the axis is used for pen slider information
236  * @GDK_AXIS_LAST: a constant equal to the numerically highest axis value.
237  *
238  * Defines how device axes are interpreted by GTK.
239  *
240  * Note that the X and Y axes are not really needed; pointer devices
241  * report their location via the x/y members of events regardless. Whether
242  * X and Y are present as axes depends on the GDK backend.
243  */
244 typedef enum
245 {
246   GDK_AXIS_IGNORE,
247   GDK_AXIS_X,
248   GDK_AXIS_Y,
249   GDK_AXIS_DELTA_X,
250   GDK_AXIS_DELTA_Y,
251   GDK_AXIS_PRESSURE,
252   GDK_AXIS_XTILT,
253   GDK_AXIS_YTILT,
254   GDK_AXIS_WHEEL,
255   GDK_AXIS_DISTANCE,
256   GDK_AXIS_ROTATION,
257   GDK_AXIS_SLIDER,
258   GDK_AXIS_LAST
259 } GdkAxisUse;
260 
261 /**
262  * GdkAxisFlags:
263  * @GDK_AXIS_FLAG_X: X axis is present
264  * @GDK_AXIS_FLAG_Y: Y axis is present
265  * @GDK_AXIS_FLAG_DELTA_X: Scroll X delta axis is present
266  * @GDK_AXIS_FLAG_DELTA_Y: Scroll Y delta axis is present
267  * @GDK_AXIS_FLAG_PRESSURE: Pressure axis is present
268  * @GDK_AXIS_FLAG_XTILT: X tilt axis is present
269  * @GDK_AXIS_FLAG_YTILT: Y tilt axis is present
270  * @GDK_AXIS_FLAG_WHEEL: Wheel axis is present
271  * @GDK_AXIS_FLAG_DISTANCE: Distance axis is present
272  * @GDK_AXIS_FLAG_ROTATION: Z-axis rotation is present
273  * @GDK_AXIS_FLAG_SLIDER: Slider axis is present
274  *
275  * Flags describing the current capabilities of a device/tool.
276  */
277 typedef enum
278 {
279   GDK_AXIS_FLAG_X        = 1 << GDK_AXIS_X,
280   GDK_AXIS_FLAG_Y        = 1 << GDK_AXIS_Y,
281   GDK_AXIS_FLAG_DELTA_X  = 1 << GDK_AXIS_DELTA_X,
282   GDK_AXIS_FLAG_DELTA_Y  = 1 << GDK_AXIS_DELTA_Y,
283   GDK_AXIS_FLAG_PRESSURE = 1 << GDK_AXIS_PRESSURE,
284   GDK_AXIS_FLAG_XTILT    = 1 << GDK_AXIS_XTILT,
285   GDK_AXIS_FLAG_YTILT    = 1 << GDK_AXIS_YTILT,
286   GDK_AXIS_FLAG_WHEEL    = 1 << GDK_AXIS_WHEEL,
287   GDK_AXIS_FLAG_DISTANCE = 1 << GDK_AXIS_DISTANCE,
288   GDK_AXIS_FLAG_ROTATION = 1 << GDK_AXIS_ROTATION,
289   GDK_AXIS_FLAG_SLIDER   = 1 << GDK_AXIS_SLIDER,
290 } GdkAxisFlags;
291 
292 /**
293  * GdkDragAction:
294  * @GDK_ACTION_COPY: Copy the data.
295  * @GDK_ACTION_MOVE: Move the data, i.e. first copy it, then delete
296  *   it from the source using the DELETE target of the X selection protocol.
297  * @GDK_ACTION_LINK: Add a link to the data. Note that this is only
298  *   useful if source and destination agree on what it means, and is not
299  *   supported on all platforms.
300  * @GDK_ACTION_ASK: Ask the user what to do with the data.
301  *
302  * Used in `GdkDrop` and `GdkDrag` to indicate the actions that the
303  * destination can and should do with the dropped data.
304  */
305 typedef enum
306 {
307   GDK_ACTION_COPY    = 1 << 0,
308   GDK_ACTION_MOVE    = 1 << 1,
309   GDK_ACTION_LINK    = 1 << 2,
310   GDK_ACTION_ASK     = 1 << 3
311 } GdkDragAction;
312 
313 /**
314  * GDK_ACTION_ALL:
315  *
316  * Defines all possible DND actions.
317  *
318  * This can be used in [method@Gdk.Drop.status] messages when any drop
319  * can be accepted or a more specific drop method is not yet known.
320  */
321 #define GDK_ACTION_ALL (GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK)
322 
323 /*
324  * GDK_DECLARE_INTERNAL_TYPE:
325  * @ModuleObjName: The name of the new type, in camel case (like GtkWidget)
326  * @module_obj_name: The name of the new type in lowercase, with words
327  *  separated by '_' (like 'gtk_widget')
328  * @MODULE: The name of the module, in all caps (like 'GTK')
329  * @OBJ_NAME: The bare name of the type, in all caps (like 'WIDGET')
330  * @ParentName: the name of the parent type, in camel case (like GtkWidget)
331  *
332  * A convenience macro for emitting the usual declarations in the
333  * header file for a type which is intended to be subclassed only
334  * by internal consumers.
335  *
336  * This macro differs from %G_DECLARE_DERIVABLE_TYPE and %G_DECLARE_FINAL_TYPE
337  * by declaring a type that is only derivable internally. Internal users can
338  * derive this type, assuming they have access to the instance and class
339  * structures; external users will not be able to subclass this type.
340  */
341 #define GDK_DECLARE_INTERNAL_TYPE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, ParentName) \
342   GType module_obj_name##_get_type (void);                                                               \
343   G_GNUC_BEGIN_IGNORE_DEPRECATIONS                                                                       \
344   typedef struct _##ModuleObjName ModuleObjName;                                                         \
345   typedef struct _##ModuleObjName##Class ModuleObjName##Class;                                           \
346                                                                                                          \
347   _GLIB_DEFINE_AUTOPTR_CHAINUP (ModuleObjName, ParentName)                                               \
348   G_DEFINE_AUTOPTR_CLEANUP_FUNC (ModuleObjName##Class, g_type_class_unref)                               \
349                                                                                                          \
350   G_GNUC_UNUSED static inline ModuleObjName * MODULE##_##OBJ_NAME (gpointer ptr) {                       \
351     return G_TYPE_CHECK_INSTANCE_CAST (ptr, module_obj_name##_get_type (), ModuleObjName); }             \
352   G_GNUC_UNUSED static inline ModuleObjName##Class * MODULE##_##OBJ_NAME##_CLASS (gpointer ptr) {        \
353     return G_TYPE_CHECK_CLASS_CAST (ptr, module_obj_name##_get_type (), ModuleObjName##Class); }         \
354   G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME (gpointer ptr) {                           \
355     return G_TYPE_CHECK_INSTANCE_TYPE (ptr, module_obj_name##_get_type ()); }                            \
356   G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME##_CLASS (gpointer ptr) {                   \
357     return G_TYPE_CHECK_CLASS_TYPE (ptr, module_obj_name##_get_type ()); }                               \
358   G_GNUC_UNUSED static inline ModuleObjName##Class * MODULE##_##OBJ_NAME##_GET_CLASS (gpointer ptr) {    \
359     return G_TYPE_INSTANCE_GET_CLASS (ptr, module_obj_name##_get_type (), ModuleObjName##Class); }       \
360   G_GNUC_END_IGNORE_DEPRECATIONS
361 
362 typedef struct _GdkKeymapKey GdkKeymapKey;
363 
364 /**
365  * GdkKeymapKey:
366  * @keycode: the hardware keycode. This is an identifying number for a
367  *   physical key.
368  * @group: indicates movement in a horizontal direction. Usually groups are used
369  *   for two different languages. In group 0, a key might have two English
370  *   characters, and in group 1 it might have two Hebrew characters. The Hebrew
371  *   characters will be printed on the key next to the English characters.
372  * @level: indicates which symbol on the key will be used, in a vertical direction.
373  *   So on a standard US keyboard, the key with the number “1” on it also has the
374  *   exclamation point ("!") character on it. The level indicates whether to use
375  *   the “1” or the “!” symbol. The letter keys are considered to have a lowercase
376  *   letter at level 0, and an uppercase letter at level 1, though only the
377  *   uppercase letter is printed.
378  *
379  * A `GdkKeymapKey` is a hardware key that can be mapped to a keyval.
380  */
381 struct _GdkKeymapKey
382 {
383   guint keycode;
384   int   group;
385   int   level;
386 };
387 
388 
389 G_END_DECLS
390 
391 /*< private >
392  * GDK_EXTERN_VAR:
393  *
394  * A macro to annotate extern variables so that they show up properly in
395  * Windows DLLs.
396  */
397 #ifndef GDK_EXTERN_VAR
398 #  ifdef G_PLATFORM_WIN32
399 #    ifdef GTK_COMPILATION
400 #      ifdef DLL_EXPORT
401 #        define GDK_EXTERN_VAR __declspec(dllexport)
402 #      else /* !DLL_EXPORT */
403 #        define GDK_EXTERN_VAR extern
404 #      endif /* !DLL_EXPORT */
405 #    else /* !GTK_COMPILATION */
406 #      define GDK_EXTERN_VAR extern __declspec(dllimport)
407 #    endif /* !GTK_COMPILATION */
408 #  else /* !G_PLATFORM_WIN32 */
409 #    define GDK_EXTERN_VAR _GDK_EXTERN
410 #  endif /* !G_PLATFORM_WIN32 */
411 #endif /* GDK_EXTERN_VAR */
412 
413 #endif /* __GDK_TYPES_H__ */
414