-Openbox::~Openbox() {
- while (screenList->count())
- delete screenList->remove(0);
-
- while (menuTimestamps->count()) {
- MenuTimestamp *ts = menuTimestamps->remove(0);
-
- if (ts->filename)
- delete [] ts->filename;
-
- delete ts;
- }
-
- if (resource.menu_file)
- delete [] resource.menu_file;
-
- if (resource.style_file)
- delete [] resource.style_file;
-
- if (resource.titlebar_layout)
- delete [] resource.titlebar_layout;
-
- delete timer;
-
- delete screenList;
- delete menuTimestamps;
-
- delete windowSearchList;
- delete menuSearchList;
- delete toolbarSearchList;
- delete groupSearchList;
-
- delete [] rc_file;
-
-#ifdef SLIT
- delete slitSearchList;
-#endif // SLIT
-}
-
-
-void Openbox::process_event(XEvent *e) {
- if ((masked == e->xany.window) && masked_window &&
- (e->type == MotionNotify)) {
- last_time = e->xmotion.time;
- masked_window->motionNotifyEvent(&e->xmotion);
-
- return;
- }
-
- switch (e->type) {
- case ButtonPress: {
- // strip the lock key modifiers
- e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask);
-
- last_time = e->xbutton.time;
-
- OpenboxWindow *win = (OpenboxWindow *) 0;
- Basemenu *menu = (Basemenu *) 0;
-
-#ifdef SLIT
- Slit *slit = (Slit *) 0;
-#endif // SLIT
-
- Toolbar *tbar = (Toolbar *) 0;
-
- if ((win = searchWindow(e->xbutton.window))) {
- win->buttonPressEvent(&e->xbutton);
-
- if (e->xbutton.button == 1)
- win->installColormap(True);
- } else if ((menu = searchMenu(e->xbutton.window))) {
- menu->buttonPressEvent(&e->xbutton);
-
-#ifdef SLIT
- } else if ((slit = searchSlit(e->xbutton.window))) {
- slit->buttonPressEvent(&e->xbutton);
-#endif // SLIT
-
- } else if ((tbar = searchToolbar(e->xbutton.window))) {
- tbar->buttonPressEvent(&e->xbutton);
- } else {
- LinkedListIterator<BScreen> it(screenList);
- BScreen *screen = it.current();
- for (; screen; it++, screen = it.current()) {
- if (e->xbutton.window == screen->getRootWindow()) {
- if (e->xbutton.button == 1) {
- if (! screen->isRootColormapInstalled())
- screen->getImageControl()->installRootColormap();
-
- if (screen->getWorkspacemenu()->isVisible())
- screen->getWorkspacemenu()->hide();
-
- if (screen->getRootmenu()->isVisible())
- screen->getRootmenu()->hide();
- } else if (e->xbutton.button == 2) {
- int mx = e->xbutton.x_root -
- (screen->getWorkspacemenu()->getWidth() / 2);
- int my = e->xbutton.y_root -
- (screen->getWorkspacemenu()->getTitleHeight() / 2);
-
- if (mx < 0) mx = 0;
- if (my < 0) my = 0;
-
- if (mx + screen->getWorkspacemenu()->getWidth() >
- screen->size().w())
- mx = screen->size().w() -
- screen->getWorkspacemenu()->getWidth() -
- screen->getBorderWidth();
-
- if (my + screen->getWorkspacemenu()->getHeight() >
- screen->size().h())
- my = screen->size().h() -
- screen->getWorkspacemenu()->getHeight() -
- screen->getBorderWidth();
-
- screen->getWorkspacemenu()->move(mx, my);
-
- if (! screen->getWorkspacemenu()->isVisible()) {
- screen->getWorkspacemenu()->removeParent();
- screen->getWorkspacemenu()->show();
- }
- } else if (e->xbutton.button == 3) {
- int mx = e->xbutton.x_root -
- (screen->getRootmenu()->getWidth() / 2);
- int my = e->xbutton.y_root -
- (screen->getRootmenu()->getTitleHeight() / 2);
-
- if (mx < 0) mx = 0;
- if (my < 0) my = 0;
-
- if (mx + screen->getRootmenu()->getWidth() > screen->size().w())
- mx = screen->size().w() -
- screen->getRootmenu()->getWidth() -
- screen->getBorderWidth();
-
- if (my + screen->getRootmenu()->getHeight() > screen->size().h())
- my = screen->size().h() -
- screen->getRootmenu()->getHeight() -
- screen->getBorderWidth();
-
- screen->getRootmenu()->move(mx, my);
-
- if (! screen->getRootmenu()->isVisible()) {
- checkMenu();
- screen->getRootmenu()->show();
- }
- } else if (e->xbutton.button == 4) {
- if ((screen->getCurrentWorkspaceID() + 1) >
- screen->getWorkspaceCount() - 1)
- screen->changeWorkspaceID(0);
- else
- screen->changeWorkspaceID(screen->getCurrentWorkspaceID() + 1);
- } else if (e->xbutton.button == 5) {
- if ((screen->getCurrentWorkspaceID() - 1) < 0)
- screen->changeWorkspaceID(screen->getWorkspaceCount() - 1);
- else
- screen->changeWorkspaceID(screen->getCurrentWorkspaceID() - 1);
- }
- }
- }
- }
-
- break;
- }
-
- case ButtonRelease: {
- // strip the lock key modifiers
- e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask);
-
- last_time = e->xbutton.time;
-
- OpenboxWindow *win = (OpenboxWindow *) 0;
- Basemenu *menu = (Basemenu *) 0;
- Toolbar *tbar = (Toolbar *) 0;
-
- if ((win = searchWindow(e->xbutton.window)))
- win->buttonReleaseEvent(&e->xbutton);
- else if ((menu = searchMenu(e->xbutton.window)))
- menu->buttonReleaseEvent(&e->xbutton);
- else if ((tbar = searchToolbar(e->xbutton.window)))
- tbar->buttonReleaseEvent(&e->xbutton);
-
- break;
- }
-
- case ConfigureRequest: {
- OpenboxWindow *win = (OpenboxWindow *) 0;
-
-#ifdef SLIT
- Slit *slit = (Slit *) 0;
-#endif // SLIT
-
- if ((win = searchWindow(e->xconfigurerequest.window))) {
- win->configureRequestEvent(&e->xconfigurerequest);
-
-#ifdef SLIT
- } else if ((slit = searchSlit(e->xconfigurerequest.window))) {
- slit->configureRequestEvent(&e->xconfigurerequest);
-#endif // SLIT
-
- } else {
- grab();
-
- if (validateWindow(e->xconfigurerequest.window)) {
- XWindowChanges xwc;
-
- xwc.x = e->xconfigurerequest.x;
- xwc.y = e->xconfigurerequest.y;
- xwc.width = e->xconfigurerequest.width;
- xwc.height = e->xconfigurerequest.height;
- xwc.border_width = e->xconfigurerequest.border_width;
- xwc.sibling = e->xconfigurerequest.above;
- xwc.stack_mode = e->xconfigurerequest.detail;
-
- XConfigureWindow(getXDisplay(), e->xconfigurerequest.window,
- e->xconfigurerequest.value_mask, &xwc);
- }
-
- ungrab();
- }
-
- break;
- }
-
- case MapRequest: {
-#ifdef DEBUG
- fprintf(stderr,
- i18n->getMessage(openboxSet, openboxMapRequest,
- "Openbox::process_event(): MapRequest for 0x%lx\n"),
- e->xmaprequest.window);
-#endif // DEBUG
-
- OpenboxWindow *win = searchWindow(e->xmaprequest.window);
-
- if (! win)
- win = new OpenboxWindow(*this, e->xmaprequest.window);
-
- if ((win = searchWindow(e->xmaprequest.window)))
- win->mapRequestEvent(&e->xmaprequest);
-
- break;
- }
-
- case MapNotify: {
- OpenboxWindow *win = searchWindow(e->xmap.window);
-
- if (win)
- win->mapNotifyEvent(&e->xmap);
-
- break;
- }
-
- case UnmapNotify: {
- OpenboxWindow *win = (OpenboxWindow *) 0;
-
-#ifdef SLIT
- Slit *slit = (Slit *) 0;
-#endif // SLIT
-
- if ((win = searchWindow(e->xunmap.window))) {
- win->unmapNotifyEvent(&e->xunmap);
- if (focused_window == win)
- focused_window = (OpenboxWindow *) 0;
-#ifdef SLIT
- } else if ((slit = searchSlit(e->xunmap.window))) {
- slit->removeClient(e->xunmap.window);
-#endif // SLIT
-
- }
-
- break;
- }
-
- case DestroyNotify: {
- OpenboxWindow *win = (OpenboxWindow *) 0;
-
-#ifdef SLIT
- Slit *slit = (Slit *) 0;
-#endif // SLIT
-
- if ((win = searchWindow(e->xdestroywindow.window))) {
- win->destroyNotifyEvent(&e->xdestroywindow);
- if (focused_window == win)
- focused_window = (OpenboxWindow *) 0;
-#ifdef SLIT
- } else if ((slit = searchSlit(e->xdestroywindow.window))) {
- slit->removeClient(e->xdestroywindow.window, False);
-#endif // SLIT
- }
-
- break;
- }
-
- case MotionNotify: {
- // strip the lock key modifiers
- e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask);
-
- last_time = e->xmotion.time;
-
- OpenboxWindow *win = (OpenboxWindow *) 0;
- Basemenu *menu = (Basemenu *) 0;
-
- if ((win = searchWindow(e->xmotion.window)))
- win->motionNotifyEvent(&e->xmotion);
- else if ((menu = searchMenu(e->xmotion.window)))
- menu->motionNotifyEvent(&e->xmotion);
-
- break;
- }
-
- case PropertyNotify: {
- last_time = e->xproperty.time;
-
- if (e->xproperty.state != PropertyDelete) {
- OpenboxWindow *win = searchWindow(e->xproperty.window);
-
- if (win)
- win->propertyNotifyEvent(e->xproperty.atom);
- }
-
- break;
- }
-
- case EnterNotify: {
- last_time = e->xcrossing.time;
-
- BScreen *screen = (BScreen *) 0;
- OpenboxWindow *win = (OpenboxWindow *) 0;
- Basemenu *menu = (Basemenu *) 0;
- Toolbar *tbar = (Toolbar *) 0;
-
-#ifdef SLIT
- Slit *slit = (Slit *) 0;
-#endif // SLIT
-
- if (e->xcrossing.mode == NotifyGrab) break;
-
- XEvent dummy;
- scanargs sa;
- sa.w = e->xcrossing.window;
- sa.enter = sa.leave = False;
- XCheckIfEvent(getXDisplay(), &dummy, queueScanner, (char *) &sa);
-
- if ((e->xcrossing.window == e->xcrossing.root) &&
- (screen = searchScreen(e->xcrossing.window))) {
- screen->getImageControl()->installRootColormap();
- } else if ((win = searchWindow(e->xcrossing.window))) {
- if (win->getScreen()->sloppyFocus() &&
- (! win->isFocused()) && (! no_focus)) {
- grab();
-
- if (((! sa.leave) || sa.inferior) && win->isVisible() &&
- win->setInputFocus())
- win->installColormap(True);
-
- ungrab();
- }
- } else if ((menu = searchMenu(e->xcrossing.window))) {
- menu->enterNotifyEvent(&e->xcrossing);
- } else if ((tbar = searchToolbar(e->xcrossing.window))) {
- tbar->enterNotifyEvent(&e->xcrossing);
-#ifdef SLIT
- } else if ((slit = searchSlit(e->xcrossing.window))) {
- slit->enterNotifyEvent(&e->xcrossing);
-#endif // SLIT
- }
- break;
- }
-
- case LeaveNotify: {
- last_time = e->xcrossing.time;
-
- OpenboxWindow *win = (OpenboxWindow *) 0;
- Basemenu *menu = (Basemenu *) 0;
- Toolbar *tbar = (Toolbar *) 0;
-
-#ifdef SLIT
- Slit *slit = (Slit *) 0;
-#endif // SLIT
-
- if ((menu = searchMenu(e->xcrossing.window)))
- menu->leaveNotifyEvent(&e->xcrossing);
- else if ((win = searchWindow(e->xcrossing.window)))
- win->installColormap(False);
- else if ((tbar = searchToolbar(e->xcrossing.window)))
- tbar->leaveNotifyEvent(&e->xcrossing);
-#ifdef SLIT
- else if ((slit = searchSlit(e->xcrossing.window)))
- slit->leaveNotifyEvent(&e->xcrossing);
-#endif // SLIT
-
- break;
- }
-
- case Expose: {
- OpenboxWindow *win = (OpenboxWindow *) 0;
- Basemenu *menu = (Basemenu *) 0;
- Toolbar *tbar = (Toolbar *) 0;
-
- if ((win = searchWindow(e->xexpose.window)))
- win->exposeEvent(&e->xexpose);
- else if ((menu = searchMenu(e->xexpose.window)))
- menu->exposeEvent(&e->xexpose);
- else if ((tbar = searchToolbar(e->xexpose.window)))
- tbar->exposeEvent(&e->xexpose);
-
- break;
- }
-
- case KeyPress: {
- Toolbar *tbar = searchToolbar(e->xkey.window);
-
- if (tbar && tbar->isEditing())
- tbar->keyPressEvent(&e->xkey);
-
- break;
- }
-
- case ColormapNotify: {
- BScreen *screen = searchScreen(e->xcolormap.window);
-
- if (screen)
- screen->setRootColormapInstalled((e->xcolormap.state ==
- ColormapInstalled) ? True : False);
-
- break;
- }
-
- case FocusIn: {
- if (e->xfocus.mode == NotifyUngrab || e->xfocus.detail == NotifyPointer)
- break;
-
- OpenboxWindow *win = searchWindow(e->xfocus.window);
- if (win && ! win->isFocused())
- setFocusedWindow(win);
-
- break;
- }
-
- case FocusOut:
- break;
-
- case ClientMessage: {
- if (e->xclient.format == 32) {
- if (e->xclient.message_type == getWMChangeStateAtom()) {
- OpenboxWindow *win = searchWindow(e->xclient.window);
- if (! win || ! win->validateClient()) return;
-
- if (e->xclient.data.l[0] == IconicState)
- win->iconify();
- if (e->xclient.data.l[0] == NormalState)
- win->deiconify();
- } else if (e->xclient.message_type == getOpenboxChangeWorkspaceAtom()) {
- BScreen *screen = searchScreen(e->xclient.window);
-
- if (screen && e->xclient.data.l[0] >= 0 &&
- e->xclient.data.l[0] < screen->getWorkspaceCount())
- screen->changeWorkspaceID(e->xclient.data.l[0]);
- } else if (e->xclient.message_type == getOpenboxChangeWindowFocusAtom()) {
- OpenboxWindow *win = searchWindow(e->xclient.window);
-
- if (win && win->isVisible() && win->setInputFocus())
- win->installColormap(True);
- } else if (e->xclient.message_type == getOpenboxCycleWindowFocusAtom()) {
- BScreen *screen = searchScreen(e->xclient.window);
-
- if (screen) {
- if (! e->xclient.data.l[0])
- screen->prevFocus();
- else
- screen->nextFocus();
- }
- } else if (e->xclient.message_type == getOpenboxChangeAttributesAtom()) {
- OpenboxWindow *win = searchWindow(e->xclient.window);
-
- if (win && win->validateClient()) {
- OpenboxHints net;
- net.flags = e->xclient.data.l[0];
- net.attrib = e->xclient.data.l[1];
- net.workspace = e->xclient.data.l[2];
- net.stack = e->xclient.data.l[3];
- net.decoration = e->xclient.data.l[4];
-
- win->changeOpenboxHints(&net);
- }
- }
- }
-
- break;
- }
-
-
- default: {
-#ifdef SHAPE
- if (e->type == getShapeEventBase()) {
- XShapeEvent *shape_event = (XShapeEvent *) e;
- OpenboxWindow *win = (OpenboxWindow *) 0;
-
- if ((win = searchWindow(e->xany.window)) ||
- (shape_event->kind != ShapeBounding))
- win->shapeEvent(shape_event);
- }
-#endif // SHAPE