Openbox *openbox;
-Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc)
- : BaseDisplay(m_argv[0], dpy_name) {
- grab();
+Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc,
+ char *menu) : BaseDisplay(m_argv[0], dpy_name) {
+ grab();
- if (! XSupportsLocale())
- fprintf(stderr, "X server does not support locale\n");
+ if (! XSupportsLocale())
+ fprintf(stderr, "X server does not support locale\n");
- if (XSetLocaleModifiers("") == NULL)
- fprintf(stderr, "cannot set locale modifiers\n");
+ if (XSetLocaleModifiers("") == NULL)
+ fprintf(stderr, "cannot set locale modifiers\n");
- ::openbox = this;
- argc = m_argc;
- argv = m_argv;
- if (rc == NULL) {
- char *homedir = getenv("HOME");
+ ::openbox = this;
+ argc = m_argc;
+ argv = m_argv;
+ if (rc == NULL || menu == NULL) {
+ char *homedir = getenv("HOME");
+ char *configdir = new char[strlen(homedir) + strlen("/.openbox") + 1];
+ sprintf(configdir, "%s/.openbox", homedir);
+ // try to make sure the ~/.openbox directory exists
+ mkdir(configdir, S_IREAD | S_IWRITE | S_IEXEC |
+ S_IRGRP | S_IWGRP | S_IXGRP |
+ S_IROTH | S_IWOTH | S_IXOTH);
- rc_file = new char[strlen(homedir) + strlen("/.openbox/rc") + 1];
- sprintf(rc_file, "%s/.openbox", homedir);
- // try to make sure the ~/.openbox directory exists
- mkdir(rc_file, S_IREAD | S_IWRITE | S_IEXEC | S_IRGRP | S_IWGRP | S_IXGRP |
- S_IROTH | S_IWOTH | S_IXOTH);
-
- sprintf(rc_file, "%s/.openbox/rc", homedir);
- } else {
- rc_file = bstrdup(rc);
- }
- config.setFile(rc_file);
+ if (rc == NULL) {
+ rc_file = new char[strlen(configdir) + strlen("/rc") + 1];
+ sprintf(rc_file, "%s/rc", configdir);
+ } else
+ rc_file = bstrdup(rc);
- no_focus = False;
+ if (menu == NULL) {
+ menu_file = new char[strlen(configdir) + strlen("/menu") + 1];
+ sprintf(menu_file, "%s/menu", configdir);
+ } else
+ menu_file = bstrdup(menu);
- resource.menu_file = resource.style_file = (char *) 0;
- resource.titlebar_layout = (char *) NULL;
- resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
+ delete [] configdir;
+ }
+ config.setFile(rc_file);
- focused_window = masked_window = (OpenboxWindow *) 0;
- masked = None;
+ no_focus = False;
- windowSearchList = new LinkedList<WindowSearch>;
- menuSearchList = new LinkedList<MenuSearch>;
+ resource.style_file = NULL;
+ resource.titlebar_layout = NULL;
+ resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
-#ifdef SLIT
- slitSearchList = new LinkedList<SlitSearch>;
-#endif // SLIT
+ current_screen = (BScreen *) 0;
+ masked_window = (OpenboxWindow *) 0;
+ masked = None;
- toolbarSearchList = new LinkedList<ToolbarSearch>;
- groupSearchList = new LinkedList<WindowSearch>;
-
- menuTimestamps = new LinkedList<MenuTimestamp>;
-
- load();
+ load();
#ifdef HAVE_GETPID
- openbox_pid = XInternAtom(getXDisplay(), "_BLACKBOX_PID", False);
+ openbox_pid = XInternAtom(getXDisplay(), "_BLACKBOX_PID", False);
#endif // HAVE_GETPID
- screenList = new LinkedList<BScreen>;
- for (int i = 0; i < getNumberOfScreens(); i++) {
- BScreen *screen = new BScreen(*this, i, config);
+ for (unsigned int s = 0; s < numberOfScreens(); s++) {
+ BScreen *screen = new BScreen(*this, s, config);
- if (! screen->isScreenManaged()) {
- delete screen;
- continue;
- }
+ if (! screen->isScreenManaged()) {
+ delete screen;
+ continue;
+ }
- screenList->insert(screen);
- }
+ screenList.push_back(screen);
+ }
- if (! screenList->count()) {
- fprintf(stderr,
- i18n->getMessage(openboxSet, openboxNoManagableScreens,
- "Openbox::Openbox: no managable screens found, aborting.\n"));
- ::exit(3);
- }
+ if (screenList.empty()) {
+ fprintf(stderr,
+ i18n(openboxSet, openboxNoManagableScreens,
+ "Openbox::Openbox: no managable screens found, aborting.\n"));
+ ::exit(3);
+ }
+ current_screen = screenList[0];
- // save current settings and default values
- save();
-
- XSynchronize(getXDisplay(), False);
- XSync(getXDisplay(), False);
+ // save current settings and default values
+ save();
- reconfigure_wait = reread_menu_wait = False;
+ XSynchronize(getXDisplay(), False);
+ XSync(getXDisplay(), False);
- timer = new BTimer(*this, *this);
- timer->setTimeout(0);
- timer->fireOnce(True);
+ reconfigure_wait = reread_menu_wait = False;
- ungrab();
-}
+ timer = new BTimer(*this, *this);
+ timer->setTimeout(0);
+ timer->fireOnce(True);
+ ungrab();
-Openbox::~Openbox() {
- while (screenList->count())
- delete screenList->remove(0);
+ focusWindow(0);
+ }
- while (menuTimestamps->count()) {
- MenuTimestamp *ts = menuTimestamps->remove(0);
- if (ts->filename)
- delete [] ts->filename;
-
- delete ts;
- }
+Openbox::~Openbox() {
+ for_each(screenList.begin(), screenList.end(),
+ PointerAssassin());
- if (resource.menu_file)
- delete [] resource.menu_file;
+ for_each(menuTimestamps.begin(), menuTimestamps.end(),
+ PointerAssassin());
if (resource.style_file)
delete [] resource.style_file;
- delete timer;
-
- delete screenList;
- delete menuTimestamps;
+ if (resource.titlebar_layout)
+ delete [] resource.titlebar_layout;
- delete windowSearchList;
- delete menuSearchList;
- delete toolbarSearchList;
- delete groupSearchList;
+ delete timer;
delete [] rc_file;
-
-#ifdef SLIT
- delete slitSearchList;
-#endif // SLIT
+ delete [] menu_file;
}
void Openbox::process_event(XEvent *e) {
- if ((masked == e->xany.window) && masked_window &&
+ if ((masked == e->xany.window && masked_window) &&
(e->type == MotionNotify)) {
last_time = e->xmotion.time;
masked_window->motionNotifyEvent(&e->xmotion);
-
return;
}
win->buttonPressEvent(&e->xbutton);
if (e->xbutton.button == 1)
- win->installColormap(True);
+ win->installColormap(True);
} else if ((menu = searchMenu(e->xbutton.window))) {
menu->buttonPressEvent(&e->xbutton);
} 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) {
+ ScreenList::iterator it;
+ for (it = screenList.begin(); it != screenList.end(); ++it) {
+ BScreen *screen = *it;
+ if (e->xbutton.window == screen->getRootWindow()) {
+ if (e->xbutton.button == 1) {
if (! screen->isRootColormapInstalled())
- screen->getImageControl()->installRootColormap();
+ screen->getImageControl()->installRootColormap();
- if (screen->getWorkspacemenu()->isVisible())
- screen->getWorkspacemenu()->hide();
+ 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();
- }
+ 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)
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);
+ 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();
case MapRequest: {
#ifdef DEBUG
fprintf(stderr,
- i18n->getMessage(openboxSet, openboxMapRequest,
- "Openbox::process_event(): MapRequest for 0x%lx\n"),
- e->xmaprequest.window);
+ i18n(openboxSet, openboxMapRequest,
+ "Openbox::process_event(): MapRequest for 0x%lx\n"),
+ e->xmaprequest.window);
#endif // DEBUG
OpenboxWindow *win = searchWindow(e->xmaprequest.window);
if (win)
win->mapNotifyEvent(&e->xmap);
- break;
+ break;
}
case UnmapNotify: {
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);
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);
case MotionNotify: {
// strip the lock key modifiers
e->xbutton.state &= ~(NumLockMask | ScrollLockMask | LockMask);
-
+
last_time = e->xmotion.time;
OpenboxWindow *win = (OpenboxWindow *) 0;
OpenboxWindow *win = searchWindow(e->xproperty.window);
if (win)
- win->propertyNotifyEvent(e->xproperty.atom);
+ win->propertyNotifyEvent(e->xproperty.atom);
}
break;
XCheckIfEvent(getXDisplay(), &dummy, queueScanner, (char *) &sa);
if ((e->xcrossing.window == e->xcrossing.root) &&
- (screen = searchScreen(e->xcrossing.window))) {
+ (screen = searchScreen(e->xcrossing.window))) {
screen->getImageControl()->installRootColormap();
} else if ((win = searchWindow(e->xcrossing.window))) {
if (win->getScreen()->sloppyFocus() &&
- (! win->isFocused()) && (! no_focus)) {
- grab();
+ (! win->isFocused()) && (! no_focus)) {
+ grab();
if (((! sa.leave) || sa.inferior) && win->isVisible() &&
win->setInputFocus())
- win->installColormap(True);
+ win->installColormap(True);
ungrab();
}
if (screen)
screen->setRootColormapInstalled((e->xcolormap.state ==
- ColormapInstalled) ? True : False);
+ ColormapInstalled) ? True : False);
break;
}
break;
OpenboxWindow *win = searchWindow(e->xfocus.window);
- if (win && ! win->isFocused())
- setFocusedWindow(win);
+ if (win && !win->isFocused())
+ focusWindow(win);
break;
}
if (! win || ! win->validateClient()) return;
if (e->xclient.data.l[0] == IconicState)
- win->iconify();
+ win->iconify();
if (e->xclient.data.l[0] == NormalState)
win->deiconify();
} else if (e->xclient.message_type == getOpenboxChangeWorkspaceAtom()) {
- BScreen *screen = searchScreen(e->xclient.window);
+ 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]);
+ 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);
+ OpenboxWindow *win = searchWindow(e->xclient.window);
- if (win && win->isVisible() && win->setInputFocus())
+ if (win && win->isVisible() && win->setInputFocus())
win->installColormap(True);
} else if (e->xclient.message_type == getOpenboxCycleWindowFocusAtom()) {
BScreen *screen = searchScreen(e->xclient.window);
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);
- }
+ 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);
+ }
}
}
OpenboxWindow *win = (OpenboxWindow *) 0;
if ((win = searchWindow(e->xany.window)) ||
- (shape_event->kind != ShapeBounding))
- win->shapeEvent(shape_event);
+ (shape_event->kind != ShapeBounding))
+ win->shapeEvent(shape_event);
}
#endif // SHAPE
BScreen *Openbox::searchScreen(Window window) {
- LinkedListIterator<BScreen> it(screenList);
-
- for (BScreen *curr = it.current(); curr; it++, curr = it.current()) {
- if (curr->getRootWindow() == window) {
- return curr;
- }
- }
-
+ ScreenList::iterator it;
+ for (it = screenList.begin(); it != screenList.end(); ++it)
+ if ((*it)->getRootWindow() == window)
+ return *it;
return (BScreen *) 0;
}
OpenboxWindow *Openbox::searchWindow(Window window) {
- LinkedListIterator<WindowSearch> it(windowSearchList);
-
- for (WindowSearch *tmp = it.current(); tmp; it++, tmp = it.current()) {
- if (tmp->getWindow() == window) {
- return tmp->getData();
- }
- }
-
- return (OpenboxWindow *) 0;
+ WindowLookup::iterator it = windowSearchList.find(window);
+ if (it == windowSearchList.end())
+ return (OpenboxWindow *) 0;
+ return it->second;
}
OpenboxWindow *Openbox::searchGroup(Window window, OpenboxWindow *win) {
- OpenboxWindow *w = (OpenboxWindow *) 0;
- LinkedListIterator<WindowSearch> it(groupSearchList);
-
- for (WindowSearch *tmp = it.current(); tmp; it++, tmp = it.current()) {
- if (tmp->getWindow() == window) {
- w = tmp->getData();
- if (w->getClientWindow() != win->getClientWindow())
- return win;
- }
- }
-
+ WindowLookup::iterator it = groupSearchList.find(window);
+ if (it != groupSearchList.end())
+ if (it->second->getClientWindow() != win->getClientWindow())
+ return win;
return (OpenboxWindow *) 0;
}
Basemenu *Openbox::searchMenu(Window window) {
- LinkedListIterator<MenuSearch> it(menuSearchList);
-
- for (MenuSearch *tmp = it.current(); tmp; it++, tmp = it.current()) {
- if (tmp->getWindow() == window)
- return tmp->getData();
- }
-
- return (Basemenu *) 0;
+ MenuLookup::iterator it = menuSearchList.find(window);
+ if (it == menuSearchList.end())
+ return (Basemenu *) 0;
+ return it->second;
}
Toolbar *Openbox::searchToolbar(Window window) {
- LinkedListIterator<ToolbarSearch> it(toolbarSearchList);
-
- for (ToolbarSearch *tmp = it.current(); tmp; it++, tmp = it.current()) {
- if (tmp->getWindow() == window)
- return tmp->getData();
- }
-
- return (Toolbar *) 0;
+ ToolbarLookup::iterator it = toolbarSearchList.find(window);
+ if (it == toolbarSearchList.end())
+ return (Toolbar *) 0;
+ return it->second;
}
#ifdef SLIT
Slit *Openbox::searchSlit(Window window) {
- LinkedListIterator<SlitSearch> it(slitSearchList);
-
- for (SlitSearch *tmp = it.current(); tmp; it++, tmp = it.current()) {
- if (tmp->getWindow() == window)
- return tmp->getData();
- }
-
- return (Slit *) 0;
+ SlitLookup::iterator it = slitSearchList.find(window);
+ if (it == slitSearchList.end())
+ return (Slit *) 0;
+ return it->second;
}
#endif // SLIT
void Openbox::saveWindowSearch(Window window, OpenboxWindow *data) {
- windowSearchList->insert(new WindowSearch(window, data));
+ windowSearchList.insert(WindowLookupPair(window, data));
}
void Openbox::saveGroupSearch(Window window, OpenboxWindow *data) {
- groupSearchList->insert(new WindowSearch(window, data));
+ groupSearchList.insert(WindowLookupPair(window, data));
}
void Openbox::saveMenuSearch(Window window, Basemenu *data) {
- menuSearchList->insert(new MenuSearch(window, data));
+ menuSearchList.insert(MenuLookupPair(window, data));
}
void Openbox::saveToolbarSearch(Window window, Toolbar *data) {
- toolbarSearchList->insert(new ToolbarSearch(window, data));
+ toolbarSearchList.insert(ToolbarLookupPair(window, data));
}
#ifdef SLIT
void Openbox::saveSlitSearch(Window window, Slit *data) {
- slitSearchList->insert(new SlitSearch(window, data));
+ slitSearchList.insert(SlitLookupPair(window, data));
}
#endif // SLIT
void Openbox::removeWindowSearch(Window window) {
- LinkedListIterator<WindowSearch> it(windowSearchList);
- for (WindowSearch *tmp = it.current(); tmp; it++, tmp = it.current()) {
- if (tmp->getWindow() == window) {
- windowSearchList->remove(tmp);
- delete tmp;
- break;
- }
- }
+ windowSearchList.erase(window);
}
void Openbox::removeGroupSearch(Window window) {
- LinkedListIterator<WindowSearch> it(groupSearchList);
- for (WindowSearch *tmp = it.current(); tmp; it++, tmp = it.current()) {
- if (tmp->getWindow() == window) {
- groupSearchList->remove(tmp);
- delete tmp;
- break;
- }
- }
+ groupSearchList.erase(window);
}
void Openbox::removeMenuSearch(Window window) {
- LinkedListIterator<MenuSearch> it(menuSearchList);
- for (MenuSearch *tmp = it.current(); tmp; it++, tmp = it.current()) {
- if (tmp->getWindow() == window) {
- menuSearchList->remove(tmp);
- delete tmp;
- break;
- }
- }
+ menuSearchList.erase(window);
}
void Openbox::removeToolbarSearch(Window window) {
- LinkedListIterator<ToolbarSearch> it(toolbarSearchList);
- for (ToolbarSearch *tmp = it.current(); tmp; it++, tmp = it.current()) {
- if (tmp->getWindow() == window) {
- toolbarSearchList->remove(tmp);
- delete tmp;
- break;
- }
- }
+ toolbarSearchList.erase(window);
}
#ifdef SLIT
void Openbox::removeSlitSearch(Window window) {
- LinkedListIterator<SlitSearch> it(slitSearchList);
- for (SlitSearch *tmp = it.current(); tmp; it++, tmp = it.current()) {
- if (tmp->getWindow() == window) {
- slitSearchList->remove(tmp);
- delete tmp;
- break;
- }
- }
+ slitSearchList.erase(window);
}
#endif // SLIT
void Openbox::shutdown() {
BaseDisplay::shutdown();
- XSetInputFocus(getXDisplay(), PointerRoot, None, CurrentTime);
+ std::for_each(screenList.begin(), screenList.end(),
+ std::mem_fun(&BScreen::shutdown));
- LinkedListIterator<BScreen> it(screenList);
- for (BScreen *s = it.current(); s; it++, s = it.current())
- s->shutdown();
+ focusWindow(0);
XSync(getXDisplay(), False);
}
void Openbox::save() {
config.setAutoSave(false);
-
+
// save all values as they are so that the defaults will be written to the rc
// file
-
- config.setValue("session.menuFile", getMenuFilename());
+
config.setValue("session.colorsPerChannel",
resource.colors_per_channel);
+ config.setValue("session.styleFile", resource.style_file);
+ config.setValue("session.titlebarLayout", resource.titlebar_layout);
config.setValue("session.doubleClickInterval",
(long)resource.double_click_interval);
config.setValue("session.autoRaiseDelay",
- ((resource.auto_raise_delay.tv_sec * 1000) +
- (resource.auto_raise_delay.tv_usec / 1000)));
+ ((resource.auto_raise_delay.tv_sec * 1000) +
+ (resource.auto_raise_delay.tv_usec / 1000)));
config.setValue("session.cacheLife", (long)resource.cache_life / 60000);
config.setValue("session.cacheMax", (long)resource.cache_max);
- config.setValue("session.styleFile", resource.style_file);
- LinkedListIterator<BScreen> it(screenList);
- for (BScreen *s = it.current(); s != NULL; it++, s = it.current()) {
- s->save();
- s->getToolbar()->save();
- s->getSlit()->save();
- }
+ std::for_each(screenList.begin(), screenList.end(),
+ std::mem_fun(&BScreen::save));
config.setAutoSave(true);
config.save();
void Openbox::load() {
if (!config.load())
- return;
+ config.create();
std::string s;
long l;
-
- if (resource.menu_file)
- delete [] resource.menu_file;
- if (config.getValue("session.menuFile", "Session.MenuFile", s))
- resource.menu_file = bstrdup(s.c_str());
- else
- resource.menu_file = bstrdup(DEFAULTMENU);
if (config.getValue("session.colorsPerChannel", "Session.ColorsPerChannel",
l))
else
resource.double_click_interval = 250;
- if (!config.getValue("session.autoRaiseDelay", "Session.AutoRaiseDelay", l))
+ if (config.getValue("session.autoRaiseDelay", "Session.AutoRaiseDelay", l))
resource.auto_raise_delay.tv_usec = l;
else
resource.auto_raise_delay.tv_usec = 400;
grab();
load();
-
- for (int i = 0, n = menuTimestamps->count(); i < n; i++) {
- MenuTimestamp *ts = menuTimestamps->remove(0);
- if (ts) {
- if (ts->filename)
- delete [] ts->filename;
+ for_each(menuTimestamps.begin(), menuTimestamps.end(),
+ PointerAssassin());
+ menuTimestamps.clear();
- delete ts;
- }
- }
-
- LinkedListIterator<BScreen> it(screenList);
- for (BScreen *screen = it.current(); screen; it++, screen = it.current()) {
- screen->reconfigure();
- }
+ std::for_each(screenList.begin(), screenList.end(),
+ std::mem_fun(&BScreen::reconfigure));
ungrab();
}
void Openbox::checkMenu() {
- Bool reread = False;
- LinkedListIterator<MenuTimestamp> it(menuTimestamps);
- for (MenuTimestamp *tmp = it.current(); tmp && (! reread);
- it++, tmp = it.current()) {
+ MenuTimestampList::iterator it;
+ for (it = menuTimestamps.begin(); it != menuTimestamps.end(); ++it) {
struct stat buf;
- if (! stat(tmp->filename, &buf)) {
- if (tmp->timestamp != buf.st_ctime)
- reread = True;
- } else {
- reread = True;
+ if (stat((*it)->filename, &buf) || (*it)->timestamp != buf.st_ctime) {
+ rereadMenu();
+ return;
}
}
-
- if (reread) rereadMenu();
}
+void Openbox::addMenuTimestamp(const char *filename) {
+ bool found = false;
+
+ MenuTimestampList::iterator it;
+ for (it = menuTimestamps.begin(); it != menuTimestamps.end(); ++it)
+ if (! strcmp((*it)->filename, filename)) {
+ found = true;
+ break;
+ }
+ if (!found) {
+ struct stat buf;
+
+ if (! stat(filename, &buf)) {
+ MenuTimestamp *ts = new MenuTimestamp;
+
+ ts->filename = bstrdup(filename);
+ ts->timestamp = buf.st_ctime;
+
+ menuTimestamps.push_back(ts);
+ }
+ }
+}
+
void Openbox::rereadMenu() {
reread_menu_wait = True;
void Openbox::real_rereadMenu() {
- for (int i = 0, n = menuTimestamps->count(); i < n; i++) {
- MenuTimestamp *ts = menuTimestamps->remove(0);
-
- if (ts) {
- if (ts->filename)
- delete [] ts->filename;
-
- delete ts;
- }
- }
+ std::for_each(menuTimestamps.begin(), menuTimestamps.end(),
+ PointerAssassin());
+ menuTimestamps.clear();
- LinkedListIterator<BScreen> it(screenList);
- for (BScreen *screen = it.current(); screen; it++, screen = it.current())
- screen->rereadMenu();
+ std::for_each(screenList.begin(), screenList.end(),
+ std::mem_fun(&BScreen::rereadMenu));
}
}
-void Openbox::setMenuFilename(const char *filename) {
- Bool found = False;
-
- LinkedListIterator<MenuTimestamp> it(menuTimestamps);
- for (MenuTimestamp *tmp = it.current(); tmp && (! found);
- it++, tmp = it.current()) {
- if (! strcmp(tmp->filename, filename)) found = True;
- }
- if (! found) {
- struct stat buf;
-
- if (! stat(filename, &buf)) {
- MenuTimestamp *ts = new MenuTimestamp;
-
- ts->filename = bstrdup(filename);
- ts->timestamp = buf.st_ctime;
-
- menuTimestamps->insert(ts);
- }
- }
-}
-
-
void Openbox::timeout() {
if (reconfigure_wait)
real_reconfigure();
}
-void Openbox::setFocusedWindow(OpenboxWindow *win) {
- BScreen *old_screen = (BScreen *) 0, *screen = (BScreen *) 0;
- OpenboxWindow *old_win = (OpenboxWindow *) 0;
+OpenboxWindow *Openbox::focusedWindow() {
+ Workspace *w;
+ if (current_screen)
+ if ((w = current_screen->getCurrentWorkspace()))
+ return w->focusedWindow();
+ return (OpenboxWindow *) 0;
+}
+
+
+void Openbox::focusWindow(OpenboxWindow *win) {
+ BScreen *old_screen = (BScreen *) 0;
Toolbar *old_tbar = (Toolbar *) 0, *tbar = (Toolbar *) 0;
Workspace *old_wkspc = (Workspace *) 0, *wkspc = (Workspace *) 0;
- if (focused_window) {
- old_win = focused_window;
+ OpenboxWindow *old_win = focusedWindow();
+ if (old_win != (OpenboxWindow *) 0) {
old_screen = old_win->getScreen();
- old_tbar = old_screen->getToolbar();
old_wkspc = old_screen->getWorkspace(old_win->getWorkspaceNumber());
+ old_tbar = old_screen->getToolbar();
- old_win->setFocusFlag(False);
- old_wkspc->getMenu()->setItemSelected(old_win->getWindowNumber(), False);
+ old_win->setFocusFlag(false);
+ old_wkspc->focusWindow((OpenboxWindow *) 0);
}
- if (win && ! win->isIconic()) {
- screen = win->getScreen();
- tbar = screen->getToolbar();
- wkspc = screen->getWorkspace(win->getWorkspaceNumber());
-
- focused_window = win;
-
- win->setFocusFlag(True);
- wkspc->getMenu()->setItemSelected(win->getWindowNumber(), True);
+ if (win && !win->isIconic()) {
+ current_screen = win->getScreen();
+ tbar = current_screen->getToolbar();
+ if (win->isStuck())
+ wkspc = current_screen->getCurrentWorkspace();
+ else
+ wkspc = current_screen->getWorkspace(win->getWorkspaceNumber());
+ win->setFocusFlag(true);
+ wkspc->focusWindow(win);
+
+ if (tbar)
+ tbar->redrawWindowLabel(true);
+ current_screen->updateNetizenWindowFocus();
} else {
- focused_window = (OpenboxWindow *) 0;
+ XSetInputFocus(getXDisplay(), PointerRoot, None, CurrentTime);
}
- if (tbar)
- tbar->redrawWindowLabel(True);
- if (screen)
- screen->updateNetizenWindowFocus();
-
if (old_tbar && old_tbar != tbar)
- old_tbar->redrawWindowLabel(True);
- if (old_screen && old_screen != screen)
+ old_tbar->redrawWindowLabel(true);
+ if (old_screen && old_screen != current_screen)
old_screen->updateNetizenWindowFocus();
}