From a0dbb0e13f19ac4cc2dddf3d94723174971df6d2 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sun, 12 May 2002 01:23:48 +0000 Subject: [PATCH] couple of LinkedLists converted to STL lists in BScreen changed teh calls to XSetInputFocus. Using the root window as the fallback when there is nothing to focus instead of the toolbar. Also, always using 'RevertToPointerRoot' instead of sometimes 'RevertToParent' --- src/Configmenu.cc | 21 ++--------- src/Screen.cc | 94 ++++++++++++++++++++++------------------------- src/Screen.h | 8 +++- src/Toolbar.cc | 4 +- src/Window.cc | 2 +- src/Workspace.cc | 13 +++---- 6 files changed, 62 insertions(+), 80 deletions(-) diff --git a/src/Configmenu.cc b/src/Configmenu.cc index 0a219662..3282463e 100644 --- a/src/Configmenu.cc +++ b/src/Configmenu.cc @@ -1,4 +1,5 @@ // Configmenu.cc for Openbox +// Copyright (c) 2002 - 2002 Ben Jansens // Copyright (c) 2001 Sean 'Shaleh' Perry // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) // @@ -184,32 +185,18 @@ void Configmenu::Focusmenu::itemSelected(int button, int index) { case 1: // click to focus configmenu->screen.setSloppyFocus(false); configmenu->screen.setAutoRaise(false); - - if (! configmenu->screen.getOpenbox().focusedWindow()) - XSetInputFocus(configmenu->screen.getOpenbox().getXDisplay(), - configmenu->screen.getToolbar()->getWindowID(), - RevertToParent, CurrentTime); - else - XSetInputFocus(configmenu->screen.getOpenbox().getXDisplay(), - configmenu->screen.getOpenbox(). - focusedWindow()->getClientWindow(), - RevertToParent, CurrentTime); - + // make windows all grab button1 clicks configmenu->screen.reconfigure(); - break; case 2: // sloppy focus configmenu->screen.setSloppyFocus(true); - + // make windows stop grabbing button1 clicks configmenu->screen.reconfigure(); - break; case 3: // auto raise with sloppy focus - bool change = ((configmenu->screen.autoRaise()) ? false : true); - configmenu->screen.setAutoRaise(change); - + configmenu->screen.setAutoRaise(!configmenu->screen.autoRaise()); break; } diff --git a/src/Screen.cc b/src/Screen.cc index f3ff579e..29a7a69d 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -236,8 +236,6 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn), workspaceNames = new LinkedList; workspacesList = new LinkedList; - rootmenuList = new LinkedList; - netizenList = new LinkedList; iconList = new LinkedList; image_control = @@ -484,9 +482,8 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn), } } - if (! resource.sloppy_focus) - XSetInputFocus(getBaseDisplay().getXDisplay(), toolbar->getWindowID(), - RevertToParent, CurrentTime); + XSetInputFocus(getBaseDisplay().getXDisplay(), + PointerRoot, None, CurrentTime); XFree(children); XFlush(getBaseDisplay().getXDisplay()); @@ -507,14 +504,14 @@ BScreen::~BScreen(void) { while (workspacesList->count()) delete workspacesList->remove(0); - while (rootmenuList->count()) - rootmenuList->remove(0); + while (!rootmenuList.empty()) + rootmenuList.erase(rootmenuList.begin()); while (iconList->count()) delete iconList->remove(0); - while (netizenList->count()) - delete netizenList->remove(0); + while (!netizenList.empty()) + netizenList.erase(netizenList.begin()); #ifdef HAVE_STRFTIME if (resource.strftime_format) @@ -535,9 +532,7 @@ BScreen::~BScreen(void) { delete workspacesList; delete workspaceNames; - delete rootmenuList; delete iconList; - delete netizenList; if (resource.wstyle.fontset) XFreeFontSet(getBaseDisplay().getXDisplay(), resource.wstyle.fontset); @@ -2012,7 +2007,7 @@ void BScreen::changeWorkspaceID(int id) { void BScreen::addNetizen(Netizen *n) { - netizenList->insert(n); + netizenList.push_back(n); n->sendWorkspaceCount(); n->sendCurrentWorkspace(); @@ -2031,80 +2026,79 @@ void BScreen::addNetizen(Netizen *n) { void BScreen::removeNetizen(Window w) { - LinkedListIterator it(netizenList); + netList::iterator it; int i = 0; - for (Netizen *n = it.current(); n; it++, i++, n = it.current()) - if (n->getWindowID() == w) { - Netizen *tmp = netizenList->remove(i); + for (it = netizenList.begin(); it != netizenList.end(); ++it) + if ((*it)->getWindowID() == w) { + Netizen *tmp = *it; + netizenList.erase(it); delete tmp; - break; } } void BScreen::updateNetizenCurrentWorkspace(void) { - LinkedListIterator it(netizenList); - for (Netizen *n = it.current(); n; it++, n = it.current()) - n->sendCurrentWorkspace(); + netList::iterator it; + for (it = netizenList.begin(); it != netizenList.end(); ++it) + (*it)->sendCurrentWorkspace(); } void BScreen::updateNetizenWorkspaceCount(void) { - LinkedListIterator it(netizenList); - for (Netizen *n = it.current(); n; it++, n = it.current()) - n->sendWorkspaceCount(); + netList::iterator it; + for (it = netizenList.begin(); it != netizenList.end(); ++it) + (*it)->sendWorkspaceCount(); } void BScreen::updateNetizenWindowFocus(void) { Window f = ((openbox.focusedWindow()) ? openbox.focusedWindow()->getClientWindow() : None); - LinkedListIterator it(netizenList); - for (Netizen *n = it.current(); n; it++, n = it.current()) - n->sendWindowFocus(f); + netList::iterator it; + for (it = netizenList.begin(); it != netizenList.end(); ++it) + (*it)->sendWindowFocus(f); } - void BScreen::updateNetizenWindowAdd(Window w, unsigned long p) { - LinkedListIterator it(netizenList); - for (Netizen *n = it.current(); n; it++, n = it.current()) - n->sendWindowAdd(w, p); + netList::iterator it; + for (it = netizenList.begin(); it != netizenList.end(); ++it) + (*it)->sendWindowAdd(w, p); } void BScreen::updateNetizenWindowDel(Window w) { - LinkedListIterator it(netizenList); - for (Netizen *n = it.current(); n; it++, n = it.current()) - n->sendWindowDel(w); + netList::iterator it; + for (it = netizenList.begin(); it != netizenList.end(); ++it) + (*it)->sendWindowDel(w); } void BScreen::updateNetizenWindowRaise(Window w) { - LinkedListIterator it(netizenList); - for (Netizen *n = it.current(); n; it++, n = it.current()) - n->sendWindowRaise(w); + netList::iterator it; + for (it = netizenList.begin(); it != netizenList.end(); ++it) + (*it)->sendWindowRaise(w); } void BScreen::updateNetizenWindowLower(Window w) { - LinkedListIterator it(netizenList); - for (Netizen *n = it.current(); n; it++, n = it.current()) - n->sendWindowLower(w); + netList::iterator it; + for (it = netizenList.begin(); it != netizenList.end(); ++it) + (*it)->sendWindowLower(w); } void BScreen::updateNetizenConfigNotify(XEvent *e) { - LinkedListIterator it(netizenList); - for (Netizen *n = it.current(); n; it++, n = it.current()) - n->sendConfigNotify(e); + netList::iterator it; + for (it = netizenList.begin(); it != netizenList.end(); ++it) + (*it)->sendConfigNotify(e); } void BScreen::raiseWindows(Window *workspace_stack, int num) { Window *session_stack = new - Window[(num + workspacesList->count() + rootmenuList->count() + 13)]; + Window[(num + workspacesList->count() + rootmenuList.size() + 13)]; int i = 0, k = num; XRaiseWindow(getBaseDisplay().getXDisplay(), iconmenu->getWindowID()); @@ -2130,9 +2124,9 @@ void BScreen::raiseWindows(Window *workspace_stack, int num) { toolbar->getMenu()->getPlacementmenu()->getWindowID(); *(session_stack + i++) = toolbar->getMenu()->getWindowID(); - LinkedListIterator rit(rootmenuList); - for (Rootmenu *tmp = rit.current(); tmp; rit++, tmp = rit.current()) - *(session_stack + i++) = tmp->getWindowID(); + menuList::iterator rit; + for (rit = rootmenuList.begin(); rit != rootmenuList.end(); ++rit) + *(session_stack + i++) = (*rit)->getWindowID(); *(session_stack + i++) = rootmenu->getWindowID(); if (toolbar->onTop()) @@ -2276,8 +2270,8 @@ void BScreen::raiseFocus(void) { void BScreen::InitMenu(void) { if (rootmenu) { - while (rootmenuList->count()) - rootmenuList->remove(0); + while (!rootmenuList.empty()) + rootmenuList.erase(rootmenuList.begin()); while (rootmenu->getCount()) rootmenu->remove(0); @@ -2580,7 +2574,7 @@ Bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) { parseMenuFile(file, submenu); submenu->update(); menu->insert(label, submenu); - rootmenuList->insert(submenu); + rootmenuList.push_back(submenu); } break; @@ -2706,7 +2700,7 @@ Bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) { if (newmenu) { stylesmenu->setLabel(label); menu->insert(label, stylesmenu); - rootmenuList->insert(stylesmenu); + rootmenuList.push_back(stylesmenu); } openbox.setMenuFilename(stylesdir); diff --git a/src/Screen.h b/src/Screen.h index 8d5b09b8..d496914b 100644 --- a/src/Screen.h +++ b/src/Screen.h @@ -53,6 +53,10 @@ #include "Image.h" #include "Resource.h" +#include +typedef std::list menuList; +typedef std::list netList; + // forward declaration class BScreen; @@ -109,8 +113,8 @@ private: Iconmenu *iconmenu; Rootmenu *rootmenu; - LinkedList *rootmenuList; - LinkedList *netizenList; + menuList rootmenuList; + netList netizenList; LinkedList *iconList; #ifdef SLIT diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 7659c87f..7e28fe62 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -971,9 +971,7 @@ void Toolbar::edit() { return; XSetInputFocus(display, frame.workspace_label, - ((screen.sloppyFocus()) ? RevertToPointerRoot : - RevertToParent), - CurrentTime); + RevertToPointerRoot, CurrentTime); XClearWindow(display, frame.workspace_label); openbox.setNoFocus(True); diff --git a/src/Window.cc b/src/Window.cc index 5a28d232..6222546f 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -1388,7 +1388,7 @@ Bool OpenboxWindow::setInputFocus(void) { } else if (! flags.focused) { if (focus_mode == F_LocallyActive || focus_mode == F_Passive) XSetInputFocus(display, client.window, - RevertToPointerRoot, CurrentTime); + RevertToPointerRoot, CurrentTime); else XSetInputFocus(display, screen->getRootWindow(), RevertToNone, CurrentTime); diff --git a/src/Workspace.cc b/src/Workspace.cc index 4b9bb33b..256ad3da 100644 --- a/src/Workspace.cc +++ b/src/Workspace.cc @@ -115,14 +115,13 @@ const int Workspace::removeWindow(OpenboxWindow *w) { if (w->isTransient() && w->getTransientFor() && w->getTransientFor()->isVisible()) { w->getTransientFor()->setInputFocus(); - } else if (screen.sloppyFocus()) { - screen.getOpenbox().focusWindow((OpenboxWindow *) 0); } else { - if (_zorder.empty() || !_zorder.front()->setInputFocus()) { + if (screen.sloppyFocus() || // sloppy focus + _zorder.empty() || // click focus but no windows + !_zorder.front()->setInputFocus()) { // tried window, but wont focus screen.getOpenbox().focusWindow((OpenboxWindow *) 0); - XSetInputFocus(screen.getOpenbox().getXDisplay(), - screen.getToolbar()->getWindowID(), - RevertToParent, CurrentTime); + XSetInputFocus(screen.getOpenbox().getXDisplay(), + PointerRoot, None, CurrentTime); } } } @@ -319,7 +318,7 @@ void Workspace::setName(char *new_name) { void Workspace::shutdown(void) { while (!_windows.empty()) { _windows[0]->restore(); - _windows.erase(_windows.begin()); + delete _windows[0]; } } -- 2.39.2