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'
This commit is contained in:
Dana Jansens 2002-05-12 01:23:48 +00:00
parent f804f86c3e
commit a0dbb0e13f
6 changed files with 62 additions and 80 deletions

View file

@ -1,4 +1,5 @@
// Configmenu.cc for Openbox // Configmenu.cc for Openbox
// Copyright (c) 2002 - 2002 Ben Jansens <ben@orodu.net>
// Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org> // Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) // 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 case 1: // click to focus
configmenu->screen.setSloppyFocus(false); configmenu->screen.setSloppyFocus(false);
configmenu->screen.setAutoRaise(false); configmenu->screen.setAutoRaise(false);
// make windows all grab button1 clicks
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);
configmenu->screen.reconfigure(); configmenu->screen.reconfigure();
break; break;
case 2: // sloppy focus case 2: // sloppy focus
configmenu->screen.setSloppyFocus(true); configmenu->screen.setSloppyFocus(true);
// make windows stop grabbing button1 clicks
configmenu->screen.reconfigure(); configmenu->screen.reconfigure();
break; break;
case 3: // auto raise with sloppy focus case 3: // auto raise with sloppy focus
bool change = ((configmenu->screen.autoRaise()) ? false : true); configmenu->screen.setAutoRaise(!configmenu->screen.autoRaise());
configmenu->screen.setAutoRaise(change);
break; break;
} }

View file

@ -236,8 +236,6 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn),
workspaceNames = new LinkedList<char>; workspaceNames = new LinkedList<char>;
workspacesList = new LinkedList<Workspace>; workspacesList = new LinkedList<Workspace>;
rootmenuList = new LinkedList<Rootmenu>;
netizenList = new LinkedList<Netizen>;
iconList = new LinkedList<OpenboxWindow>; iconList = new LinkedList<OpenboxWindow>;
image_control = image_control =
@ -484,9 +482,8 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn),
} }
} }
if (! resource.sloppy_focus) XSetInputFocus(getBaseDisplay().getXDisplay(),
XSetInputFocus(getBaseDisplay().getXDisplay(), toolbar->getWindowID(), PointerRoot, None, CurrentTime);
RevertToParent, CurrentTime);
XFree(children); XFree(children);
XFlush(getBaseDisplay().getXDisplay()); XFlush(getBaseDisplay().getXDisplay());
@ -507,14 +504,14 @@ BScreen::~BScreen(void) {
while (workspacesList->count()) while (workspacesList->count())
delete workspacesList->remove(0); delete workspacesList->remove(0);
while (rootmenuList->count()) while (!rootmenuList.empty())
rootmenuList->remove(0); rootmenuList.erase(rootmenuList.begin());
while (iconList->count()) while (iconList->count())
delete iconList->remove(0); delete iconList->remove(0);
while (netizenList->count()) while (!netizenList.empty())
delete netizenList->remove(0); netizenList.erase(netizenList.begin());
#ifdef HAVE_STRFTIME #ifdef HAVE_STRFTIME
if (resource.strftime_format) if (resource.strftime_format)
@ -535,9 +532,7 @@ BScreen::~BScreen(void) {
delete workspacesList; delete workspacesList;
delete workspaceNames; delete workspaceNames;
delete rootmenuList;
delete iconList; delete iconList;
delete netizenList;
if (resource.wstyle.fontset) if (resource.wstyle.fontset)
XFreeFontSet(getBaseDisplay().getXDisplay(), resource.wstyle.fontset); XFreeFontSet(getBaseDisplay().getXDisplay(), resource.wstyle.fontset);
@ -2012,7 +2007,7 @@ void BScreen::changeWorkspaceID(int id) {
void BScreen::addNetizen(Netizen *n) { void BScreen::addNetizen(Netizen *n) {
netizenList->insert(n); netizenList.push_back(n);
n->sendWorkspaceCount(); n->sendWorkspaceCount();
n->sendCurrentWorkspace(); n->sendCurrentWorkspace();
@ -2031,80 +2026,79 @@ void BScreen::addNetizen(Netizen *n) {
void BScreen::removeNetizen(Window w) { void BScreen::removeNetizen(Window w) {
LinkedListIterator<Netizen> it(netizenList); netList::iterator it;
int i = 0; int i = 0;
for (Netizen *n = it.current(); n; it++, i++, n = it.current()) for (it = netizenList.begin(); it != netizenList.end(); ++it)
if (n->getWindowID() == w) { if ((*it)->getWindowID() == w) {
Netizen *tmp = netizenList->remove(i); Netizen *tmp = *it;
netizenList.erase(it);
delete tmp; delete tmp;
break; break;
} }
} }
void BScreen::updateNetizenCurrentWorkspace(void) { void BScreen::updateNetizenCurrentWorkspace(void) {
LinkedListIterator<Netizen> it(netizenList); netList::iterator it;
for (Netizen *n = it.current(); n; it++, n = it.current()) for (it = netizenList.begin(); it != netizenList.end(); ++it)
n->sendCurrentWorkspace(); (*it)->sendCurrentWorkspace();
} }
void BScreen::updateNetizenWorkspaceCount(void) { void BScreen::updateNetizenWorkspaceCount(void) {
LinkedListIterator<Netizen> it(netizenList); netList::iterator it;
for (Netizen *n = it.current(); n; it++, n = it.current()) for (it = netizenList.begin(); it != netizenList.end(); ++it)
n->sendWorkspaceCount(); (*it)->sendWorkspaceCount();
} }
void BScreen::updateNetizenWindowFocus(void) { void BScreen::updateNetizenWindowFocus(void) {
Window f = ((openbox.focusedWindow()) ? Window f = ((openbox.focusedWindow()) ?
openbox.focusedWindow()->getClientWindow() : None); openbox.focusedWindow()->getClientWindow() : None);
LinkedListIterator<Netizen> it(netizenList); netList::iterator it;
for (Netizen *n = it.current(); n; it++, n = it.current()) for (it = netizenList.begin(); it != netizenList.end(); ++it)
n->sendWindowFocus(f); (*it)->sendWindowFocus(f);
} }
void BScreen::updateNetizenWindowAdd(Window w, unsigned long p) { void BScreen::updateNetizenWindowAdd(Window w, unsigned long p) {
LinkedListIterator<Netizen> it(netizenList); netList::iterator it;
for (Netizen *n = it.current(); n; it++, n = it.current()) for (it = netizenList.begin(); it != netizenList.end(); ++it)
n->sendWindowAdd(w, p); (*it)->sendWindowAdd(w, p);
} }
void BScreen::updateNetizenWindowDel(Window w) { void BScreen::updateNetizenWindowDel(Window w) {
LinkedListIterator<Netizen> it(netizenList); netList::iterator it;
for (Netizen *n = it.current(); n; it++, n = it.current()) for (it = netizenList.begin(); it != netizenList.end(); ++it)
n->sendWindowDel(w); (*it)->sendWindowDel(w);
} }
void BScreen::updateNetizenWindowRaise(Window w) { void BScreen::updateNetizenWindowRaise(Window w) {
LinkedListIterator<Netizen> it(netizenList); netList::iterator it;
for (Netizen *n = it.current(); n; it++, n = it.current()) for (it = netizenList.begin(); it != netizenList.end(); ++it)
n->sendWindowRaise(w); (*it)->sendWindowRaise(w);
} }
void BScreen::updateNetizenWindowLower(Window w) { void BScreen::updateNetizenWindowLower(Window w) {
LinkedListIterator<Netizen> it(netizenList); netList::iterator it;
for (Netizen *n = it.current(); n; it++, n = it.current()) for (it = netizenList.begin(); it != netizenList.end(); ++it)
n->sendWindowLower(w); (*it)->sendWindowLower(w);
} }
void BScreen::updateNetizenConfigNotify(XEvent *e) { void BScreen::updateNetizenConfigNotify(XEvent *e) {
LinkedListIterator<Netizen> it(netizenList); netList::iterator it;
for (Netizen *n = it.current(); n; it++, n = it.current()) for (it = netizenList.begin(); it != netizenList.end(); ++it)
n->sendConfigNotify(e); (*it)->sendConfigNotify(e);
} }
void BScreen::raiseWindows(Window *workspace_stack, int num) { void BScreen::raiseWindows(Window *workspace_stack, int num) {
Window *session_stack = new Window *session_stack = new
Window[(num + workspacesList->count() + rootmenuList->count() + 13)]; Window[(num + workspacesList->count() + rootmenuList.size() + 13)];
int i = 0, k = num; int i = 0, k = num;
XRaiseWindow(getBaseDisplay().getXDisplay(), iconmenu->getWindowID()); XRaiseWindow(getBaseDisplay().getXDisplay(), iconmenu->getWindowID());
@ -2130,9 +2124,9 @@ void BScreen::raiseWindows(Window *workspace_stack, int num) {
toolbar->getMenu()->getPlacementmenu()->getWindowID(); toolbar->getMenu()->getPlacementmenu()->getWindowID();
*(session_stack + i++) = toolbar->getMenu()->getWindowID(); *(session_stack + i++) = toolbar->getMenu()->getWindowID();
LinkedListIterator<Rootmenu> rit(rootmenuList); menuList::iterator rit;
for (Rootmenu *tmp = rit.current(); tmp; rit++, tmp = rit.current()) for (rit = rootmenuList.begin(); rit != rootmenuList.end(); ++rit)
*(session_stack + i++) = tmp->getWindowID(); *(session_stack + i++) = (*rit)->getWindowID();
*(session_stack + i++) = rootmenu->getWindowID(); *(session_stack + i++) = rootmenu->getWindowID();
if (toolbar->onTop()) if (toolbar->onTop())
@ -2276,8 +2270,8 @@ void BScreen::raiseFocus(void) {
void BScreen::InitMenu(void) { void BScreen::InitMenu(void) {
if (rootmenu) { if (rootmenu) {
while (rootmenuList->count()) while (!rootmenuList.empty())
rootmenuList->remove(0); rootmenuList.erase(rootmenuList.begin());
while (rootmenu->getCount()) while (rootmenu->getCount())
rootmenu->remove(0); rootmenu->remove(0);
@ -2580,7 +2574,7 @@ Bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) {
parseMenuFile(file, submenu); parseMenuFile(file, submenu);
submenu->update(); submenu->update();
menu->insert(label, submenu); menu->insert(label, submenu);
rootmenuList->insert(submenu); rootmenuList.push_back(submenu);
} }
break; break;
@ -2706,7 +2700,7 @@ Bool BScreen::parseMenuFile(FILE *file, Rootmenu *menu) {
if (newmenu) { if (newmenu) {
stylesmenu->setLabel(label); stylesmenu->setLabel(label);
menu->insert(label, stylesmenu); menu->insert(label, stylesmenu);
rootmenuList->insert(stylesmenu); rootmenuList.push_back(stylesmenu);
} }
openbox.setMenuFilename(stylesdir); openbox.setMenuFilename(stylesdir);

View file

@ -53,6 +53,10 @@
#include "Image.h" #include "Image.h"
#include "Resource.h" #include "Resource.h"
#include <list>
typedef std::list<Rootmenu *> menuList;
typedef std::list<Netizen *> netList;
// forward declaration // forward declaration
class BScreen; class BScreen;
@ -109,8 +113,8 @@ private:
Iconmenu *iconmenu; Iconmenu *iconmenu;
Rootmenu *rootmenu; Rootmenu *rootmenu;
LinkedList<Rootmenu> *rootmenuList; menuList rootmenuList;
LinkedList<Netizen> *netizenList; netList netizenList;
LinkedList<OpenboxWindow> *iconList; LinkedList<OpenboxWindow> *iconList;
#ifdef SLIT #ifdef SLIT

View file

@ -971,9 +971,7 @@ void Toolbar::edit() {
return; return;
XSetInputFocus(display, frame.workspace_label, XSetInputFocus(display, frame.workspace_label,
((screen.sloppyFocus()) ? RevertToPointerRoot : RevertToPointerRoot, CurrentTime);
RevertToParent),
CurrentTime);
XClearWindow(display, frame.workspace_label); XClearWindow(display, frame.workspace_label);
openbox.setNoFocus(True); openbox.setNoFocus(True);

View file

@ -115,14 +115,13 @@ const int Workspace::removeWindow(OpenboxWindow *w) {
if (w->isTransient() && w->getTransientFor() && if (w->isTransient() && w->getTransientFor() &&
w->getTransientFor()->isVisible()) { w->getTransientFor()->isVisible()) {
w->getTransientFor()->setInputFocus(); w->getTransientFor()->setInputFocus();
} else if (screen.sloppyFocus()) {
screen.getOpenbox().focusWindow((OpenboxWindow *) 0);
} else { } 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); screen.getOpenbox().focusWindow((OpenboxWindow *) 0);
XSetInputFocus(screen.getOpenbox().getXDisplay(), XSetInputFocus(screen.getOpenbox().getXDisplay(),
screen.getToolbar()->getWindowID(), PointerRoot, None, CurrentTime);
RevertToParent, CurrentTime);
} }
} }
} }
@ -319,7 +318,7 @@ void Workspace::setName(char *new_name) {
void Workspace::shutdown(void) { void Workspace::shutdown(void) {
while (!_windows.empty()) { while (!_windows.empty()) {
_windows[0]->restore(); _windows[0]->restore();
_windows.erase(_windows.begin()); delete _windows[0];
} }
} }