xglcomp
diff src/cwin.cc @ 12:1c0d056ec360
moving slowly
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 05 Feb 2016 03:33:18 +0200 |
parents | b0081a0c211f |
children |
line diff
1.1 --- a/src/cwin.cc Thu Feb 04 04:15:15 2016 +0200 1.2 +++ b/src/cwin.cc Fri Feb 05 03:33:18 2016 +0200 1.3 @@ -2,6 +2,7 @@ 1.4 #include <vector> 1.5 #include <algorithm> 1.6 #include <X11/Xlib.h> 1.7 +#include <X11/extensions/Xcomposite.h> 1.8 #include <X11/extensions/Xdamage.h> 1.9 #include "cwin.h" 1.10 #include "logger.h" 1.11 @@ -14,9 +15,12 @@ 1.12 { 1.13 xwin = xid; 1.14 xpixmap = 0; 1.15 + pixmap_valid = false; 1.16 memset(&attr, 0, sizeof attr); 1.17 mapped = false; 1.18 damage = 0; 1.19 + damaged = false; 1.20 + tex_valid = false; 1.21 } 1.22 1.23 CompWindow::~CompWindow() 1.24 @@ -29,6 +33,43 @@ 1.25 } 1.26 } 1.27 1.28 +bool CompWindow::update_attr() 1.29 +{ 1.30 + if(!xwin) return false; 1.31 + 1.32 + XGetWindowAttributes(dpy, xwin, &attr); 1.33 + return true; 1.34 +} 1.35 + 1.36 +bool CompWindow::update_pixmap() 1.37 +{ 1.38 + if(!xwin) return false; 1.39 + 1.40 + Pixmap pix = XCompositeNameWindowPixmap(dpy, xwin); 1.41 + if(!pix) { 1.42 + log_error("failed to get window %x pixmap\n", xwin); 1.43 + return false; 1.44 + } 1.45 + 1.46 + if(pix != xpixmap) { 1.47 + if(xpixmap) { 1.48 + XFreePixmap(dpy, xpixmap); 1.49 + } 1.50 + xpixmap = pix; 1.51 + tex_valid = false; 1.52 + } 1.53 + pixmap_valid = true; 1.54 + return true; 1.55 +} 1.56 + 1.57 +bool CompWindow::update_texture() 1.58 +{ 1.59 + if(!xwin || !xpixmap) return false; 1.60 + tex.set_image(dpy, xpixmap); 1.61 + tex_valid = true; 1.62 + return true; 1.63 +} 1.64 + 1.65 void add_window(CompWindow *cwin) 1.66 { 1.67 if(have_window(cwin)) {