]> git.tdb.fi Git - geometrycompositor.git/blobdiff - source/main.c
Check that the root pixmap exists before using it
[geometrycompositor.git] / source / main.c
index a1bfe6a3dc5373e16f15c1a09e121df006ebdad7..23c061b86fc3a5557dfba3b2266499f29b36ef1c 100644 (file)
@@ -506,6 +506,7 @@ CompositedWindow *add_window(Compositor *compositor, CompositedScreen *screen, W
 
        window->texture = create_2d_texture();
        window->mask_texture = create_2d_texture();
+       window->use_mask = 0;
        window->recreate_mask = (window->map_state==IsViewable);
 
        XShapeSelectInput(compositor->display, window->window, ShapeNotifyMask);
@@ -814,22 +815,34 @@ void update_root_pixmap(Compositor *compositor, CompositedScreen *screen)
        unsigned long overflow;
        unsigned long length;
        long *pixmap;
+       Window root;
+       int x, y;
+       unsigned width;
+       unsigned height;
+       unsigned border;
+       unsigned depth;
+
+       use_gl(compositor, screen);
+
+       if(screen->root_glx_pixmap)
+       {
+               glXDestroyPixmap(compositor->display, screen->root_glx_pixmap);
+               screen->root_glx_pixmap = 0;
+       }
 
        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);
+       if(XGetGeometry(compositor->display, screen->root_pixmap, &root, &x, &y, &width, &height, &border, &depth))
+               screen->root_glx_pixmap = pixmap_to_glx_pixmap(compositor, screen, screen->root_pixmap);
+       else
+               screen->root_pixmap = None;
 
        XFree(pixmap);
 }
@@ -879,6 +892,9 @@ int initialize_screen(Compositor *compositor, unsigned number)
                        return 0;
        XRRFreeScreenResources(xrr_res);
 
+       screen->root_pixmap = 0;
+       screen->root_glx_pixmap = 0;
+
        update_geometry_correction(compositor, screen);
        update_root_pixmap(compositor, screen);
 
@@ -995,6 +1011,9 @@ void shutdown_screen(Compositor *compositor, CompositedScreen *screen)
                }
        }
 
+       glDeleteTextures(1, &screen->root_texture);
+       glXDestroyPixmap(compositor->display, screen->root_glx_pixmap);
+
        glDeleteBuffers(1, &screen->window_vertex_buffer);
        glDeleteVertexArrays(1, &screen->window_vertex_array);
        glDeleteFramebuffers(1, &screen->framebuffer);
@@ -1145,14 +1164,14 @@ void process_property_event(Compositor *compositor, XPropertyEvent *event)
 {
        CompositedScreen *screen;
 
-       if(event->atom!=compositor->correction_atom)
-               return;
-
        screen = find_screen_by_root(compositor, event->window);
        if(!screen)
                return;
 
-       update_geometry_correction(compositor, screen);
+       if(event->atom==compositor->correction_atom)
+               update_geometry_correction(compositor, screen);
+       else if(event->atom==compositor->root_pmap_atom)
+               update_root_pixmap(compositor, screen);
 }
 
 void process_damage_event(Compositor *compositor, XDamageNotifyEvent *event)
@@ -1242,6 +1261,7 @@ void refresh_screen(Compositor *compositor, CompositedScreen *screen)
 
        use_gl(compositor, screen);
 
+       glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        glBindFramebuffer(GL_DRAW_FRAMEBUFFER, screen->framebuffer);
 
        use_mask = -1;
@@ -1258,10 +1278,7 @@ void refresh_screen(Compositor *compositor, CompositedScreen *screen)
                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)
        {
@@ -1299,7 +1316,6 @@ void refresh_screen(Compositor *compositor, CompositedScreen *screen)
        }
 
        glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
-       glClearColor(0.5f, 0.0f, 0.5f, 0.0f);
        glClear(GL_COLOR_BUFFER_BIT);
        glBindTexture(GL_TEXTURE_2D, screen->fb_texture);
        glEnable(GL_PRIMITIVE_RESTART);