From: Dana Jansens Date: Mon, 13 Jan 2003 08:13:58 +0000 (+0000) Subject: move the Openbox::instance pointer to simply "openbox". X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=9e77a88d269bfafb78e56a646bfacebdd6ff4c5a;p=chaz%2Fopenbox move the Openbox::instance pointer to simply "openbox". --- diff --git a/src/actions.cc b/src/actions.cc index 73f6317b..c3675cc3 100644 --- a/src/actions.cc +++ b/src/actions.cc @@ -45,7 +45,7 @@ void Actions::insertPress(const XButtonEvent &e) a->button = e.button; a->pos.setPoint(e.x_root, e.y_root); - Client *c = Openbox::instance->findClient(e.window); + Client *c = openbox->findClient(e.window); if (c) a->clientarea = c->area(); } @@ -73,21 +73,21 @@ void Actions::buttonPressHandler(const XButtonEvent &e) // run the PRESS python hook WidgetBase *w = dynamic_cast - (Openbox::instance->findHandler(e.window)); + (openbox->findHandler(e.window)); assert(w); // everything should be a widget // kill off the Button1Mask etc, only want the modifiers unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask); int screen; - Client *c = Openbox::instance->findClient(e.window); + Client *c = openbox->findClient(e.window); if (c) screen = c->screen(); else screen = otk::Display::findScreen(e.root)->screen(); MouseData data(screen, c, e.time, state, e.button, w->mcontext(), MousePress); - Openbox::instance->bindings()->fireButton(&data); + openbox->bindings()->fireButton(&data); if (_button) return; // won't count toward CLICK events @@ -112,7 +112,7 @@ void Actions::buttonReleaseHandler(const XButtonEvent &e) removePress(e); WidgetBase *w = dynamic_cast - (Openbox::instance->findHandler(e.window)); + (openbox->findHandler(e.window)); assert(w); // everything should be a widget // not for the button we're watching? @@ -134,14 +134,14 @@ void Actions::buttonReleaseHandler(const XButtonEvent &e) unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask); int screen; - Client *c = Openbox::instance->findClient(e.window); + Client *c = openbox->findClient(e.window); if (c) screen = c->screen(); else screen = otk::Display::findScreen(e.root)->screen(); MouseData data(screen, c, e.time, state, e.button, w->mcontext(), MouseClick); - Openbox::instance->bindings()->fireButton(&data); + openbox->bindings()->fireButton(&data); // XXX: dont load this every time!!@* @@ -154,7 +154,7 @@ void Actions::buttonReleaseHandler(const XButtonEvent &e) // run the DOUBLECLICK python hook data.action = MouseDoubleClick; - Openbox::instance->bindings()->fireButton(&data); + openbox->bindings()->fireButton(&data); // reset so you cant triple click for 2 doubleclicks _release.win = 0; @@ -175,13 +175,13 @@ void Actions::enterHandler(const XCrossingEvent &e) // run the ENTER python hook int screen; - Client *c = Openbox::instance->findClient(e.window); + Client *c = openbox->findClient(e.window); if (c) screen = c->screen(); else screen = otk::Display::findScreen(e.root)->screen(); EventData data(screen, c, EventEnterWindow, e.state); - Openbox::instance->bindings()->fireEvent(&data); + openbox->bindings()->fireEvent(&data); } @@ -191,13 +191,13 @@ void Actions::leaveHandler(const XCrossingEvent &e) // run the LEAVE python hook int screen; - Client *c = Openbox::instance->findClient(e.window); + Client *c = openbox->findClient(e.window); if (c) screen = c->screen(); else screen = otk::Display::findScreen(e.root)->screen(); EventData data(screen, c, EventLeaveWindow, e.state); - Openbox::instance->bindings()->fireEvent(&data); + openbox->bindings()->fireEvent(&data); } @@ -208,7 +208,7 @@ void Actions::keyPressHandler(const XKeyEvent &e) // kill off the Button1Mask etc, only want the modifiers unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask); - Openbox::instance->bindings()-> + openbox->bindings()-> fireKey(otk::Display::findScreen(e.root)->screen(), state, e.keycode, e.time); } @@ -235,7 +235,7 @@ void Actions::motionHandler(const XMotionEvent &e) } WidgetBase *w = dynamic_cast - (Openbox::instance->findHandler(e.window)); + (openbox->findHandler(e.window)); assert(w); // everything should be a widget // run the MOTION python hook @@ -244,14 +244,14 @@ void Actions::motionHandler(const XMotionEvent &e) Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask); unsigned int button = _posqueue[0]->button; int screen; - Client *c = Openbox::instance->findClient(e.window); + Client *c = openbox->findClient(e.window); if (c) screen = c->screen(); else screen = otk::Display::findScreen(e.root)->screen(); MouseData data(screen, c, e.time, state, button, w->mcontext(), MouseMotion, x_root, y_root, _posqueue[0]->pos, _posqueue[0]->clientarea); - Openbox::instance->bindings()->fireButton(&data); + openbox->bindings()->fireButton(&data); } void Actions::mapRequestHandler(const XMapRequestEvent &e) @@ -283,13 +283,13 @@ void Actions::xkbHandler(const XkbEvent &e) switch (((XkbAnyEvent*)&e)->xkb_type) { case XkbBellNotify: w = ((XkbBellNotifyEvent*)&e)->window; - Client *c = Openbox::instance->findClient(w); + Client *c = openbox->findClient(w); if (c) screen = c->screen(); else - screen = Openbox::instance->focusedScreen()->number(); + screen = openbox->focusedScreen()->number(); EventData data(screen, c, EventBell, 0); - Openbox::instance->bindings()->fireEvent(&data); + openbox->bindings()->fireEvent(&data); break; } } diff --git a/src/bindings.cc b/src/bindings.cc index a8dfaed0..253e1383 100644 --- a/src/bindings.cc +++ b/src/bindings.cc @@ -145,7 +145,7 @@ KeyBindingTree *Bindings::buildtree(const StringVect &keylist, Bindings::Bindings() : _curpos(&_keytree), _resetkey(0,0), - _timer(Openbox::instance->timerManager(), + _timer(openbox->timerManager(), (otk::TimeoutHandler)resetChains, this) { _timer.setTimeout(5000); // chains reset after 5 seconds @@ -341,7 +341,7 @@ void Bindings::removeAllKeys() void Bindings::grabKeys(bool grab) { - for (int i = 0; i < Openbox::instance->screenCount(); ++i) { + for (int i = 0; i < openbox->screenCount(); ++i) { Window root = otk::Display::screenInfo(i)->rootWindow(); KeyBindingTree *p = _curpos->first_child; @@ -387,7 +387,7 @@ void Bindings::fireKey(int screen, unsigned int modifiers, unsigned int key, grabKeys(true); otk::Display::ungrab(); } else { - Client *c = Openbox::instance->focusedClient(); + Client *c = openbox->focusedClient(); KeyData data(screen, c, time, modifiers, key); CallbackList::iterator it, end = p->callbacks.end(); for (it = p->callbacks.begin(); it != end; ++it) @@ -440,8 +440,8 @@ bool Bindings::addButton(const std::string &but, MouseContext context, bind->binding.modifiers = b.modifiers; _buttons[context].push_back(bind); // grab the button on all clients - for (int sn = 0; sn < Openbox::instance->screenCount(); ++sn) { - Screen *s = Openbox::instance->screen(sn); + for (int sn = 0; sn < openbox->screenCount(); ++sn) { + Screen *s = openbox->screen(sn); Client::List::iterator c_it, c_end = s->clients.end(); for (c_it = s->clients.begin(); c_it != c_end; ++c_it) { grabButton(true, bind->binding, context, *c_it); @@ -466,8 +466,8 @@ void Bindings::removeAllButtons() } } // ungrab the button on all clients - for (int sn = 0; sn < Openbox::instance->screenCount(); ++sn) { - Screen *s = Openbox::instance->screen(sn); + for (int sn = 0; sn < openbox->screenCount(); ++sn) { + Screen *s = openbox->screen(sn); Client::List::iterator c_it, c_end = s->clients.end(); for (c_it = s->clients.begin(); c_it != c_end; ++c_it) { grabButton(false, (*it)->binding, (MouseContext)i, *c_it); diff --git a/src/client.cc b/src/client.cc index cdef1f94..231992f1 100644 --- a/src/client.cc +++ b/src/client.cc @@ -72,7 +72,7 @@ Client::Client(int screen, Window window) Client::~Client() { - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); // clean up childrens' references while (!_transients.empty()) { @@ -84,7 +84,7 @@ Client::~Client() if (_transient_for) _transient_for->_transients.remove(this); // remove from old parent - if (Openbox::instance->state() != Openbox::State_Exiting) { + if (openbox->state() != Openbox::State_Exiting) { // these values should not be persisted across a window unmapping/mapping property->erase(_window, otk::Property::net_wm_desktop); property->erase(_window, otk::Property::net_wm_state); @@ -94,16 +94,16 @@ Client::~Client() void Client::getDesktop() { - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); // defaults to the current desktop - _desktop = Openbox::instance->screen(_screen)->desktop(); + _desktop = openbox->screen(_screen)->desktop(); if (!property->get(_window, otk::Property::net_wm_desktop, otk::Property::Atom_Cardinal, (long unsigned*)&_desktop)) { // make sure the hint exists - Openbox::instance->property()->set(_window, + openbox->property()->set(_window, otk::Property::net_wm_desktop, otk::Property::Atom_Cardinal, (unsigned)_desktop); @@ -113,7 +113,7 @@ void Client::getDesktop() void Client::getType() { - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); _type = (WindowType) -1; @@ -245,7 +245,7 @@ void Client::setupDecorAndFunctions() void Client::getMwmHints() { - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); unsigned long num = MwmHints::elements; unsigned long *hints; @@ -283,7 +283,7 @@ void Client::getArea() void Client::getState() { - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); _modal = _shaded = _max_horz = _max_vert = _fullscreen = _above = _below = _skip_taskbar = _skip_pager = false; @@ -368,7 +368,7 @@ void Client::calcLayer() { if we don't have a frame, then we aren't mapped yet (and this would SIGSEGV :) */ - Openbox::instance->screen(_screen)->restack(true, this); // raise + openbox->screen(_screen)->restack(true, this); // raise } } } @@ -376,7 +376,7 @@ void Client::calcLayer() { void Client::updateProtocols() { - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); Atom *proto; int num_return = 0; @@ -480,7 +480,7 @@ void Client::updateWMHints() void Client::updateTitle() { - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); _title = ""; @@ -502,7 +502,7 @@ void Client::updateTitle() void Client::updateIconTitle() { - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); _icon_title = ""; @@ -521,7 +521,7 @@ void Client::updateIconTitle() void Client::updateClass() { - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); // set the defaults _app_name = _app_class = _role = ""; @@ -548,7 +548,7 @@ void Client::updateStrut() { unsigned long num = 4; unsigned long *data; - if (!Openbox::instance->property()->get(_window, + if (!openbox->property()->get(_window, otk::Property::net_wm_strut, otk::Property::Atom_Cardinal, &num, &data)) @@ -560,7 +560,7 @@ void Client::updateStrut() _strut.top = data[2]; _strut.bottom = data[3]; - Openbox::instance->screen(_screen)->updateStrut(); + openbox->screen(_screen)->updateStrut(); } delete [] data; @@ -574,7 +574,7 @@ void Client::updateTransientFor() if (XGetTransientForHint(otk::Display::display, _window, &t) && t != _window) { // cant be transient to itself! - c = Openbox::instance->findClient(t); + c = openbox->findClient(t); assert(c != this); // if this happens then we need to check for it if (!c /*XXX: && _group*/) { @@ -606,7 +606,7 @@ void Client::propertyHandler(const XPropertyEvent &e) { otk::EventHandler::propertyHandler(e); - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); // compress changes to a single property into a single change XEvent ce; @@ -671,13 +671,13 @@ void Client::setDesktop(long target) _desktop = target; - Openbox::instance->property()->set(_window, + openbox->property()->set(_window, otk::Property::net_wm_desktop, otk::Property::Atom_Cardinal, (unsigned)_desktop); // 'move' the window to the new desktop - if (_desktop == Openbox::instance->screen(_screen)->desktop() || + if (_desktop == openbox->screen(_screen)->desktop() || _desktop == (signed)0xffffffff) frame->show(); else @@ -687,7 +687,7 @@ void Client::setDesktop(long target) void Client::setState(StateAction action, long data1, long data2) { - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); bool shadestate = _shaded; if (!(action == State_Add || action == State_Remove || @@ -865,7 +865,7 @@ void Client::clientMessageHandler(const XClientMessageEvent &e) if (e.format != 32) return; - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); if (e.message_type == property->atom(otk::Property::wm_change_state)) { // compress changes into a single change @@ -926,7 +926,7 @@ void Client::clientMessageHandler(const XClientMessageEvent &e) shade(false); // XXX: deiconify focus(); - Openbox::instance->screen(_screen)->restack(true, this); // raise + openbox->screen(_screen)->restack(true, this); // raise } } @@ -1037,7 +1037,7 @@ void Client::move(int x, int y) void Client::close() { XEvent ce; - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); if (!(_functions & Func_Close)) return; @@ -1063,7 +1063,7 @@ void Client::close() void Client::changeState() { - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); unsigned long state[2]; state[0] = _wmstate; @@ -1128,7 +1128,7 @@ bool Client::focus() const if (_focus_notify) { XEvent ce; - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); ce.xclient.type = ClientMessage; ce.xclient.message_type = property->atom(otk::Property::wm_protocols); @@ -1136,7 +1136,7 @@ bool Client::focus() const ce.xclient.window = _window; ce.xclient.format = 32; ce.xclient.data.l[0] = property->atom(otk::Property::wm_take_focus); - ce.xclient.data.l[1] = Openbox::instance->lastTime(); + ce.xclient.data.l[1] = openbox->lastTime(); ce.xclient.data.l[2] = 0l; ce.xclient.data.l[3] = 0l; ce.xclient.data.l[4] = 0l; @@ -1151,8 +1151,8 @@ void Client::unfocus() const { if (!_focused) return; - assert(Openbox::instance->focusedClient() == this); - Openbox::instance->setFocusedClient(0); + assert(openbox->focusedClient() == this); + openbox->setFocusedClient(0); } @@ -1167,7 +1167,7 @@ void Client::focusHandler(const XFocusChangeEvent &e) frame->focus(); _focused = true; - Openbox::instance->setFocusedClient(this); + openbox->setFocusedClient(this); } @@ -1182,8 +1182,8 @@ void Client::unfocusHandler(const XFocusChangeEvent &e) frame->unfocus(); _focused = false; - if (Openbox::instance->focusedClient() == this) - Openbox::instance->setFocusedClient(0); + if (openbox->focusedClient() == this) + openbox->setFocusedClient(0); } @@ -1239,13 +1239,13 @@ void Client::configureRequestHandler(const XConfigureRequestEvent &e) switch (e.detail) { case Below: case BottomIf: - Openbox::instance->screen(_screen)->restack(false, this); // lower + openbox->screen(_screen)->restack(false, this); // lower break; case Above: case TopIf: default: - Openbox::instance->screen(_screen)->restack(true, this); // raise + openbox->screen(_screen)->restack(true, this); // raise break; } } @@ -1269,7 +1269,7 @@ void Client::unmapHandler(const XUnmapEvent &e) otk::EventHandler::unmapHandler(e); // this deletes us etc - Openbox::instance->screen(_screen)->unmanageWindow(this); + openbox->screen(_screen)->unmanageWindow(this); } @@ -1282,7 +1282,7 @@ void Client::destroyHandler(const XDestroyWindowEvent &e) otk::EventHandler::destroyHandler(e); // this deletes us etc - Openbox::instance->screen(_screen)->unmanageWindow(this); + openbox->screen(_screen)->unmanageWindow(this); } @@ -1311,7 +1311,7 @@ void Client::reparentHandler(const XReparentEvent &e) XPutBackEvent(otk::Display::display, &ev); // this deletes us etc - Openbox::instance->screen(_screen)->unmanageWindow(this); + openbox->screen(_screen)->unmanageWindow(this); } } diff --git a/src/frame.cc b/src/frame.cc index ce5e961e..35634b4c 100644 --- a/src/frame.cc +++ b/src/frame.cc @@ -24,7 +24,7 @@ namespace ob { const long Frame::event_mask; Frame::Frame(Client *client, otk::Style *style) - : otk::Widget(Openbox::instance, style, Horizontal, 0, 1, true), + : otk::Widget(openbox, style, Horizontal, 0, 1, true), WidgetBase(WidgetBase::Type_Frame), _client(client), _screen(otk::Display::screenInfo(client->screen())), @@ -45,8 +45,8 @@ Frame::Frame(Client *client, otk::Style *style) XSelectInput(otk::Display::display, _window, Frame::event_mask); - _grip_left.setCursor(Openbox::instance->cursors().ll_angle); - _grip_right.setCursor(Openbox::instance->cursors().lr_angle); + _grip_left.setCursor(openbox->cursors().ll_angle); + _grip_right.setCursor(openbox->cursors().lr_angle); _label.setText(_client->title()); @@ -412,7 +412,7 @@ void Frame::grabClient() member set the root window, and one set to the client, but both get handled and need to be ignored. */ - if (Openbox::instance->state() == Openbox::State_Starting) + if (openbox->state() == Openbox::State_Starting) _client->ignore_unmaps += 2; // select the event mask on the client's parent (to receive config req's) diff --git a/src/openbox.cc b/src/openbox.cc index 2be91335..0b3148e8 100644 --- a/src/openbox.cc +++ b/src/openbox.cc @@ -51,7 +51,7 @@ extern "C" { namespace ob { -Openbox *Openbox::instance = (Openbox *) 0; +Openbox *openbox = (Openbox *) 0; void Openbox::signalHandler(int signal) @@ -59,7 +59,7 @@ void Openbox::signalHandler(int signal) switch (signal) { case SIGUSR1: printf("Caught SIGUSR1 signal. Restarting.\n"); - instance->restart(); + openbox->restart(); break; case SIGHUP: @@ -67,7 +67,7 @@ void Openbox::signalHandler(int signal) case SIGTERM: case SIGPIPE: printf("Caught signal %d. Exiting.\n", signal); - instance->shutdown(); + openbox->shutdown(); break; case SIGFPE: @@ -86,7 +86,7 @@ Openbox::Openbox(int argc, char **argv) _state = State_Starting; // initializing everything - Openbox::instance = this; + openbox = this; _displayreq = (char*) 0; _argv = argv; @@ -378,7 +378,7 @@ void Openbox::setFocusedClient(Client *c) // call the python Focus callbacks EventData data(_focused_screen->number(), c, EventFocus, 0); - Openbox::instance->bindings()->fireEvent(&data); + _bindings->fireEvent(&data); } void Openbox::execute(int screen, const std::string &bin) diff --git a/src/openbox.hh b/src/openbox.hh index 51671897..9001db60 100644 --- a/src/openbox.hh +++ b/src/openbox.hh @@ -38,6 +38,14 @@ struct Cursors { Cursor ur_angle; //!< For resizing the right corner of a window }; +class Openbox; + +//! The single instance of the Openbox class for the application +/*! + Since this variable is globally available in the application, the Openbox + class does not need to be passed around to any of the other classes. +*/ +extern Openbox *openbox; //! The main class for the Openbox window manager /*! @@ -52,13 +60,6 @@ struct Cursors { class Openbox : public otk::EventDispatcher, public otk::EventHandler { public: - //! The single instance of the Openbox class for the application - /*! - Since this variable is globally available in the application, the Openbox - class does not need to be passed around to any of the other classes. - */ - static Openbox *instance; - //! The posible running states of the window manager enum RunState { State_Starting, //!< The window manager is starting up (being created) diff --git a/src/openbox.i b/src/openbox.i index 6f768502..59dbecdd 100644 --- a/src/openbox.i +++ b/src/openbox.i @@ -20,9 +20,9 @@ //%include std_list.i //%template(ClientList) std::list; -%ignore ob::Openbox::instance; +%ignore ob::openbox; %inline %{ - ob::Openbox *Openbox_instance() { return ob::Openbox::instance; } + ob::Openbox *Openbox_instance() { return ob::openbox; } %}; %{ @@ -96,7 +96,7 @@ void python_callback(PyObject *func, KeyData *data) %} %extend ob::Screen { Client *client(int i) { - if (i >= (int)self->clients.size()) + if (i < 0 || i >= (int)self->clients.size()) return NULL; ob::Client::List::iterator it = self->clients.begin(); std::advance(it,i); diff --git a/src/openbox_wrap.cc b/src/openbox_wrap.cc index e26d59e1..d098ed8b 100644 --- a/src/openbox_wrap.cc +++ b/src/openbox_wrap.cc @@ -813,7 +813,7 @@ std::string SwigString_AsString(PyObject* o) { #include - ob::Openbox *Openbox_instance() { return ob::Openbox::instance; } + ob::Openbox *Openbox_instance() { return ob::openbox; } namespace ob { @@ -889,7 +889,7 @@ void python_callback(PyObject *func, KeyData *data) #include "ustring.hh" ob::Client *ob_Screen_client(ob::Screen *self,int i){ - if (i >= (int)self->clients.size()) + if (i < 0 || i >= (int)self->clients.size()) return NULL; ob::Client::List::iterator it = self->clients.begin(); std::advance(it,i); diff --git a/src/python.cc b/src/python.cc index f6ed7a7e..912f196d 100644 --- a/src/python.cc +++ b/src/python.cc @@ -100,7 +100,7 @@ PyObject *mbind(const std::string &button, ob::MouseContext context, return NULL; } - if (!ob::Openbox::instance->bindings()->addButton(button, context, + if (!ob::openbox->bindings()->addButton(button, context, action, func)) { PyErr_SetString(PyExc_RuntimeError,"Unable to add binding."); return NULL; @@ -115,7 +115,7 @@ PyObject *ebind(ob::EventAction action, PyObject *func) return NULL; } - if (!ob::Openbox::instance->bindings()->addEvent(action, func)) { + if (!ob::openbox->bindings()->addEvent(action, func)) { PyErr_SetString(PyExc_RuntimeError,"Unable to add binding."); return NULL; } @@ -145,7 +145,7 @@ PyObject *kbind(PyObject *keylist, ob::KeyContext context, PyObject *func) } (void)context; // XXX use this sometime! - if (!ob::Openbox::instance->bindings()->addKey(vectkeylist, func)) { + if (!ob::openbox->bindings()->addKey(vectkeylist, func)) { PyErr_SetString(PyExc_RuntimeError,"Unable to add binding."); return NULL; } @@ -174,7 +174,7 @@ PyObject *kunbind(PyObject *keylist, PyObject *func) vectkeylist.push_back(PyString_AsString(str)); } - if (!ob::Openbox::instance->bindings()->removeKey(vectkeylist, func)) { + if (!ob::openbox->bindings()->removeKey(vectkeylist, func)) { PyErr_SetString(PyExc_RuntimeError, "Could not remove callback."); return NULL; } @@ -183,12 +183,12 @@ PyObject *kunbind(PyObject *keylist, PyObject *func) void kunbind_all() { - ob::Openbox::instance->bindings()->removeAllKeys(); + ob::openbox->bindings()->removeAllKeys(); } void set_reset_key(const std::string &key) { - ob::Openbox::instance->bindings()->setResetKey(key); + ob::openbox->bindings()->setResetKey(key); } PyObject *send_client_msg(Window target, int type, Window about, @@ -205,7 +205,7 @@ PyObject *send_client_msg(Window target, int type, Window about, e.xclient.type = ClientMessage; e.xclient.format = 32; e.xclient.message_type = - Openbox::instance->property()->atom((otk::Property::Atoms)type); + openbox->property()->atom((otk::Property::Atoms)type); e.xclient.window = about; e.xclient.data.l[0] = data; e.xclient.data.l[1] = data1; diff --git a/src/screen.cc b/src/screen.cc index c211df12..884f85c3 100644 --- a/src/screen.cc +++ b/src/screen.cc @@ -65,17 +65,17 @@ Screen::Screen(int screen) printf(_("Managing screen %d: visual 0x%lx, depth %d\n"), _number, XVisualIDFromVisual(_info->visual()), _info->depth()); - Openbox::instance->property()->set(_info->rootWindow(), + openbox->property()->set(_info->rootWindow(), otk::Property::openbox_pid, otk::Property::Atom_Cardinal, (unsigned long) getpid()); // set the mouse cursor for the root window (the default cursor) XDefineCursor(otk::Display::display, _info->rootWindow(), - Openbox::instance->cursors().session); + openbox->cursors().session); // initialize the shit that is used for all drawing on the screen - _image_control = new otk::ImageControl(Openbox::instance->timerManager(), + _image_control = new otk::ImageControl(openbox->timerManager(), _info, true); _image_control->installRootColormap(); _root_cmap_installed = True; @@ -101,7 +101,7 @@ Screen::Screen(int screen) // Set the netwm properties for geometry unsigned long geometry[] = { _info->width(), _info->height() }; - Openbox::instance->property()->set(_info->rootWindow(), + openbox->property()->set(_info->rootWindow(), otk::Property::net_desktop_geometry, otk::Property::Atom_Cardinal, geometry, 2); @@ -109,7 +109,7 @@ Screen::Screen(int screen) // Set the net_desktop_names property std::vector names; python_get_stringlist("desktop_names", &names); - Openbox::instance->property()->set(_info->rootWindow(), + openbox->property()->set(_info->rootWindow(), otk::Property::net_desktop_names, otk::Property::utf8, names); @@ -137,11 +137,11 @@ Screen::Screen(int screen) calcArea(); // initialize the available working area // register this class as the event handler for the root window - Openbox::instance->registerHandler(_info->rootWindow(), this); + openbox->registerHandler(_info->rootWindow(), this); // call the python Startup callbacks EventData data(_number, 0, EventShutdown, 0); - Openbox::instance->bindings()->fireEvent(&data); + openbox->bindings()->fireEvent(&data); } @@ -157,7 +157,7 @@ Screen::~Screen() // call the python Shutdown callbacks EventData data(_number, 0, EventShutdown, 0); - Openbox::instance->bindings()->fireEvent(&data); + openbox->bindings()->fireEvent(&data); XDestroyWindow(otk::Display::display, _focuswindow); XDestroyWindow(otk::Display::display, _supportwindow); @@ -284,17 +284,17 @@ void Screen::changeSupportedAtoms() 0, 0, 1, 1, 0, 0, 0); // set supporting window - Openbox::instance->property()->set(_info->rootWindow(), + openbox->property()->set(_info->rootWindow(), otk::Property::net_supporting_wm_check, otk::Property::Atom_Window, _supportwindow); //set properties on the supporting window - Openbox::instance->property()->set(_supportwindow, + openbox->property()->set(_supportwindow, otk::Property::net_wm_name, otk::Property::utf8, "Openbox"); - Openbox::instance->property()->set(_supportwindow, + openbox->property()->set(_supportwindow, otk::Property::net_supporting_wm_check, otk::Property::Atom_Window, _supportwindow); @@ -363,9 +363,9 @@ void Screen::changeSupportedAtoms() // convert to the atom values for (int i = 0; i < num_supported; ++i) supported[i] = - Openbox::instance->property()->atom((otk::Property::Atoms)supported[i]); + openbox->property()->atom((otk::Property::Atoms)supported[i]); - Openbox::instance->property()->set(_info->rootWindow(), + openbox->property()->set(_info->rootWindow(), otk::Property::net_supported, otk::Property::Atom_Atom, supported, num_supported); @@ -390,7 +390,7 @@ void Screen::changeClientList() } else windows = (Window*) 0; - Openbox::instance->property()->set(_info->rootWindow(), + openbox->property()->set(_info->rootWindow(), otk::Property::net_client_list, otk::Property::Atom_Window, windows, size); @@ -423,7 +423,7 @@ void Screen::changeStackingList() } else windows = (Window*) 0; - Openbox::instance->property()->set(_info->rootWindow(), + openbox->property()->set(_info->rootWindow(), otk::Property::net_client_list_stacking, otk::Property::Atom_Window, windows, size); @@ -442,7 +442,7 @@ void Screen::changeWorkArea() { dims[(i * 4) + 2] = _area.width(); dims[(i * 4) + 3] = _area.height(); } - Openbox::instance->property()->set(_info->rootWindow(), + openbox->property()->set(_info->rootWindow(), otk::Property::net_workarea, otk::Property::Atom_Cardinal, dims, 4 * _num_desktops); @@ -480,9 +480,9 @@ void Screen::manageWindow(Window window) // create the Client class, which gets all of the hints on the window client = new Client(_number, window); // register for events - Openbox::instance->registerHandler(window, client); + openbox->registerHandler(window, client); // add to the wm's map - Openbox::instance->addClient(window, client); + openbox->addClient(window, client); // we dont want a border on the client client->toggleClientBorder(false); @@ -491,29 +491,29 @@ void Screen::manageWindow(Window window) // reparented back to root automatically XChangeSaveSet(otk::Display::display, window, SetModeInsert); - if (!(Openbox::instance->state() == Openbox::State_Starting || + if (!(openbox->state() == Openbox::State_Starting || client->positionRequested())) { // position the window intelligenty .. hopefully :) // call the python PLACEWINDOW binding EventData data(_number, client, EventPlaceWindow, 0); - Openbox::instance->bindings()->fireEvent(&data); + openbox->bindings()->fireEvent(&data); } // create the decoration frame for the client window client->frame = new Frame(client, &_style); // add to the wm's map - 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); - Openbox::instance->addClient(client->frame->button_max(), client); - Openbox::instance->addClient(client->frame->button_iconify(), client); - Openbox::instance->addClient(client->frame->button_stick(), client); - Openbox::instance->addClient(client->frame->button_close(), client); - Openbox::instance->addClient(client->frame->handle(), client); - Openbox::instance->addClient(client->frame->grip_left(), client); - Openbox::instance->addClient(client->frame->grip_right(), client); + openbox->addClient(client->frame->window(), client); + openbox->addClient(client->frame->plate(), client); + openbox->addClient(client->frame->titlebar(), client); + openbox->addClient(client->frame->label(), client); + openbox->addClient(client->frame->button_max(), client); + openbox->addClient(client->frame->button_iconify(), client); + openbox->addClient(client->frame->button_stick(), client); + openbox->addClient(client->frame->button_close(), client); + openbox->addClient(client->frame->handle(), client); + openbox->addClient(client->frame->grip_left(), client); + openbox->addClient(client->frame->grip_right(), client); // reparent the client to the frame client->frame->grabClient(); @@ -536,11 +536,11 @@ void Screen::manageWindow(Window window) // update the root properties changeClientList(); - Openbox::instance->bindings()->grabButtons(true, client); + openbox->bindings()->grabButtons(true, client); // call the python NEWWINDOW binding EventData data(_number, client, EventNewWindow, 0); - Openbox::instance->bindings()->fireEvent(&data); + openbox->bindings()->fireEvent(&data); #ifdef DEBUG printf("Managed window 0x%lx\n", window); @@ -554,25 +554,25 @@ void Screen::unmanageWindow(Client *client) // call the python CLOSEWINDOW binding EventData data(_number, client, EventCloseWindow, 0); - Openbox::instance->bindings()->fireEvent(&data); + openbox->bindings()->fireEvent(&data); - Openbox::instance->bindings()->grabButtons(false, client); + openbox->bindings()->grabButtons(false, client); // remove from the wm's map - Openbox::instance->removeClient(client->window()); - Openbox::instance->removeClient(frame->window()); - Openbox::instance->removeClient(frame->plate()); - Openbox::instance->removeClient(frame->titlebar()); - Openbox::instance->removeClient(frame->label()); - Openbox::instance->removeClient(frame->button_max()); - Openbox::instance->removeClient(frame->button_iconify()); - Openbox::instance->removeClient(frame->button_stick()); - Openbox::instance->removeClient(frame->button_close()); - Openbox::instance->removeClient(frame->handle()); - Openbox::instance->removeClient(frame->grip_left()); - Openbox::instance->removeClient(frame->grip_right()); + openbox->removeClient(client->window()); + openbox->removeClient(frame->window()); + openbox->removeClient(frame->plate()); + openbox->removeClient(frame->titlebar()); + openbox->removeClient(frame->label()); + openbox->removeClient(frame->button_max()); + openbox->removeClient(frame->button_iconify()); + openbox->removeClient(frame->button_stick()); + openbox->removeClient(frame->button_close()); + openbox->removeClient(frame->handle()); + openbox->removeClient(frame->grip_left()); + openbox->removeClient(frame->grip_right()); // unregister for handling events - Openbox::instance->clearHandler(client->window()); + openbox->clearHandler(client->window()); // remove the window from our save set XChangeSaveSet(otk::Display::display, client->window(), SetModeDelete); @@ -646,7 +646,7 @@ void Screen::changeDesktop(long desktop) long old = _desktop; _desktop = desktop; - Openbox::instance->property()->set(_info->rootWindow(), + openbox->property()->set(_info->rootWindow(), otk::Property::net_current_desktop, otk::Property::Atom_Cardinal, _desktop); @@ -663,8 +663,8 @@ void Screen::changeDesktop(long desktop) } // force the callbacks to fire - if (!Openbox::instance->focusedClient()) - Openbox::instance->setFocusedClient(0); + if (!openbox->focusedClient()) + openbox->setFocusedClient(0); } void Screen::changeNumDesktops(long num) @@ -676,7 +676,7 @@ void Screen::changeNumDesktops(long num) // XXX: move windows on desktops that will no longer exist! _num_desktops = num; - Openbox::instance->property()->set(_info->rootWindow(), + openbox->property()->set(_info->rootWindow(), otk::Property::net_number_of_desktops, otk::Property::Atom_Cardinal, _num_desktops); @@ -684,7 +684,7 @@ void Screen::changeNumDesktops(long num) // set the viewport hint unsigned long *viewport = new unsigned long[_num_desktops * 2]; memset(viewport, 0, sizeof(unsigned long) * _num_desktops * 2); - Openbox::instance->property()->set(_info->rootWindow(), + openbox->property()->set(_info->rootWindow(), otk::Property::net_desktop_viewport, otk::Property::Atom_Cardinal, viewport, _num_desktops * 2); @@ -697,7 +697,7 @@ void Screen::changeNumDesktops(long num) void Screen::updateDesktopNames() { - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); unsigned long num = (unsigned) -1; @@ -716,7 +716,7 @@ void Screen::setDesktopName(long i, const otk::ustring &name) if (i >= _num_desktops) return; - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); otk::Property::StringVect newnames = _desktop_names; newnames[i] = name; @@ -729,7 +729,7 @@ void Screen::propertyHandler(const XPropertyEvent &e) { otk::EventHandler::propertyHandler(e); - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); // compress changes to a single property into a single change XEvent ce; @@ -753,7 +753,7 @@ void Screen::clientMessageHandler(const XClientMessageEvent &e) if (e.format != 32) return; - const otk::Property *property = Openbox::instance->property(); + const otk::Property *property = openbox->property(); if (e.message_type == property->atom(otk::Property::net_current_desktop)) { changeDesktop(e.data.l[0]); @@ -778,14 +778,14 @@ void Screen::mapRequestHandler(const XMapRequestEvent &e) right to the client window, because of how they are sent and their struct layout. */ - Client *c = Openbox::instance->findClient(e.window); + Client *c = openbox->findClient(e.window); if (c) { // send a net_active_window message XEvent ce; ce.xclient.type = ClientMessage; ce.xclient.message_type = - Openbox::instance->property()->atom(otk::Property::net_active_window); + openbox->property()->atom(otk::Property::net_active_window); ce.xclient.display = otk::Display::display; ce.xclient.window = c->window(); ce.xclient.format = 32;