unsigned window_vertex_array;
unsigned framebuffer;
unsigned fb_texture;
+ Pixmap root_pixmap;
+ GLXPixmap root_glx_pixmap;
+ unsigned root_texture;
CompositedWindow *windows;
unsigned nwindows;
unsigned windows_capacity;
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB;
PFNGLXBINDTEXIMAGEEXTPROC glXBindTexImageEXT;
PFNGLXRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT;
+ Atom root_pmap_atom;
Atom correction_atom;
Atom monitors_atom;
int dirty;
glDepthMask(GL_FALSE);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+ screen->root_texture = create_2d_texture();
+
return 1;
}
return NULL;
}
-void create_window_pixmap(Compositor *compositor, CompositedScreen *screen, CompositedWindow *window)
+GLXPixmap pixmap_to_glx_pixmap(Compositor *compositor, CompositedScreen *screen, Pixmap pixmap)
{
int attribs[5];
unsigned i;
- if(window->pixmap)
- {
- glXDestroyPixmap(compositor->display, window->glx_pixmap);
- XFreePixmap(compositor->display, window->pixmap);
- }
-
i = 0;
attribs[i++] = GLX_TEXTURE_TARGET_EXT;
attribs[i++] = GLX_TEXTURE_2D_EXT;
attribs[i++] = GLX_TEXTURE_FORMAT_RGBA_EXT;
attribs[i++] = None;
+ return glXCreatePixmap(compositor->display, screen->fbconfig, pixmap, attribs);
+}
+
+void create_window_pixmap(Compositor *compositor, CompositedScreen *screen, CompositedWindow *window)
+{
+ if(window->pixmap)
+ {
+ glXDestroyPixmap(compositor->display, window->glx_pixmap);
+ XFreePixmap(compositor->display, window->pixmap);
+ }
+
window->pixmap = XCompositeNameWindowPixmap(compositor->display, window->window);
- window->glx_pixmap = glXCreatePixmap(compositor->display, screen->fbconfig, window->pixmap, attribs);
+ window->glx_pixmap = pixmap_to_glx_pixmap(compositor, screen, window->pixmap);
window->recreate_pixmap = 0;
}
XFree(values);
}
+void update_root_pixmap(Compositor *compositor, CompositedScreen *screen)
+{
+ Atom prop_type;
+ int prop_format;
+ unsigned long overflow;
+ unsigned long length;
+ long *pixmap;
+
+ XGetWindowProperty(compositor->display, screen->root, compositor->root_pmap_atom, 0, 1, False, XA_PIXMAP,
+ &prop_type, &prop_format, &length, &overflow, (unsigned char **)&pixmap);
+ if(prop_type!=XA_PIXMAP || prop_format!=32)
+ {
+ screen->root_pixmap = 0;
+ if(screen->root_glx_pixmap)
+ {
+ glXDestroyPixmap(compositor->display, screen->root_glx_pixmap);
+ screen->root_glx_pixmap = 0;
+ }
+ return;
+ }
+
+ screen->root_pixmap = pixmap[0];
+ screen->root_glx_pixmap = pixmap_to_glx_pixmap(compositor, screen, screen->root_pixmap);
+
+ XFree(pixmap);
+}
+
int initialize_screen(Compositor *compositor, unsigned number)
{
CompositedScreen *screen;
XRRFreeScreenResources(xrr_res);
update_geometry_correction(compositor, screen);
+ update_root_pixmap(compositor, screen);
XQueryTree(compositor->display, screen->root, &dummy_root, &dummy_parent, &children, &nchildren);
compositor->glXBindTexImageEXT = (PFNGLXBINDTEXIMAGEEXTPROC)glXGetProcAddress((unsigned char *)"glXBindTexImageEXT");
compositor->glXReleaseTexImageEXT = (PFNGLXRELEASETEXIMAGEEXTPROC)glXGetProcAddress((unsigned char *)"glXReleaseTexImageEXT");
+ compositor->root_pmap_atom = XInternAtom(compositor->display, "_XROOTPMAP_ID", False);
compositor->correction_atom = XInternAtom(compositor->display, "GEOMETRY_CORRECTION", False);
compositor->monitors_atom = XInternAtom(compositor->display, "GEOMETRY_CORRECTION_MONITORS", False);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, screen->framebuffer);
- glClearColor(0.5f, 0.5f, 0.5f, 0.0f);
- glClear(GL_COLOR_BUFFER_BIT);
-
use_mask = -1;
glBindVertexArray(screen->window_vertex_array);
+
+ if(screen->root_pixmap)
+ {
+ use_mask = 0;
+ glUseProgram(screen->program);
+ glBindTexture(GL_TEXTURE_2D, screen->root_texture);
+ compositor->glXBindTexImageEXT(compositor->display, screen->root_glx_pixmap, GLX_FRONT_LEFT_EXT, NULL);
+ glUniform4f(screen->geometry_loc, 0.0f, 0.0f, 1.0f, 1.0f);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ compositor->glXReleaseTexImageEXT(compositor->display, screen->root_glx_pixmap, GLX_FRONT_LEFT_EXT);
+ }
+ else
+ {
+ glClearColor(0.5f, 0.5f, 0.5f, 0.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+ }
+
for(i=0; i<screen->nwindows; ++i)
{
CompositedWindow *window;