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