]> git.tdb.fi Git - geometrycompositor.git/commitdiff
Process DestroyNotify events
authorMikko Rasa <tdb@tdb.fi>
Fri, 11 Dec 2015 16:52:31 +0000 (18:52 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 11 Dec 2015 16:52:31 +0000 (18:52 +0200)
source/main.c

index 05b59557495cf9725cee2553db1b3cc5fa1fd2a8..9865eb9ac7c7f84d2104c423e41f31614b4ab6fb 100644 (file)
@@ -310,6 +310,21 @@ void add_window(Compositor *compositor, CompositedScreen *screen, Window w)
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 }
 
+void remove_window(CompositedScreen *screen, Window w)
+{
+       unsigned i;
+
+       for(i=0; i<screen->nwindows; ++i)
+               if(screen->windows[i].window==w)
+               {
+                       glDeleteTextures(1, &screen->windows[i].texture);
+
+                       --screen->nwindows;
+                       for(; i<screen->nwindows; ++i)
+                               screen->windows[i] = screen->windows[i+1];
+               }
+}
+
 CompositedScreen *find_screen_by_root(Compositor *compositor, Window root)
 {
        unsigned i;
@@ -487,6 +502,15 @@ void process_create_window_event(Compositor *compositor, XCreateWindowEvent *eve
        add_window(compositor, screen, event->window);
 }
 
+void process_destroy_window_event(Compositor *compositor, XDestroyWindowEvent *event)
+{
+       CompositedScreen *screen = find_screen_by_root(compositor, event->event);
+       if(!screen)
+               return;
+
+       remove_window(screen, event->window);
+}
+
 void process_map_event(Compositor *compositor, XMapEvent *event)
 {
        CompositedScreen *screen = find_screen_by_root(compositor, event->event);
@@ -538,6 +562,9 @@ int process_event(Compositor *compositor)
        case CreateNotify:
                process_create_window_event(compositor, &event.xcreatewindow);
                break;
+       case DestroyNotify:
+               process_destroy_window_event(compositor, &event.xdestroywindow);
+               break;
        case MapNotify:
                process_map_event(compositor, &event.xmap);
                break;