From df3d926cb2da067f323d3fd839bbcd759ddf92c4 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 17 Mar 2003 22:04:20 +0000 Subject: [PATCH] rming almost all the old python stuffs --- openbox/clientwrap.c | 1029 ----------------------------------------- openbox/clientwrap.h | 19 - openbox/configwrap.c | 80 ---- openbox/configwrap.h | 15 - openbox/hooks.c | 296 ------------ openbox/hooks.h | 56 --- openbox/openboxwrap.c | 502 -------------------- openbox/openboxwrap.h | 17 - openbox/python.c | 60 --- openbox/python.h | 10 - 10 files changed, 2084 deletions(-) delete mode 100644 openbox/clientwrap.c delete mode 100644 openbox/clientwrap.h delete mode 100644 openbox/configwrap.c delete mode 100644 openbox/configwrap.h delete mode 100644 openbox/hooks.c delete mode 100644 openbox/hooks.h delete mode 100644 openbox/openboxwrap.c delete mode 100644 openbox/openboxwrap.h delete mode 100644 openbox/python.c delete mode 100644 openbox/python.h diff --git a/openbox/clientwrap.c b/openbox/clientwrap.c deleted file mode 100644 index fe3783ed..00000000 --- a/openbox/clientwrap.c +++ /dev/null @@ -1,1029 +0,0 @@ -#include "clientwrap.h" -#include "client.h" -#include "frame.h" -#include "engine.h" -#include "stacking.h" -#include "focus.h" -#include "prop.h" -#include - -/*************************************************************************** - - Define the type 'ClientWrap' - - ***************************************************************************/ - -#define IS_CWRAP(v) ((v)->ob_type == &ClientWrapType) -#define IS_VALID_CWRAP(v) ((v)->client != NULL) -#define CHECK_CWRAP(self, funcname) { \ - if (!IS_CWRAP(self)) { \ - PyErr_SetString(PyExc_TypeError, \ - "descriptor '" funcname "' requires a 'Client' " \ - "object"); \ - return NULL; \ - } \ - if (!IS_VALID_CWRAP(self)) { \ - PyErr_SetString(PyExc_ValueError, \ - "This 'Client' is wrapping a client which no longer "\ - "exists."); \ - return NULL; \ - } \ -} - - -staticforward PyTypeObject ClientWrapType; - -/*************************************************************************** - - Attribute methods - - ***************************************************************************/ - -static PyObject *cwrap_valid(ClientWrap *self, PyObject *args) -{ - if (!IS_CWRAP(self)) { - PyErr_SetString(PyExc_TypeError, - "descriptor 'valid' requires a 'Client' object"); - return NULL; - } - return PyInt_FromLong(self->client != NULL); -} - -static PyObject *cwrap_title(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "title"); - if (!PyArg_ParseTuple(args, ":title")) - return NULL; - return PyString_FromString(self->client->title); -} - -static PyObject *cwrap_setTitle(ClientWrap *self, PyObject *args) -{ - char *title; - - CHECK_CWRAP(self, "setTitle"); - if (!PyArg_ParseTuple(args, "s:setTitle", &title)) - return NULL; - - PROP_SETS(self->client->window, net_wm_name, utf8, title); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_iconTitle(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "iconTitle"); - if (!PyArg_ParseTuple(args, ":iconTitle")) - return NULL; - return PyString_FromString(self->client->icon_title); -} - -static PyObject *cwrap_setIconTitle(ClientWrap *self, PyObject *args) -{ - char *title; - - CHECK_CWRAP(self, "setIconTitle"); - if (!PyArg_ParseTuple(args, "s:setIconTitle", &title)) - return NULL; - - PROP_SETS(self->client->window, net_wm_icon_name, utf8, title); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_desktop(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "desktop"); - if (!PyArg_ParseTuple(args, ":desktop")) - return NULL; - return PyInt_FromLong(self->client->desktop); -} - -static PyObject *cwrap_setDesktop(ClientWrap *self, PyObject *args) -{ - int desktop; - CHECK_CWRAP(self, "setDesktop"); - if (!PyArg_ParseTuple(args, "i:setDesktop", &desktop)) - return NULL; - client_set_desktop(self->client, desktop); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_resName(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "resName"); - if (!PyArg_ParseTuple(args, ":resName")) - return NULL; - return PyString_FromString(self->client->res_name); -} - -static PyObject *cwrap_resClass(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "resClass"); - if (!PyArg_ParseTuple(args, ":resClass")) - return NULL; - return PyString_FromString(self->client->res_class); -} - -static PyObject *cwrap_role(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "role"); - if (!PyArg_ParseTuple(args, ":role")) - return NULL; - return PyString_FromString(self->client->role); -} - -static PyObject *cwrap_transient(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "transient"); - if (!PyArg_ParseTuple(args, ":transient")) - return NULL; - return PyInt_FromLong(!!self->client->transient); -} - -static PyObject *cwrap_transientFor(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "transientFor"); - if (!PyArg_ParseTuple(args, ":transientFor")) - return NULL; - if (self->client->transient_for != NULL) - return clientwrap_new(self->client->transient_for); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_transients(ClientWrap *self, PyObject *args) -{ - PyObject *tuple; - GSList *it; - guint i, s; - - CHECK_CWRAP(self, "transients"); - if (!PyArg_ParseTuple(args, ":transients")) - return NULL; - s = g_slist_length(self->client->transients); - tuple = PyTuple_New(s); - for (i = 0, it = self->client->transients; i < s; ++i, it = it->next) - PyTuple_SET_ITEM(tuple, i, clientwrap_new(it->data)); - return tuple; -} - -static PyObject *cwrap_type(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "type"); - if (!PyArg_ParseTuple(args, ":type")) - return NULL; - return PyInt_FromLong(self->client->type); -} - -static PyObject *cwrap_normal(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "normal"); - if (!PyArg_ParseTuple(args, ":normal")) - return NULL; - return PyInt_FromLong(!!client_normal(self->client)); -} - -static PyObject *cwrap_area(ClientWrap *self, PyObject *args) -{ - PyObject *tuple; - - CHECK_CWRAP(self, "area"); - if (!PyArg_ParseTuple(args, ":area")) - return NULL; - tuple = PyTuple_New(4); - PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(self->client->frame->area.x)); - PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(self->client->frame->area.y)); - PyTuple_SET_ITEM(tuple, 2, - PyInt_FromLong(self->client->frame->area.width)); - PyTuple_SET_ITEM(tuple, 3, - PyInt_FromLong(self->client->frame->area.height)); - return tuple; -} - -static PyObject *cwrap_setArea(ClientWrap *self, PyObject *args) -{ - int x, y, w, h, final = TRUE; - - CHECK_CWRAP(self, "setArea"); - if (!PyArg_ParseTuple(args, "(iiii)|i:setArea", &x, &y, &w, &h, &final)) - return NULL; - - frame_frame_gravity(self->client->frame, &x, &y); - w -= self->client->frame->size.left + self->client->frame->size.right; - h -= self->client->frame->size.top + self->client->frame->size.bottom; - client_configure(self->client, Corner_TopLeft, x, y, w, h, TRUE, final); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_clientArea(ClientWrap *self, PyObject *args) -{ - PyObject *tuple; - - CHECK_CWRAP(self, "clientArea"); - if (!PyArg_ParseTuple(args, ":clientArea")) - return NULL; - tuple = PyTuple_New(4); - PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(self->client->area.x)); - PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(self->client->area.y)); - PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(self->client->area.width)); - PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(self->client->area.height)); - return tuple; -} - -static PyObject *cwrap_setClientArea(ClientWrap *self, PyObject *args) -{ - int x, y, w, h; - - CHECK_CWRAP(self, "setClientArea"); - if (!PyArg_ParseTuple(args, "(iiii)|i:setClientArea", &x, &y, &w, &h)) - return NULL; - - client_configure(self->client, Corner_TopLeft, x, y, w, h, TRUE, TRUE); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_frameSize(ClientWrap *self, PyObject *args) -{ - PyObject *tuple; - - CHECK_CWRAP(self, "frameSize"); - if (!PyArg_ParseTuple(args, ":frameSize")) - return NULL; - tuple = PyTuple_New(4); - PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(self->client->frame->size.left)); - PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(self->client->frame->size.top)); - PyTuple_SET_ITEM(tuple, 2, - PyInt_FromLong(self->client->frame->size.right)); - PyTuple_SET_ITEM(tuple, 3, - PyInt_FromLong(self->client->frame->size.bottom)); - return tuple; -} - -static PyObject *cwrap_strut(ClientWrap *self, PyObject *args) -{ - PyObject *tuple; - - CHECK_CWRAP(self, "strut"); - if (!PyArg_ParseTuple(args, ":strut")) - return NULL; - tuple = PyTuple_New(4); - PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(self->client->strut.left)); - PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(self->client->strut.top)); - PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(self->client->strut.right)); - PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(self->client->strut.bottom)); - return tuple; -} - -static PyObject *cwrap_logicalSize(ClientWrap *self, PyObject *args) -{ - PyObject *tuple; - - CHECK_CWRAP(self, "logicalSize"); - if (!PyArg_ParseTuple(args, ":logicalSize")) - return NULL; - tuple = PyTuple_New(2); - PyTuple_SET_ITEM(tuple, 0, - PyInt_FromLong(self->client->logical_size.width)); - PyTuple_SET_ITEM(tuple, 1, - PyInt_FromLong(self->client->logical_size.height)); - return tuple; -} - -static PyObject *cwrap_canFocus(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "canFocus"); - if (!PyArg_ParseTuple(args, ":canFocus")) - return NULL; - return PyInt_FromLong(!!self->client->can_focus); -} - -static PyObject *cwrap_focus(ClientWrap *self, PyObject *args) -{ - int focus = TRUE; - - CHECK_CWRAP(self, "focus"); - if (!PyArg_ParseTuple(args, "|i:focus", &focus)) - return NULL; - if (focus) - return PyInt_FromLong(!!client_focus(self->client)); - else { - if (focus_client == self->client) - client_unfocus(self->client); - Py_INCREF(Py_None); - return Py_None; - } -} - -static PyObject *cwrap_focused(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "focused"); - if (!PyArg_ParseTuple(args, ":focused")) - return NULL; - return PyInt_FromLong(!!self->client->focused); -} - -static PyObject *cwrap_visible(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "visible"); - if (!PyArg_ParseTuple(args, ":visible")) - return NULL; - return PyInt_FromLong(!!self->client->frame->visible); -} - -static PyObject *cwrap_setVisible(ClientWrap *self, PyObject *args) -{ - int show; - - CHECK_CWRAP(self, "setVisible"); - if (!PyArg_ParseTuple(args, "i:setVisible", &show)) - return NULL; - if (show) - engine_frame_show(self->client->frame); - else - engine_frame_hide(self->client->frame); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_modal(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "modal"); - if (!PyArg_ParseTuple(args, ":modal")) - return NULL; - return PyInt_FromLong(!!self->client->modal); -} - -static PyObject *cwrap_setModal(ClientWrap *self, PyObject *args) -{ - int modal; - - CHECK_CWRAP(self, "setModal"); - if (!PyArg_ParseTuple(args, "i:setModal", &modal)) - return NULL; - - client_set_state(self->client, - (modal ? prop_atoms.net_wm_state_add : - prop_atoms.net_wm_state_remove), - prop_atoms.net_wm_state_modal, 0); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_shaded(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "shaded"); - if (!PyArg_ParseTuple(args, ":shaded")) - return NULL; - return PyInt_FromLong(!!self->client->shaded); -} - -static PyObject *cwrap_setShaded(ClientWrap *self, PyObject *args) -{ - int shaded; - - CHECK_CWRAP(self, "setShaded"); - if (!PyArg_ParseTuple(args, "i:setShaded", &shaded)) - return NULL; - - client_shade(self->client, shaded); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_iconic(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "iconic"); - if (!PyArg_ParseTuple(args, ":iconic")) - return NULL; - return PyInt_FromLong(!!self->client->iconic); -} - -static PyObject *cwrap_setIconic(ClientWrap *self, PyObject *args) -{ - int iconify, current = TRUE; - - CHECK_CWRAP(self, "setIconic"); - if (!PyArg_ParseTuple(args, "i|i:setIconic", &iconify, ¤t)) - return NULL; - - client_iconify(self->client, iconify, current); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_maximizedHorz(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "maximizedHorz"); - if (!PyArg_ParseTuple(args, ":maximizedHorz")) - return NULL; - return PyInt_FromLong(!!self->client->max_horz); -} - -static PyObject *cwrap_setMaximizedHorz(ClientWrap *self, PyObject *args) -{ - int max; - - CHECK_CWRAP(self, "setMaximizedHorz"); - if (!PyArg_ParseTuple(args, "i:setMaximizedHorz", &max)) - return NULL; - - client_set_state(self->client, - (max ? prop_atoms.net_wm_state_add : - prop_atoms.net_wm_state_remove), - prop_atoms.net_wm_state_maximized_horz, 0); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_maximizedVert(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "maximizedVert"); - if (!PyArg_ParseTuple(args, ":maximizedVert")) - return NULL; - return PyInt_FromLong(!!self->client->max_vert); -} - -static PyObject *cwrap_setMaximizedVert(ClientWrap *self, PyObject *args) -{ - int max; - - CHECK_CWRAP(self, "setMaximizedVert"); - if (!PyArg_ParseTuple(args, "i:setMaximizedVert", &max)) - return NULL; - - client_set_state(self->client, - (max ? prop_atoms.net_wm_state_add : - prop_atoms.net_wm_state_remove), - prop_atoms.net_wm_state_maximized_vert, 0); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_maximized(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "maximized"); - if (!PyArg_ParseTuple(args, ":maximized")) - return NULL; - return PyInt_FromLong(self->client->max_vert || self->client->max_horz); -} - -static PyObject *cwrap_setMaximized(ClientWrap *self, PyObject *args) -{ - int max; - - CHECK_CWRAP(self, "setMaximized"); - if (!PyArg_ParseTuple(args, "i:setMaximized", &max)) - return NULL; - - client_set_state(self->client, - (max ? prop_atoms.net_wm_state_add : - prop_atoms.net_wm_state_remove), - prop_atoms.net_wm_state_maximized_vert, - prop_atoms.net_wm_state_maximized_horz); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_fullscreen(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "fullscreen"); - if (!PyArg_ParseTuple(args, ":fullscreen")) - return NULL; - return PyInt_FromLong(!!self->client->fullscreen); -} - -static PyObject *cwrap_setFullscreen(ClientWrap *self, PyObject *args) -{ - int fs; - - CHECK_CWRAP(self, "setFullscreen"); - if (!PyArg_ParseTuple(args, "i:setFullscreen", &fs)) - return NULL; - - client_set_state(self->client, - (fs ? prop_atoms.net_wm_state_add : - prop_atoms.net_wm_state_remove), - prop_atoms.net_wm_state_fullscreen, 0); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_stacking(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "stacking"); - if (!PyArg_ParseTuple(args, ":stacking")) - return NULL; - return PyInt_FromLong(self->client->above ? 1 : - self->client->below ? -1 : 0); -} - -static PyObject *cwrap_setStacking(ClientWrap *self, PyObject *args) -{ - int stack; - - CHECK_CWRAP(self, "setStacking"); - if (!PyArg_ParseTuple(args, "i:setStacking", &stack)) - return NULL; - client_set_state(self->client, - (stack > 0 ? prop_atoms.net_wm_state_add : - prop_atoms.net_wm_state_remove), - prop_atoms.net_wm_state_above, 0); - client_set_state(self->client, - (stack < 0 ? prop_atoms.net_wm_state_add : - prop_atoms.net_wm_state_remove), - prop_atoms.net_wm_state_below, 0); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_raiseWindow(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "raiseWindow"); - if (!PyArg_ParseTuple(args, ":raiseWindow")) - return NULL; - stacking_raise(self->client); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_lowerWindow(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "lowerWindow"); - if (!PyArg_ParseTuple(args, ":lowerWindow")) - return NULL; - stacking_lower(self->client); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_skipPager(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "skipPager"); - if (!PyArg_ParseTuple(args, ":skipPager")) - return NULL; - return PyInt_FromLong(!!self->client->skip_pager); -} - -static PyObject *cwrap_setSkipPager(ClientWrap *self, PyObject *args) -{ - int skip; - - CHECK_CWRAP(self, "setSkipPager"); - if (!PyArg_ParseTuple(args, "i:setSkipPager", &skip)) - return NULL; - - client_set_state(self->client, - (skip ? prop_atoms.net_wm_state_add : - prop_atoms.net_wm_state_remove), - prop_atoms.net_wm_state_skip_pager, 0); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_skipTaskbar(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "skipTaskbar"); - if (!PyArg_ParseTuple(args, ":skipTaskbar")) - return NULL; - return PyInt_FromLong(!!self->client->skip_taskbar); -} - -static PyObject *cwrap_setSkipTaskbar(ClientWrap *self, PyObject *args) -{ - int skip; - - CHECK_CWRAP(self, "setSkipTaskbar"); - if (!PyArg_ParseTuple(args, "i:setSkipTaskbar", &skip)) - return NULL; - - client_set_state(self->client, - (skip ? prop_atoms.net_wm_state_add : - prop_atoms.net_wm_state_remove), - prop_atoms.net_wm_state_skip_taskbar, 0); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_disableDecorations(ClientWrap *self, PyObject *args) -{ - int title, handle, border; - - CHECK_CWRAP(self, "disableDecorations"); - if (!PyArg_ParseTuple(args, "iii:disableDecorations", &title, &handle, - &border)) - return NULL; - - self->client->disabled_decorations = 0; - if (title) self->client->disabled_decorations |= Decor_Titlebar; - if (handle) self->client->disabled_decorations |= Decor_Handle; - if (border) self->client->disabled_decorations |= Decor_Border; - client_setup_decor_and_functions(self->client); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_close(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "close"); - if (!PyArg_ParseTuple(args, ":close")) - return NULL; - client_close(self->client); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *cwrap_window(ClientWrap *self, PyObject *args) -{ - CHECK_CWRAP(self, "window"); - if (!PyArg_ParseTuple(args, ":window")) - return NULL; - return PyInt_FromLong(self->client->window); -} - -#define METH(n, d) {#n, (PyCFunction)cwrap_##n, METH_VARARGS, #d} - -static PyMethodDef ClientWrapMethods[] = { - METH(valid, - "Returns if the Client instance is still valid. Client instances are " - "marked as invalid when the Client they are associated is " - "closed/destroyed/released."), - METH(title, - "Returns the client's title."), - METH(setTitle, - "Change the client's title to the given string. This change will be " - "overwritten if/when the client changes its title."), - METH(iconTitle, - "Returns's the client's icon title. The icon title is the title to " - "be displayed when the client is iconified."), - METH(setIconTitle, - "Change the client's icon title to the given string. This change " - "will be overwritten if/when the client changes its icon title."), - METH(desktop, - "Returns the desktop on which the client is visible. This value will " - "always be in the range [0, ob.Openbox.numDesktops()), unless it is " - "0xffffffff. A value of 0xffffffff indicates the client is visible " - "on all desktops."), - METH(setDesktop, - "Moves the client to the specified desktop. The desktop must be in " - "the range [0, ob.Openbox.numDesktops()), unless it is 0xffffffff. A " - "value of 0xffffffff indicates the client is visible on all " - "desktops."), - METH(resName, - "Returns the resouce name of the client. The resource name is meant " - "to provide an instance name for the client."), - METH(resClass, - "Returns the resouce class of the client. The resource class is " - "meant to provide the genereal class of the application. e.g. " - "'Emacs', 'Xterm', 'XClock', 'XLoad', and so on."), - METH(role, - "Returns the client's role. The role is meant to distinguish between " - "different windows of an application. Each window should have a " - "unique role."), - METH(transient, - "Returns True or False describing if the client is a transient " - "window. Transient windows are 'temporary' windows, such as " - "preference dialogs, and usually have a parent window, which can be " - "found from transientFor()."), - METH(transientFor, - "Returns the client for which this client is a transient. See " - "transient() for a description of transience."), - METH(transients, - "Returns a tuple containing all the Clients which are transients of " - "this window. See transient() for a description of transience."), - METH(type, - "Returns the logical type of the window. This is one of the " - "ClientType constants. See also normal()."), - METH(normal, - "Returns True or False for if the client is a 'normal' window. " - "Normal windows make up most applications. Non-normal windows have " - "special rules applied to them at times such as for focus handling. " - "An example of a non-normal window is 'gnome-panel'. This value is " - "determined from the client's type(), but does not imply that the " - "window is ClientType.Normal. Rather this is a more generic " - "definition of 'normal' windows, and includes dialogs and others."), - METH(area, - "Returns the area of the screen which the client occupies. It may be " - "important to note that this is the position and size of the client " - "*with* its decorations. If you want the underlying position and " - "size of the client itself, you should use clientArea(). See also " - "logicalSize()."), - - METH(setArea, - "Sets the client's area, moving and resizing it as specified (or as " - "close as can be accomidated)."), - METH(clientArea, - "Returns the area of the screen which the client considers itself to " - "be occupying. This value is not what you see and should not be used " - "for most things (it should, for example, be used for persisting a " - "client's dimentions across sessions). See also area()."), - METH(setClientArea, - "Sets the area of the screen which the client considers itself to be " - "occupying. This is not the on-screen visible position and size, and " - "should be used with care. You probably want to use setArea() to " - "adjust the client. This should be used if you want the client " - "window (inside the decorations) to be a specific size. Adjusting " - "the client's position with this function is probably always a bad " - "idea, because of window gravity."), - METH(strut, - "Returns the application's specified strut. The strut is the amount " - "of space that should be reserved for the application on each side " - "of the screen."), - METH(frameSize, - "Returns the size of the decorations around the client window."), - METH(logicalSize, - "Returns the client's logical size. The logical size is the client's " - "size in more user friendly terms. For many apps this is simply the " - "size of the client in pixels, however for some apps this will " - "differ (e.g. terminal emulators). This value should be used when " - "displaying an applications size to the user."), - METH(canFocus, - "Returns True or False for if the client can be focused."), - METH(focus, - "Focuses (or unfocuses) the client window. Windows which return " - "False for canFocus() or visible() cannot be focused. When this " - "function returns, the client's focused() state will not be changed " - "yet. This only sends the request through the X server. You should " - "wait for the hooks.focused hook to fire, and not assume the client " - "has been focused."), - METH(focused, - "Returns True or False for if the client has the input focus."), - METH(visible, - "Returns True or False for if the client is visible. A client is not " - "visible if it is iconic() or if its desktop() is not visible."), - METH(setVisible, - "Shows or hides the client. This has no effect if its current " - "visible() state is requested."), - METH(modal, - "Returns True or False for if the client is a modal window. Modal " - "windows indicate that they must be dealt with before the program " - "can continue. When a modal window is a transient(), its " - "transientFor() client cannot be focused or raised above it."), - METH(setModal, - "Make the client window modal or non-modal."), - METH(shaded, - "Returns True or False for if the client is shaded. Shaded windows " - "have only their titlebar decorations showing."), - METH(setShaded, - "Shade or unshade the client. Shaded windows have only their " - "titlebar decorations showing. Windows which do not have a titlebar " - "cannot be shaded."), - METH(iconic, - "Returns True or False for if the window is iconified. Iconified " - "windows are not visible on any desktops."), - METH(setIconic, - "Iconifies or restores the client window. Iconified windows are not " - "visible on any desktops. Iconified windows can be restored to the " - "currently visible desktop or to their original (native) desktop."), - METH(maximizedHorz, - "Returns whether the client is maximized in the horizontal " - "direction."), - METH(setMaximizedHorz, - "Maximizes or restores a client horizontally."), - METH(maximizedVert, - "Returns whether the client is maximized in the vertical direction."), - METH(setMaximizedVert, - "Maximizes or restores a client vertically."), - METH(maximized, - "Returns whether the client is maximized in the horizontal or " - "vertical direction."), - METH(setMaximized, - "Maximizes or restores a client vertically and horzontally."), - METH(fullscreen, - "Returns if the client is in fullscreen mode. Fullscreen windows are " - "kept above all other windows and are stretched to fill the entire " - "physical display."), - METH(setFullscreen, - "Set a client into or out of fullscreen mode. Fullscreen windows are " - "kept above all other windows and are stretched to fill the entire " - "physical display."), - METH(stacking, - "Returns if the client will be stacked above/below other clients in " - "the same layer."), - METH(setStacking, - "Set how the client will be stacked according to other clients in " - "its layer."), - METH(raiseWindow, - "Raises the window to the top of its stacking layer."), - METH(lowerWindow, - "Lowers the window to the bottom of its stacking layer."), - METH(skipPager, - "Returns if the client has requested to be skipped (not displayed) " - "by pagers."), - METH(setSkipPager, - "Set whether the client should be skipped (not displayed) by " - "pagers."), - METH(skipTaskbar, - "Returns if the client has requested to be skipped (not displayed) " - "by taskbars."), - METH(setSkipTaskbar, - "Set whether the client should be skipped (not displayed) by " - "taskbars."), - METH(disableDecorations, - "Choose which decorations to disable on the client. Note that " - "decorations can only be disabled, and decorations that would " - "normally not be shown cannot be added. These values may have " - "slightly different meanings in different theme engines."), - METH(close, - "Requests the client to close its window."), - METH(window, - "Returns the client's window id. This is the id by which the X " - "server knows the client."), - { NULL, NULL, 0, NULL } -}; - -/*************************************************************************** - - Type methods/struct - - ***************************************************************************/ - -/*static PyObject *cwrap_getattr(ClientWrap *self, char *name) -{ - CHECK_CWRAP(self, "getattr"); - return Py_FindMethod(ClientWrapAttributeMethods, (PyObject*)self, name); -}*/ - -static void cwrap_dealloc(ClientWrap *self) -{ - if (self->client != NULL) - self->client->wrap = NULL; - PyObject_Del((PyObject*) self); -} - -static PyObject *cwrap_repr(ClientWrap *self) -{ - CHECK_CWRAP(self, "repr"); - return PyString_FromFormat("Client: 0x%x", (guint)self->client->window); -} - -static int cwrap_compare(ClientWrap *self, ClientWrap *other) -{ - Window w1, w2; - if (!IS_VALID_CWRAP(self)) { - PyErr_SetString(PyExc_ValueError, - "This 'Client' is wrapping a client which no longer " - "exists."); - } - - w1 = self->client->window; - w2 = other->client->window; - return w1 > w2 ? 1 : w1 < w2 ? -1 : 0; -} - -static PyTypeObject ClientWrapType = { - PyObject_HEAD_INIT(NULL) - 0, - "Client", - sizeof(ClientWrap), - 0, - (destructor) cwrap_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - (cmpfunc) cwrap_compare, /*tp_compare*/ - (reprfunc) cwrap_repr, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ -}; - - -/*************************************************************************** - - Define the type 'ClientType' - - ***************************************************************************/ - -#define IS_CTYPE(v) ((v)->ob_type == &ClientTypeType) -#define CHECK_CTYPE(self, funcname) { \ - if (!IS_CTYPE(self)) { \ - PyErr_SetString(PyExc_TypeError, \ - "descriptor '" funcname "' requires a 'ClientType' " \ - "object"); \ - return NULL; \ - } \ -} - -staticforward PyTypeObject ClientTypeType; - -typedef struct ClientType { - PyObject_HEAD -} ClientType; - -static void ctype_dealloc(PyObject *self) -{ - PyObject_Del(self); -} - -static PyObject *ctype_getattr(ClientType *self, char *name) -{ - struct S { char *name; int val; }; - struct S s[] = { - { "Normal", Type_Normal }, - { "Dialog", Type_Dialog }, - { "Desktop", Type_Desktop }, - { "Dock", Type_Dock }, - { "Toolbar", Type_Toolbar }, - { "Menu", Type_Menu }, - { "Utility", Type_Utility }, - { "Splash", Type_Splash }, - { NULL, 0 } }; - int i; - - CHECK_CTYPE(self, "__getattr__"); - - for (i = 0; s[i].name != NULL; ++i) - if (!strcmp(s[i].name, name)) - return PyInt_FromLong(s[i].val); - PyErr_SetString(PyExc_AttributeError, "invalid attribute"); - return NULL; -} - -static PyTypeObject ClientTypeType = { - PyObject_HEAD_INIT(NULL) - 0, - "Type", - sizeof(ClientType), - 0, - (destructor) ctype_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) ctype_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ -}; - -/*************************************************************************** - - External methods - - ***************************************************************************/ - -void clientwrap_startup() -{ - PyObject *ob, *obdict, *type; - - ClientWrapType.ob_type = &PyType_Type; - ClientWrapType.tp_methods = ClientWrapMethods; - PyType_Ready(&ClientWrapType); - - ClientTypeType.ob_type = &PyType_Type; - PyType_Ready(&ClientTypeType); - - /* get the ob module/dict */ - ob = PyImport_ImportModule("ob"); /* new */ - g_assert(ob != NULL); - obdict = PyModule_GetDict(ob); /* borrowed */ - g_assert(obdict != NULL); - - /* add the Client type to the ob module */ - PyDict_SetItemString(obdict, "Client", (PyObject*) &ClientWrapType); - - /* add an instance of ClientType */ - type = (PyObject*) PyObject_New(ClientType, &ClientTypeType); - PyDict_SetItemString(obdict, "ClientType", type); - Py_DECREF(type); - - Py_DECREF(ob); -} - -void clientwrap_shutdown() -{ -} - -PyObject *clientwrap_new(Client *client) -{ - g_assert(client != NULL); - - if (client->wrap != NULL) { - /* already has a wrapper! */ - Py_INCREF((PyObject*) client->wrap); - } else { - client->wrap = PyObject_New(ClientWrap, &ClientWrapType); - client->wrap->client = client; - } - return (PyObject*) client->wrap; -} diff --git a/openbox/clientwrap.h b/openbox/clientwrap.h deleted file mode 100644 index b20ca914..00000000 --- a/openbox/clientwrap.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __clientwrap_h -#define __clientwrap_h - -#include - -struct Client; - -/* ClientWrap is a PyObject */ -typedef struct ClientWrap { - PyObject_HEAD - struct Client *client; -} ClientWrap; - -void clientwrap_startup(); -void clientwrap_shutdown(); - -PyObject *clientwrap_new(struct Client *client); - -#endif diff --git a/openbox/configwrap.c b/openbox/configwrap.c deleted file mode 100644 index 3afa5c4c..00000000 --- a/openbox/configwrap.c +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include - -/* This simply wraps the config.py module so that it can be accessed from the - C code. -*/ - -static PyObject *add, *get, *set, *reset; - -void configwrap_startup() -{ - PyObject *c, *cdict; - - /* get the ob module/dict */ - c = PyImport_ImportModule("config"); /* new */ - g_assert(c != NULL); - cdict = PyModule_GetDict(c); /* borrowed */ - g_assert(cdict != NULL); - - /* get the functions */ - add = PyDict_GetItemString(cdict, "add"); - g_assert(add != NULL); - get = PyDict_GetItemString(cdict, "get"); - g_assert(get != NULL); - set = PyDict_GetItemString(cdict, "set"); - g_assert(set != NULL); - reset = PyDict_GetItemString(cdict, "reset"); - g_assert(reset != NULL); - - Py_DECREF(c); -} - -void configwrap_shutdown() -{ - Py_DECREF(get); - Py_DECREF(set); - Py_DECREF(reset); - Py_DECREF(add); -} - -void configwrap_add_int(char *modname, char *varname, char *friendname, - char *description, int defvalue) -{ - PyObject *r; - - r= PyObject_CallFunction(add, "sssssi", modname, varname, - friendname, description, "integer", defvalue); - g_assert(r != NULL); - Py_DECREF(r); -} - -int configwrap_get_int(char *modname, char *varname) -{ - PyObject *r; - int i; - - r = PyObject_CallFunction(get, "ss", modname, varname); - g_assert(r != NULL); - i = PyInt_AsLong(r); - Py_DECREF(r); - return i; -} - -void configwrap_set_int(char *modname, char *varname, int value) -{ - PyObject *r; - - r = PyObject_CallFunction(set, "ssi", modname, varname, value); - g_assert(r != NULL); - Py_DECREF(r); -} - -void configwrap_reset(char *modname, char *varname) -{ - PyObject *r; - - r = PyObject_CallFunction(reset, "ss", modname, varname); - g_assert(r != NULL); - Py_DECREF(r); -} diff --git a/openbox/configwrap.h b/openbox/configwrap.h deleted file mode 100644 index 729646a3..00000000 --- a/openbox/configwrap.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef __configwrap_h -#define __configwrap_h - -void configwrap_startup(); -void configwrap_shutdown(); - -void configwrap_add_int(char *modname, char *varname, char *friendname, - char *description, int defvalue); -int configwrap_get_int(char *modname, char *varname); -void configwrap_set_int(char *modname, char *varname, int value); - - -void configwrap_reset(char *modname, char *varname); - -#endif diff --git a/openbox/hooks.c b/openbox/hooks.c deleted file mode 100644 index ba5095fb..00000000 --- a/openbox/hooks.c +++ /dev/null @@ -1,296 +0,0 @@ -#include "hooks.h" -#include - -/* - * - * Define the 'Hook' class type - * - */ -#define IS_HOOK(v) ((v)->ob_type == &HookType) - -staticforward PyTypeObject HookType; - -typedef struct HookObject { - PyObject_HEAD - GSList *funcs; -} HookObject; - -static int hook_init(HookObject *self, PyObject *args, PyObject *kwds) -{ - char *keywords[] = { 0 }; - if (!PyArg_ParseTupleAndKeywords(args, kwds, ":__init__", keywords)) - return -1; - self->funcs = NULL; - return 0; -} - -static void hook_dealloc(HookObject *self) -{ - GSList *it; - - for (it = self->funcs; it != NULL; it = it->next) - Py_DECREF((PyObject*) it->data); - - PyObject_Del((PyObject*) self); -} - -static PyObject *hook_fire(HookObject *self, PyObject *args) -{ - GSList *it; - - if (!IS_HOOK(self)) { - PyErr_SetString(PyExc_TypeError, - "descriptor 'fire' requires a 'Hook' object"); - return NULL; - } - - for (it = self->funcs; it != NULL; it = it->next) { - PyObject *ret = PyObject_CallObject(it->data, args); - if (ret == NULL) - return NULL; - Py_DECREF(ret); - } - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *hook_append(HookObject *self, PyObject *args) -{ - PyObject *func; - - if (!IS_HOOK(self)) { - PyErr_SetString(PyExc_TypeError, - "descriptor 'append' requires a 'Hook' object"); - return NULL; - } - if (!PyArg_ParseTuple(args, "O:append", &func)) - return NULL; - if (!PyCallable_Check(func)) { - PyErr_SetString(PyExc_TypeError, - "descriptor 'append' requires a callable argument"); - return NULL; - } - self->funcs = g_slist_append(self->funcs, func); - Py_INCREF(func); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *hook_remove(HookObject *self, PyObject *args) -{ - PyObject *func; - GSList *it; - - if (!IS_HOOK(self)) { - PyErr_SetString(PyExc_TypeError, - "descriptor 'remove' requires a 'Hook' object"); - return NULL; - } - if (!PyArg_ParseTuple(args, "O:remove", &func)) - return NULL; - if (!PyCallable_Check(func)) { - PyErr_SetString(PyExc_TypeError, - "descriptor 'remove' requires a callable argument"); - return NULL; - } - - it = g_slist_find(self->funcs, func); - if (it != NULL) { - self->funcs = g_slist_delete_link(self->funcs, it); - Py_DECREF(func); - - Py_INCREF(Py_None); - return Py_None; - } - PyErr_SetString(PyExc_TypeError, - "given callable object was not found in Hook"); - return NULL; -} - -static PyObject *hook_call(HookObject *self, PyObject *args) -{ - PyObject *ret; - GSList *it, *next; - gboolean stop = FALSE; - - if (!IS_HOOK(self)) { - PyErr_SetString(PyExc_TypeError, - "descriptor '__call__' requires a 'Hook' object"); - return NULL; - } - - for (it = self->funcs; !stop && it != NULL;) { - next = it->next; /* incase the hook removes itself */ - - ret = PyObject_CallObject(it->data, args); - if (ret == NULL) - return NULL; - if (ret != Py_None) - stop = TRUE; - Py_DECREF(ret); - - it = next; - } - - Py_INCREF(Py_None); - return Py_None; -} - -static PyTypeObject HookType = { - PyObject_HEAD_INIT(NULL) - 0, - "Hook", - sizeof(HookObject), - 0, - (destructor) hook_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ -}; - -static PyMethodDef HookMethods[] = { - {"append", (PyCFunction)hook_append, METH_VARARGS, - "hook.add(func) -- Add a function to the hook." }, - {"remove", (PyCFunction)hook_remove, METH_VARARGS, - "hook.remove(func) -- Remove a function from the hook." }, - { NULL, NULL, 0, NULL } -}; - - -/* - * - * Module initialization/finalization - * - */ - -static PyObject *hooks, *hooksdict; - -static PyMethodDef HooksMethods[] = { - { NULL, NULL, 0, NULL } -}; - -struct HookObject *hooks_create(char *name) -{ - HookObject *hook; - int ret; - - hook = PyObject_New(HookObject, &HookType); - hook->funcs = NULL; - - /* add it to the hooks module */ - ret = PyDict_SetItemString(hooksdict, name, (PyObject*) hook); - g_assert(ret != -1); - - return hook; -} - -void hooks_startup() -{ - HookType.ob_type = &PyType_Type; - HookType.tp_methods = HookMethods; - HookType.tp_alloc = PyType_GenericAlloc; - HookType.tp_new = PyType_GenericNew; - HookType.tp_init = (initproc) hook_init; - HookType.tp_call = (ternaryfunc) hook_call; - PyType_Ready(&HookType); - - Py_InitModule("hooks", HooksMethods); - - /* get the hooks module/dict */ - hooks = PyImport_ImportModule("hooks"); /* new */ - g_assert(hooks != NULL); - hooksdict = PyModule_GetDict(hooks); /* borrowed */ - g_assert(hooksdict != NULL); - - /* add the Hook type to the hooks module */ - PyDict_SetItemString(hooksdict, "Hook", (PyObject*) &HookType); - - hook_startup = hooks_create("startup"); - hook_shutdown = hooks_create("shutdown"); - hook_visibledesktop = hooks_create("visibledesktop"); - hook_numdesktops = hooks_create("numdesktops"); - hook_desktopnames = hooks_create("desktopnames"); - hook_showdesktop = hooks_create("showdesktop"); - hook_screenconfiguration = hooks_create("screenconfiguration"); - hook_screenarea = hooks_create("screenarea"); - hook_managed = hooks_create("managed"); - hook_closed = hooks_create("closed"); - hook_bell = hooks_create("bell"); - hook_urgent = hooks_create("urgent"); - hook_pointerenter = hooks_create("pointerenter"); - hook_pointerleave = hooks_create("pointerleave"); - hook_focused = hooks_create("focused"); - hook_requestactivate = hooks_create("requestactivate"); - hook_title = hooks_create("title"); - hook_desktop = hooks_create("desktop"); - hook_iconic = hooks_create("iconic"); - hook_shaded = hooks_create("shaded"); - hook_maximized = hooks_create("maximized"); - hook_fullscreen = hooks_create("fullscreen"); - hook_visible = hooks_create("visible"); - hook_configuration = hooks_create("configuration"); -} - -void hooks_shutdown() -{ - Py_DECREF(hook_startup); - Py_DECREF(hook_shutdown); - Py_DECREF(hook_visibledesktop); - Py_DECREF(hook_numdesktops); - Py_DECREF(hook_desktopnames); - Py_DECREF(hook_showdesktop); - Py_DECREF(hook_screenconfiguration); - Py_DECREF(hook_screenarea); - Py_DECREF(hook_managed); - Py_DECREF(hook_closed); - Py_DECREF(hook_bell); - Py_DECREF(hook_urgent); - Py_DECREF(hook_pointerenter); - Py_DECREF(hook_pointerleave); - Py_DECREF(hook_focused); - Py_DECREF(hook_requestactivate); - Py_DECREF(hook_title); - Py_DECREF(hook_desktop); - Py_DECREF(hook_iconic); - Py_DECREF(hook_shaded); - Py_DECREF(hook_maximized); - Py_DECREF(hook_fullscreen); - Py_DECREF(hook_visible); - Py_DECREF(hook_configuration); - - Py_DECREF(hooks); -} - -void hooks_fire(struct HookObject *hook, PyObject *args) -{ - PyObject *ret = hook_call(hook, args); - if (ret == NULL) - PyErr_Print(); - Py_XDECREF(ret); -} - -void hooks_fire_client(struct HookObject *hook, struct Client *client) -{ - PyObject *args; - - if (client != NULL) { - PyObject *c = clientwrap_new(client); - g_assert(c != NULL); - args = Py_BuildValue("(O)", c); - Py_DECREF(c); - } else { - args = Py_BuildValue("(O)", Py_None); - } - - g_assert(args != NULL); - hooks_fire(hook, args); - Py_DECREF(args); -} diff --git a/openbox/hooks.h b/openbox/hooks.h deleted file mode 100644 index 3211d7cf..00000000 --- a/openbox/hooks.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef __hooks_h -#define __hooks_h - -#include "clientwrap.h" -#include - -void hooks_startup(); -void hooks_shutdown(); - -struct HookObject; - -struct HookObject *hooks_create(char *name); - -struct HookObject *hook_startup; -struct HookObject *hook_shutdown; -struct HookObject *hook_visibledesktop; -struct HookObject *hook_numdesktops; -struct HookObject *hook_desktopnames; -struct HookObject *hook_showdesktop; -struct HookObject *hook_screenconfiguration; -struct HookObject *hook_screenarea; -struct HookObject *hook_managed; -struct HookObject *hook_closed; -struct HookObject *hook_bell; -struct HookObject *hook_urgent; -struct HookObject *hook_pointerenter; -struct HookObject *hook_pointerleave; -struct HookObject *hook_focused; -struct HookObject *hook_requestactivate; -struct HookObject *hook_title; -struct HookObject *hook_desktop; -struct HookObject *hook_iconic; -struct HookObject *hook_shaded; -struct HookObject *hook_maximized; -struct HookObject *hook_fullscreen; -struct HookObject *hook_visible; -struct HookObject *hook_configuration; - -#define HOOKFIRE(hook, ...) \ -{ \ - PyObject *args = Py_BuildValue(__VA_ARGS__); \ - g_assert(args != NULL); \ - hooks_fire(hook_##hook, args); \ - Py_DECREF(args); \ -} - -#define HOOKFIRECLIENT(hook, client) \ -{ \ - hooks_fire_client(hook_##hook, client); \ -} - -void hooks_fire(struct HookObject *hook, PyObject *args); - -void hooks_fire_client(struct HookObject *hook, struct Client *client); - -#endif diff --git a/openbox/openboxwrap.c b/openbox/openboxwrap.c deleted file mode 100644 index c73e725a..00000000 --- a/openbox/openboxwrap.c +++ /dev/null @@ -1,502 +0,0 @@ -#include "openboxwrap.h" -#include "openbox.h" -#include "screen.h" -#include "prop.h" - -/*************************************************************************** - - Define the type 'OpenboxWrap' - - ***************************************************************************/ - -#define IS_OWRAP(v) ((v)->ob_type == &OpenboxWrapType) -#define CHECK_OWRAP(self, funcname) { \ - if (!IS_OWRAP(self)) { \ - PyErr_SetString(PyExc_TypeError, \ - "descriptor '" funcname "' requires a 'Openbox' " \ - "object"); \ - return NULL; \ - } \ -} - - -staticforward PyTypeObject OpenboxWrapType; - -/*************************************************************************** - - Attribute methods - - ***************************************************************************/ - -static PyObject *owrap_shutdown(OpenboxWrap *self, PyObject *args) -{ - CHECK_OWRAP(self, "shutdown"); - if (!PyArg_ParseTuple(args, ":shutdown")) - return NULL; - ob_shutdown = TRUE; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *owrap_restart(OpenboxWrap *self, PyObject *args) -{ - char *path = NULL; - - CHECK_OWRAP(self, "restart"); - if (!PyArg_ParseTuple(args, "|s:restart", &path)) - return NULL; - ob_shutdown = ob_restart = TRUE; - ob_restart_path = path; - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *owrap_state(OpenboxWrap *self, PyObject *args) -{ - CHECK_OWRAP(self, "state"); - if (!PyArg_ParseTuple(args, ":state")) - return NULL; - return PyInt_FromLong(ob_state); -} - -static PyObject *owrap_desktop(OpenboxWrap *self, PyObject *args) -{ - CHECK_OWRAP(self, "desktop"); - if (!PyArg_ParseTuple(args, ":desktop")) - return NULL; - return PyInt_FromLong(screen_desktop); -} - -static PyObject *owrap_setDesktop(OpenboxWrap *self, PyObject *args) -{ - int desktop; - - CHECK_OWRAP(self, "setDesktop"); - if (!PyArg_ParseTuple(args, "i:setDesktop", &desktop)) - return NULL; - if (desktop < 0 || (unsigned)desktop >= screen_num_desktops) { - PyErr_SetString(PyExc_ValueError, "invalid desktop"); - return NULL; - } - screen_set_desktop(desktop); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *owrap_setNextDesktop(OpenboxWrap *self, PyObject *args) -{ - gboolean wrap = TRUE; - guint d; - - CHECK_OWRAP(self, "setNextDesktop"); - if (!PyArg_ParseTuple(args, "|i:setNextDesktop", &wrap)) - return NULL; - d = screen_desktop + 1; - if (d >= screen_num_desktops && wrap) - d = 0; - if (d < screen_num_desktops) - screen_set_desktop(d); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *owrap_setPreviousDesktop(OpenboxWrap *self, PyObject *args) -{ - gboolean wrap = TRUE; - guint d; - - CHECK_OWRAP(self, "setPreviousDesktop"); - if (!PyArg_ParseTuple(args, "|i:setPreviousDesktop", &wrap)) - return NULL; - d = screen_desktop - 1; - if (d >= screen_num_desktops && wrap) - d = screen_num_desktops - 1; - if (d < screen_num_desktops) - screen_set_desktop(d); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *owrap_numDesktops(OpenboxWrap *self, PyObject *args) -{ - CHECK_OWRAP(self, "numDesktops"); - if (!PyArg_ParseTuple(args, ":numDesktops")) - return NULL; - return PyInt_FromLong(screen_num_desktops); -} - -static PyObject *owrap_setNumDesktops(OpenboxWrap *self, PyObject *args) -{ - int desktops; - - CHECK_OWRAP(self, "setNumDesktops"); - if (!PyArg_ParseTuple(args, "i:setNumDesktops", &desktops)) - return NULL; - if (desktops <= 0) { - PyErr_SetString(PyExc_ValueError, "invalid number of desktops"); - return NULL; - } - screen_set_num_desktops(desktops); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *owrap_desktopNames(OpenboxWrap *self, PyObject *args) -{ - PyObject *tuple; - int i, s; - - CHECK_OWRAP(self, "desktopNames"); - if (!PyArg_ParseTuple(args, ":desktopNames")) - return NULL; - s = screen_desktop_names->len; - tuple = PyTuple_New(s); - for (i = 0; i < s; ++i) - PyTuple_SET_ITEM(tuple, i, g_ptr_array_index(screen_desktop_names, i)); - return tuple; -} - -static PyObject *owrap_setDesktopNames(OpenboxWrap *self, PyObject *args) -{ - PyObject *seq; - int i, s; - GPtrArray *data; - - CHECK_OWRAP(self, "setDesktopNames"); - if (!PyArg_ParseTuple(args, "O:setDesktopNames", &seq)) - return NULL; - if (!PySequence_Check(seq)) - PyErr_SetString(PyExc_TypeError, "expected a sequence"); - return NULL; - - s = PySequence_Size(seq); - for (i = 0; i < s; ++i) { - PyObject *item; - gboolean check; - item = PySequence_GetItem(seq, i); /* new */ - check = PyString_Check(item); - Py_DECREF(item); - if (!check) { - PyErr_SetString(PyExc_TypeError, "expected a sequence of strings"); - return NULL; - } - } - - data = g_ptr_array_sized_new(s); - for (i = 0; i < s; ++i) { - PyObject *item; - item = PySequence_GetItem(seq, i); /* new */ - g_ptr_array_index(data, i) = PyString_AsString(item); /* borrowed */ - Py_DECREF(item); - } - - PROP_SETSA(ob_root, net_desktop_names, utf8, data); - g_ptr_array_free(data, TRUE); - - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *owrap_showingDesktop(OpenboxWrap *self, PyObject *args) -{ - CHECK_OWRAP(self, "showingDesktop"); - if (!PyArg_ParseTuple(args, ":showingDesktop")) - return NULL; - return PyInt_FromLong(!!screen_showing_desktop); -} - -static PyObject *owrap_setShowingDesktop(OpenboxWrap *self, PyObject *args) -{ - int show; - - CHECK_OWRAP(self, "setShowingDesktop"); - if (!PyArg_ParseTuple(args, "i:setShowingDesktop", &show)) - return NULL; - screen_show_desktop(show); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject *owrap_screenArea(OpenboxWrap *self, PyObject *args) -{ - int desktop; - Rect *area; - PyObject *tuple; - - CHECK_OWRAP(self, "screenArea"); - if (!PyArg_ParseTuple(args, "i:screenArea", &desktop)) - return NULL; - - area = screen_area(desktop); - if (area == NULL) { - PyErr_SetString(PyExc_ValueError, "invalid desktop"); - return NULL; - } - - tuple = PyTuple_New(4); - PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(area->x)); - PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(area->y)); - PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(area->width)); - PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(area->height)); - return tuple; -} - -static PyObject *owrap_screenStrut(OpenboxWrap *self, PyObject *args) -{ - int desktop; - Strut *strut; - PyObject *tuple; - - CHECK_OWRAP(self, "screenStrut"); - if (!PyArg_ParseTuple(args, "i:screenStrut", &desktop)) - return NULL; - - strut = screen_strut(desktop); - if (strut == NULL) { - PyErr_SetString(PyExc_ValueError, "invalid desktop"); - return NULL; - } - - tuple = PyTuple_New(4); - PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(strut->left)); - PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(strut->top)); - PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(strut->right)); - PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(strut->bottom)); - return tuple; -} - -static PyObject *owrap_physicalSize(OpenboxWrap *self, PyObject *args) -{ - PyObject *tuple; - - CHECK_OWRAP(self, "physicalSize"); - if (!PyArg_ParseTuple(args, ":physicalSize")) - return NULL; - - tuple = PyTuple_New(2); - PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(screen_physical_size.width)); - PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(screen_physical_size.height)); - return tuple; -} - -static PyObject *owrap_screenNumber(OpenboxWrap *self, PyObject *args) -{ - CHECK_OWRAP(self, "screenNumber"); - if (!PyArg_ParseTuple(args, ":screenNumber")) - return NULL; - return PyInt_FromLong(ob_screen); -} - -static PyObject *owrap_rootWindow(OpenboxWrap *self, PyObject *args) -{ - CHECK_OWRAP(self, "rootWindow"); - if (!PyArg_ParseTuple(args, ":rootWindow")) - return NULL; - return PyInt_FromLong(ob_root); -} - -static PyObject *owrap_clientList(OpenboxWrap *self, PyObject *args) -{ - CHECK_OWRAP(self, "clientList"); - if (!PyArg_ParseTuple(args, ":clientList")) - return NULL; - Py_INCREF(self->client_list); - return self->client_list; -} - -#define METH(n, d) {#n, (PyCFunction)owrap_##n, METH_VARARGS, #d} - -static PyMethodDef OpenboxWrapMethods[] = { - METH(shutdown, - "Causes Openbox to shutdown and exit."), - METH(restart, - "Causes Openbox to shutdown and restart. If path is specified, " - "Openbox will shutdown and attempt to run the specified executable " - "instead of restarting itself. If that fails, however, it will " - "restart itself."), - METH(state, - "Returns Openbox's current state, this will be one of the State " - "constants."), - METH(desktop, - "Returns the number of the currently visible desktop. This will be " - "in the range of [0, numDesktops())."), - METH(setDesktop, - "Sets the specified desktop as the visible desktop."), - METH(setNextDesktop, - "Sets the visible desktop to the next desktop, optionally wrapping " - "around when reaching the last."), - METH(setPreviousDesktop, - "Sets the visible desktop to the previous desktop, optionally " - "wrapping around when reaching the first."), - METH(numDesktops, - "Returns the number of desktops available."), - METH(desktopNames, - "Returns a tuple of names, containing a name for each desktop. The " - "tuple may have a length greater than numDesktops() if more names " - "have been specified."), - METH(setDesktopNames, - "Sets the names for the desktops."), - METH(showingDesktop, - "Returns True or False, depicting if Openbox is in 'showing the " - "desktop' mode. In 'showing the desktop' mode, all normal clients " - "are hidden and the desktop is given focus if possible."), - METH(setShowingDesktop, - "Enters or leaves 'showing the desktop' mode. See showingDesktop() " - "for a description of this mode."), - METH(screenArea, - "Returns the on-screen available area. This is the area not reserved " - "by applications' struts. Windows should be placed within this area, " - "not within the physicalSize()."), - METH(screenStrut, - "Returns the combined strut which has been reserved by all " - "applications on the desktops."), - METH(physicalSize, - "Returns the physical size of the display device (in pixels)."), - METH(screenNumber, - "Returns the number of the screen on which Openbox is running."), - METH(rootWindow, - "Return the window id of the root window."), - METH(clientList, - "Returns a all clients currently being managed by Openbox. This list " - "is updated as clients are managed and closed/destroyed/released."), - { NULL, NULL, 0, NULL } -}; - -/*************************************************************************** - - Type methods/struct - - ***************************************************************************/ - -/*static PyObject *owrap_getattr(OpenboxWrap *self, char *name) -{ - CHECK_OWRAP(self, "getattr"); - return Py_FindMethod(OpenboxWrapAttributeMethods, (PyObject*)self, name); -}*/ - -static void owrap_dealloc(OpenboxWrap *self) -{ - PyObject_Del((PyObject*) self); -} - -static PyTypeObject OpenboxWrapType = { - PyObject_HEAD_INIT(NULL) - 0, - "Openbox", - sizeof(OpenboxWrap), - 0, - (destructor) owrap_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ -}; - -/*************************************************************************** - - Define the type 'OpenboxState' - - ***************************************************************************/ - -#define IS_OSTATE(v) ((v)->ob_type == &OpenboxStateType) -#define CHECK_OSTATE(self, funcname) { \ - if (!IS_OSTATE(self)) { \ - PyErr_SetString(PyExc_TypeError, \ - "descriptor '" funcname "' requires a 'State' " \ - "object"); \ - return NULL; \ - } \ -} - -staticforward PyTypeObject OpenboxStateType; - -typedef struct OpenboxState { - PyObject_HEAD -} OpenboxState; - -static void ostate_dealloc(PyObject *self) -{ - PyObject_Del(self); -} - -static PyObject *ostate_getattr(OpenboxState *self, char *name) -{ - struct S { char *name; int val; }; - struct S s[] = { - { "Starting", State_Starting }, - { "Running", State_Running }, - { "Exiting", State_Exiting }, - { NULL, 0 } }; - int i; - - CHECK_OSTATE(self, "__getattr__"); - - for (i = 0; s[i].name != NULL; ++i) - if (!strcmp(s[i].name, name)) - return PyInt_FromLong(s[i].val); - PyErr_SetString(PyExc_AttributeError, "invalid attribute"); - return NULL; -} - -static PyTypeObject OpenboxStateType = { - PyObject_HEAD_INIT(NULL) - 0, - "State", - sizeof(OpenboxState), - 0, - (destructor) ostate_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc) ostate_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ -}; - -/*************************************************************************** - - External methods - - ***************************************************************************/ - -void openboxwrap_startup() -{ - PyObject *ob, *obdict, *state; - - OpenboxWrapType.ob_type = &PyType_Type; - OpenboxWrapType.tp_methods = OpenboxWrapMethods; - PyType_Ready(&OpenboxWrapType); - - /* get the ob module/dict */ - ob = PyImport_ImportModule("ob"); /* new */ - g_assert(ob != NULL); - obdict = PyModule_GetDict(ob); /* borrowed */ - g_assert(obdict != NULL); - - /* add an Openbox instance to the ob module */ - openboxwrap_obj = PyObject_New(OpenboxWrap, &OpenboxWrapType); - openboxwrap_obj->client_list = PyList_New(0); - - PyDict_SetItemString(obdict, "Openbox", (PyObject*) openboxwrap_obj); - - /* add an instance of OpenboxState */ - state = (PyObject*) PyObject_New(OpenboxState, &OpenboxStateType); - PyDict_SetItemString(obdict, "State", state); - Py_DECREF(state); - - Py_DECREF(ob); -} - -void openboxwrap_shutdown() -{ - Py_DECREF(openboxwrap_obj->client_list); - Py_DECREF(openboxwrap_obj); -} diff --git a/openbox/openboxwrap.h b/openbox/openboxwrap.h deleted file mode 100644 index 8e54f2d5..00000000 --- a/openbox/openboxwrap.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __openboxwrap_h -#define __openboxwrap_h - -#include - -/* OpenboxWrap is a PyObject */ -typedef struct OpenboxWrap { - PyObject_HEAD - PyObject *client_list; -} OpenboxWrap; - -OpenboxWrap *openboxwrap_obj; - -void openboxwrap_startup(); -void openboxwrap_shutdown(); - -#endif diff --git a/openbox/python.c b/openbox/python.c deleted file mode 100644 index 52f19f3f..00000000 --- a/openbox/python.c +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include - -static PyMethodDef ObMethods[] = { - { NULL, NULL, 0, NULL } -}; - -static PyMethodDef InputMethods[] = { - { NULL, NULL, 0, NULL } -}; - -void python_startup() -{ - PyObject *sys, *sysdict, *syspath, *path1, *path2; - char *homescriptdir; - - Py_Initialize(); - - /* fix up the system path */ - - sys = PyImport_ImportModule("sys"); /* new */ - sysdict = PyModule_GetDict(sys); /* borrowed */ - syspath = PyDict_GetItemString(sysdict, "path"); /* borrowed */ - - path1 = PyString_FromString(SCRIPTDIR); /* new */ - PyList_Insert(syspath, 0, path1); - Py_DECREF(path1); - - homescriptdir = g_build_filename(g_get_home_dir(), ".openbox", NULL); - path2 = PyString_FromString(homescriptdir); /* new */ - PyList_Insert(syspath, 0, path2); - Py_DECREF(path2); - g_free(homescriptdir); - - Py_DECREF(sys); - - /* create the 'ob' module */ - Py_InitModule("ob", ObMethods); - - /* create the 'input' module */ - Py_InitModule("input", InputMethods); -} - -void python_shutdown() -{ - Py_Finalize(); -} - -gboolean python_import(char *module) -{ - PyObject *mod; - - mod = PyImport_ImportModule(module); /* new */ - if (mod == NULL) { - PyErr_Print(); - return FALSE; - } - Py_DECREF(mod); - return TRUE; -} diff --git a/openbox/python.h b/openbox/python.h deleted file mode 100644 index 90366315..00000000 --- a/openbox/python.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __python_h -#define __python_h - -void python_startup(); -void python_shutdown(); - -/*! Import a python module */ -gboolean python_import(char *module); - -#endif -- 2.39.2