merge the C branch into HEAD
[mikachu/openbox.git] / c / eventdata.h
1 #ifndef __eventdata_h
2 #define __eventdata_h
3
4 #include "obexport.h"
5 #include <Python.h>
6 #include <glib.h>
7
8 struct Client;
9
10 typedef struct {
11     int temp:1; /* just a placeholder to kill warnings for now.. */
12 } LogicalEvent;
13
14 typedef struct {
15     /*! The button which generated the event */
16     guint button;
17     /*! The pointer's x position on the root window when the event occured */
18     int xroot;
19     /*! The pointer's y position on the root window when the event occured */
20     int yroot;
21     /*! The modifiers that were pressed when the event occured. A bitmask of:
22       ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, 
23       Mod4Mask, Mod5Mask */
24     guint modifiers;
25     /*! The name of the button/modifier combination being pressed,
26       eg "Mod1-1" */
27     char *name;
28 } PointerEvent;
29
30 typedef struct {
31     /*! The keycode of the key which generated the event */
32     guint keycode;
33     /*! The modifiers that were pressed when the event occured. A bitmask of:
34       ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, 
35       Mod4Mask, Mod5Mask */
36     guint modifiers;
37     /* The list of strings which make up the chain that fired,
38        eg ("Mod1-a", "a") */
39     GList *keylist;
40 } KeyEvent;
41
42 /* EventData is a PyObject */
43 typedef struct EventData {
44     PyObject_HEAD
45     /* The type of event which occured */
46     EventType type;
47     /*! The context in which the event occured, the type of window it occured
48       for. */
49     const char *context;
50     /* The Client on which the event occured, or NULL */
51     struct Client *client;
52
53     union EventDetails {
54         LogicalEvent *logical;
55         PointerEvent *pointer;
56         KeyEvent *key;
57     } details;
58 } EventData;
59
60 void eventdata_startup();
61 void eventdata_shutdown();
62
63 EventData *eventdata_new_logical(EventType type, GQuark context,
64                                  struct Client *client);
65 EventData *eventdata_new_pointer(EventType type, GQuark context,
66                                  struct Client *client, guint modifiers,
67                                  guint button, char *name,
68                                  int xroot, int yroot);
69 EventData *eventdata_new_key(EventType type, GQuark context,
70                              struct Client *client, guint modifiers,
71                              guint keycode, GList *keylist);
72 void eventdata_free(EventData *data);
73
74 #endif