update to cleaned up otk api
This commit is contained in:
parent
06de24ec66
commit
68194ce957
10 changed files with 71 additions and 93 deletions
|
@ -17,7 +17,7 @@ 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 python_client.cc
|
||||
buttonwidget.cc python.cc
|
||||
|
||||
MAINTAINERCLEANFILES= Makefile.in
|
||||
|
||||
|
|
|
@ -22,11 +22,14 @@ extern "C" {
|
|||
#include "otk/rect.hh"
|
||||
#include "otk/eventhandler.hh"
|
||||
#include "widget.hh"
|
||||
#include "python.hh"
|
||||
|
||||
namespace ob {
|
||||
|
||||
class OBFrame;
|
||||
|
||||
extern PyTypeObject OBClient_Type;
|
||||
|
||||
//! Maintains the state of a client window.
|
||||
/*!
|
||||
OBClient maintains the state of a client window. The state consists of the
|
||||
|
@ -40,6 +43,7 @@ class OBFrame;
|
|||
change (such as causing a redraw of the titlebar after the title is changed).
|
||||
*/
|
||||
class OBClient : public otk::OtkEventHandler, public OBWidget {
|
||||
PyObject_HEAD
|
||||
public:
|
||||
|
||||
//! The frame window which decorates around the client window
|
||||
|
|
40
src/frame.cc
40
src/frame.cc
|
@ -41,7 +41,7 @@ OBFrame::OBFrame(OBClient *client, otk::Style *style)
|
|||
assert(client);
|
||||
assert(style);
|
||||
|
||||
XSelectInput(otk::OBDisplay::display, getWindow(), OBFrame::event_mask);
|
||||
XSelectInput(otk::OBDisplay::display, window(), OBFrame::event_mask);
|
||||
|
||||
unmanaged();
|
||||
_titlebar.unmanaged();
|
||||
|
@ -98,7 +98,7 @@ void OBFrame::setStyle(otk::Style *style)
|
|||
_style = style;
|
||||
|
||||
// XXX: change when focus changes!
|
||||
XSetWindowBorder(otk::OBDisplay::display, getWindow(),
|
||||
XSetWindowBorder(otk::OBDisplay::display, window(),
|
||||
_style->getBorderColor()->pixel());
|
||||
|
||||
// if !replace, then adjust() will get called after the client is grabbed!
|
||||
|
@ -191,23 +191,23 @@ void OBFrame::adjustSize()
|
|||
for (int i = 0, len = layout.size(); i < len; ++i) {
|
||||
switch (layout[i]) {
|
||||
case 'I':
|
||||
_button_iconify.move(x, _button_iconify.getRect().y());
|
||||
_button_iconify.move(x, _button_iconify.rect().y());
|
||||
x += _button_iconify.width();
|
||||
break;
|
||||
case 'L':
|
||||
_label.move(x, _label.getRect().y());
|
||||
_label.move(x, _label.rect().y());
|
||||
x += _label.width();
|
||||
break;
|
||||
case 'M':
|
||||
_button_max.move(x, _button_max.getRect().y());
|
||||
_button_max.move(x, _button_max.rect().y());
|
||||
x += _button_max.width();
|
||||
break;
|
||||
case 'S':
|
||||
_button_stick.move(x, _button_stick.getRect().y());
|
||||
_button_stick.move(x, _button_stick.rect().y());
|
||||
x += _button_stick.width();
|
||||
break;
|
||||
case 'C':
|
||||
_button_close.move(x, _button_close.getRect().y());
|
||||
_button_close.move(x, _button_close.rect().y());
|
||||
x += _button_close.width();
|
||||
break;
|
||||
default:
|
||||
|
@ -227,7 +227,7 @@ void OBFrame::adjustSize()
|
|||
// the 'buttons size' since theyre all the same
|
||||
_button_iconify.width() * 2,
|
||||
_handle.height());
|
||||
_grip_right.setGeometry(((_handle.getRect().right() + 1) -
|
||||
_grip_right.setGeometry(((_handle.rect().right() + 1) -
|
||||
_button_iconify.width() * 2),
|
||||
-bwidth,
|
||||
// XXX: get a Point class in otk and use that for
|
||||
|
@ -304,13 +304,13 @@ void OBFrame::adjustShape()
|
|||
|
||||
if (!_client->shaped()) {
|
||||
// clear the shape on the frame window
|
||||
XShapeCombineMask(otk::OBDisplay::display, getWindow(), ShapeBounding,
|
||||
XShapeCombineMask(otk::OBDisplay::display, window(), ShapeBounding,
|
||||
_innersize.left,
|
||||
_innersize.top,
|
||||
None, ShapeSet);
|
||||
} else {
|
||||
// make the frame's shape match the clients
|
||||
XShapeCombineShape(otk::OBDisplay::display, getWindow(), ShapeBounding,
|
||||
XShapeCombineShape(otk::OBDisplay::display, window(), ShapeBounding,
|
||||
_innersize.left,
|
||||
_innersize.top,
|
||||
_client->window(), ShapeBounding, ShapeSet);
|
||||
|
@ -319,22 +319,22 @@ void OBFrame::adjustShape()
|
|||
XRectangle xrect[2];
|
||||
|
||||
if (_decorations & OBClient::Decor_Titlebar) {
|
||||
xrect[0].x = _titlebar.getRect().x();
|
||||
xrect[0].y = _titlebar.getRect().y();
|
||||
xrect[0].x = _titlebar.rect().x();
|
||||
xrect[0].y = _titlebar.rect().y();
|
||||
xrect[0].width = _titlebar.width() + bwidth * 2; // XXX: this is useless once the widget handles borders!
|
||||
xrect[0].height = _titlebar.height() + bwidth * 2;
|
||||
++num;
|
||||
}
|
||||
|
||||
if (_decorations & OBClient::Decor_Handle) {
|
||||
xrect[1].x = _handle.getRect().x();
|
||||
xrect[1].y = _handle.getRect().y();
|
||||
xrect[1].x = _handle.rect().x();
|
||||
xrect[1].y = _handle.rect().y();
|
||||
xrect[1].width = _handle.width() + bwidth * 2; // XXX: this is useless once the widget handles borders!
|
||||
xrect[1].height = _handle.height() + bwidth * 2;
|
||||
++num;
|
||||
}
|
||||
|
||||
XShapeCombineRectangles(otk::OBDisplay::display, getWindow(),
|
||||
XShapeCombineRectangles(otk::OBDisplay::display, window(),
|
||||
ShapeBounding, 0, 0, xrect, num,
|
||||
ShapeUnion, Unsorted);
|
||||
}
|
||||
|
@ -347,11 +347,11 @@ void OBFrame::grabClient()
|
|||
|
||||
// reparent the client to the frame
|
||||
XReparentWindow(otk::OBDisplay::display, _client->window(),
|
||||
_plate.getWindow(), 0, 0);
|
||||
_plate.window(), 0, 0);
|
||||
_client->ignore_unmaps++;
|
||||
|
||||
// select the event mask on the client's parent (to receive config req's)
|
||||
XSelectInput(otk::OBDisplay::display, _plate.getWindow(),
|
||||
XSelectInput(otk::OBDisplay::display, _plate.window(),
|
||||
SubstructureRedirectMask);
|
||||
|
||||
// map the client so it maps when the frame does
|
||||
|
@ -374,7 +374,7 @@ void OBFrame::releaseClient(bool remap)
|
|||
// according to the ICCCM - if the client doesn't reparent to
|
||||
// root, then we have to do it for them
|
||||
XReparentWindow(otk::OBDisplay::display, _client->window(),
|
||||
_screen->getRootWindow(),
|
||||
_screen->rootWindow(),
|
||||
_client->area().x(), _client->area().y());
|
||||
}
|
||||
|
||||
|
@ -445,8 +445,8 @@ void OBFrame::clientGravity(int &x, int &y)
|
|||
|
||||
void OBFrame::frameGravity(int &x, int &y)
|
||||
{
|
||||
x = getRect().x();
|
||||
y = getRect().y();
|
||||
x = rect().x();
|
||||
y = rect().y();
|
||||
|
||||
// horizontal
|
||||
switch (_client->gravity()) {
|
||||
|
|
20
src/frame.hh
20
src/frame.hh
|
@ -113,25 +113,25 @@ public:
|
|||
void frameGravity(int &x, int &y);
|
||||
|
||||
//! Gets the window id of the frame's "plate" subelement
|
||||
inline Window plate() const { return _plate.getWindow(); }
|
||||
inline Window plate() const { return _plate.window(); }
|
||||
//! Gets the window id of the frame's "titlebar" subelement
|
||||
inline Window titlebar() const { return _titlebar.getWindow(); }
|
||||
inline Window titlebar() const { return _titlebar.window(); }
|
||||
//! Gets the window id of the frame's "label" subelement
|
||||
inline Window label() const { return _label.getWindow(); }
|
||||
inline Window label() const { return _label.window(); }
|
||||
//! Gets the window id of the frame's "close button" subelement
|
||||
inline Window button_close() const { return _button_close.getWindow(); }
|
||||
inline Window button_close() const { return _button_close.window(); }
|
||||
//! Gets the window id of the frame's "iconify button" subelement
|
||||
inline Window button_iconify() const { return _button_iconify.getWindow(); }
|
||||
inline Window button_iconify() const { return _button_iconify.window(); }
|
||||
//! Gets the window id of the frame's "maximize button" subelement
|
||||
inline Window button_max() const { return _button_max.getWindow(); }
|
||||
inline Window button_max() const { return _button_max.window(); }
|
||||
//! Gets the window id of the frame's "sticky button" subelement
|
||||
inline Window button_stick() const { return _button_stick.getWindow(); }
|
||||
inline Window button_stick() const { return _button_stick.window(); }
|
||||
//! Gets the window id of the frame's "handle" subelement
|
||||
inline Window handle() const { return _handle.getWindow(); }
|
||||
inline Window handle() const { return _handle.window(); }
|
||||
//! Gets the window id of the frame's "left grip" subelement
|
||||
inline Window grip_left() const { return _grip_left.getWindow(); }
|
||||
inline Window grip_left() const { return _grip_left.window(); }
|
||||
//! Gets the window id of the frame's "right grip" subelement
|
||||
inline Window grip_right() const { return _grip_right.getWindow(); }
|
||||
inline Window grip_right() const { return _grip_right.window(); }
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "client.hh"
|
||||
#include "screen.hh"
|
||||
#include "actions.hh"
|
||||
#include "python_client.hh"
|
||||
#include "otk/property.hh"
|
||||
#include "otk/display.hh"
|
||||
#include "otk/assassin.hh"
|
||||
|
@ -91,8 +90,8 @@ Openbox::Openbox(int argc, char **argv)
|
|||
_doshutdown = false;
|
||||
_rcfilepath = otk::expandTilde("~/.openbox/rc3");
|
||||
|
||||
_pyclients = (PyDictObject*) PyDict_New();
|
||||
assert(_pyclients);
|
||||
_clients = (PyDictObject*) PyDict_New();
|
||||
assert(_clients);
|
||||
|
||||
parseCommandLine(argc, argv);
|
||||
|
||||
|
@ -276,35 +275,25 @@ void Openbox::eventLoop()
|
|||
|
||||
void Openbox::addClient(Window window, OBClient *client)
|
||||
{
|
||||
_clients[window] = client;
|
||||
|
||||
// maintain the python list here too
|
||||
PyClientObject* pyclient = PyObject_New(PyClientObject, &PyClient_Type);
|
||||
pyclient->window = window;
|
||||
pyclient->client = client;
|
||||
PyDict_SetItem((PyObject*)_pyclients, PyLong_FromLong(window),
|
||||
(PyObject*)pyclient);
|
||||
PyDict_SetItem((PyObject*)_clients, PyLong_FromLong(window),
|
||||
(PyObject*)client);
|
||||
}
|
||||
|
||||
|
||||
void Openbox::removeClient(Window window)
|
||||
{
|
||||
_clients.erase(window);
|
||||
PyDict_DelItem((PyObject*)_clients, PyLong_FromLong(window));
|
||||
}
|
||||
|
||||
|
||||
OBClient *Openbox::findClient(Window window)
|
||||
{
|
||||
/*
|
||||
NOTE: we dont use _clients[] to find the value because that will insert
|
||||
a new null into the hash, which really sucks when we want to clean up the
|
||||
hash at shutdown!
|
||||
*/
|
||||
ClientMap::iterator it = _clients.find(window);
|
||||
if (it != _clients.end())
|
||||
return it->second;
|
||||
else
|
||||
return (OBClient*) 0;
|
||||
PyClientObject *client = PyDist_GetItem((PyObject*)_clients,
|
||||
PyLong_FromLong(window));
|
||||
if (client)
|
||||
return client->client;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ extern "C" {
|
|||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "python.hh"
|
||||
#include "otk/screeninfo.hh"
|
||||
|
@ -69,9 +68,6 @@ public:
|
|||
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;
|
||||
|
||||
//! A list of OBScreen classes
|
||||
typedef std::vector<OBScreen *> ScreenList;
|
||||
|
||||
|
@ -93,8 +89,7 @@ private:
|
|||
char *_argv0;
|
||||
|
||||
//! A list of all managed clients
|
||||
ClientMap _clients;
|
||||
PyDictObject *_pyclients;
|
||||
PyDictObject *_clients;
|
||||
|
||||
//! A list of all the managed screens
|
||||
ScreenList _screens;
|
||||
|
@ -171,7 +166,7 @@ public:
|
|||
//! Returns the mouse cursors used throughout Openbox
|
||||
inline const Cursors &cursors() const { return _cursors; }
|
||||
|
||||
inline PyDictObject *pyclients() const { return _pyclients; }
|
||||
inline PyDictObject *clients() const { return _clients; }
|
||||
|
||||
//! The main function of the Openbox class
|
||||
/*!
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#endif
|
||||
|
||||
#include "python.hh"
|
||||
#include "python_client.hh"
|
||||
#include "client.hh"
|
||||
#include "openbox.hh"
|
||||
|
||||
namespace ob {
|
||||
|
@ -28,8 +28,8 @@ static PyMethodDef OBMethods[] = {
|
|||
{"shit", shit, METH_VARARGS,
|
||||
"Do some shit, yo!"},
|
||||
|
||||
{"get_client_dict", get_client_dict, METH_VARARGS,
|
||||
"Get the list of all clients"},
|
||||
/* {"get_client_dict", get_client_dict, METH_VARARGS,
|
||||
"Get the list of all clients"},*/
|
||||
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
|
|
@ -11,26 +11,17 @@ namespace ob {
|
|||
|
||||
extern "C" {
|
||||
|
||||
PyObject *get_client_dict(PyObject* self, PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ":get_client_dict"))
|
||||
return NULL;
|
||||
return PyDictProxy_New((PyObject*)Openbox::instance->pyclients());
|
||||
}
|
||||
|
||||
|
||||
|
||||
PyObject *getWindow(PyObject* self, PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ":getWindow"))
|
||||
return NULL;
|
||||
return PyLong_FromLong(((PyClientObject*)self)->window);
|
||||
return PyLong_FromLong(((PyClientObject*)self)->client->window());
|
||||
}
|
||||
|
||||
|
||||
|
||||
static PyMethodDef attr_methods[] = {
|
||||
{"getWindow", getWindow, METH_VARARGS,
|
||||
{"getWindow", (PyCFunction)getWindow, METH_VARARGS,
|
||||
"Return the window id."},
|
||||
{NULL, NULL, 0, NULL} /* sentinel */
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@ OBRootWindow::OBRootWindow(int screen)
|
|||
{
|
||||
updateDesktopNames();
|
||||
|
||||
Openbox::instance->registerHandler(_info->getRootWindow(), this);
|
||||
Openbox::instance->registerHandler(_info->rootWindow(), this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -34,7 +34,7 @@ void OBRootWindow::updateDesktopNames()
|
|||
|
||||
unsigned long num = (unsigned) -1;
|
||||
|
||||
if (!property->get(_info->getRootWindow(),
|
||||
if (!property->get(_info->rootWindow(),
|
||||
otk::OBProperty::net_desktop_names,
|
||||
otk::OBProperty::utf8, &num, &_names))
|
||||
_names.clear();
|
||||
|
@ -88,7 +88,7 @@ void OBRootWindow::setDesktopName(int i, const std::string &name)
|
|||
|
||||
otk::OBProperty::StringVect newnames = _names;
|
||||
newnames[i] = name;
|
||||
property->set(_info->getRootWindow(), otk::OBProperty::net_desktop_names,
|
||||
property->set(_info->rootWindow(), otk::OBProperty::net_desktop_names,
|
||||
otk::OBProperty::utf8, newnames);
|
||||
}
|
||||
|
||||
|
@ -104,8 +104,7 @@ void OBRootWindow::mapRequestHandler(const XMapRequestEvent &e)
|
|||
if (client) {
|
||||
// XXX: uniconify and/or unshade the window
|
||||
} else {
|
||||
Openbox::instance->screen(_info->getScreenNumber())->
|
||||
manageWindow(e.window);
|
||||
Openbox::instance->screen(_info->screen())->manageWindow(e.window);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ OBScreen::OBScreen(int screen, const otk::Configuration &config)
|
|||
|
||||
::running = false;
|
||||
XErrorHandler old = XSetErrorHandler(::anotherWMRunning);
|
||||
XSelectInput(otk::OBDisplay::display, _info->getRootWindow(),
|
||||
XSelectInput(otk::OBDisplay::display, _info->rootWindow(),
|
||||
OBScreen::event_mask);
|
||||
XSync(otk::OBDisplay::display, false);
|
||||
XSetErrorHandler(old);
|
||||
|
@ -54,15 +54,15 @@ OBScreen::OBScreen(int screen, const otk::Configuration &config)
|
|||
if (! _managed) return; // was unable to manage the screen
|
||||
|
||||
printf(_("Managing screen %d: visual 0x%lx, depth %d\n"),
|
||||
_number, XVisualIDFromVisual(_info->getVisual()), _info->getDepth());
|
||||
_number, XVisualIDFromVisual(_info->visual()), _info->depth());
|
||||
|
||||
Openbox::instance->property()->set(_info->getRootWindow(),
|
||||
Openbox::instance->property()->set(_info->rootWindow(),
|
||||
otk::OBProperty::openbox_pid,
|
||||
otk::OBProperty::Atom_Cardinal,
|
||||
(unsigned long) getpid());
|
||||
|
||||
// set the mouse cursor for the root window (the default cursor)
|
||||
XDefineCursor(otk::OBDisplay::display, _info->getRootWindow(),
|
||||
XDefineCursor(otk::OBDisplay::display, _info->rootWindow(),
|
||||
Openbox::instance->cursors().session);
|
||||
|
||||
// initialize the shit that is used for all drawing on the screen
|
||||
|
@ -77,14 +77,14 @@ OBScreen::OBScreen(int screen, const otk::Configuration &config)
|
|||
|
||||
|
||||
// Set the netwm atoms for geomtery and viewport
|
||||
unsigned long geometry[] = { _info->getWidth(),
|
||||
_info->getHeight() };
|
||||
Openbox::instance->property()->set(_info->getRootWindow(),
|
||||
unsigned long geometry[] = { _info->width(),
|
||||
_info->height() };
|
||||
Openbox::instance->property()->set(_info->rootWindow(),
|
||||
otk::OBProperty::net_desktop_geometry,
|
||||
otk::OBProperty::Atom_Cardinal,
|
||||
geometry, 2);
|
||||
unsigned long viewport[] = { 0, 0 };
|
||||
Openbox::instance->property()->set(_info->getRootWindow(),
|
||||
Openbox::instance->property()->set(_info->rootWindow(),
|
||||
otk::OBProperty::net_desktop_viewport,
|
||||
otk::OBProperty::Atom_Cardinal,
|
||||
viewport, 2);
|
||||
|
@ -112,7 +112,7 @@ void OBScreen::manageExisting()
|
|||
{
|
||||
unsigned int i, j, nchild;
|
||||
Window r, p, *children;
|
||||
XQueryTree(otk::OBDisplay::display, _info->getRootWindow(), &r, &p,
|
||||
XQueryTree(otk::OBDisplay::display, _info->rootWindow(), &r, &p,
|
||||
&children, &nchild);
|
||||
|
||||
// preen the window list of all icon windows... for better dockapp support
|
||||
|
@ -205,8 +205,8 @@ void OBScreen::calcArea()
|
|||
}
|
||||
|
||||
_area.setRect(current_left, current_top,
|
||||
_info->getWidth() - (current_left + current_right),
|
||||
_info->getHeight() - (current_top + current_bottom));
|
||||
_info->width() - (current_left + current_right),
|
||||
_info->height() - (current_top + current_bottom));
|
||||
|
||||
/*
|
||||
#ifdef XINERAMA
|
||||
|
@ -255,7 +255,7 @@ void OBScreen::setClientList()
|
|||
} else
|
||||
windows = (Window*) 0;
|
||||
|
||||
Openbox::instance->property()->set(_info->getRootWindow(),
|
||||
Openbox::instance->property()->set(_info->rootWindow(),
|
||||
otk::OBProperty::net_client_list,
|
||||
otk::OBProperty::Atom_Window,
|
||||
windows, _clients.size());
|
||||
|
@ -288,7 +288,7 @@ void OBScreen::setStackingList()
|
|||
void OBScreen::setWorkArea() {
|
||||
unsigned long area[] = { _area.x(), _area.y(),
|
||||
_area.width(), _area.height() };
|
||||
Openbox::instance->property()->set(_info->getRootWindow(),
|
||||
Openbox::instance->property()->set(_info->rootWindow(),
|
||||
otk::OBProperty::net_workarea,
|
||||
otk::OBProperty::Atom_Cardinal,
|
||||
area, 4);
|
||||
|
@ -369,7 +369,7 @@ void OBScreen::manageWindow(Window window)
|
|||
client->frame = new OBFrame(client, &_style);
|
||||
|
||||
// add to the wm's map
|
||||
Openbox::instance->addClient(client->frame->getWindow(), client);
|
||||
Openbox::instance->addClient(client->frame->window(), client);
|
||||
Openbox::instance->addClient(client->frame->plate(), client);
|
||||
Openbox::instance->addClient(client->frame->titlebar(), client);
|
||||
Openbox::instance->addClient(client->frame->label(), client);
|
||||
|
@ -403,7 +403,7 @@ void OBScreen::unmanageWindow(OBClient *client)
|
|||
|
||||
// remove from the wm's map
|
||||
Openbox::instance->removeClient(client->window());
|
||||
Openbox::instance->removeClient(frame->getWindow());
|
||||
Openbox::instance->removeClient(frame->window());
|
||||
Openbox::instance->removeClient(frame->plate());
|
||||
Openbox::instance->removeClient(frame->titlebar());
|
||||
Openbox::instance->removeClient(frame->label());
|
||||
|
|
Loading…
Reference in a new issue