From b7cfb7990668847fd2aa3095d803560d4482ff51 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 11 Dec 2015 18:52:31 +0200 Subject: [PATCH] Process DestroyNotify events --- source/main.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/source/main.c b/source/main.c index 05b5955..9865eb9 100644 --- a/source/main.c +++ b/source/main.c @@ -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; inwindows; ++i) + if(screen->windows[i].window==w) + { + glDeleteTextures(1, &screen->windows[i].texture); + + --screen->nwindows; + for(; inwindows; ++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; -- 2.43.0