From 0c4c33f9f595818868dc83f8582909f68dd7efdd Mon Sep 17 00:00:00 2001 From: fluxgen Date: Mon, 4 Feb 2002 22:33:09 +0000 Subject: replaced LinkedList with stl container --- src/Basemenu.cc | 117 +++++++++++---------- src/Basemenu.hh | 12 +-- src/Slit.cc | 310 +++++++++++++++++++++++++++++--------------------------- src/Slit.hh | 10 +- 4 files changed, 238 insertions(+), 211 deletions(-) diff --git a/src/Basemenu.cc b/src/Basemenu.cc index d92b3db..4beca57 100644 --- a/src/Basemenu.cc +++ b/src/Basemenu.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Basemenu.cc,v 1.7 2002/01/26 11:22:06 fluxgen Exp $ +// $Id: Basemenu.cc,v 1.8 2002/02/04 22:33:09 fluxgen Exp $ // stupid macros needed to access some functions in version 2 of the GNU C // library @@ -155,8 +155,6 @@ Basemenu::Basemenu(BScreen *scrn) { screen->getVisual(), attrib_mask, &attrib); fluxbox->saveMenuSearch(menu.frame, this); - menuitems = new LinkedList; - // even though this is the end of the constructor the menu is still not // completely created. items must be inserted and it must be update()'d } @@ -168,12 +166,10 @@ Basemenu::~Basemenu(void) { if (shown && shown->getWindowID() == getWindowID()) shown = (Basemenu *) 0; - int n = menuitems->count(); + int n = menuitems.size() - 1; for (int i = 0; i < n; ++i) remove(0); - delete menuitems; - if (menu.label) delete [] menu.label; @@ -207,9 +203,13 @@ int Basemenu::insert(const char *l, int function, const char *e, int pos) { if (e) exec = StringUtil::strdup(e); BasemenuItem *item = new BasemenuItem(label, function, exec); - menuitems->insert(item, pos); + if (pos == -1) { + menuitems.push_back(item); + } else { + menuitems.insert(menuitems.begin() + pos, item); + } - return menuitems->count(); + return menuitems.size(); } @@ -219,26 +219,35 @@ int Basemenu::insert(const char *l, Basemenu *submenu, int pos) { if (l) label = StringUtil::strdup(l); BasemenuItem *item = new BasemenuItem(label, submenu); - menuitems->insert(item, pos); + if (pos == -1) { + menuitems.push_back(item); + } else { + menuitems.insert(menuitems.begin() + pos, item); + } submenu->parent = this; - return menuitems->count(); + return menuitems.size(); } int Basemenu::insert(const char **ulabel, int pos, int function) { BasemenuItem *item = new BasemenuItem(ulabel, function); - menuitems->insert(item, pos); + if (pos == -1) { + menuitems.push_back(item); + } else { + menuitems.insert(menuitems.begin() + pos, item); + } - return menuitems->count(); + return menuitems.size(); } int Basemenu::remove(int index) { - if (index < 0 || index > menuitems->count()) return -1; + if (index < 0 || index > menuitems.size()) return -1; - BasemenuItem *item = menuitems->remove(index); + Menuitems::iterator it = menuitems.erase(menuitems.begin() + index); + BasemenuItem *item = (*it); if (item) { if ((! internal_menu) && (item->submenu())) { @@ -247,8 +256,7 @@ int Basemenu::remove(int index) { if (! tmp->internal_menu) { delete tmp; } else - - tmp->internal_hide(); + tmp->internal_hide(); } if (item->label()) @@ -265,7 +273,7 @@ int Basemenu::remove(int index) { else if (which_sub > index) which_sub--; - return menuitems->count(); + return menuitems.size(); } @@ -310,9 +318,10 @@ void Basemenu::update(void) { menu.item_w = 1; int ii = 0; - LinkedListIterator it(menuitems); - for (; it.current(); it++) { - BasemenuItem *itmp = it.current(); + Menuitems::iterator it = menuitems.begin(); + Menuitems::iterator it_end = menuitems.end(); + for (; it != it_end; ++it) { + BasemenuItem *itmp = (*it); const char *s = ((itmp->u && *itmp->u) ? *itmp->u : ((itmp->l) ? itmp->l : (const char *) 0)); @@ -330,18 +339,18 @@ void Basemenu::update(void) { menu.item_w = ((menu.item_w < (unsigned int) ii) ? ii : menu.item_w); } - if (menuitems->count()) { + if (menuitems.size()) { menu.sublevels = 1; - while (((menu.item_h * (menuitems->count() + 1) / menu.sublevels) + while (((menu.item_h * (menuitems.size() + 1) / menu.sublevels) + menu.title_h + screen->getBorderWidth()) > screen->getHeight()) menu.sublevels++; if (menu.sublevels < menu.minsub) menu.sublevels = menu.minsub; - menu.persub = menuitems->count() / menu.sublevels; - if (menuitems->count() % menu.sublevels) menu.persub++; + menu.persub = menuitems.size() / menu.sublevels; + if (menuitems.size() % menu.sublevels) menu.persub++; } else { menu.sublevels = 0; menu.persub = 0; @@ -423,7 +432,7 @@ void Basemenu::update(void) { if (title_vis && visible) redrawTitle(); int i = 0; - for (i = 0; visible && i < menuitems->count(); i++) + for (i = 0; visible && i < menuitems.size(); i++) if (i == which_sub) { drawItem(i, True, 0); drawSubmenu(i); @@ -464,7 +473,7 @@ void Basemenu::hide(void) { void Basemenu::internal_hide(void) { if (which_sub != -1) { - BasemenuItem *tmp = menuitems->find(which_sub); + BasemenuItem *tmp = menuitems[which_sub]; tmp->submenu()->internal_hide(); } @@ -539,14 +548,14 @@ void Basemenu::redrawTitle(void) { void Basemenu::drawSubmenu(int index) { if (which_sub != -1 && which_sub != index) { - BasemenuItem *itmp = menuitems->find(which_sub); + BasemenuItem *itmp = menuitems[which_sub]; if (! itmp->submenu()->isTorn()) itmp->submenu()->internal_hide(); } - if (index >= 0 && index < menuitems->count()) { - BasemenuItem *item = menuitems->find(index); + if (index >= 0 && index < menuitems.size()) { + BasemenuItem *item = menuitems[index]; if (item->submenu() && visible && (! item->submenu()->isTorn()) && item->isEnabled()) { @@ -607,8 +616,8 @@ void Basemenu::drawSubmenu(int index) { Bool Basemenu::hasSubmenu(int index) { - if ((index >= 0) && (index < menuitems->count())) - if (menuitems->find(index)->submenu()) + if ((index >= 0) && (index < menuitems.size())) + if (menuitems[index]->submenu()) return True; else return False; @@ -620,9 +629,9 @@ Bool Basemenu::hasSubmenu(int index) { void Basemenu::drawItem(int index, Bool highlight, Bool clear, int x, int y, unsigned int w, unsigned int h) { - if (index < 0 || index > menuitems->count()) return; + if (index < 0 || index > menuitems.size()) return; - BasemenuItem *item = menuitems->find(index); + BasemenuItem *item = menuitems[index]; if (! item) return; Bool dotext = True, dohilite = True, dosel = True; @@ -802,7 +811,7 @@ void Basemenu::setLabel(const char *l) { void Basemenu::setItemSelected(int index, Bool sel) { - if (index < 0 || index >= menuitems->count()) return; + if (index < 0 || index >= menuitems.size()) return; BasemenuItem *item = find(index); if (! item) return; @@ -813,7 +822,7 @@ void Basemenu::setItemSelected(int index, Bool sel) { Bool Basemenu::isItemSelected(int index) { - if (index < 0 || index >= menuitems->count()) return False; + if (index < 0 || index >= menuitems.size()) return False; BasemenuItem *item = find(index); if (! item) return False; @@ -823,7 +832,7 @@ Bool Basemenu::isItemSelected(int index) { void Basemenu::setItemEnabled(int index, Bool enable) { - if (index < 0 || index >= menuitems->count()) return; + if (index < 0 || index >= menuitems.size()) return; BasemenuItem *item = find(index); if (! item) return; @@ -834,7 +843,7 @@ void Basemenu::setItemEnabled(int index, Bool enable) { Bool Basemenu::isItemEnabled(int index) { - if (index < 0 || index >= menuitems->count()) return False; + if (index < 0 || index >= menuitems.size()) return False; BasemenuItem *item = find(index); if (! item) return False; @@ -848,11 +857,11 @@ void Basemenu::buttonPressEvent(XButtonEvent *be) { int sbl = (be->x / menu.item_w), i = (be->y / menu.item_h); int w = (sbl * menu.persub) + i; - if (w < menuitems->count() && w >= 0) { + if (w < menuitems.size() && w >= 0) { which_press = i; which_sbl = sbl; - BasemenuItem *item = menuitems->find(w); + BasemenuItem *item = menuitems[w]; if (item->submenu()) drawSubmenu(w); @@ -891,7 +900,7 @@ void Basemenu::buttonReleaseEvent(XButtonEvent *re) { w = (sbl * menu.persub) + i, p = (which_sbl * menu.persub) + which_press; - if (w < menuitems->count() && w >= 0) { + if (w < menuitems.size() && w >= 0) { drawItem(p, (p == which_sub), True); if (p == w && isItemEnabled(w)) { @@ -937,10 +946,10 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) { w = (sbl * menu.persub) + i; if ((i != which_press || sbl != which_sbl) && - (w < menuitems->count() && w >= 0)) { + (w < menuitems.size() && w >= 0)) { if (which_press != -1 && which_sbl != -1) { int p = (which_sbl * menu.persub) + which_press; - BasemenuItem *item = menuitems->find(p); + BasemenuItem *item = menuitems[p]; drawItem(p, False, True); if (item->submenu()) { @@ -955,7 +964,7 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) { which_press = i; which_sbl = sbl; - BasemenuItem *itmp = menuitems->find(w); + BasemenuItem *itmp = menuitems[w]; if (itmp->submenu()) drawSubmenu(w); @@ -970,8 +979,6 @@ void Basemenu::exposeEvent(XExposeEvent *ee) { if (ee->window == menu.title) { redrawTitle(); } else if (ee->window == menu.frame) { - LinkedListIterator it(menuitems); - // this is a compilicated algorithm... lets do it step by step... // first... we see in which sub level the expose starts... and how many // items down in that sublevel @@ -988,12 +995,16 @@ void Basemenu::exposeEvent(XExposeEvent *ee) { int i, ii; for (i = sbl; i <= sbl_d; i++) { // set the iterator to the first item in the sublevel needing redrawing - it.set(id + (i * menu.persub)); - for (ii = id; ii <= id_d && it.current(); it++, ii++) { - int index = ii + (i * menu.persub); - // redraw the item - drawItem(index, (which_sub == index), False, - ee->x, ee->y, ee->width, ee->height); + int index = id + i * menu.persub; + if (index < menuitems.size() && index >= 0) { + Menuitems::iterator it = menuitems.begin() + index; + Menuitems::iterator it_end = menuitems.end(); + for (ii = id; ii <= id_d && it != it_end; ++it, ii++) { + int index = ii + (i * menu.persub); + // redraw the item + drawItem(index, (which_sub == index), False, + ee->x, ee->y, ee->width, ee->height); + } } } } @@ -1025,7 +1036,7 @@ void Basemenu::enterNotifyEvent(XCrossingEvent *ce) { XMoveWindow(display, menu.window, menu.x_shift, menu.y_shift); if (which_sub != -1) { - BasemenuItem *tmp = menuitems->find(which_sub); + BasemenuItem *tmp = menuitems[which_sub]; if (tmp->submenu()->isVisible()) { int sbl = (ce->x / menu.item_w), i = (ce->y / menu.item_h), w = (sbl * menu.persub) + i; @@ -1044,7 +1055,7 @@ void Basemenu::enterNotifyEvent(XCrossingEvent *ce) { void Basemenu::leaveNotifyEvent(XCrossingEvent *ce) { if (ce->window == menu.frame) { - if (which_press != -1 && which_sbl != -1 && menuitems->count() > 0) { + if (which_press != -1 && which_sbl != -1 && menuitems.size() > 0) { int p = (which_sbl * menu.persub) + which_press; drawItem(p, (p == which_sub), True); diff --git a/src/Basemenu.hh b/src/Basemenu.hh index 24c8078..af40983 100644 --- a/src/Basemenu.hh +++ b/src/Basemenu.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Basemenu.hh,v 1.4 2002/01/11 09:24:46 fluxgen Exp $ +// $Id: Basemenu.hh,v 1.5 2002/02/04 22:33:09 fluxgen Exp $ #ifndef _BASEMENU_HH_ #define _BASEMENU_HH_ @@ -37,12 +37,12 @@ class Fluxbox; class BImageControl; class BScreen; -#include "LinkedList.hh" - +#include class Basemenu { private: - LinkedList *menuitems; + typedef std::vector Menuitems; + Menuitems menuitems; Fluxbox *fluxbox; Basemenu *parent; BImageControl *image_ctrl; @@ -66,7 +66,7 @@ private: protected: - inline BasemenuItem *find(int index) { return menuitems->find(index); } + inline BasemenuItem *find(int index) { return menuitems[index]; } inline void setTitleVisibility(Bool b) { title_vis = b; } inline void setMovable(Bool b) { movable = b; } inline void setHideTree(Bool h) { hide_tree = h; } @@ -99,7 +99,7 @@ public: inline const int &getX(void) const { return menu.x; } inline const int &getY(void) const { return menu.y; } - inline int getCount(void) { return menuitems->count(); } + inline int getCount(void) { return menuitems.size(); } inline const int &getCurrentSubmenu(void) const { return which_sub; } inline const unsigned int &getWidth(void) const { return menu.width; } diff --git a/src/Slit.cc b/src/Slit.cc index c263ba9..48a916e 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -40,6 +40,8 @@ #include "Slit.hh" #include "Toolbar.hh" +#include + Slit::Slit(BScreen *scr) { screen = scr; @@ -55,13 +57,11 @@ Slit::Slit(BScreen *scr) { timer->setTimeout(fluxbox->getAutoRaiseDelay()); timer->fireOnce(True); - clientList = new LinkedList; - slitmenu = new Slitmenu(this); XSetWindowAttributes attrib; unsigned long create_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | - CWColormap | CWOverrideRedirect | CWEventMask; + CWColormap | CWOverrideRedirect | CWEventMask; attrib.background_pixmap = None; attrib.background_pixel = attrib.border_pixel = screen->getBorderColor()->getPixel(); @@ -87,10 +87,8 @@ Slit::Slit(BScreen *scr) { Slit::~Slit() { fluxbox->grab(); - if (timer->isTiming()) timer->stop(); delete timer; - delete clientList; delete slitmenu; screen->getImageControl()->removeImage(frame.pixmap); @@ -116,9 +114,8 @@ void Slit::addClient(Window w) { if ((wmhints->flags & IconWindowHint) && (wmhints->icon_window != None)) { XMoveWindow(display, client->client_window, screen->getWidth() + 10, - screen->getHeight() + 10); - XMapWindow(display, client->client_window); - + screen->getHeight() + 10); + XMapWindow(display, client->client_window); client->icon_window = wmhints->icon_window; client->window = client->icon_window; } else { @@ -150,24 +147,24 @@ void Slit::addClient(Window w) { // Check if KDE v2.x dock applet if (XGetWindowProperty(fluxbox->getXDisplay(), w, - fluxbox->getKWM2DockwindowAtom(), 0l, 1l, False, - fluxbox->getKWM2DockwindowAtom(), - &ajunk, &ijunk, &uljunk, &uljunk, - (unsigned char **) &data) == Success) { + fluxbox->getKWM2DockwindowAtom(), 0l, 1l, False, + fluxbox->getKWM2DockwindowAtom(), + &ajunk, &ijunk, &uljunk, &uljunk, + (unsigned char **) &data) == Success) { iskdedockapp = (data && data[0] != 0); XFree((char *) data); - } + } // Check if KDE v1.x dock applet if (!iskdedockapp) { if (XGetWindowProperty(fluxbox->getXDisplay(), w, - fluxbox->getKWM1DockwindowAtom(), 0l, 1l, False, - fluxbox->getKWM1DockwindowAtom(), - &ajunk, &ijunk, &uljunk, &uljunk, - (unsigned char **) &data) == Success) { + fluxbox->getKWM1DockwindowAtom(), 0l, 1l, False, + fluxbox->getKWM1DockwindowAtom(), + &ajunk, &ijunk, &uljunk, &uljunk, + (unsigned char **) &data) == Success) { iskdedockapp = (data && data[0] != 0); - XFree((char *) data); - } + XFree((char *) data); + } } if (iskdedockapp) @@ -187,16 +184,16 @@ void Slit::addClient(Window w) { XSelectInput(display, client->window, NoEventMask); XReparentWindow(display, client->window, frame.window, 0, 0); - XMapRaised(display, client->window); //TODO: bbkeys bug here? + XMapRaised(display, client->window); XChangeSaveSet(display, client->window, SetModeInsert); XSelectInput(display, frame.window, SubstructureRedirectMask | - ButtonPressMask | EnterWindowMask | LeaveWindowMask); + ButtonPressMask | EnterWindowMask | LeaveWindowMask); XSelectInput(display, client->window, StructureNotifyMask | - SubstructureNotifyMask | EnterWindowMask); + SubstructureNotifyMask | EnterWindowMask); XFlush(display); - clientList->insert(client); + clientList.push_back(client); fluxbox->saveSlitSearch(client->client_window, this); fluxbox->saveSlitSearch(client->icon_window, this); @@ -207,10 +204,11 @@ void Slit::addClient(Window w) { } -void Slit::removeClient(SlitClient *client, Bool remap) { +void Slit::removeClient(SlitClient *client, bool remap) { fluxbox->removeSlitSearch(client->client_window); fluxbox->removeSlitSearch(client->icon_window); - clientList->remove(client); + + clientList.remove(client); screen->removeNetizen(client->window); @@ -218,10 +216,10 @@ void Slit::removeClient(SlitClient *client, Bool remap) { XSelectInput(display, frame.window, NoEventMask); XSelectInput(display, client->window, NoEventMask); XReparentWindow(display, client->window, screen->getRootWindow(), - client->x, client->y); + client->x, client->y); XChangeSaveSet(display, client->window, SetModeDelete); XSelectInput(display, frame.window, SubstructureRedirectMask | - ButtonPressMask | EnterWindowMask | LeaveWindowMask); + ButtonPressMask | EnterWindowMask | LeaveWindowMask); XFlush(display); } @@ -229,20 +227,21 @@ void Slit::removeClient(SlitClient *client, Bool remap) { } -void Slit::removeClient(Window w, Bool remap) { +void Slit::removeClient(Window w, bool remap) { fluxbox->grab(); - Bool reconf = False; + bool reconf = false; - LinkedListIterator it(clientList); - for (; it.current(); it++) - if (it.current()->window == w) { - removeClient(it.current(), remap); - reconf = True; + SlitClients::iterator it = clientList.begin(); + SlitClients::iterator it_end = clientList.end(); + for (; it != it_end; ++it) { + if ((*it)->window == w) { + removeClient((*it), remap); + reconf = true; break; } - + } if (reconf) reconfigure(); fluxbox->ungrab(); @@ -252,15 +251,18 @@ void Slit::removeClient(Window w, Bool remap) { void Slit::reconfigure(void) { frame.width = 0; frame.height = 0; - LinkedListIterator it(clientList); switch (screen->getSlitDirection()) { case VERTICAL: - for (; it.current(); it++) { - frame.height += it.current()->height + screen->getBevelWidth(); - - if (frame.width < it.current()->width) - frame.width = it.current()->width; + { + SlitClients::iterator it = clientList.begin(); + SlitClients::iterator it_end = clientList.end(); + for (; it != it_end; ++it) { + frame.height += (*it)->height + screen->getBevelWidth(); + + if (frame.width < (*it)->width) + frame.width = (*it)->width; + } } if (frame.width < 1) @@ -276,11 +278,15 @@ void Slit::reconfigure(void) { break; case HORIZONTAL: - for (; it.current(); it++) { - frame.width += it.current()->width + screen->getBevelWidth(); - - if (frame.height < it.current()->height) - frame.height = it.current()->height; + { + SlitClients::iterator it = clientList.begin(); + SlitClients::iterator it_end = clientList.end(); + for (; it != it_end; ++it) { + frame.width += (*it)->width + screen->getBevelWidth(); + + if (frame.height < (*it)->height) + frame.height = (*it)->height; + } } if (frame.width < 1) @@ -300,9 +306,9 @@ void Slit::reconfigure(void) { XSetWindowBorderWidth(display ,frame.window, screen->getBorderWidth()); XSetWindowBorder(display, frame.window, - screen->getBorderColor()->getPixel()); + screen->getBorderColor()->getPixel()); - if (! clientList->count()) + if (clientList.size()==0) XUnmapWindow(display, frame.window); else XMapWindow(display, frame.window); @@ -316,49 +322,52 @@ void Slit::reconfigure(void) { texture->getColor()->getPixel()); } else { frame.pixmap = image_ctrl->renderImage(frame.width, frame.height, - texture); + texture); XSetWindowBackgroundPixmap(display, frame.window, frame.pixmap); } if (tmp) image_ctrl->removeImage(tmp); XClearWindow(display, frame.window); int x, y; - it.reset(); switch (screen->getSlitDirection()) { case VERTICAL: x = 0; y = screen->getBevelWidth(); - for (; it.current(); it++) { - x = (frame.width - it.current()->width) / 2; - - XMoveResizeWindow(display, it.current()->window, x, y, - it.current()->width, it.current()->height); - XMapWindow(display, it.current()->window); - - // for ICCCM compliance - it.current()->x = x; - it.current()->y = y; - - XEvent event; - event.type = ConfigureNotify; - - event.xconfigure.display = display; - event.xconfigure.event = it.current()->window; - event.xconfigure.window = it.current()->window; - event.xconfigure.x = x; - event.xconfigure.y = y; - event.xconfigure.width = it.current()->width; - event.xconfigure.height = it.current()->height; - event.xconfigure.border_width = 0; - event.xconfigure.above = frame.window; - event.xconfigure.override_redirect = False; - - XSendEvent(display, it.current()->window, False, StructureNotifyMask, - &event); - - y += it.current()->height + screen->getBevelWidth(); + { + SlitClients::iterator it = clientList.begin(); + SlitClients::iterator it_end = clientList.end(); + for (; it != it_end; ++it) { + x = (frame.width - (*it)->width) / 2; + + XMoveResizeWindow(display, (*it)->window, x, y, + (*it)->width, (*it)->height); + XMapWindow(display, (*it)->window); + + // for ICCCM compliance + (*it)->x = x; + (*it)->y = y; + + XEvent event; + event.type = ConfigureNotify; + + event.xconfigure.display = display; + event.xconfigure.event = (*it)->window; + event.xconfigure.window = (*it)->window; + event.xconfigure.x = x; + event.xconfigure.y = y; + event.xconfigure.width = (*it)->width; + event.xconfigure.height = (*it)->height; + event.xconfigure.border_width = 0; + event.xconfigure.above = frame.window; + event.xconfigure.override_redirect = False; + + XSendEvent(display, (*it)->window, False, StructureNotifyMask, + &event); + + y += (*it)->height + screen->getBevelWidth(); + } } break; @@ -367,35 +376,39 @@ void Slit::reconfigure(void) { x = screen->getBevelWidth(); y = 0; - for (; it.current(); it++) { - y = (frame.height - it.current()->height) / 2; - - XMoveResizeWindow(display, it.current()->window, x, y, - it.current()->width, it.current()->height); - XMapWindow(display, it.current()->window); - - // for ICCCM compliance - it.current()->x = x; - it.current()->y = y; - - XEvent event; - event.type = ConfigureNotify; - - event.xconfigure.display = display; - event.xconfigure.event = it.current()->window; - event.xconfigure.window = it.current()->window; - event.xconfigure.x = frame.x + x + screen->getBorderWidth(); - event.xconfigure.y = frame.y + y + screen->getBorderWidth(); - event.xconfigure.width = it.current()->width; - event.xconfigure.height = it.current()->height; - event.xconfigure.border_width = 0; - event.xconfigure.above = frame.window; - event.xconfigure.override_redirect = False; - - XSendEvent(display, it.current()->window, False, StructureNotifyMask, - &event); - - x += it.current()->width + screen->getBevelWidth(); + { + SlitClients::iterator it = clientList.begin(); + SlitClients::iterator it_end = clientList.end(); + for (; it != it_end; ++it) { + y = (frame.height - (*it)->height) / 2; + + XMoveResizeWindow(display, (*it)->window, x, y, + (*it)->width, (*it)->height); + XMapWindow(display, (*it)->window); + + // for ICCCM compliance + (*it)->x = x; + (*it)->y = y; + + XEvent event; + event.type = ConfigureNotify; + + event.xconfigure.display = display; + event.xconfigure.event = (*it)->window; + event.xconfigure.window = (*it)->window; + event.xconfigure.x = frame.x + x + screen->getBorderWidth(); + event.xconfigure.y = frame.y + y + screen->getBorderWidth(); + event.xconfigure.width = (*it)->width; + event.xconfigure.height = (*it)->height; + event.xconfigure.border_width = 0; + event.xconfigure.above = frame.window; + event.xconfigure.override_redirect = False; + + XSendEvent(display, (*it)->window, False, StructureNotifyMask, + &event); + + x += (*it)->width + screen->getBevelWidth(); + } } break; @@ -412,21 +425,21 @@ void Slit::reposition(void) { frame.x = 0; frame.y = 0; if (screen->getSlitDirection() == VERTICAL) { - frame.x_hidden = screen->getBevelWidth() - screen->getBorderWidth() - - frame.width; + frame.x_hidden = screen->getBevelWidth() - + screen->getBorderWidth() - frame.width; frame.y_hidden = 0; } else { frame.x_hidden = 0; - frame.y_hidden = screen->getBevelWidth() - screen->getBorderWidth() - - frame.height; + frame.y_hidden = screen->getBevelWidth() - + screen->getBorderWidth() - frame.height; } break; case CENTERLEFT: frame.x = 0; frame.y = (screen->getHeight() - frame.height) / 2; - frame.x_hidden = screen->getBevelWidth() - screen->getBorderWidth() - - frame.width; + frame.x_hidden = screen->getBevelWidth() - + screen->getBorderWidth() - frame.width; frame.y_hidden = frame.y; break; @@ -439,8 +452,8 @@ void Slit::reposition(void) { frame.y_hidden = frame.y; } else { frame.x_hidden = 0; - frame.y_hidden = screen->getHeight() - screen->getBevelWidth() - - screen->getBorderWidth(); + frame.y_hidden = screen->getHeight() - + screen->getBevelWidth() - screen->getBorderWidth(); } break; @@ -448,29 +461,29 @@ void Slit::reposition(void) { frame.x = (screen->getWidth() - frame.width) / 2; frame.y = 0; frame.x_hidden = frame.x; - frame.y_hidden = screen->getBevelWidth() - screen->getBorderWidth() - - frame.height; + frame.y_hidden = screen->getBevelWidth() - + screen->getBorderWidth() - frame.height; break; case BOTTOMCENTER: frame.x = (screen->getWidth() - frame.width) / 2; frame.y = screen->getHeight() - frame.height - screen->getBorderWidth2x(); frame.x_hidden = frame.x; - frame.y_hidden = screen->getHeight() - screen->getBevelWidth() - - screen->getBorderWidth(); + frame.y_hidden = screen->getHeight() - + screen->getBevelWidth() - screen->getBorderWidth(); break; case TOPRIGHT: frame.x = screen->getWidth() - frame.width - screen->getBorderWidth2x(); frame.y = 0; if (screen->getSlitDirection() == VERTICAL) { - frame.x_hidden = screen->getWidth() - screen->getBevelWidth() - - screen->getBorderWidth(); + frame.x_hidden = screen->getWidth() - + screen->getBevelWidth() - screen->getBorderWidth(); frame.y_hidden = 0; } else { frame.x_hidden = frame.x; - frame.y_hidden = screen->getBevelWidth() - screen->getBorderWidth() - - frame.height; + frame.y_hidden = screen->getBevelWidth() - + screen->getBorderWidth() - frame.height; } break; @@ -478,8 +491,8 @@ void Slit::reposition(void) { default: frame.x = screen->getWidth() - frame.width - screen->getBorderWidth2x(); frame.y = (screen->getHeight() - frame.height) / 2; - frame.x_hidden = screen->getWidth() - screen->getBevelWidth() - - screen->getBorderWidth(); + frame.x_hidden = screen->getWidth() - + screen->getBevelWidth() - screen->getBorderWidth(); frame.y_hidden = frame.y; break; @@ -487,22 +500,22 @@ void Slit::reposition(void) { frame.x = screen->getWidth() - frame.width - screen->getBorderWidth2x(); frame.y = screen->getHeight() - frame.height - screen->getBorderWidth2x(); if (screen->getSlitDirection() == VERTICAL) { - frame.x_hidden = screen->getWidth() - screen->getBevelWidth() - - screen->getBorderWidth(); + frame.x_hidden = screen->getWidth() - + screen->getBevelWidth() - screen->getBorderWidth(); frame.y_hidden = frame.y; } else { frame.x_hidden = frame.x; - frame.y_hidden = screen->getHeight() - screen->getBevelWidth() - - screen->getBorderWidth(); + frame.y_hidden = screen->getHeight() - + screen->getBevelWidth() - screen->getBorderWidth(); } break; } Toolbar *tbar = screen->getToolbar(); int sw = frame.width + screen->getBorderWidth2x(), - sh = frame.height + screen->getBorderWidth2x(), - tw = tbar->getWidth() + screen->getBorderWidth(), - th = tbar->getHeight() + screen->getBorderWidth(); + sh = frame.height + screen->getBorderWidth2x(), + tw = tbar->getWidth() + screen->getBorderWidth(), + th = tbar->getHeight() + screen->getBorderWidth(); if (tbar->getX() < frame.x + sw && tbar->getX() + tw > frame.x && tbar->getY() < frame.y + sh && tbar->getY() + th > frame.y) { @@ -511,28 +524,28 @@ void Slit::reposition(void) { if (screen->getSlitDirection() == VERTICAL) frame.y_hidden += tbar->getExposedHeight(); else - frame.y_hidden = frame.y; + frame.y_hidden = frame.y; } else { frame.y -= tbar->getExposedHeight(); if (screen->getSlitDirection() == VERTICAL) frame.y_hidden -= tbar->getExposedHeight(); else - frame.y_hidden = frame.y; + frame.y_hidden = frame.y; } } if (hidden) XMoveResizeWindow(display, frame.window, frame.x_hidden, - frame.y_hidden, frame.width, frame.height); + frame.y_hidden, frame.width, frame.height); else XMoveResizeWindow(display, frame.window, frame.x, - frame.y, frame.width, frame.height); + frame.y, frame.width, frame.height); } void Slit::shutdown(void) { - while (clientList->count()) - removeClient(clientList->first()); + while (clientList.size() != 0) + removeClient(clientList.front()); } @@ -597,7 +610,7 @@ void Slit::configureRequestEvent(XConfigureRequestEvent *e) { fluxbox->grab(); if (fluxbox->validateWindow(e->window)) { - Bool reconf = False; + bool reconf = false; XWindowChanges xwc; xwc.x = e->x; @@ -610,15 +623,16 @@ void Slit::configureRequestEvent(XConfigureRequestEvent *e) { XConfigureWindow(display, e->window, e->value_mask, &xwc); - LinkedListIterator it(clientList); - for (; it.current(); it++) - if (it.current()->window == e->window) - if (it.current()->width != ((unsigned) e->width) || - it.current()->height != ((unsigned) e->height)) { - it.current()->width = (unsigned) e->width; - it.current()->height = (unsigned) e->height; + SlitClients::iterator it = clientList.begin(); + SlitClients::iterator it_end = clientList.end(); + for (; it != it_end; ++it) + if ((*it)->window == e->window) + if ((*it)->width != ((unsigned) e->width) || + (*it)->height != ((unsigned) e->height)) { + (*it)->width = (unsigned) e->width; + (*it)->height = (unsigned) e->height; - reconf = True; + reconf = true; break; } diff --git a/src/Slit.hh b/src/Slit.hh index f79dbd5..43a91e9 100644 --- a/src/Slit.hh +++ b/src/Slit.hh @@ -30,8 +30,8 @@ class Slit; class Slitmenu; #include "Basemenu.hh" -#include "LinkedList.hh" +#include class Slitmenu : public Basemenu { private: @@ -100,7 +100,9 @@ private: BScreen *screen; BTimer *timer; - LinkedList *clientList; + typedef std::list SlitClients; + + SlitClients clientList; Slitmenu *slitmenu; struct frame { @@ -137,8 +139,8 @@ public: inline const unsigned int &getHeight(void) const { return frame.height; } void addClient(Window); - void removeClient(SlitClient *, Bool = True); - void removeClient(Window, Bool = True); + void removeClient(SlitClient *, bool = true); + void removeClient(Window, bool = true); void reconfigure(void); void reposition(void); void shutdown(void); -- cgit v0.11.2