change XLayerItem to hold FbWindows instead of X Window IDs (Window)

This commit is contained in:
rathnor 2003-02-18 15:08:12 +00:00
parent 9de08b90e8
commit aa602770fb
4 changed files with 34 additions and 31 deletions

View file

@ -20,7 +20,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: MultLayers.cc,v 1.5 2003/02/09 14:11:13 rathnor Exp $ // $Id: MultLayers.cc,v 1.6 2003/02/18 15:08:12 rathnor Exp $
#include "MultLayers.hh" #include "MultLayers.hh"
#include "XLayer.hh" #include "XLayer.hh"
@ -151,10 +151,7 @@ void MultLayers::moveToLayer(XLayerItem &item, int layernum) {
void MultLayers::restack() { void MultLayers::restack() {
int layernum=0, winnum=0, size=0; int layernum=0, winnum=0, size = this->size();
for (; layernum < m_layers.size(); layernum++) {
size += m_layers[layernum]->countWindows();
}
Window *winlist = new Window[size]; Window *winlist = new Window[size];
for (layernum=0; layernum < m_layers.size(); layernum++) { for (layernum=0; layernum < m_layers.size(); layernum++) {
@ -166,13 +163,14 @@ void MultLayers::restack() {
for (; it != it_end; ++it) { for (; it != it_end; ++it) {
XLayerItem::Windows::const_iterator wit = (*it)->getWindows().begin(); XLayerItem::Windows::const_iterator wit = (*it)->getWindows().begin();
XLayerItem::Windows::const_iterator wit_end = (*it)->getWindows().end(); XLayerItem::Windows::const_iterator wit_end = (*it)->getWindows().end();
for (; wit != wit_end; ++wit, winnum++) { for (; wit != wit_end; ++wit) {
winlist[winnum] = (*wit); if ((*wit)->window())
winlist[winnum++] = (*wit)->window();
} }
} }
} }
XRestackWindows(FbTk::App::instance()->display(), winlist, size); XRestackWindows(FbTk::App::instance()->display(), winlist, winnum);
delete [] winlist; delete [] winlist;
} }

View file

@ -20,7 +20,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: XLayer.cc,v 1.5 2003/02/09 14:11:14 rathnor Exp $ // $Id: XLayer.cc,v 1.6 2003/02/18 15:08:12 rathnor Exp $
#include "XLayer.hh" #include "XLayer.hh"
#include "XLayerItem.hh" #include "XLayerItem.hh"
@ -53,12 +53,13 @@ void XLayer::restack() {
for (size_t i=0; it != it_end; ++it, i++) { for (size_t i=0; it != it_end; ++it, i++) {
XLayerItem::Windows::const_iterator wit = (*it)->getWindows().begin(); XLayerItem::Windows::const_iterator wit = (*it)->getWindows().begin();
XLayerItem::Windows::const_iterator wit_end = (*it)->getWindows().end(); XLayerItem::Windows::const_iterator wit_end = (*it)->getWindows().end();
for (; wit != wit_end; ++wit, j++) { for (; wit != wit_end; ++wit) {
winlist[j] = (*wit); if ((*wit)->window())
winlist[j++] = (*wit)->window();
} }
} }
XRestackWindows(FbTk::App::instance()->display(), winlist, num_windows); XRestackWindows(FbTk::App::instance()->display(), winlist, j);
delete [] winlist; delete [] winlist;
@ -84,7 +85,8 @@ void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) {
// if there are no windows provided for above us, // if there are no windows provided for above us,
// then we must have to go right to the top of the stack // then we must have to go right to the top of the stack
if (!above) { // must need to go right to top if (!above) { // must need to go right to top
XRaiseWindow(FbTk::App::instance()->display(), item->getWindows().front()); if (item->getWindows().front()->window())
XRaiseWindow(FbTk::App::instance()->display(), item->getWindows().front()->window());
// if this XLayerItem has more than one window, // if this XLayerItem has more than one window,
// then we'll stack the rest in under the front one too // then we'll stack the rest in under the front one too
@ -105,18 +107,20 @@ void XLayer::stackBelowItem(XLayerItem *item, XLayerItem *above) {
winnum = 1; winnum = 1;
size = num+1; size = num+1;
winlist = new Window[size]; winlist = new Window[size];
winlist[0] = above->getWindows().back(); // assume that above's window exists
winlist[0] = above->getWindows().back()->window();
} }
// fill the rest of the array // fill the rest of the array
XLayerItem::Windows::iterator it = item->getWindows().begin(); XLayerItem::Windows::iterator it = item->getWindows().begin();
XLayerItem::Windows::iterator it_end = item->getWindows().end(); XLayerItem::Windows::iterator it_end = item->getWindows().end();
for (; it != it_end; ++it, winnum++) { for (; it != it_end; ++it) {
winlist[winnum] = (*it); if ((*it)->window())
winlist[winnum++] = (*it)->window();
} }
// stack the windows // stack the windows
XRestackWindows(FbTk::App::instance()->display(), winlist, size); XRestackWindows(FbTk::App::instance()->display(), winlist, winnum);
delete [] winlist; delete [] winlist;

View file

@ -20,16 +20,16 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: XLayerItem.cc,v 1.5 2003/02/09 14:11:14 rathnor Exp $ // $Id: XLayerItem.cc,v 1.6 2003/02/18 15:08:12 rathnor Exp $
#include "XLayerItem.hh" #include "XLayerItem.hh"
#include "XLayer.hh" #include "XLayer.hh"
using namespace FbTk; using namespace FbTk;
XLayerItem::XLayerItem(Window win, XLayer &layer) : XLayerItem::XLayerItem(FbWindow &win, XLayer &layer) :
m_layer(&layer), m_layeriterator(0) { m_layer(&layer), m_layeriterator(0) {
m_windows.push_front(win); m_windows.push_front(&win);
m_layer->insert(*this); m_layer->insert(*this);
} }
@ -76,21 +76,21 @@ void XLayerItem::moveToLayer(int layernum) {
m_layer->moveToLayer(*this, layernum); m_layer->moveToLayer(*this, layernum);
} }
void XLayerItem::addWindow(Window win) { void XLayerItem::addWindow(FbWindow &win) {
// I'd like to think we can trust ourselves that it won't be added twice... // I'd like to think we can trust ourselves that it won't be added twice...
// Otherwise we're always scanning through the list. // Otherwise we're always scanning through the list.
m_windows.push_back(win); m_windows.push_back(&win);
} }
void XLayerItem::removeWindow(Window win) { void XLayerItem::removeWindow(FbWindow &win) {
// I'd like to think we can trust ourselves that it won't be added twice... // I'd like to think we can trust ourselves that it won't be added twice...
// Otherwise we're always scanning through the list. // Otherwise we're always scanning through the list.
XLayerItem::Windows::iterator it = std::find(m_windows.begin(), m_windows.end(), win); XLayerItem::Windows::iterator it = std::find(m_windows.begin(), m_windows.end(), &win);
m_windows.erase(it); m_windows.erase(it);
} }
void XLayerItem::bringToTop(Window win) { void XLayerItem::bringToTop(FbWindow &win) {
removeWindow(win); removeWindow(win);
addWindow(win); addWindow(win);
} }

View file

@ -20,7 +20,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: XLayerItem.hh,v 1.5 2003/02/09 14:11:14 rathnor Exp $ // $Id: XLayerItem.hh,v 1.6 2003/02/18 15:08:12 rathnor Exp $
#ifndef FBTK_XLAYERITEM_HH #ifndef FBTK_XLAYERITEM_HH
#define FBTK_XLAYERITEM_HH #define FBTK_XLAYERITEM_HH
@ -28,6 +28,7 @@
#include "LayerItem.hh" #include "LayerItem.hh"
#include "XLayer.hh" #include "XLayer.hh"
#include "NotCopyable.hh" #include "NotCopyable.hh"
#include "FbWindow.hh"
#include <X11/Xlib.h> #include <X11/Xlib.h>
@ -36,9 +37,9 @@ namespace FbTk {
class XLayerItem : public LayerItem, private NotCopyable { class XLayerItem : public LayerItem, private NotCopyable {
public: public:
typedef std::list<Window> Windows; typedef std::list<FbWindow *> Windows;
XLayerItem(Window win, XLayer &layer); XLayerItem(FbWindow &win, XLayer &layer);
~XLayerItem(); ~XLayerItem();
void setLayer(XLayer &layer); void setLayer(XLayer &layer);
@ -65,11 +66,11 @@ public:
// an XLayerItem holds several windows that are equivalent in a layer // an XLayerItem holds several windows that are equivalent in a layer
// (i.e. if one is raised, then they should all be). // (i.e. if one is raised, then they should all be).
void addWindow(Window win); void addWindow(FbWindow &win);
void removeWindow(Window win); void removeWindow(FbWindow &win);
// using this you can bring one window to the top of this item (equivalent to add then remove) // using this you can bring one window to the top of this item (equivalent to add then remove)
void bringToTop(Window win); void bringToTop(FbWindow &win);
Windows &getWindows() { return m_windows; } Windows &getWindows() { return m_windows; }
size_t numWindows() const { return m_windows.size(); } size_t numWindows() const { return m_windows.size(); }