]> icculus.org git repositories - mikachu/openbox.git/blob - src/python.hh
desktops
[mikachu/openbox.git] / src / python.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef   __python_hh
3 #define   __python_hh
4
5 /*! @file python.hh
6   @brief wee
7 */
8
9 #include "otk/point.hh"
10 #include "otk/rect.hh"
11
12 extern "C" {
13 #include <X11/Xlib.h>
14 #include <Python.h>
15 }
16
17 #include <string>
18 #include <vector>
19
20 namespace ob {
21
22 enum MouseContext {
23   MC_Frame,
24   MC_Titlebar,
25   MC_Handle,
26   MC_Window,
27   MC_MaximizeButton,
28   MC_CloseButton,
29   MC_IconifyButton,
30   MC_StickyButton,
31   MC_Grip,
32   MC_Root,
33   MC_MenuItem,
34   NUM_MOUSE_CONTEXT
35 };
36
37 enum MouseAction {
38   MousePress,
39   MouseClick,
40   MouseDoubleClick,
41   MouseMotion,
42   NUM_MOUSE_ACTION
43 };
44
45 enum KeyContext {
46   KC_Menu,
47   KC_All,
48   NUM_KEY_CONTEXT
49 };
50
51 enum EventAction {
52   EventEnterWindow,
53   EventLeaveWindow,
54   EventNewWindow,
55   EventCloseWindow,
56   NUM_EVENTS
57 };
58
59 #ifndef SWIG
60
61 // *** MotionData can be (and is) cast ButtonData!! (in actions.cc) *** //
62 typedef struct {
63   PyObject_HEAD;
64   Window window;
65   Time time;
66   unsigned int state;
67   unsigned int button;
68   MouseContext context;
69   MouseAction action;
70   int xroot;
71   int yroot;
72   int pressx;
73   int pressy;
74   int press_clientx;
75   int press_clienty;
76   int press_clientwidth;
77   int press_clientheight;
78 } MotionData;
79
80 // *** MotionData can be (and is) cast ButtonData!! (in actions.cc) *** //
81 typedef struct {
82   PyObject_HEAD;
83   Window window;
84   Time time;
85   unsigned int state;
86   unsigned int button;
87   MouseContext context;
88   MouseAction action;
89 } ButtonData;
90
91 typedef struct {
92   PyObject_HEAD;
93   Window window;
94   unsigned int state;
95   EventAction action;
96 } EventData;
97
98 typedef struct {
99   PyObject_HEAD;
100   Window window;
101   Time time;
102   unsigned int state;
103   unsigned int key;
104 } KeyData;
105
106 void python_init(char *argv0);
107 void python_destroy();
108 bool python_exec(const std::string &path);
109                  
110 MotionData *new_motion_data(Window window, Time time, unsigned int state,
111                             unsigned int button, MouseContext context,
112                             MouseAction action, int xroot, int yroot,
113                             const otk::Point &initpos,
114                             const otk::Rect &initarea);
115 ButtonData *new_button_data(Window window, Time time, unsigned int state,
116                             unsigned int button, MouseContext context,
117                             MouseAction action);
118 EventData *new_event_data(Window window, EventAction action,
119                            unsigned int state);
120 KeyData *new_key_data(Window window, Time time, unsigned int state,
121                       unsigned int key);
122
123 void python_callback(PyObject *func, PyObject *data);
124
125 bool python_get_long(const char *name, long *value);
126 bool python_get_string(const char *name, std::string *value);
127 bool python_get_stringlist(const char *name, std::vector<std::string> *value);
128 #endif
129
130 PyObject *mbind(const std::string &button, ob::MouseContext context,
131                 ob::MouseAction action, PyObject *func);
132
133 PyObject *kbind(PyObject *keylist, ob::KeyContext context, PyObject *func);
134
135 PyObject *ebind(ob::EventAction action, PyObject *func);
136
137 void set_reset_key(const std::string &key);
138
139 }
140
141 #endif // __python_hh