split the ob module into separate .i's

cleanly define the interface, add functions for modifying the objects (via client messages)
This commit is contained in:
Dana Jansens 2003-02-17 15:42:31 +00:00
parent 0dd7ebcba9
commit c217a73090
8 changed files with 357 additions and 62 deletions

View file

@ -44,6 +44,6 @@ ob.i: $(addprefix ../src/,openbox.hh screen.hh client.hh python.hh frame.hh)
wrap_otk.cc: otk.i
$(SWIG) $(SWIG_PYTHON_OPT) $(filter -I%,$(CPPFLAGS)) -nodefault -o $@ $<
wrap_ob.cc: ob.i callback.i
wrap_ob.cc: ob.i callback.i ob_client.i ob_screen.i ob_openbox.i ob_frame.i ob_python.i
$(SWIG) $(SWIG_PYTHON_OPT) $(filter -I%,$(CPPFLAGS)) -nodefault -o $@ $<

View file

@ -1,5 +1,7 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
%include "std_string.i"
%{
/*
Calls a python callback for the MouseCallback function type
@ -100,6 +102,8 @@ static void PythonEventCallback(ob::EventData *data, void *pyfunc)
}
%inline %{
#include "bindings.hh"
bool mbind(const std::string &button, ob::MouseContext::MC context,
ob::MouseAction::MA action, PyObject *func)
{

View file

@ -3,67 +3,8 @@
%module ob
%{
#include "config.h"
#include "frame.hh"
#include "openbox.hh"
#include "screen.hh"
#include "client.hh"
#include "bindings.hh"
#include "actions.hh"
#include "python.hh"
#include "otk/otk.hh"
%}
%include "stl.i"
%include "callback.i"
%immutable ob::openbox;
/*
%ignore ob::openbox;
%inline %{
ob::Openbox *Openbox_instance() { return ob::openbox; }
%};
*/
%typemap(python,out) std::list<ob::Client*> {
unsigned int s = $1.size();
PyObject *l = PyList_New(s);
std::list<ob::Client*>::const_iterator it = $1.begin(), end = $1.end();
for (unsigned int i = 0; i < s; ++i, ++it) {
PyObject *pdata = SWIG_NewPointerObj((void *) *it,
SWIGTYPE_p_ob__Client, 0);
PyList_SET_ITEM(l, i, pdata);
}
$result = l;
}
// do this through events
%ignore ob::Screen::showDesktop(bool);
%ignore ob::Screen::managed;
%ignore ob::Screen::config;
%import "otk.i"
%import "actions.hh"
%include "openbox.hh"
%include "screen.hh"
%include "client.hh"
%include "frame.hh"
%include "python.hh"
// for Window etc
%import "X11/X.h"
%inline %{
void set_reset_key(const std::string &key)
{
ob::openbox->bindings()->setResetKey(key);
}
#include <X11/Xlib.h>
#include "otk/display.hh"
void send_client_msg(Window target, Atom type, Window about,
long data=0, long data1=0, long data2=0,
long data3=0, long data4=0)
@ -84,6 +25,27 @@ void send_client_msg(Window target, Atom type, Window about,
&e);
}
%}
%include "ob_openbox.i"
%include "ob_screen.i"
%include "ob_client.i"
%include "ob_frame.i"
%include "ob_python.i"
%include "callback.i"
%import "otk.i"
// for Window etc
%import "X11/X.h"
%inline %{
#include <string>
void set_reset_key(const std::string &key)
{
ob::openbox->bindings()->setResetKey(key);
}
void execute(const std::string &bin, int screen=0)
{
if (screen >= ScreenCount(**otk::display))

158
wrap/ob_client.i Normal file
View file

@ -0,0 +1,158 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
%module ob_client
%{
#include "config.h"
#include "client.hh"
%}
%include "otk.i" // XXX otk_size.i!!!
%include "ustring.i"
%include "std_string.i"
namespace ob {
%immutable Client::frame;
%ignore Client::event_mask;
%ignore Client::no_propagate_mask;
%ignore Client::ignore_unmaps;
%ignore Client::Client(int, Window);
%ignore Client::~Client();
%ignore Client::icon(const otk::Size &) const;
%ignore Client::pixmapIcon() const;
%ignore Client::pixmapIconMask() const;
%ignore Client::showhide();
%ignore Client::focus();
%ignore Client::unfocus() const;
%ignore Client::validate() const;
%ignore Client::installColormap(bool) const;
%ignore Client::focusHandler(const XFocusChangeEvent &);
%ignore Client::unfocusHandler(const XFocusChangeEvent &);
%ignore Client::propertyHandler(const XPropertyEvent &);
%ignore Client::clientMessageHandler(const XClientMessageEvent &);
%ignore Client::configureRequestHandler(const XConfigureRequestEvent &);
%ignore Client::unmapHandler(const XUnmapEvent &);
%ignore Client::destroyHandler(const XDestroyWindowEvent &);
%ignore Client::reparentHandler(const XReparentEvent &);
%ignore Client::mapRequestHandler(const XMapRequestEvent &);
%ignore Client::shapeHandler(const XShapeEvent &);
%extend Client {
void focus(bool unshade = false, bool raise = false) {
Window root = otk::display->screenInfo(self->screen())->rootWindow();
send_client_msg(root, otk::Property::atoms.openbox_active_window,
self->window(), unshade ? 1 : 0, raise ? 1 : 0);
}
bool __cmp__(const Client *o) { return self->window() != o->window(); }
void raiseWindow() {
Window root = RootWindow(**otk::display, self->screen());
send_client_msg(root, otk::Property::atoms.openbox_restack_window,
self->window(), 0);
}
void lowerWindow() {
Window root = RootWindow(**otk::display, self->screen());
send_client_msg(root, otk::Property::atoms.openbox_restack_window,
self->window(), 1);
}
void setDesktop(unsigned int desktop) {
Window root = RootWindow(**otk::display, self->screen());
send_client_msg(root, otk::Property::atoms.net_wm_desktop,
self->window(), desktop);
}
void iconify(bool icon = true) {
Window root = RootWindow(**otk::display, self->screen());
send_client_msg(root, otk::Property::atoms.wm_change_state,
self->window(), icon ? IconicState : NormalState);
}
void close() {
Window root = RootWindow(**otk::display, self->screen());
send_client_msg(root, otk::Property::atoms.net_close_window,
self->window(), 0);
}
void shade(bool shade = true) {
Window root = RootWindow(**otk::display, self->screen());
send_client_msg(root, otk::Property::atoms.net_wm_state,
self->window(),
(shade ? otk::Property::atoms.net_wm_state_add :
otk::Property::atoms.net_wm_state_remove),
otk::Property::atoms.net_wm_state_shaded);
}
void maximize(bool max = true) {
Window root = RootWindow(**otk::display, self->screen());
send_client_msg(root, otk::Property::atoms.net_wm_state,
self->window(),
(max ? otk::Property::atoms.net_wm_state_add :
otk::Property::atoms.net_wm_state_remove),
otk::Property::atoms.net_wm_state_maximized_horz,
otk::Property::atoms.net_wm_state_maximized_vert);
}
void maximizeHorizontal(bool max = true) {
Window root = RootWindow(**otk::display, self->screen());
send_client_msg(root, otk::Property::atoms.net_wm_state,
self->window(),
(max ? otk::Property::atoms.net_wm_state_add :
otk::Property::atoms.net_wm_state_remove),
otk::Property::atoms.net_wm_state_maximized_horz);
}
void maximizeVertical(bool max = true) {
Window root = RootWindow(**otk::display, self->screen());
send_client_msg(root, otk::Property::atoms.net_wm_state,
self->window(),
(max ? otk::Property::atoms.net_wm_state_add :
otk::Property::atoms.net_wm_state_remove),
otk::Property::atoms.net_wm_state_maximized_vert);
}
void setSkipTaskbar(bool skip = true) {
Window root = RootWindow(**otk::display, self->screen());
send_client_msg(root, otk::Property::atoms.net_wm_state,
self->window(),
(skip ? otk::Property::atoms.net_wm_state_add :
otk::Property::atoms.net_wm_state_remove),
otk::Property::atoms.net_wm_state_skip_taskbar);
}
void setSkipPager(bool skip = true) {
Window root = RootWindow(**otk::display, self->screen());
send_client_msg(root, otk::Property::atoms.net_wm_state,
self->window(),
(skip ? otk::Property::atoms.net_wm_state_add :
otk::Property::atoms.net_wm_state_remove),
otk::Property::atoms.net_wm_state_skip_pager);
}
void setAbove(bool above = true) {
Window root = RootWindow(**otk::display, self->screen());
send_client_msg(root, otk::Property::atoms.net_wm_state,
self->window(),
(above ? otk::Property::atoms.net_wm_state_add :
otk::Property::atoms.net_wm_state_remove),
otk::Property::atoms.net_wm_state_above);
}
void setBelow(bool below = true) {
Window root = RootWindow(**otk::display, self->screen());
send_client_msg(root, otk::Property::atoms.net_wm_state,
self->window(),
(below ? otk::Property::atoms.net_wm_state_add :
otk::Property::atoms.net_wm_state_remove),
otk::Property::atoms.net_wm_state_below);
}
};
}
%import "../otk/eventhandler.hh"
%include "client.hh"

39
wrap/ob_frame.i Normal file
View file

@ -0,0 +1,39 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
%module ob_frame
%{
#include "config.h"
#include "frame.hh"
%}
namespace ob {
%ignore FrameGeometry;
%ignore Frame::event_mask;
%ignore Frame::Frame(Client*);
%ignore Frame::~Frame();
%ignore Frame::styleChanged(const otk::RenderStyle &);
%ignore Frame::grabClient();
%ignore Frame::releaseClient();
%ignore Frame::adjustSize();
%ignore Frame::adjustPosition();
%ignore Frame::adjustShape();
%ignore Frame::adjustState();
%ignore Frame::adjustFocus();
%ignore Frame::adjustTitle();
%ignore Frame::adjustIcon();
%ignore Frame::visible();
%ignore Frame::show();
%ignore Frame::hide();
%ignore Frame::buttonPressHandler(const XButtonEvent &);
%ignore Frame::buttonReleaseHandler(const XButtonEvent &);
%ignore Frame::mouseContext(Window) const;
%ignore Frame::allWindows() const;
}
%import "../otk/renderstyle.hh"
%import "../otk/eventhandler.hh"
%include "frame.hh"

34
wrap/ob_openbox.i Normal file
View file

@ -0,0 +1,34 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
%module ob_openbox
%{
#include "config.h"
#include "openbox.hh"
%}
%include "ob_screen.i"
%include "ob_client.i"
%include "std_string.i"
namespace ob {
%ignore Cursors;
%immutable openbox;
%ignore Openbox::Openbox(int, char **);
%ignore Openbox::~Openbox();
%ignore Openbox::actions() const;
%ignore Openbox::bindings() const;
%ignore Openbox::cursors() const;
%ignore Openbox::eventLoop();
%ignore Openbox::addClient(Window, Client*);
%ignore Openbox::removeClient(Window);
%ignore Openbox::setFocusedClient(Client*);
%ignore Openbox::doRestart() const;
%ignore Openbox::restartProgram() const;
}
%include "openbox.hh"

18
wrap/ob_python.i Normal file
View file

@ -0,0 +1,18 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
%module ob_python
%{
#include "config.h"
#include "python.hh"
%}
namespace ob {
%ignore python_init(char*);
%ignore python_destroy();
%ignore python_exec(const std::string &);
}
%include "python.hh"

80
wrap/ob_screen.i Normal file
View file

@ -0,0 +1,80 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
%module ob_screen
%{
#include "config.h"
#include "screen.hh"
#include "otk/display.hh"
#include "otk/property.hh"
%}
%include "ob_client.i"
%include "otk.i" // XXX otk_rect.i!!!
%include "ustring.i"
%typemap(python,out) std::list<ob::Client*> {
unsigned int s = $1.size();
PyObject *l = PyList_New(s);
std::list<ob::Client*>::const_iterator it = $1.begin(), end = $1.end();
for (unsigned int i = 0; i < s; ++i, ++it) {
PyObject *pdata = SWIG_NewPointerObj((void*)*it,SWIGTYPE_p_ob__Client,0);
PyList_SET_ITEM(l, i, pdata);
}
$result = l;
}
%typemap(python,out) const otk::Property::StringVect& {
otk::Property::StringVect *v = $1;
unsigned int s = v->size();
PyObject *l = PyList_New(s);
otk::Property::StringVect::const_iterator it = v->begin(), end = v->end();
for (unsigned int i = 0; i < s; ++i, ++it) {
PyObject *pdata = PyString_FromString(it->c_str());
PyList_SET_ITEM(l, i, pdata);
}
$result = l;
}
namespace ob {
%extend Screen {
void showDesktop(bool show) {
Window root = RootWindow(**otk::display, self->number());
send_client_msg(root, otk::Property::atoms.net_showing_desktop,
root, show);
}
void changeDesktop(unsigned int desktop) {
Window root = RootWindow(**otk::display, self->number());
send_client_msg(root, otk::Property::atoms.net_current_desktop,
root, desktop);
}
}
%immutable Screen::clients;
%ignore Screen::event_mask;
%ignore Screen::Screen(int);
%ignore Screen::~Screen();
%ignore Screen::focuswindow() const;
%ignore Screen::managed() const;
%ignore Screen::config();
%rename(ignored_showDesktop) Screen::showDesktop(bool show);
%ignore Screen::ignored_showDesktop(bool show);
%ignore Screen::updateStruts();
%ignore Screen::manageExisting();
%ignore Screen::manageWindow(Window);
%ignore Screen::unmanageWindow(Client*);
%ignore Screen::raiseWindow(Client*);
%ignore Screen::lowerWindow(Client*);
%ignore Screen::installColormap(bool) const;
%ignore Screen::propertyHandler(const XPropertyEvent &);
%ignore Screen::clientMessageHandler(const XClientMessageEvent &);
%ignore Screen::mapRequestHandler(const XMapRequestEvent &);
}
%include "screen.hh"