From dded46b567c21be30b0044bc1e332c0b0028feb7 Mon Sep 17 00:00:00 2001 From: Andrew Hannam Date: Mon, 25 Jul 2016 19:26:28 +1000 Subject: [PATCH] FIx bug where WM_Raise doesn't raise children if the parent is raised. --- src/gwin/gwin_wm.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/gwin/gwin_wm.c b/src/gwin/gwin_wm.c index 6bc5013b..ee951335 100644 --- a/src/gwin/gwin_wm.c +++ b/src/gwin/gwin_wm.c @@ -988,6 +988,35 @@ static void WM_Raise(GHandle gh) { gfxQueueASyncRemove(&_GWINList, &gh->wmq); gfxQueueASyncPut(&_GWINList, &gh->wmq); + #if GWIN_NEED_CONTAINERS + // Any children need to be moved + if ((gh->flags & GWIN_FLG_CONTAINER)) { + GHandle child; + bool_t restart; + + // Raise the children too. + // Note children can also have their own children so after each move required we have to start again. + for(gh = gwinGetNextWindow(0); gh; gh = gwinGetNextWindow(gh)) { + if ((gh->flags & GWIN_FLG_CONTAINER)) { + restart = FALSE; + for(child = gwinGetNextWindow(0); child && child != gh; child = gwinGetNextWindow(child)) { + if (child->parent == gh) { + // Oops - this child is behind its parent + gfxQueueASyncRemove(&_GWINList, &child->wmq); + gfxQueueASyncPut(&_GWINList, &child->wmq); + // Continue the loop here effectively restarts at the front of the list + // for this parent container as we have moved this child to the start of the list. + // We also need to restart everything once this container is done. + restart = TRUE; + } + } + if (restart) + gh = 0; + } + } + } + #endif + // Redraw the window _gwinUpdate(gh); }