]> Pileus Git - ~andy/gtk/blob - gdk/gdkevents.h
Add ability to print selection
[~andy/gtk] / gdk / gdkevents.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 #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
28 #error "Only <gdk/gdk.h> can be included directly."
29 #endif
30
31 #ifndef __GDK_EVENTS_H__
32 #define __GDK_EVENTS_H__
33
34 #include <gdk/gdkcolor.h>
35 #include <gdk/gdktypes.h>
36 #include <gdk/gdkdnd.h>
37 #include <gdk/gdkinput.h>
38
39 G_BEGIN_DECLS
40
41 #define GDK_TYPE_EVENT          (gdk_event_get_type ())
42
43 #define GDK_PRIORITY_EVENTS     (G_PRIORITY_DEFAULT)
44 #define GDK_PRIORITY_REDRAW     (G_PRIORITY_HIGH_IDLE + 20)
45
46
47 typedef struct _GdkEventAny         GdkEventAny;
48 typedef struct _GdkEventExpose      GdkEventExpose;
49 typedef struct _GdkEventNoExpose    GdkEventNoExpose;
50 typedef struct _GdkEventVisibility  GdkEventVisibility;
51 typedef struct _GdkEventMotion      GdkEventMotion;
52 typedef struct _GdkEventButton      GdkEventButton;
53 typedef struct _GdkEventScroll      GdkEventScroll;  
54 typedef struct _GdkEventKey         GdkEventKey;
55 typedef struct _GdkEventFocus       GdkEventFocus;
56 typedef struct _GdkEventCrossing    GdkEventCrossing;
57 typedef struct _GdkEventConfigure   GdkEventConfigure;
58 typedef struct _GdkEventProperty    GdkEventProperty;
59 typedef struct _GdkEventSelection   GdkEventSelection;
60 typedef struct _GdkEventOwnerChange GdkEventOwnerChange;
61 typedef struct _GdkEventProximity   GdkEventProximity;
62 typedef struct _GdkEventClient      GdkEventClient;
63 typedef struct _GdkEventDND         GdkEventDND;
64 typedef struct _GdkEventWindowState GdkEventWindowState;
65 typedef struct _GdkEventSetting     GdkEventSetting;
66 typedef struct _GdkEventGrabBroken  GdkEventGrabBroken;
67
68 typedef union  _GdkEvent            GdkEvent;
69
70 typedef void (*GdkEventFunc) (GdkEvent *event,
71                               gpointer  data);
72
73 /* Event filtering */
74
75 typedef void GdkXEvent;   /* Can be cast to window system specific
76                            * even type, XEvent on X11, MSG on Win32.
77                            */
78
79 typedef enum {
80   GDK_FILTER_CONTINUE,    /* Event not handled, continue processesing */
81   GDK_FILTER_TRANSLATE,   /* Native event translated into a GDK event and
82                              stored in the "event" structure that was
83                              passed in */
84   GDK_FILTER_REMOVE       /* Terminate processing, removing event */
85 } GdkFilterReturn;
86
87 typedef GdkFilterReturn (*GdkFilterFunc) (GdkXEvent *xevent,
88                                           GdkEvent *event,
89                                           gpointer  data);
90
91
92 /* Event types.
93  *   Nothing: No event occurred.
94  *   Delete: A window delete event was sent by the window manager.
95  *           The specified window should be deleted.
96  *   Destroy: A window has been destroyed.
97  *   Expose: Part of a window has been uncovered.
98  *   NoExpose: Same as expose, but no expose event was generated.
99  *   VisibilityNotify: A window has become fully/partially/not obscured.
100  *   MotionNotify: The mouse has moved.
101  *   ButtonPress: A mouse button was pressed.
102  *   ButtonRelease: A mouse button was release.
103  *   KeyPress: A key was pressed.
104  *   KeyRelease: A key was released.
105  *   EnterNotify: A window was entered.
106  *   LeaveNotify: A window was exited.
107  *   FocusChange: The focus window has changed. (The focus window gets
108  *                keyboard events).
109  *   Resize: A window has been resized.
110  *   Map: A window has been mapped. (It is now visible on the screen).
111  *   Unmap: A window has been unmapped. (It is no longer visible on
112  *          the screen).
113  *   Scroll: A mouse wheel was scrolled either up or down.
114  */
115 typedef enum
116 {
117   GDK_NOTHING           = -1,
118   GDK_DELETE            = 0,
119   GDK_DESTROY           = 1,
120   GDK_EXPOSE            = 2,
121   GDK_MOTION_NOTIFY     = 3,
122   GDK_BUTTON_PRESS      = 4,
123   GDK_2BUTTON_PRESS     = 5,
124   GDK_3BUTTON_PRESS     = 6,
125   GDK_BUTTON_RELEASE    = 7,
126   GDK_KEY_PRESS         = 8,
127   GDK_KEY_RELEASE       = 9,
128   GDK_ENTER_NOTIFY      = 10,
129   GDK_LEAVE_NOTIFY      = 11,
130   GDK_FOCUS_CHANGE      = 12,
131   GDK_CONFIGURE         = 13,
132   GDK_MAP               = 14,
133   GDK_UNMAP             = 15,
134   GDK_PROPERTY_NOTIFY   = 16,
135   GDK_SELECTION_CLEAR   = 17,
136   GDK_SELECTION_REQUEST = 18,
137   GDK_SELECTION_NOTIFY  = 19,
138   GDK_PROXIMITY_IN      = 20,
139   GDK_PROXIMITY_OUT     = 21,
140   GDK_DRAG_ENTER        = 22,
141   GDK_DRAG_LEAVE        = 23,
142   GDK_DRAG_MOTION       = 24,
143   GDK_DRAG_STATUS       = 25,
144   GDK_DROP_START        = 26,
145   GDK_DROP_FINISHED     = 27,
146   GDK_CLIENT_EVENT      = 28,
147   GDK_VISIBILITY_NOTIFY = 29,
148   GDK_NO_EXPOSE         = 30,
149   GDK_SCROLL            = 31,
150   GDK_WINDOW_STATE      = 32,
151   GDK_SETTING           = 33,
152   GDK_OWNER_CHANGE      = 34,
153   GDK_GRAB_BROKEN       = 35,
154   GDK_DAMAGE            = 36
155 } GdkEventType;
156
157 /* Event masks. (Used to select what types of events a window
158  *  will receive).
159  */
160 typedef enum
161 {
162   GDK_EXPOSURE_MASK             = 1 << 1,
163   GDK_POINTER_MOTION_MASK       = 1 << 2,
164   GDK_POINTER_MOTION_HINT_MASK  = 1 << 3,
165   GDK_BUTTON_MOTION_MASK        = 1 << 4,
166   GDK_BUTTON1_MOTION_MASK       = 1 << 5,
167   GDK_BUTTON2_MOTION_MASK       = 1 << 6,
168   GDK_BUTTON3_MOTION_MASK       = 1 << 7,
169   GDK_BUTTON_PRESS_MASK         = 1 << 8,
170   GDK_BUTTON_RELEASE_MASK       = 1 << 9,
171   GDK_KEY_PRESS_MASK            = 1 << 10,
172   GDK_KEY_RELEASE_MASK          = 1 << 11,
173   GDK_ENTER_NOTIFY_MASK         = 1 << 12,
174   GDK_LEAVE_NOTIFY_MASK         = 1 << 13,
175   GDK_FOCUS_CHANGE_MASK         = 1 << 14,
176   GDK_STRUCTURE_MASK            = 1 << 15,
177   GDK_PROPERTY_CHANGE_MASK      = 1 << 16,
178   GDK_VISIBILITY_NOTIFY_MASK    = 1 << 17,
179   GDK_PROXIMITY_IN_MASK         = 1 << 18,
180   GDK_PROXIMITY_OUT_MASK        = 1 << 19,
181   GDK_SUBSTRUCTURE_MASK         = 1 << 20,
182   GDK_SCROLL_MASK               = 1 << 21,
183   GDK_ALL_EVENTS_MASK           = 0x3FFFFE
184 } GdkEventMask;
185
186 typedef enum
187 {
188   GDK_VISIBILITY_UNOBSCURED,
189   GDK_VISIBILITY_PARTIAL,
190   GDK_VISIBILITY_FULLY_OBSCURED
191 } GdkVisibilityState;
192
193 typedef enum
194 {
195   GDK_SCROLL_UP,
196   GDK_SCROLL_DOWN,
197   GDK_SCROLL_LEFT,
198   GDK_SCROLL_RIGHT
199 } GdkScrollDirection;
200
201 /* Types of enter/leave notifications.
202  *   Ancestor:
203  *   Virtual:
204  *   Inferior:
205  *   Nonlinear:
206  *   NonlinearVirtual:
207  *   Unknown: An unknown type of enter/leave event occurred.
208  */
209 typedef enum
210 {
211   GDK_NOTIFY_ANCESTOR           = 0,
212   GDK_NOTIFY_VIRTUAL            = 1,
213   GDK_NOTIFY_INFERIOR           = 2,
214   GDK_NOTIFY_NONLINEAR          = 3,
215   GDK_NOTIFY_NONLINEAR_VIRTUAL  = 4,
216   GDK_NOTIFY_UNKNOWN            = 5
217 } GdkNotifyType;
218
219 /* Enter/leave event modes.
220  *   NotifyNormal
221  *   NotifyGrab
222  *   NotifyUngrab
223  */
224 typedef enum
225 {
226   GDK_CROSSING_NORMAL,
227   GDK_CROSSING_GRAB,
228   GDK_CROSSING_UNGRAB,
229   GDK_CROSSING_GTK_GRAB,
230   GDK_CROSSING_GTK_UNGRAB,
231   GDK_CROSSING_STATE_CHANGED
232 } GdkCrossingMode;
233
234 typedef enum
235 {
236   GDK_PROPERTY_NEW_VALUE,
237   GDK_PROPERTY_DELETE
238 } GdkPropertyState;
239
240 typedef enum
241 {
242   GDK_WINDOW_STATE_WITHDRAWN  = 1 << 0,
243   GDK_WINDOW_STATE_ICONIFIED  = 1 << 1,
244   GDK_WINDOW_STATE_MAXIMIZED  = 1 << 2,
245   GDK_WINDOW_STATE_STICKY     = 1 << 3,
246   GDK_WINDOW_STATE_FULLSCREEN = 1 << 4,
247   GDK_WINDOW_STATE_ABOVE      = 1 << 5,
248   GDK_WINDOW_STATE_BELOW      = 1 << 6
249 } GdkWindowState;
250
251 typedef enum
252 {
253   GDK_SETTING_ACTION_NEW,
254   GDK_SETTING_ACTION_CHANGED,
255   GDK_SETTING_ACTION_DELETED
256 } GdkSettingAction;
257
258 typedef enum
259 {
260   GDK_OWNER_CHANGE_NEW_OWNER,
261   GDK_OWNER_CHANGE_DESTROY,
262   GDK_OWNER_CHANGE_CLOSE
263 } GdkOwnerChange;
264
265 struct _GdkEventAny
266 {
267   GdkEventType type;
268   GdkWindow *window;
269   gint8 send_event;
270 };
271
272 struct _GdkEventExpose
273 {
274   GdkEventType type;
275   GdkWindow *window;
276   gint8 send_event;
277   GdkRectangle area;
278   GdkRegion *region;
279   gint count; /* If non-zero, how many more events follow. */
280 };
281
282 struct _GdkEventNoExpose
283 {
284   GdkEventType type;
285   GdkWindow *window;
286   gint8 send_event;
287 };
288
289 struct _GdkEventVisibility
290 {
291   GdkEventType type;
292   GdkWindow *window;
293   gint8 send_event;
294   GdkVisibilityState state;
295 };
296
297 struct _GdkEventMotion
298 {
299   GdkEventType type;
300   GdkWindow *window;
301   gint8 send_event;
302   guint32 time;
303   gdouble x;
304   gdouble y;
305   gdouble *axes;
306   guint state;
307   gint16 is_hint;
308   GdkDevice *device;
309   gdouble x_root, y_root;
310 };
311
312 struct _GdkEventButton
313 {
314   GdkEventType type;
315   GdkWindow *window;
316   gint8 send_event;
317   guint32 time;
318   gdouble x;
319   gdouble y;
320   gdouble *axes;
321   guint state;
322   guint button;
323   GdkDevice *device;
324   gdouble x_root, y_root;
325 };
326
327 struct _GdkEventScroll
328 {
329   GdkEventType type;
330   GdkWindow *window;
331   gint8 send_event;
332   guint32 time;
333   gdouble x;
334   gdouble y;
335   guint state;
336   GdkScrollDirection direction;
337   GdkDevice *device;
338   gdouble x_root, y_root;
339 };
340
341 struct _GdkEventKey
342 {
343   GdkEventType type;
344   GdkWindow *window;
345   gint8 send_event;
346   guint32 time;
347   guint state;
348   guint keyval;
349   gint length;
350   gchar *string;
351   guint16 hardware_keycode;
352   guint8 group;
353   guint is_modifier : 1;
354 };
355
356 struct _GdkEventCrossing
357 {
358   GdkEventType type;
359   GdkWindow *window;
360   gint8 send_event;
361   GdkWindow *subwindow;
362   guint32 time;
363   gdouble x;
364   gdouble y;
365   gdouble x_root;
366   gdouble y_root;
367   GdkCrossingMode mode;
368   GdkNotifyType detail;
369   gboolean focus;
370   guint state;
371 };
372
373 struct _GdkEventFocus
374 {
375   GdkEventType type;
376   GdkWindow *window;
377   gint8 send_event;
378   gint16 in;
379 };
380
381 struct _GdkEventConfigure
382 {
383   GdkEventType type;
384   GdkWindow *window;
385   gint8 send_event;
386   gint x, y;
387   gint width;
388   gint height;
389 };
390
391 struct _GdkEventProperty
392 {
393   GdkEventType type;
394   GdkWindow *window;
395   gint8 send_event;
396   GdkAtom atom;
397   guint32 time;
398   guint state;
399 };
400
401 struct _GdkEventSelection
402 {
403   GdkEventType type;
404   GdkWindow *window;
405   gint8 send_event;
406   GdkAtom selection;
407   GdkAtom target;
408   GdkAtom property;
409   guint32 time;
410   GdkNativeWindow requestor;
411 };
412
413 struct _GdkEventOwnerChange
414 {
415   GdkEventType type;
416   GdkWindow *window;
417   gint8 send_event;
418   GdkNativeWindow owner;
419   GdkOwnerChange reason;
420   GdkAtom selection;
421   guint32 time;
422   guint32 selection_time;
423 };
424
425 /* This event type will be used pretty rarely. It only is important
426    for XInput aware programs that are drawing their own cursor */
427
428 struct _GdkEventProximity
429 {
430   GdkEventType type;
431   GdkWindow *window;
432   gint8 send_event;
433   guint32 time;
434   GdkDevice *device;
435 };
436
437 struct _GdkEventClient
438 {
439   GdkEventType type;
440   GdkWindow *window;
441   gint8 send_event;
442   GdkAtom message_type;
443   gushort data_format;
444   union {
445     char b[20];
446     short s[10];
447     long l[5];
448   } data;
449 };
450
451 struct _GdkEventSetting
452 {
453   GdkEventType type;
454   GdkWindow *window;
455   gint8 send_event;
456   GdkSettingAction action;
457   char *name;
458 };
459
460 struct _GdkEventWindowState
461 {
462   GdkEventType type;
463   GdkWindow *window;
464   gint8 send_event;
465   GdkWindowState changed_mask;
466   GdkWindowState new_window_state;
467 };
468
469 struct _GdkEventGrabBroken {
470   GdkEventType type;
471   GdkWindow *window;
472   gint8 send_event;
473   gboolean keyboard;
474   gboolean implicit;
475   GdkWindow *grab_window;
476 };
477
478 /* Event types for DND */
479
480 struct _GdkEventDND {
481   GdkEventType type;
482   GdkWindow *window;
483   gint8 send_event;
484   GdkDragContext *context;
485
486   guint32 time;
487   gshort x_root, y_root;
488 };
489
490 union _GdkEvent
491 {
492   GdkEventType              type;
493   GdkEventAny               any;
494   GdkEventExpose            expose;
495   GdkEventNoExpose          no_expose;
496   GdkEventVisibility        visibility;
497   GdkEventMotion            motion;
498   GdkEventButton            button;
499   GdkEventScroll            scroll;
500   GdkEventKey               key;
501   GdkEventCrossing          crossing;
502   GdkEventFocus             focus_change;
503   GdkEventConfigure         configure;
504   GdkEventProperty          property;
505   GdkEventSelection         selection;
506   GdkEventOwnerChange       owner_change;
507   GdkEventProximity         proximity;
508   GdkEventClient            client;
509   GdkEventDND               dnd;
510   GdkEventWindowState       window_state;
511   GdkEventSetting           setting;
512   GdkEventGrabBroken        grab_broken;
513 };
514
515 GType     gdk_event_get_type            (void) G_GNUC_CONST;
516
517 gboolean  gdk_events_pending            (void);
518 GdkEvent* gdk_event_get                 (void);
519
520 GdkEvent* gdk_event_peek                (void);
521 GdkEvent* gdk_event_get_graphics_expose (GdkWindow      *window);
522 void      gdk_event_put                 (const GdkEvent *event);
523
524 GdkEvent* gdk_event_new                 (GdkEventType    type);
525 GdkEvent* gdk_event_copy                (const GdkEvent *event);
526 void      gdk_event_free                (GdkEvent       *event);
527
528 guint32   gdk_event_get_time            (const GdkEvent  *event);
529 gboolean  gdk_event_get_state           (const GdkEvent  *event,
530                                          GdkModifierType *state);
531 gboolean  gdk_event_get_coords          (const GdkEvent  *event,
532                                          gdouble         *x_win,
533                                          gdouble         *y_win);
534 gboolean  gdk_event_get_root_coords     (const GdkEvent  *event,
535                                          gdouble         *x_root,
536                                          gdouble         *y_root);
537 gboolean  gdk_event_get_axis            (const GdkEvent  *event,
538                                          GdkAxisUse       axis_use,
539                                          gdouble         *value);
540 void      gdk_event_request_motions     (const GdkEventMotion *event);
541 void      gdk_event_handler_set         (GdkEventFunc    func,
542                                          gpointer        data,
543                                          GDestroyNotify  notify);
544
545 void       gdk_event_set_screen         (GdkEvent        *event,
546                                          GdkScreen       *screen);
547 GdkScreen *gdk_event_get_screen         (const GdkEvent  *event);
548
549 void      gdk_set_show_events           (gboolean        show_events);
550 gboolean  gdk_get_show_events           (void);
551
552 #ifndef GDK_MULTIHEAD_SAFE
553 void gdk_add_client_message_filter (GdkAtom       message_type,
554                                     GdkFilterFunc func,
555                                     gpointer      data);
556
557 gboolean gdk_setting_get (const gchar *name,
558                           GValue      *value); 
559 #endif /* GDK_MULTIHEAD_SAFE */
560
561 G_END_DECLS
562
563 #endif /* __GDK_EVENTS_H__ */