]> icculus.org git repositories - mikachu/openbox.git/blob - src/python.hh
moving a window is possible once again
[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 #ifndef SWIG
52
53 // *** MotionData can be (and is) cast ButtonData!! (in actions.cc) *** //
54 typedef struct {
55   PyObject_HEAD;
56   Window window;
57   Time time;
58   unsigned int state;
59   unsigned int button;
60   MouseContext context;
61   MouseAction action;
62   int xroot;
63   int yroot;
64   int pressx;
65   int pressy;
66   int press_clientx;
67   int press_clienty;
68   int press_clientwidth;
69   int press_clientheight;
70 } MotionData;
71
72 // *** MotionData can be (and is) cast ButtonData!! (in actions.cc) *** //
73 typedef struct {
74   PyObject_HEAD;
75   Window window;
76   Time time;
77   unsigned int state;
78   unsigned int button;
79   MouseContext context;
80   MouseAction action;
81 } ButtonData;
82
83 typedef struct {
84   PyObject_HEAD;
85   Window window;
86   Time time;
87   unsigned int state;
88   unsigned int key;
89 } KeyData;
90
91 void python_init(char *argv0);
92 void python_destroy();
93 bool python_exec(const std::string &path);
94                  
95 MotionData *new_motion_data(Window window, Time time, unsigned int state,
96                             unsigned int button, MouseContext context,
97                             MouseAction action, int xroot, int yroot,
98                             const otk::Point &initpos,
99                             const otk::Rect &initarea);
100 ButtonData *new_button_data(Window window, Time time, unsigned int state,
101                             unsigned int button, MouseContext context,
102                             MouseAction action);
103 KeyData *new_key_data(Window window, Time time, unsigned int state,
104                       unsigned int key);
105
106 void python_callback(PyObject *func, PyObject *data);
107
108 bool python_get_string(const char *name, std::string *value);
109 bool python_get_stringlist(const char *name, std::vector<std::string> *value);
110 #endif
111
112 PyObject * mbind(const std::string &button, ob::MouseContext context,
113                  ob::MouseAction action, PyObject *func);
114
115 PyObject * kbind(PyObject *keylist, ob::KeyContext context, PyObject *func);
116 PyObject * kunbind(PyObject *keylist);
117 void kunbind_all();
118 void set_reset_key(const std::string &key);
119
120 }
121
122 #endif // __python_hh