summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am28
-rw-r--r--src/bindings.cc84
-rw-r--r--src/bindings.hh63
-rw-r--r--src/python.cc192
-rw-r--r--src/python.hh36
5 files changed, 103 insertions, 300 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index efb49e1f..bdf6a50a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,44 +3,26 @@ scriptdir = $(libdir)/openbox/python
DEFAULT_MENU=$(pkgdatadir)/menu
DEFAULT_STYLE=$(pkgdatadir)/styles/mbdtex
-CXXFLAGS=$(XFT_CFLAGS) $(PYTHON_CFLAGS) @CXXFLAGS@ \
+CPPFLAGS=$(XFT_CFLAGS) $(PYTHON_CFLAGS) @CPPFLAGS@ \
-DDEFAULTMENU=\"$(DEFAULT_MENU)\" \
-DDEFAULTSTYLE=\"$(DEFAULT_STYLE)\" \
-DLOCALEDIR=\"$(localedir)\" \
-DSCRIPTDIR=\"$(scriptdir)\"
-LIBS=$(XFT_LIBS) $(PYTHON_LIBS) @LIBS@
-
-INCLUDES= -I..
+LIBS=$(XFT_LIBS) $(PYTHON_LIBS) @LIBS@ $(SWIG_PYTHON_LIB)
bin_PROGRAMS= openbox3
openbox3_LDADD=-L../otk -lotk @LIBINTL@
-
+openbox3_LDFLAGS=-export-dynamic
openbox3_SOURCES= actions.cc client.cc frame.cc openbox.cc screen.cc \
main.cc backgroundwidget.cc labelwidget.cc \
- buttonwidget.cc python.cc bindings.cc \
- openbox_wrap.cc
+ buttonwidget.cc python.cc bindings.cc
noinst_HEADERS= actions.hh backgroundwidget.hh bindings.hh buttonwidget.hh \
client.hh frame.hh labelwidget.hh openbox.hh python.hh \
screen.hh widgetbase.hh
-openbox3_LDFLAGS= $(PYTHON_LDFLAGS)
-
-script_DATA = ob.py
-
-EXTRA_DIST = $(script_DATA)
MAINTAINERCLEANFILES= Makefile.in
distclean-local:
- rm -f *\~ *.orig *.rej .\#*
-
-openbox.i: openbox.hh screen.hh client.hh python.hh frame.hh
- touch $@
-
-%.py: %_wrap.cc
-
-%_wrap.cc: %.i
- swig -c -I../otk $(filter -I%,$(CXXFLAGS)) -python -shadow -c++ -nodefault -o $@ $<
-
-# local dependencies
+ $(RM) *\~ *.orig *.rej .\#*
diff --git a/src/bindings.cc b/src/bindings.cc
index cafc8501..167d0a85 100644
--- a/src/bindings.cc
+++ b/src/bindings.cc
@@ -9,7 +9,6 @@
#include "openbox.hh"
#include "client.hh"
#include "frame.hh"
-#include "python.hh"
#include "otk/display.hh"
extern "C" {
@@ -118,7 +117,7 @@ static void destroytree(KeyBindingTree *tree)
}
KeyBindingTree *Bindings::buildtree(const StringVect &keylist,
- PyObject *callback) const
+ KeyCallback callback, void *data) const
{
if (keylist.empty()) return 0; // nothing in the list.. return 0
@@ -131,7 +130,7 @@ KeyBindingTree *Bindings::buildtree(const StringVect &keylist,
if (!p) {
// this is the first built node, the bottom node of the tree
ret->chain = false;
- ret->callbacks.push_back(callback);
+ ret->callbacks.push_back(KeyCallbackData(callback, data));
}
ret->first_child = p;
if (!translate(*it, ret->binding)) {
@@ -148,7 +147,7 @@ Bindings::Bindings()
: _curpos(&_keytree),
_resetkey(0,0),
_timer((otk::Timer *) 0),
- _keybgrab_callback(0)
+ _keybgrab_callback(0, 0)
{
// setResetKey("C-g"); // set the default reset key
}
@@ -224,12 +223,13 @@ KeyBindingTree *Bindings::find(KeyBindingTree *search,
}
-bool Bindings::addKey(const StringVect &keylist, PyObject *callback)
+bool Bindings::addKey(const StringVect &keylist, KeyCallback callback,
+ void *data)
{
KeyBindingTree *tree, *t;
bool conflict;
- if (!(tree = buildtree(keylist, callback)))
+ if (!(tree = buildtree(keylist, callback, data)))
return false; // invalid binding requested
t = find(tree, &conflict);
@@ -241,7 +241,7 @@ bool Bindings::addKey(const StringVect &keylist, PyObject *callback)
if (t) {
// already bound to something
- t->callbacks.push_back(callback);
+ t->callbacks.push_back(KeyCallbackData(callback, data));
destroytree(tree);
} else {
// grab the server here to make sure no key pressed go missed
@@ -255,13 +255,11 @@ bool Bindings::addKey(const StringVect &keylist, PyObject *callback)
otk::display->ungrab();
}
- Py_INCREF(callback);
-
return true;
}
/*
-bool Bindings::removeKey(const StringVect &keylist, PyObject *callback)
+bool Bindings::removeKey(const StringVect &keylist, KeyCallback callback, void *data)
{
assert(false); // XXX: function not implemented yet
@@ -273,9 +271,9 @@ bool Bindings::removeKey(const StringVect &keylist, PyObject *callback)
KeyBindingTree *t = find(tree, &conflict);
if (t) {
- CallbackList::iterator it = std::find(t->callbacks.begin(),
- t->callbacks.end(),
- callback);
+ KeyCallbackList::iterator it = std::find(t->callbacks.begin(),
+ t->callbacks.end(),
+ callback);
if (it != t->callbacks.end()) {
// grab the server here to make sure no key pressed go missed
otk::display->grab();
@@ -320,7 +318,6 @@ static void remove_branch(KeyBindingTree *first)
remove_branch(p->first_child);
KeyBindingTree *s = p->next_sibling;
while(!p->callbacks.empty()) {
- Py_XDECREF(p->callbacks.front());
p->callbacks.pop_front();
}
delete p;
@@ -372,10 +369,10 @@ void Bindings::grabKeys(bool grab)
}
-bool Bindings::grabKeyboard(int screen, PyObject *callback)
+bool Bindings::grabKeyboard(int screen, KeyCallback callback, void *data)
{
assert(callback);
- if (_keybgrab_callback) return false; // already grabbed
+ if (_keybgrab_callback.callback) return false; // already grabbed
if (!openbox->screen(screen))
return false; // the screen is not managed
@@ -384,16 +381,17 @@ bool Bindings::grabKeyboard(int screen, PyObject *callback)
if (XGrabKeyboard(**otk::display, root, false, GrabModeAsync,
GrabModeAsync, CurrentTime))
return false;
- _keybgrab_callback = callback;
+ _keybgrab_callback.callback = callback;
+ _keybgrab_callback.data = data;
return true;
}
void Bindings::ungrabKeyboard()
{
- if (!_keybgrab_callback) return; // not grabbed
+ if (!_keybgrab_callback.callback) return; // not grabbed
- _keybgrab_callback = 0;
+ _keybgrab_callback = KeyCallbackData(0, 0);
XUngrabKeyboard(**otk::display, CurrentTime);
XUngrabPointer(**otk::display, CurrentTime);
}
@@ -420,10 +418,10 @@ void Bindings::ungrabPointer()
void Bindings::fireKey(int screen, unsigned int modifiers, unsigned int key,
Time time, KeyAction::KA action)
{
- if (_keybgrab_callback) {
+ if (_keybgrab_callback.callback) {
Client *c = openbox->focusedClient();
KeyData data(screen, c, time, modifiers, key, action);
- python_callback(_keybgrab_callback, &data);
+ _keybgrab_callback.fire(&data);
}
// KeyRelease events only occur during keyboard grabs
@@ -450,9 +448,9 @@ void Bindings::fireKey(int screen, unsigned int modifiers, unsigned int key,
} else {
Client *c = openbox->focusedClient();
KeyData data(screen, c, time, modifiers, key, action);
- CallbackList::iterator it, end = p->callbacks.end();
+ KeyCallbackList::iterator it, end = p->callbacks.end();
for (it = p->callbacks.begin(); it != end; ++it)
- python_callback(*it, &data);
+ it->fire(&data);
resetChains(this);
}
break;
@@ -478,7 +476,8 @@ void Bindings::resetChains(Bindings *self)
bool Bindings::addButton(const std::string &but, MouseContext::MC context,
- MouseAction::MA action, PyObject *callback)
+ MouseAction::MA action, MouseCallback callback,
+ void *data)
{
assert(context >= 0 && context < MouseContext::NUM_MOUSE_CONTEXT);
assert(action >= 0 && action < MouseAction::NUM_MOUSE_ACTION);
@@ -515,8 +514,7 @@ bool Bindings::addButton(const std::string &but, MouseContext::MC context,
}
} else
bind = *it;
- bind->callbacks[action].push_back(callback);
- Py_INCREF(callback);
+ bind->callbacks[action].push_back(MouseCallbackData(callback, data));
return true;
}
@@ -527,7 +525,6 @@ void Bindings::removeAllButtons()
for (it = _buttons[i].begin(); it != end; ++it) {
for (int a = 0; a < MouseAction::NUM_MOUSE_ACTION; ++a) {
while (!(*it)->callbacks[a].empty()) {
- Py_XDECREF((*it)->callbacks[a].front());
(*it)->callbacks[a].pop_front();
}
}
@@ -593,17 +590,19 @@ void Bindings::fireButton(MouseData *data)
for (it = _buttons[data->context].begin(); it != end; ++it)
if ((*it)->binding.key == data->button &&
(*it)->binding.modifiers == data->state) {
- CallbackList::iterator c_it,c_end = (*it)->callbacks[data->action].end();
+ MouseCallbackList::iterator c_it,
+ c_end = (*it)->callbacks[data->action].end();
for (c_it = (*it)->callbacks[data->action].begin();
c_it != c_end; ++c_it)
- python_callback(*c_it, data);
+ c_it->fire(data);
}
}
-bool Bindings::addEvent(EventAction::EA action, PyObject *callback)
+bool Bindings::addEvent(EventAction::EA action, EventCallback callback,
+ void *data)
{
- if (action < 0 || action >= EventAction::NUM_EVENTS) {
+ if (action < 0 || action >= EventAction::NUM_EVENT_ACTION) {
return false;
}
#ifdef XKB
@@ -611,22 +610,22 @@ bool Bindings::addEvent(EventAction::EA action, PyObject *callback)
XkbSelectEvents(**otk::display, XkbUseCoreKbd,
XkbBellNotifyMask, XkbBellNotifyMask);
#endif // XKB
- _eventlist[action].push_back(callback);
- Py_INCREF(callback);
+ _eventlist[action].push_back(EventCallbackData(callback, data));
return true;
}
-bool Bindings::removeEvent(EventAction::EA action, PyObject *callback)
+bool Bindings::removeEvent(EventAction::EA action, EventCallback callback,
+ void *data)
{
- if (action < 0 || action >= EventAction::NUM_EVENTS) {
+ if (action < 0 || action >= EventAction::NUM_EVENT_ACTION) {
return false;
}
- CallbackList::iterator it = std::find(_eventlist[action].begin(),
- _eventlist[action].end(),
- callback);
+ EventCallbackList::iterator it = std::find(_eventlist[action].begin(),
+ _eventlist[action].end(),
+ EventCallbackData(callback,
+ data));
if (it != _eventlist[action].end()) {
- Py_XDECREF(*it);
_eventlist[action].erase(it);
#ifdef XKB
if (action == EventAction::Bell && _eventlist[action].empty())
@@ -640,9 +639,8 @@ bool Bindings::removeEvent(EventAction::EA action, PyObject *callback)
void Bindings::removeAllEvents()
{
- for (int i = 0; i < EventAction::NUM_EVENTS; ++i) {
+ for (int i = 0; i < EventAction::NUM_EVENT_ACTION; ++i) {
while (!_eventlist[i].empty()) {
- Py_XDECREF(_eventlist[i].front());
_eventlist[i].pop_front();
}
}
@@ -650,9 +648,9 @@ void Bindings::removeAllEvents()
void Bindings::fireEvent(EventData *data)
{
- CallbackList::iterator c_it, c_end = _eventlist[data->action].end();
+ EventCallbackList::iterator c_it, c_end = _eventlist[data->action].end();
for (c_it = _eventlist[data->action].begin(); c_it != c_end; ++c_it)
- python_callback(*c_it, data);
+ c_it->fire(data);
}
}
diff --git a/src/bindings.hh b/src/bindings.hh
index 772b2a40..53565c38 100644
--- a/src/bindings.hh
+++ b/src/bindings.hh
@@ -10,10 +10,6 @@
#include "python.hh"
#include "otk/timer.hh"
-extern "C" {
-#include <Python.h>
-}
-
#include <string>
#include <list>
#include <vector>
@@ -22,7 +18,42 @@ namespace ob {
class Client;
-typedef std::list<PyObject *> CallbackList;
+struct MouseCallbackData {
+ MouseCallback callback;
+ void *data;
+ MouseCallbackData(MouseCallback c, void *d) : callback(c), data(d) {}
+ void fire(MouseData *d) { callback(d, data); }
+ bool operator==(const MouseCallbackData &other) { return (callback ==
+ other.callback &&
+ data ==
+ other.data); }
+};
+
+struct KeyCallbackData {
+ KeyCallback callback;
+ void *data;
+ KeyCallbackData(KeyCallback c, void *d) : callback(c), data(d) {}
+ void fire(KeyData *d) { callback(d, data); }
+ bool operator==(const KeyCallbackData &other) { return (callback ==
+ other.callback &&
+ data ==
+ other.data); }
+};
+
+struct EventCallbackData {
+ EventCallback callback;
+ void *data;
+ EventCallbackData(EventCallback c, void *d) : callback(c), data(d) {}
+ void fire(EventData *d) { callback(d, data); }
+ bool operator==(const EventCallbackData &other) { return (callback ==
+ other.callback &&
+ data ==
+ other.data); }
+};
+
+typedef std::list<MouseCallbackData> MouseCallbackList;
+typedef std::list<KeyCallbackData> KeyCallbackList;
+typedef std::list<EventCallbackData> EventCallbackList;
typedef struct Binding {
unsigned int modifiers;
@@ -37,7 +68,7 @@ typedef struct Binding {
typedef struct KeyBindingTree {
Binding binding;
- CallbackList callbacks; // the callbacks given for the binding in add()
+ KeyCallbackList callbacks; // the callbacks given for the binding in add()
bool chain; // true if this is a chain to another key (not an action)
struct KeyBindingTree *next_sibling; // the next binding in the tree at the same
@@ -51,7 +82,7 @@ typedef struct KeyBindingTree {
typedef struct ButtonBinding {
Binding binding;
- CallbackList callbacks[MouseAction::NUM_MOUSE_ACTION];
+ MouseCallbackList callbacks[MouseAction::NUM_MOUSE_ACTION];
ButtonBinding() : binding(0, 0) {}
};
@@ -71,7 +102,7 @@ private:
KeyBindingTree *find(KeyBindingTree *search, bool *conflict) const;
KeyBindingTree *buildtree(const StringVect &keylist,
- PyObject *callback) const;
+ KeyCallback callback, void *data) const;
void assimilate(KeyBindingTree *node);
static void resetChains(Bindings *self); // the timer's timeout function
@@ -82,9 +113,9 @@ private:
void grabButton(bool grab, const Binding &b, MouseContext::MC context,
Client *client);
- CallbackList _eventlist[EventAction::NUM_EVENTS];
+ EventCallbackList _eventlist[EventAction::NUM_EVENT_ACTION];
- PyObject *_keybgrab_callback;
+ KeyCallbackData _keybgrab_callback;
public:
//! Initializes an Bindings object
@@ -101,14 +132,14 @@ public:
a chain or not), or if any of the strings in the keylist are invalid.
@return true if the binding could be added; false if it could not.
*/
- bool addKey(const StringVect &keylist, PyObject *callback);
+ bool addKey(const StringVect &keylist, KeyCallback callback, void *data);
////! Removes a key binding
///*!
// @return The callbackid of the binding, or '< 0' if there was no binding to
// be removed.
//*/
- //bool removeKey(const StringVect &keylist, PyObject *callback);
+ //bool removeKey(const StringVect &keylist, KeyCallback callback, void *data);
//! Removes all key bindings
void removeAllKeys();
@@ -120,14 +151,14 @@ public:
void grabKeys(bool grab);
- bool grabKeyboard(int screen, PyObject *callback);
+ bool grabKeyboard(int screen, KeyCallback callback, void *data);
void ungrabKeyboard();
bool grabPointer(int screen);
void ungrabPointer();
bool addButton(const std::string &but, MouseContext::MC context,
- MouseAction::MA action, PyObject *callback);
+ MouseAction::MA action, MouseCallback callback, void *data);
void grabButtons(bool grab, Client *client);
@@ -137,10 +168,10 @@ public:
void fireButton(MouseData *data);
//! Bind a callback for an event
- bool addEvent(EventAction::EA action, PyObject *callback);
+ bool addEvent(EventAction::EA action, EventCallback callback, void *data);
//! Unbind the callback function from an event
- bool removeEvent(EventAction::EA action, PyObject *callback);
+ bool removeEvent(EventAction::EA action, EventCallback callback, void *data);
//! Remove all callback functions
void removeAllEvents();
diff --git a/src/python.cc b/src/python.cc
index a99416ae..10bcbdb7 100644
--- a/src/python.cc
+++ b/src/python.cc
@@ -8,12 +8,6 @@
#include "otk/display.hh"
#include "otk/util.hh"
-extern "C" {
-// The initializer in openbox_wrap.cc / otk_wrap.cc
-extern void init_ob(void);
-extern void init_otk(void);
-}
-
namespace ob {
static PyObject *obdict = NULL;
@@ -23,19 +17,17 @@ void python_init(char *argv0)
// start the python engine
Py_SetProgramName(argv0);
Py_Initialize();
- // initialize the C python module
- init_otk();
- init_ob();
// prepend the openbox directories for python scripts to the sys path
PyRun_SimpleString("import sys");
PyRun_SimpleString("sys.path.insert(0, '" SCRIPTDIR "')");
PyRun_SimpleString(const_cast<char*>(("sys.path.insert(0, '" +
otk::expandTilde("~/.openbox/python") +
"')").c_str()));
- PyRun_SimpleString("import ob; import otk; import config;");
+ //PyRun_SimpleString("import ob; import otk; import config;");
+ PyRun_SimpleString("import config;");
// set up convenience global variables
- PyRun_SimpleString("ob.openbox = ob.Openbox_instance()");
- PyRun_SimpleString("otk.display = otk.Display_instance()");
+ //PyRun_SimpleString("ob.openbox = ob.Openbox_instance()");
+ //PyRun_SimpleString("otk.display = otk.Display_instance()");
// set up access to the python global variables
PyObject *obmodule = PyImport_AddModule("config");
@@ -90,180 +82,4 @@ bool python_get_stringlist(const char *name, std::vector<otk::ustring> *value)
return true;
}
-// ************************************* //
-// Stuff for calling from Python scripts //
-// ************************************* //
-
-PyObject *mbind(const std::string &button, ob::MouseContext::MC context,
- ob::MouseAction::MA action, PyObject *func)
-{
- if (!PyCallable_Check(func)) {
- PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
- return NULL;
- }
- if(context < 0 || context >= MouseContext::NUM_MOUSE_CONTEXT) {
- PyErr_SetString(PyExc_ValueError, "Invalid MouseContext");
- return NULL;
- }
- if(action < 0 || action >= MouseAction::NUM_MOUSE_ACTION) {
- PyErr_SetString(PyExc_ValueError, "Invalid MouseAction");
- return NULL;
- }
-
- if (!ob::openbox->bindings()->addButton(button, context,
- action, func)) {
- PyErr_SetString(PyExc_RuntimeError,"Unable to add binding.");
- return NULL;
- }
- Py_INCREF(Py_None); return Py_None;
-}
-
-PyObject *ebind(ob::EventAction::EA action, PyObject *func)
-{
- if (!PyCallable_Check(func)) {
- PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
- return NULL;
- }
-
- if (!ob::openbox->bindings()->addEvent(action, func)) {
- PyErr_SetString(PyExc_RuntimeError,"Unable to add binding.");
- return NULL;
- }
- Py_INCREF(Py_None); return Py_None;
-}
-
-PyObject *kgrab(int screen, PyObject *func)
-{
- if (!PyCallable_Check(func)) {
- PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
- return NULL;
- }
-
- if (!ob::openbox->bindings()->grabKeyboard(screen, func)) {
- PyErr_SetString(PyExc_RuntimeError,"Unable to grab keybaord.");
- return NULL;
- }
- Py_INCREF(Py_None); return Py_None;
-}
-
-PyObject *kungrab()
-{
- ob::openbox->bindings()->ungrabKeyboard();
- Py_INCREF(Py_None); return Py_None;
-}
-
-PyObject *mgrab(int screen)
-{
- if (!ob::openbox->bindings()->grabPointer(screen)) {
- PyErr_SetString(PyExc_RuntimeError,"Unable to grab pointer.");
- return NULL;
- }
- Py_INCREF(Py_None); return Py_None;
-}
-
-PyObject *mungrab()
-{
- ob::openbox->bindings()->ungrabPointer();
- Py_INCREF(Py_None); return Py_None;
-}
-
-PyObject *kbind(PyObject *keylist, ob::KeyContext::KC context, PyObject *func)
-{
- if (!PyCallable_Check(func)) {
- PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
- return NULL;
- }
- if (!PyList_Check(keylist)) {
- PyErr_SetString(PyExc_TypeError, "Invalid keylist. Not a list.");
- return NULL;
- }
-
- ob::Bindings::StringVect vectkeylist;
- for (int i = 0, end = PyList_Size(keylist); i < end; ++i) {
- PyObject *str = PyList_GetItem(keylist, i);
- if (!PyString_Check(str)) {
- PyErr_SetString(PyExc_TypeError,
- "Invalid keylist. It must contain only strings.");
- return NULL;
- }
- vectkeylist.push_back(PyString_AsString(str));
- }
-
- (void)context; // XXX use this sometime!
- if (!ob::openbox->bindings()->addKey(vectkeylist, func)) {
- PyErr_SetString(PyExc_RuntimeError,"Unable to add binding.");
- return NULL;
- }
- Py_INCREF(Py_None); return Py_None;
-}
-
-/*
-PyObject *kunbind(PyObject *keylist, PyObject *func)
-{
- if (!PyList_Check(keylist)) {
- PyErr_SetString(PyExc_TypeError, "Invalid keylist. Not a list.");
- return NULL;
- }
- if (!PyCallable_Check(func)) {
- PyErr_SetString(PyExc_TypeError, "Invalid callback function.");
- return NULL;
- }
-
- ob::Bindings::StringVect vectkeylist;
- for (int i = 0, end = PyList_Size(keylist); i < end; ++i) {
- PyObject *str = PyList_GetItem(keylist, i);
- if (!PyString_Check(str)) {
- PyErr_SetString(PyExc_TypeError,
- "Invalid keylist. It must contain only strings.");
- return NULL;
- }
- vectkeylist.push_back(PyString_AsString(str));
- }
-
- if (!ob::openbox->bindings()->removeKey(vectkeylist, func)) {
- PyErr_SetString(PyExc_RuntimeError, "Could not remove callback.");
- return NULL;
- }
- Py_INCREF(Py_None); return Py_None;
-}
-*/
-
-void kunbind_all()
-{
- ob::openbox->bindings()->removeAllKeys();
-}
-
-void set_reset_key(const std::string &key)
-{
- ob::openbox->bindings()->setResetKey(key);
-}
-
-PyObject *send_client_msg(Window target, Atom type, Window about,
- long data, long data1, long data2,
- long data3, long data4)
-{
- XEvent e;
- e.xclient.type = ClientMessage;
- e.xclient.format = 32;
- e.xclient.message_type = type;
- e.xclient.window = about;
- e.xclient.data.l[0] = data;
- e.xclient.data.l[1] = data1;
- e.xclient.data.l[2] = data2;
- e.xclient.data.l[3] = data3;
- e.xclient.data.l[4] = data4;
-
- XSendEvent(**otk::display, target, false,
- SubstructureRedirectMask | SubstructureNotifyMask,
- &e);
- Py_INCREF(Py_None); return Py_None;
-}
-
-void execute(const std::string &bin, int screen)
-{
- if (screen >= ScreenCount(**otk::display))
- screen = 0;
- otk::bexec(bin, otk::display->screenInfo(screen)->displayString());
-}
-
}
diff --git a/src/python.hh b/src/python.hh
index 3fd6baa9..77a7bf5c 100644
--- a/src/python.hh
+++ b/src/python.hh
@@ -121,7 +121,7 @@ struct EventAction {
*/
UrgentWindow
#if ! (defined(DOXYGEN_IGNORE) || defined(SWIG))
- , NUM_EVENTS
+ , NUM_EVENT_ACTION
#endif
};
};
@@ -222,6 +222,11 @@ public:
}
};
+// The void*'s will be used to hold the native language's function pointer
+typedef void (*MouseCallback)(MouseData*, void*);
+typedef void (*KeyCallback)(KeyData*, void*);
+typedef void (*EventCallback)(EventData*, void*);
+
#ifndef SWIG
void python_init(char *argv0);
@@ -232,37 +237,8 @@ bool python_get_long(const char *name, long *value);
bool python_get_string(const char *name, otk::ustring *value);
bool python_get_stringlist(const char *name, std::vector<otk::ustring> *value);
-/***********************************************
- * These are found in openbox.i, not python.cc *
- ***********************************************/
-void python_callback(PyObject *func, MouseData *data);
-void python_callback(PyObject *func, EventData *data);
-void python_callback(PyObject *func, KeyData *data);
-
#endif // SWIG
-PyObject *mbind(const std::string &button, ob::MouseContext::MC context,
- ob::MouseAction::MA action, PyObject *func);
-
-PyObject *kbind(PyObject *keylist, ob::KeyContext::KC context, PyObject *func);
-
-PyObject *kgrab(int screen, PyObject *func);
-PyObject *kungrab();
-
-PyObject *mgrab(int screen);
-PyObject *mungrab();
-
-PyObject *ebind(ob::EventAction::EA action, PyObject *func);
-
-void set_reset_key(const std::string &key);
-
-PyObject *send_client_msg(Window target, Atom type, Window about,
- long data, long data1 = 0, long data2 = 0,
- long data3 = 0, long data4 = 0);
-
-
-void execute(const std::string &bin, int screen=0);
-
}