From e5ed2f2f1cfe8898a3862c25e25576c19401a765 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 13 May 2008 18:54:08 +0200 Subject: [PATCH] [swindow] Permit to delete NULL swindow Signed-off-by: Julien Danjou --- client.c | 3 +-- common/swindow.c | 12 ------------ common/swindow.h | 17 ++++++++++++++++- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/client.c b/client.c index be5616e1d..984b3c27d 100644 --- a/client.c +++ b/client.c @@ -750,8 +750,7 @@ client_unmanage(client_t *c) xcb_aux_sync(globalconf.connection); xcb_ungrab_server(globalconf.connection); - if(c->titlebar.sw) - simplewindow_delete(&c->titlebar.sw); + simplewindow_delete(&c->titlebar.sw); p_delete(&c); } diff --git a/common/swindow.c b/common/swindow.c index 7d5b847f5..6f39106eb 100644 --- a/common/swindow.c +++ b/common/swindow.c @@ -82,18 +82,6 @@ simplewindow_new(xcb_connection_t *conn, int phys_screen, int x, int y, return sw; } -/** Destroy a simple window and all its resources. - * \param sw The simple_window_t to delete. - */ -void -simplewindow_delete(simple_window_t **sw) -{ - xcb_destroy_window((*sw)->connection, (*sw)->window); - xcb_free_pixmap((*sw)->connection, (*sw)->drawable); - xcb_free_gc((*sw)->connection, (*sw)->gc); - p_delete(sw); -} - /** Move a simple window. * \param sw The simple window to move. * \param x New x coordinate. diff --git a/common/swindow.h b/common/swindow.h index 2c6c73b7c..ed6a3a062 100644 --- a/common/swindow.h +++ b/common/swindow.h @@ -44,7 +44,22 @@ typedef struct simple_window_t } simple_window_t; simple_window_t * simplewindow_new(xcb_connection_t *, int, int, int, unsigned int, unsigned int, unsigned int); -void simplewindow_delete(simple_window_t **); + +/** Destroy a simple window and all its resources. + * \param sw The simple_window_t to delete. + */ +static inline void +simplewindow_delete(simple_window_t **sw) +{ + if(*sw) + { + xcb_destroy_window((*sw)->connection, (*sw)->window); + xcb_free_pixmap((*sw)->connection, (*sw)->drawable); + xcb_free_gc((*sw)->connection, (*sw)->gc); + p_delete(sw); + } +} + void simplewindow_move(simple_window_t *, int, int); void simplewindow_resize(simple_window_t *, unsigned int, unsigned int);