From 13364a0181a60cc65aad904fcace51ff071e5b99 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Mon, 28 Mar 2011 08:29:30 +0200 Subject: [PATCH] Turn globalonf.drawins into the list of visible drawins This fixes a crash when the opacity of a not-visible drawin is changed. This happened because we got a PropertyNotify for our own change of _NET_WM_OPACITY and then tried to set the drawin's opacity to this new value. However, the drawin was only reachable through globalconf.drawins and wasn't ref'd in lua. This means that the luaA_object_push() call in property_handle_net_wm_opacity() didn't find the drawin and instead pushed a nil. This then later caused an unprotected lua error in window_set_opacity(). Signed-off-by: Uli Schlachter --- objects/drawin.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/objects/drawin.c b/objects/drawin.c index ab1977b4a..0ba028c4e 100644 --- a/objects/drawin.c +++ b/objects/drawin.c @@ -60,12 +60,6 @@ drawin_wipe(drawin_t *w) { /* The drawin must already be unmapped, else it * couldn't be garbage collected -> no unmap needed */ - foreach(item, globalconf.drawins) - if(*item == w) - { - drawin_array_remove(&globalconf.drawins, item); - break; - } if(strut_has_value(&w->strut)) { screen_t *screen = @@ -173,8 +167,6 @@ drawin_init(drawin_t *w) /* Set the right properties */ ewmh_update_window_type(w->window, window_translate_type(w->type)); ewmh_update_strut(w->window, &w->strut); - - drawin_array_append(&globalconf.drawins, w); } /** Refresh the window content by copying its pixmap data to its window. @@ -275,6 +267,20 @@ drawin_map(drawin_t *drawin) client_restore_enterleave_events(); /* Stack this drawin correctly */ stack_windows(); + /* Add it to the list of visible drawins */ + drawin_array_append(&globalconf.drawins, drawin); +} + +static void +drawin_unmap(drawin_t *drawin) +{ + xcb_unmap_window(globalconf.connection, drawin->window); + foreach(item, globalconf.drawins) + if(*item == drawin) + { + drawin_array_remove(&globalconf.drawins, item); + break; + } } /** Get a drawin by its window. @@ -316,7 +322,7 @@ drawin_set_visible(lua_State *L, int udx, bool v) /* Active BMA */ client_ignore_enterleave_events(); /* Unmap window */ - xcb_unmap_window(globalconf.connection, drawin->window); + drawin_unmap(drawin); /* Active BMA */ client_restore_enterleave_events(); /* unref it */