X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Fscreen.cc;h=09f57d64ebde4200b24e0593844da1b4cded300e;hb=889df8a74da733c849cb52c3a76ae59956755882;hp=896f38081d15756f85a55fdeef1d16ab52a84a2e;hpb=33ddfc7664d5988c370303217e5f1e3fdb431dd9;p=chaz%2Fopenbox diff --git a/src/screen.cc b/src/screen.cc index 896f3808..09f57d64 100644 --- a/src/screen.cc +++ b/src/screen.cc @@ -138,6 +138,11 @@ OBScreen::OBScreen(int screen) // register this class as the event handler for the root window Openbox::instance->registerHandler(_info->rootWindow(), this); + + // call the python Startup callbacks + EventData *data = new_event_data(_number, 0, EventShutdown, 0); + Openbox::instance->bindings()->fireEvent(data); + Py_XDECREF((PyObject*)data); } @@ -151,6 +156,11 @@ OBScreen::~OBScreen() while (!clients.empty()) unmanageWindow(clients.front()); + // call the python Shutdown callbacks + EventData *data = new_event_data(_number, 0, EventShutdown, 0); + Openbox::instance->bindings()->fireEvent(data); + Py_XDECREF((PyObject*)data); + XDestroyWindow(otk::OBDisplay::display, _focuswindow); XDestroyWindow(otk::OBDisplay::display, _supportwindow); @@ -449,19 +459,21 @@ void OBScreen::manageWindow(Window window) XWMHints *wmhint; XSetWindowAttributes attrib_set; + otk::OBDisplay::grab(); + // is the window a docking app if ((wmhint = XGetWMHints(otk::OBDisplay::display, window))) { if ((wmhint->flags & StateHint) && wmhint->initial_state == WithdrawnState) { //slit->addClient(w); // XXX: make dock apps work! + otk::OBDisplay::ungrab(); + XFree(wmhint); return; } XFree(wmhint); } - otk::OBDisplay::grab(); - // choose the events we want to receive on the CLIENT window attrib_set.event_mask = OBClient::event_mask; attrib_set.do_not_propagate_mask = OBClient::no_propagate_mask; @@ -482,8 +494,13 @@ void OBScreen::manageWindow(Window window) // reparented back to root automatically XChangeSaveSet(otk::OBDisplay::display, window, SetModeInsert); - if (!client->positionRequested()) { - // XXX: position the window intelligenty + if (!(Openbox::instance->state() == Openbox::State_Starting || + client->positionRequested())) { + // position the window intelligenty .. hopefully :) + // call the python PLACEWINDOW binding + EventData *data = new_event_data(_number, window, EventPlaceWindow, 0); + Openbox::instance->bindings()->fireEvent(data); + Py_DECREF((PyObject*)data); } // create the decoration frame for the client window @@ -502,9 +519,14 @@ void OBScreen::manageWindow(Window window) Openbox::instance->addClient(client->frame->grip_left(), client); Openbox::instance->addClient(client->frame->grip_right(), client); + // reparent the client to the frame + client->frame->grabClient(); + // if on the current desktop.. (or all desktops) - if (client->desktop() == _desktop || client->desktop() == (signed)0xffffffff) + if (client->desktop() == _desktop || + client->desktop() == (signed)0xffffffff) { client->frame->show(); + } // XXX: handle any requested states such as maximized @@ -520,12 +542,8 @@ void OBScreen::manageWindow(Window window) Openbox::instance->bindings()->grabButtons(true, client); - // XXX: make this optional or more intelligent - if (client->normal()) - client->focus(); - // call the python NEWWINDOW binding - EventData *data = new_event_data(window, EventNewWindow, 0); + EventData *data = new_event_data(_number, window, EventNewWindow, 0); Openbox::instance->bindings()->fireEvent(data); Py_DECREF((PyObject*)data); @@ -533,33 +551,18 @@ void OBScreen::manageWindow(Window window) } -void OBScreen::unmanageWindow(OBClient *client) +void OBScreen::unmanageWindow(OBClient *client, bool reparented) { OBFrame *frame = client->frame; // call the python CLOSEWINDOW binding - EventData *data = new_event_data(client->window(), EventCloseWindow, 0); + EventData *data = new_event_data(_number, client->window(), + EventCloseWindow, 0); Openbox::instance->bindings()->fireEvent(data); Py_DECREF((PyObject*)data); Openbox::instance->bindings()->grabButtons(false, client); - // remove from the stacking order - _stacking.remove(client); - - // pass around focus if this window was focused XXX do this better! - if (Openbox::instance->focusedClient() == client) { - OBClient *newfocus = 0; - OBClient::List::iterator it, end = _stacking.end(); - for (it = _stacking.begin(); it != end; ++it) - if ((*it)->normal() && (*it)->focus()) { - newfocus = *it; - break; - } - if (!newfocus) - client->unfocus(); - } - // remove from the wm's map Openbox::instance->removeClient(client->window()); Openbox::instance->removeClient(frame->window()); @@ -587,11 +590,26 @@ void OBScreen::unmanageWindow(OBClient *client) // give the client its border back client->toggleClientBorder(true); + if (!reparented) + // reparent the window out of the frame + frame->releaseClient(); + else + // the client is already reparented, so, since we unmapped the window + // above, we remap it here. aren't we nice? :) + XMapWindow(otk::OBDisplay::display, client->window()); + delete client->frame; client->frame = 0; + // remove from the stacking order + _stacking.remove(client); + // remove from the screen's list clients.remove(client); + + // unfocus the client (calls the focus callbacks) + client->unfocus(); + delete client; // update the root properties @@ -631,6 +649,8 @@ void OBScreen::changeDesktop(long desktop) if (!(desktop >= 0 && desktop < _num_desktops)) return; + printf("Moving to desktop %ld\n", desktop); + long old = _desktop; _desktop = desktop; @@ -639,6 +659,8 @@ void OBScreen::changeDesktop(long desktop) otk::OBProperty::Atom_Cardinal, _desktop); + if (old == _desktop) return; + OBClient::List::iterator it, end = clients.end(); for (it = clients.begin(); it != end; ++it) { if ((*it)->desktop() == old) { @@ -647,6 +669,10 @@ void OBScreen::changeDesktop(long desktop) (*it)->frame->show(); } } + + // force the callbacks to fire + if (!Openbox::instance->focusedClient()) + Openbox::instance->setFocusedClient(0); } void OBScreen::changeNumDesktops(long num) @@ -655,6 +681,8 @@ void OBScreen::changeNumDesktops(long num) if (!(num > 0)) return; + // XXX: move windows on desktops that will no longer exist! + _num_desktops = num; Openbox::instance->property()->set(_info->rootWindow(), otk::OBProperty::net_number_of_desktops,