added "pixel32" typedef for 32bit rgb data
[openbox.git] / src / python.hh
blobde9afdfb626bea56179b0168f63f8a33f36e6fc8
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __python_hh
3 #define __python_hh
5 /*! @file python.hh
6 @brief wee
7 */
9 #include "otk/point.hh"
10 #include "otk/rect.hh"
11 #include "otk/property.hh"
12 #include "otk/display.hh"
13 #include "otk/ustring.hh"
15 extern "C" {
16 #include <X11/Xlib.h>
17 #include <Python.h>
20 #include <string>
21 #include <vector>
23 namespace ob {
25 class Client;
27 enum MouseContext {
28 MC_Frame,
29 MC_Titlebar,
30 MC_Handle,
31 MC_Window,
32 MC_MaximizeButton,
33 MC_CloseButton,
34 MC_IconifyButton,
35 MC_StickyButton,
36 MC_Grip,
37 MC_Root,
38 MC_MenuItem,
39 NUM_MOUSE_CONTEXT
42 enum MouseAction {
43 MousePress,
44 MouseClick,
45 MouseDoubleClick,
46 MouseMotion,
47 NUM_MOUSE_ACTION
50 enum KeyContext {
51 KC_Menu,
52 KC_All,
53 NUM_KEY_CONTEXT
56 enum EventAction {
57 EventEnterWindow,
58 EventLeaveWindow,
59 EventPlaceWindow,
60 EventNewWindow,
61 EventCloseWindow,
62 EventStartup,
63 EventShutdown,
64 EventFocus,
65 EventBell,
66 NUM_EVENTS
69 class MouseData {
70 public:
71 int screen;
72 Client *client;
73 Time time;
74 unsigned int state;
75 unsigned int button;
76 MouseContext context;
77 MouseAction action;
78 int xroot;
79 int yroot;
80 int pressx;
81 int pressy;
82 int press_clientx;
83 int press_clienty;
84 int press_clientwidth;
85 int press_clientheight;
87 MouseData(int screen, Client *client, Time time, unsigned int state,
88 unsigned int button, MouseContext context, MouseAction action,
89 int xroot, int yroot, const otk::Point &initpos,
90 const otk::Rect &initarea) {
91 this->screen = screen;
92 this->client = client;
93 this->time = time;
94 this->state = state;
95 this->button = button;
96 this->context= context;
97 this->action = action;
98 this->xroot = xroot;
99 this->yroot = yroot;
100 this->pressx = initpos.x();
101 this->pressy = initpos.y();
102 this->press_clientx = initarea.x();
103 this->press_clienty = initarea.y();
104 this->press_clientwidth = initarea.width();
105 this->press_clientheight = initarea.height();
107 MouseData(int screen, Client *client, Time time, unsigned int state,
108 unsigned int button, MouseContext context, MouseAction action) {
109 this->screen = screen;
110 this->client = client;
111 this->time = time;
112 this->state = state;
113 this->button = button;
114 this->context= context;
115 this->action = action;
116 this->xroot = xroot;
117 this->yroot = yroot;
118 this->pressx = 0;
119 this->pressy = 0;
120 this->press_clientx = 0;
121 this->press_clienty = 0;
122 this->press_clientwidth = 0;
123 this->press_clientheight = 0;
127 class EventData {
128 public:
129 int screen;
130 Client *client;
131 unsigned int state;
132 EventAction action;
134 EventData(int screen, Client *client, EventAction action,
135 unsigned int state) {
136 this->screen = screen;
137 this->client = client;
138 this->action = action;
139 this->state = state;
143 class KeyData {
144 public:
145 int screen;
146 Client *client;
147 Time time;
148 unsigned int state;
149 std::string key;
151 KeyData(int screen, Client *client, Time time, unsigned int state,
152 unsigned int key) {
153 this->screen = screen;
154 this->client = client;
155 this->time = time;
156 this->state = state;
157 this->key = XKeysymToString(XKeycodeToKeysym(**otk::display,
158 key, 0));
162 #ifndef SWIG
164 void python_init(char *argv0);
165 void python_destroy();
166 bool python_exec(const std::string &path);
168 bool python_get_long(const char *name, long *value);
169 bool python_get_string(const char *name, otk::ustring *value);
170 bool python_get_stringlist(const char *name, std::vector<otk::ustring> *value);
172 /***********************************************
173 * These are found in openbox.i, not python.cc *
174 ***********************************************/
175 void python_callback(PyObject *func, MouseData *data);
176 void python_callback(PyObject *func, EventData *data);
177 void python_callback(PyObject *func, KeyData *data);
179 #endif // SWIG
181 PyObject *mbind(const std::string &button, ob::MouseContext context,
182 ob::MouseAction action, PyObject *func);
184 PyObject *kbind(PyObject *keylist, ob::KeyContext context, PyObject *func);
186 PyObject *ebind(ob::EventAction action, PyObject *func);
188 void set_reset_key(const std::string &key);
190 PyObject *send_client_msg(Window target, Atom type, Window about,
191 long data, long data1 = 0, long data2 = 0,
192 long data3 = 0, long data4 = 0);
196 #endif // __python_hh