xglcomp

annotate src/cwin.cc @ 2:876efea9424c

OpenGL
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 22 Jan 2016 06:31:03 +0200
parents b2b7cb950c28
children e831d38e6faa
rev   line source
nuclear@0 1 #include <vector>
nuclear@1 2 #include <algorithm>
nuclear@0 3 #include "cwin.h"
nuclear@0 4 #include "logger.h"
nuclear@0 5
nuclear@1 6 static std::vector<CompWindow*> cwinlist;
nuclear@0 7
nuclear@2 8 CompWindow::CompWindow(Window xid)
nuclear@2 9 {
nuclear@2 10 xwin = xid;
nuclear@2 11 xpixmap = 0;
nuclear@2 12 }
nuclear@2 13
nuclear@0 14 void add_window(CompWindow *cwin)
nuclear@0 15 {
nuclear@0 16 if(have_window(cwin)) {
nuclear@0 17 log_warning("add_window trying to add duplicate, ignoring\n");
nuclear@0 18 return;
nuclear@0 19 }
nuclear@0 20
nuclear@0 21 cwinlist.push_back(cwin);
nuclear@0 22 }
nuclear@0 23
nuclear@2 24 bool remove_window(CompWindow *cwin)
nuclear@1 25 {
nuclear@1 26 auto it = std::find(cwinlist.begin(), cwinlist.end(), cwin);
nuclear@1 27 if(it != cwinlist.end()) {
nuclear@1 28 cwinlist.erase(it);
nuclear@1 29 return true;
nuclear@1 30 }
nuclear@1 31 return false;
nuclear@1 32 }
nuclear@1 33
nuclear@1 34 bool have_window(CompWindow *cwin)
nuclear@1 35 {
nuclear@1 36 return std::find(cwinlist.begin(), cwinlist.end(), cwin) != cwinlist.end();
nuclear@1 37 }
nuclear@1 38
nuclear@1 39 CompWindow *find_window_xid(Window xid)
nuclear@1 40 {
nuclear@1 41 if(!xid) return 0;
nuclear@1 42
nuclear@1 43 for(size_t i=0; i<cwinlist.size(); i++) {
nuclear@1 44 if(cwinlist[i]->xwin == xid) {
nuclear@1 45 return cwinlist[i];
nuclear@1 46 }
nuclear@1 47 }
nuclear@1 48 return 0;
nuclear@1 49 }
nuclear@1 50
nuclear@1 51 CompWindow *find_window_pixmap(Pixmap pix)
nuclear@1 52 {
nuclear@1 53 if(!pix) return 0;
nuclear@1 54
nuclear@1 55 for(size_t i=0; i<cwinlist.size(); i++) {
nuclear@1 56 if(cwinlist[i]->xpixmap == pix) {
nuclear@1 57 return cwinlist[i];
nuclear@1 58 }
nuclear@1 59 }
nuclear@1 60 return 0;
nuclear@1 61 }
nuclear@1 62
nuclear@1 63 int get_window_count()
nuclear@1 64 {
nuclear@1 65 return (int)cwinlist.size();
nuclear@1 66 }
nuclear@1 67
nuclear@1 68 CompWindow *get_window(int idx)
nuclear@1 69 {
nuclear@1 70 if(idx < 0 || idx >= (int)cwinlist.size()) {
nuclear@1 71 return 0;
nuclear@1 72 }
nuclear@1 73 return cwinlist[idx];
nuclear@1 74 }