From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/window.c | 26 ++++++++++++++++++++++++++ dlls/winex11.drv/x11drv.h | 2 ++ 2 files changed, 28 insertions(+)
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 81effbaa45c..04be7cdd331 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -131,10 +131,18 @@ static void host_window_release( struct host_window *win )
XDeleteContext( data->display, host_window_context, win->window ); if (win->parent) host_window_release( win->parent ); + free( win->children ); free( win ); } }
+static unsigned int find_host_window_child( struct host_window *win, Window child ) +{ + unsigned int i; + for (i = 0; i < win->children_count; i++) if (win->children[i].window == child) break; + return i; +} + static int host_window_error( Display *display, XErrorEvent *event, void *arg ) { return (event->error_code == BadWindow); @@ -168,7 +176,25 @@ struct host_window *get_host_window( Window window, BOOL create ) static void host_window_reparent( struct host_window **win, Window parent, Window window ) { struct host_window *old = *win, *new = get_host_window( parent, TRUE ); + unsigned int index; + void *tmp; + if ((*win = new)) host_window_add_ref( new ); + + if (old && (index = find_host_window_child( old, window )) < old->children_count) + { + old->children[index] = old->children[old->children_count - 1]; + old->children_count--; + } + + if (new && (index = find_host_window_child( new, window )) == new->children_count) + { + if (!(tmp = realloc( new->children, (index + 1) * sizeof(*new->children) ))) return; + new->children = tmp; + new->children[index].window = window; + new->children_count++; + } + if (old) host_window_release( old ); }
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 4f555d8e32f..1c2468e8a63 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -367,6 +367,8 @@ struct host_window LONG refcount; Window window; struct host_window *parent; + unsigned int children_count; + struct { Window window; } *children; };
extern void host_window_destroy( struct host_window *win );