all repos — openbox @ 700984bd150d98a6876c117c2e1b1b3c72cffce1

openbox fork - make it a bit more like ryudo

src/python_client.cc (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-

#ifdef HAVE_CONFIG_H
# include "../config.h"
#endif

#include "python_client.hh"
#include "openbox.hh"

namespace ob {

extern "C" {

PyObject *get_client_dict(PyObject* self, PyObject* args)
{
  if (!PyArg_ParseTuple(args, ":get_client_dict"))
    return NULL;
  return PyDictProxy_New(Openbox::instance->pyclients());
}



PyObject *getWindow(PyObject* self, PyObject* args)
{
  if (!PyArg_ParseTuple(args, ":getWindow"))
    return NULL;
  return PyLong_FromLong(((PyClientObject*)self)->window);
}



static PyMethodDef attr_methods[] = {
  {"getWindow", getWindow, METH_VARARGS,
   "Return the window id."},
  {NULL, NULL, 0, NULL}           /* sentinel */
};

static PyObject *getattr(PyObject *obj, char *name)
{
  return Py_FindMethod(attr_methods, obj, name);
}



static void client_dealloc(PyObject* self)
{
  PyObject_Del(self);
}

PyTypeObject PyClient_Type = {
  PyObject_HEAD_INIT(NULL)
  0,
  "Client",
  sizeof(PyClientObject),
  0,
  client_dealloc, /*tp_dealloc*/
  0,          /*tp_print*/
  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 */
};

}
}