nuclear@0: #include nuclear@1: #include nuclear@0: #include "cwin.h" nuclear@0: #include "logger.h" nuclear@0: nuclear@1: static std::vector cwinlist; nuclear@0: nuclear@2: CompWindow::CompWindow(Window xid) nuclear@2: { nuclear@2: xwin = xid; nuclear@2: xpixmap = 0; nuclear@2: } nuclear@2: nuclear@0: void add_window(CompWindow *cwin) nuclear@0: { nuclear@0: if(have_window(cwin)) { nuclear@0: log_warning("add_window trying to add duplicate, ignoring\n"); nuclear@0: return; nuclear@0: } nuclear@0: nuclear@0: cwinlist.push_back(cwin); nuclear@0: } nuclear@0: nuclear@2: bool remove_window(CompWindow *cwin) nuclear@1: { nuclear@1: auto it = std::find(cwinlist.begin(), cwinlist.end(), cwin); nuclear@1: if(it != cwinlist.end()) { nuclear@1: cwinlist.erase(it); nuclear@1: return true; nuclear@1: } nuclear@1: return false; nuclear@1: } nuclear@1: nuclear@1: bool have_window(CompWindow *cwin) nuclear@1: { nuclear@1: return std::find(cwinlist.begin(), cwinlist.end(), cwin) != cwinlist.end(); nuclear@1: } nuclear@1: nuclear@1: CompWindow *find_window_xid(Window xid) nuclear@1: { nuclear@1: if(!xid) return 0; nuclear@1: nuclear@1: for(size_t i=0; ixwin == xid) { nuclear@1: return cwinlist[i]; nuclear@1: } nuclear@1: } nuclear@1: return 0; nuclear@1: } nuclear@1: nuclear@1: CompWindow *find_window_pixmap(Pixmap pix) nuclear@1: { nuclear@1: if(!pix) return 0; nuclear@1: nuclear@1: for(size_t i=0; ixpixmap == pix) { nuclear@1: return cwinlist[i]; nuclear@1: } nuclear@1: } nuclear@1: return 0; nuclear@1: } nuclear@1: nuclear@1: int get_window_count() nuclear@1: { nuclear@1: return (int)cwinlist.size(); nuclear@1: } nuclear@1: nuclear@1: CompWindow *get_window(int idx) nuclear@1: { nuclear@1: if(idx < 0 || idx >= (int)cwinlist.size()) { nuclear@1: return 0; nuclear@1: } nuclear@1: return cwinlist[idx]; nuclear@1: }