using python and swig for now.

This commit is contained in:
Dana Jansens 2002-12-23 00:04:32 +00:00
parent 3cf5a8b6dd
commit 5f78b51429
8 changed files with 118 additions and 40 deletions

View file

@ -80,12 +80,18 @@ AC_CHECK_HEADER([python2.2/Python.h],
See http://www.python.org
]))
AC_CHECK_LIB([python2.2], [Py_Initialize],
PYTHON_LDFLAGS="-lpython2.2 -Xlinker -export-dynamic",
PYTHON_LDFLAGS="-lpython2.2",
dnl -Xlinker -export-dynamic",
AC_MSG_ERROR([Openbox requires the use of Python 2.2. This is its secret special formula for extreme sexiness.
See http://www.python.org
]))
PYTHON_CFLAGS="-I/usr/include/python2.2 -I/usr/gwar/include/python2.2"
AC_SUBST([PYTHON_CFLAGS])
AC_SUBST([PYTHON_LDFLAGS])
dnl Check for guile
GUILE_FLAGS
dnl Check for X headers and libraries
AC_PATH_X
AC_PATH_XTRA

View file

@ -2,12 +2,12 @@ localedir=$(datadir)/locale
DEFAULT_MENU=$(pkgdatadir)/menu
DEFAULT_STYLE=$(pkgdatadir)/styles/mbdtex
CPPFLAGS=$(XFT_CFLAGS) @CPPFLAGS@ \
CPPFLAGS=$(XFT_CFLAGS) $(GUILE_CFLAGS) $(PYTHON_CFLAGS) @CPPFLAGS@ \
-DDEFAULTMENU=\"$(DEFAULT_MENU)\" \
-DDEFAULTSTYLE=\"$(DEFAULT_STYLE)\" \
-DLOCALEDIR=\"$(localedir)\"
LIBS=$(XFT_LIBS) $(PYTHON_LDFLAGS) @LIBS@
LIBS=$(XFT_LIBS) $(GUILE_LDFLAGS) $(PYTHON_LDFLAGS) @LIBS@
INCLUDES= -I../otk
@ -17,11 +17,19 @@ openbox3_LDADD=../otk/libotk.a @LIBINTL@
openbox3_SOURCES= actions.cc client.cc frame.cc openbox.cc screen.cc \
main.cc rootwindow.cc backgroundwidget.cc labelwidget.cc \
buttonwidget.cc python.cc
buttonwidget.cc openbox_wrap.cc
# guile.cc
MAINTAINERCLEANFILES= Makefile.in
distclean-local:
rm -f *\~ *.orig *.rej .\#*
openbox.i: openbox.hh screen.hh client.hh
touch openbox.i
openbox_wrap.cc: openbox.i
swig -python -c++ -nodefault -module openbox -o openbox_wrap.cc openbox.i
# swig -guile -c++ -nodefault -o openbox_wrap.cc openbox.i
# local dependencies

View file

@ -27,6 +27,20 @@ namespace ob {
class OBFrame;
//! The MWM Hints as retrieved from the window property
/*!
This structure only contains 3 elements, even though the Motif 2.0
structure contains 5. We only use the first 3, so that is all gets defined.
*/
struct MwmHints {
//! The number of elements in the OBClient::MwmHints struct
static const unsigned int elements = 3;
unsigned long flags; //!< A bitmask of OBClient::MwmFlags values
unsigned long functions; //!< A bitmask of OBClient::MwmFunctions values
unsigned long decorations;//!< A bitmask of OBClient::MwmDecorations values
};
//! Maintains the state of a client window.
/*!
OBClient maintains the state of a client window. The state consists of the
@ -111,19 +125,6 @@ public:
//! Holds a bitmask of OBClient::Decoration values
typedef unsigned char DecorationFlags;
//! The MWM Hints as retrieved from the window property
/*!
This structure only contains 3 elements, even though the Motif 2.0
structure contains 5. We only use the first 3, so that is all gets defined.
*/
typedef struct MwmHints {
//! The number of elements in the OBClient::MwmHints struct
static const unsigned int elements = 3;
unsigned long flags; //!< A bitmask of OBClient::MwmFlags values
unsigned long functions; //!< A bitmask of OBClient::MwmFunctions values
unsigned long decorations;//!< A bitmask of OBClient::MwmDecorations values
};
//! Possible actions that can be made with the _NET_WM_STATE client message
enum StateAction { State_Remove = 0, //!< _NET_WM_STATE_REMOVE
State_Add, //!< _NET_WM_STATE_ADD
@ -306,6 +307,7 @@ private:
// XXX: updateTransientFor();
public:
#ifndef SWIG
//! Constructs a new OBClient object around a specified window id
/*!
@param window The window id that the OBClient class should handle
@ -314,6 +316,7 @@ public:
OBClient(int screen, Window window);
//! Destroys the OBClient object
virtual ~OBClient();
#endif
//! Returns the screen on which the clien resides
inline int screen() const { return _screen; }

View file

@ -13,6 +13,8 @@ extern "C" {
# include <locale.h>
#endif // HAVE_LOCALE_H
#include <guile/gh.h>
#include "gettext.h"
}
@ -22,17 +24,21 @@ using std::string;
#include "blackbox.hh"
#include "openbox.hh"
void main_prog(int argc, char **argv) {
ob::Openbox openbox(argc, argv);
//ob::Blackbox blackbox(argc, argv, 0);
//Blackbox blackbox(argv, session_display, rc_file);
openbox.eventLoop();
}
int main(int argc, char **argv) {
// initialize the locale
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
ob::Openbox openbox(argc, argv);
//ob::Blackbox blackbox(argc, argv, 0);
//Blackbox blackbox(argv, session_display, rc_file);
openbox.eventLoop();
return(0);
// start up guile
//gh_enter(argc, argv, main_prog);
main_prog(argc, argv);
}

View file

@ -1,4 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; -*-
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifdef HAVE_CONFIG_H
# include "../config.h"
@ -9,7 +9,6 @@
#include "client.hh"
#include "screen.hh"
#include "actions.hh"
#include "python.hh"
#include "otk/property.hh"
#include "otk/display.hh"
#include "otk/assassin.hh"
@ -43,7 +42,12 @@ extern "C" {
# include <sys/select.h>
#endif // HAVE_SYS_SELECT_H
#include <python2.2/Python.h>
//#include <guile/gh.h>
#include <Python.h>
// The initializer in openbox_wrap.cc
extern void init_openbox(void);
#include "gettext.h"
#define _(str) gettext(str)
@ -153,10 +157,24 @@ Openbox::Openbox(int argc, char **argv)
::exit(1);
}
// initialize the python interface
/*
// make our guile interfaces exist
SWIG_init();
// run the guile of d3th
FILE *rcpyfd = fopen("/home/natas/.openbox/user.scm", "r");
if (!rcpyfd) {
printf("failed to load guile script /home/natas/.openbox/user.scm\n");
} else {
fclose(rcpyfd);
gh_load("/home/natas/.openbox/user.scm");
}
*/
Py_SetProgramName(argv[0]);
Py_Initialize();
initopenbox(); // initialize the static 'openbox' module
//initopenbox(); // initialize the static 'openbox' module
init_openbox();
FILE *rcpyfd = fopen("/home/natas/.openbox/user.py", "r");
if (!rcpyfd) {
printf("failed to load python file /home/natas/.openbox/user.py\n");
@ -164,6 +182,7 @@ Openbox::Openbox(int argc, char **argv)
PyRun_SimpleFile(rcpyfd, "/home/natas/.openbox/user.py");
fclose(rcpyfd);
}
_state = State_Normal; // done starting
}

View file

@ -1,4 +1,4 @@
// -*- mode: C++; indent-tabs-mode: nil; -*-
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
#ifndef __openbox_hh
#define __openbox_hh
@ -31,6 +31,17 @@ class OBScreen;
class OBClient;
class OBActions;
//! Mouse cursors used throughout Openbox
struct Cursors {
Cursor session; //!< The default mouse cursor
Cursor move; //!< For moving a window
Cursor ll_angle; //!< For resizing the bottom left corner of a window
Cursor lr_angle; //!< For resizing the bottom right corner of a window
Cursor ul_angle; //!< For resizing the top left corner of a window
Cursor ur_angle; //!< For resizing the right corner of a window
};
//! The main class for the Openbox window manager
/*!
Only a single instance of the Openbox class may be used in the application. A
@ -58,16 +69,6 @@ public:
State_Exiting //!< The window manager is exiting (being destroyed)
};
//! Mouse cursors used throughout Openbox
struct Cursors {
Cursor session; //!< The default mouse cursor
Cursor move; //!< For moving a window
Cursor ll_angle; //!< For resizing the bottom left corner of a window
Cursor lr_angle; //!< For resizing the bottom right corner of a window
Cursor ul_angle; //!< For resizing the top left corner of a window
Cursor ur_angle; //!< For resizing the right corner of a window
};
//! A map for looking up a specific client class from the window id
typedef std::map<Window, OBClient *> ClientMap;
@ -138,6 +139,7 @@ private:
static void signalHandler(int signal);
public:
#ifndef SWIG
//! Openbox constructor.
/*!
\param argc Number of command line arguments, as received in main()
@ -146,6 +148,7 @@ public:
Openbox(int argc, char **argv);
//! Openbox destructor.
virtual ~Openbox();
#endif
//! Returns the state of the window manager (starting, exiting, etc)
inline RunState state() const { return _state; }
@ -169,6 +172,7 @@ public:
//! Returns the mouse cursors used throughout Openbox
inline const Cursors &cursors() const { return _cursors; }
#ifndef SWIG
//! The main function of the Openbox class
/*!
This function should be called after instantiating the Openbox class.
@ -176,6 +180,7 @@ public:
The Openbox::shutdown method will cause this function to exit.
*/
void eventLoop();
#endif
//! Adds an OBClient to the client list for lookups
void addClient(Window window, OBClient *client);

28
src/openbox.i Normal file
View file

@ -0,0 +1,28 @@
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
%module openbox
%{
#ifdef HAVE_CONFIG_H
# include "../config.h"
#endif
#include "openbox.hh"
#include "screen.hh"
#include "client.hh"
%}
%immutable ob::Openbox::instance;
%include "openbox.hh"
%include "screen.hh"
%include "client.hh"
%include stl.i
%include std_list.i
%{
class OBClient;
%}
%template(ClientList) std::list<OBClient*>;

View file

@ -94,10 +94,12 @@ private:
void setWorkArea();
public:
#ifndef SWIG
//! Constructs a new OBScreen object
OBScreen(int screen, const otk::Configuration &config);
//! Destroys the OBScreen object
virtual ~OBScreen();
#endif
//! Returns if the screen was successfully managed
/*!
@ -112,6 +114,7 @@ public:
//! Returns the style in use on the screen
inline const otk::Style *style() const { return &_style; }
inline ClientList clients() { return _clients; }
//! Adds a window's strut to the screen's list of reserved spaces
void addStrut(otk::Strut *strut);