]> Dogcows Code - chaz/openbox/blob - src/python.hh
new python interface! using the .py shadow wrappers from swig
[chaz/openbox] / 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 #include "otk/property.hh"
12 #include "otk/display.hh"
13
14 extern "C" {
15 #include <X11/Xlib.h>
16 #include <Python.h>
17 }
18
19 #include <string>
20 #include <vector>
21
22 namespace ob {
23
24 class OBClient;
25
26 enum MouseContext {
27 MC_Frame,
28 MC_Titlebar,
29 MC_Handle,
30 MC_Window,
31 MC_MaximizeButton,
32 MC_CloseButton,
33 MC_IconifyButton,
34 MC_StickyButton,
35 MC_Grip,
36 MC_Root,
37 MC_MenuItem,
38 NUM_MOUSE_CONTEXT
39 };
40
41 enum MouseAction {
42 MousePress,
43 MouseClick,
44 MouseDoubleClick,
45 MouseMotion,
46 NUM_MOUSE_ACTION
47 };
48
49 enum KeyContext {
50 KC_Menu,
51 KC_All,
52 NUM_KEY_CONTEXT
53 };
54
55 enum EventAction {
56 EventEnterWindow,
57 EventLeaveWindow,
58 EventPlaceWindow,
59 EventNewWindow,
60 EventCloseWindow,
61 EventStartup,
62 EventShutdown,
63 EventFocus,
64 EventBell,
65 NUM_EVENTS
66 };
67
68 class MouseData {
69 public:
70 int screen;
71 OBClient *client;
72 Time time;
73 unsigned int state;
74 unsigned int button;
75 MouseContext context;
76 MouseAction action;
77 int xroot;
78 int yroot;
79 int pressx;
80 int pressy;
81 int press_clientx;
82 int press_clienty;
83 int press_clientwidth;
84 int press_clientheight;
85
86 MouseData(int screen, OBClient *client, Time time, unsigned int state,
87 unsigned int button, MouseContext context, MouseAction action,
88 int xroot, int yroot, const otk::Point &initpos,
89 const otk::Rect &initarea) {
90 this->screen = screen;
91 this->client = client;
92 this->time = time;
93 this->state = state;
94 this->button = button;
95 this->context= context;
96 this->action = action;
97 this->xroot = xroot;
98 this->yroot = yroot;
99 this->pressx = initpos.x();
100 this->pressy = initpos.y();
101 this->press_clientx = initarea.x();
102 this->press_clienty = initarea.y();
103 this->press_clientwidth = initarea.width();
104 this->press_clientheight = initarea.height();
105 }
106 MouseData(int screen, OBClient *client, Time time, unsigned int state,
107 unsigned int button, MouseContext context, MouseAction action) {
108 this->screen = screen;
109 this->client = client;
110 this->time = time;
111 this->state = state;
112 this->button = button;
113 this->context= context;
114 this->action = action;
115 this->xroot = xroot;
116 this->yroot = yroot;
117 this->pressx = 0;
118 this->pressy = 0;
119 this->press_clientx = 0;
120 this->press_clienty = 0;
121 this->press_clientwidth = 0;
122 this->press_clientheight = 0;
123 }
124 };
125
126 class EventData {
127 public:
128 int screen;
129 OBClient *client;
130 unsigned int state;
131 EventAction action;
132
133 EventData(int screen, OBClient *client, EventAction action,
134 unsigned int state) {
135 this->screen = screen;
136 this->client = client;
137 this->action = action;
138 this->state = state;
139 }
140 };
141
142 class KeyData {
143 public:
144 int screen;
145 OBClient *client;
146 Time time;
147 unsigned int state;
148 std::string key;
149
150 KeyData(int screen, OBClient *client, Time time, unsigned int state,
151 unsigned int key) {
152 this->screen = screen;
153 this->client = client;
154 this->time = time;
155 this->state = state;
156 this->key = XKeysymToString(XKeycodeToKeysym(otk::OBDisplay::display,
157 key, 0));
158 }
159 };
160
161 #ifndef SWIG
162
163 void python_init(char *argv0);
164 void python_destroy();
165 bool python_exec(const std::string &path);
166
167 bool python_get_long(const char *name, long *value);
168 bool python_get_string(const char *name, std::string *value);
169 bool python_get_stringlist(const char *name, std::vector<std::string> *value);
170
171 /***********************************************
172 * These are found in openbox.i, not python.cc *
173 ***********************************************/
174 void python_callback(PyObject *func, MouseData *data);
175 void python_callback(PyObject *func, EventData *data);
176 void python_callback(PyObject *func, KeyData *data);
177
178 #endif // SWIG
179
180 PyObject *mbind(const std::string &button, ob::MouseContext context,
181 ob::MouseAction action, PyObject *func);
182
183 PyObject *kbind(PyObject *keylist, ob::KeyContext context, PyObject *func);
184
185 PyObject *ebind(ob::EventAction action, PyObject *func);
186
187 void set_reset_key(const std::string &key);
188
189 PyObject *send_client_msg(Window target, int type, Window about,
190 long data, long data1 = 0, long data2 = 0,
191 long data3 = 0, long data4 = 0);
192 }
193
194
195 #endif // __python_hh
This page took 0.045399 seconds and 5 git commands to generate.