# HG changeset patch # User Darkvater # Date 1167412061 0 # Node ID 1af12f02bf178310aba6115be9aa94d577ced475 # Parent 9498578ecbf2bc132ddee92687bbac1bfe99b39c (svn r7618) -Feature: Add support for a parent<>child relationship in Window terms. A child is a window whose parent pointer is non-null. Deleting the parent cascades deleting the children as well; children first. diff -r 9498578ecbf2 -r 1af12f02bf17 window.c --- a/window.c Fri Dec 29 16:40:22 2006 +0000 +++ b/window.c Fri Dec 29 17:07:41 2006 +0000 @@ -287,6 +287,21 @@ SetDirtyBlocks(w->left, w->top, w->left + w->width, w->top + w->height); } +/** Find the Window whose parent pointer points to this window + * @parent w Window to find child of + * @return return a Window pointer that is the child of w, or NULL otherwise */ +static Window *FindChildWindow(const Window *w) +{ + Window* const *wz; + + FOR_ALL_WINDOWS(wz) { + Window *v = *wz; + if (v->parent == w) return v; + } + + return NULL; +} + /** Find the z-value of a window. A window must already be open * or the behaviour is undefined but function should never fail */ Window **FindWindowZPosition(const Window *w) @@ -301,9 +316,14 @@ void DeleteWindow(Window *w) { + Window *v; Window **wz; if (w == NULL) return; + /* Delete any children a window might have in a head-recursive manner */ + v = FindChildWindow(w); + if (v != NULL) DeleteWindow(v); + if (_thd.place_mode != VHM_NONE && _thd.window_class == w->window_class && _thd.window_number == w->window_number) { @@ -317,6 +337,7 @@ free(w->widget); w->widget = NULL; w->widget_count = 0; + w->parent = NULL; /* Find the window in the z-array, and effectively remove it * by moving all windows after it one to the left */ diff -r 9498578ecbf2 -r 1af12f02bf17 window.h --- a/window.h Fri Dec 29 16:40:22 2006 +0000 +++ b/window.h Fri Dec 29 17:07:41 2006 +0000 @@ -335,6 +335,7 @@ uint32 desc_flags; WindowMessage message; + Window *parent; byte custom[WINDOW_CUSTOM_SIZE]; };