Alexandre Julliard : server: Hide a window before destroying it if it was still visible.

Alexandre Julliard julliard at winehq.org
Wed Jun 3 09:31:14 CDT 2009


Module: wine
Branch: master
Commit: 5dcf157b5bbbc039dce9eabe3f26bd50da7b33f7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5dcf157b5bbbc039dce9eabe3f26bd50da7b33f7

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Jun  3 11:29:15 2009 +0200

server: Hide a window before destroying it if it was still visible.

---

 server/thread.c |    2 +-
 server/window.c |   82 +++++++++++++++++++++++++++++++++----------------------
 2 files changed, 50 insertions(+), 34 deletions(-)

diff --git a/server/thread.c b/server/thread.c
index 6ce59c8..e931e81 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -264,9 +264,9 @@ static void cleanup_thread( struct thread *thread )
     if (thread->reply_fd) release_object( thread->reply_fd );
     if (thread->wait_fd) release_object( thread->wait_fd );
     free( thread->suspend_context );
-    free_msg_queue( thread );
     cleanup_clipboard_thread(thread);
     destroy_thread_windows( thread );
+    free_msg_queue( thread );
     close_thread_desktop( thread );
     for (i = 0; i < MAX_INFLIGHT_FDS; i++)
     {
diff --git a/server/window.c b/server/window.c
index a24b2d6..a0e0788 100644
--- a/server/window.c
+++ b/server/window.c
@@ -378,39 +378,6 @@ static void detach_window_thread( struct window *win )
     win->thread = NULL;
 }
 
-/* destroy a window */
-void destroy_window( struct window *win )
-{
-    /* destroy all children */
-    while (!list_empty(&win->children))
-        destroy_window( LIST_ENTRY( list_head(&win->children), struct window, entry ));
-    while (!list_empty(&win->unlinked))
-        destroy_window( LIST_ENTRY( list_head(&win->unlinked), struct window, entry ));
-
-    /* reset global window pointers, if the corresponding window is destroyed */
-    if (win == shell_window) shell_window = NULL;
-    if (win == shell_listview) shell_listview = NULL;
-    if (win == progman_window) progman_window = NULL;
-    if (win == taskman_window) taskman_window = NULL;
-    free_user_handle( win->handle );
-    destroy_properties( win );
-    list_remove( &win->entry );
-    if (is_desktop_window(win))
-    {
-        struct desktop *desktop = win->desktop;
-        assert( desktop->top_window == win || desktop->msg_window == win );
-        if (desktop->top_window == win) desktop->top_window = NULL;
-        else desktop->msg_window = NULL;
-    }
-    detach_window_thread( win );
-    if (win->win_region) free_region( win->win_region );
-    if (win->update_region) free_region( win->update_region );
-    if (win->class) release_class( win->class );
-    free( win->text );
-    memset( win, 0x55, sizeof(*win) + win->nb_extra_bytes - 1 );
-    free( win );
-}
-
 /* get the process owning the top window of a given desktop */
 struct process *get_top_window_owner( struct desktop *desktop )
 {
@@ -1696,6 +1663,55 @@ static void set_window_region( struct window *win, struct region *region, int re
 }
 
 
+/* destroy a window */
+void destroy_window( struct window *win )
+{
+    /* hide the window */
+    if (is_visible(win))
+    {
+        struct region *vis_rgn = get_visible_region( win, DCX_WINDOW );
+        win->style &= ~WS_VISIBLE;
+        if (vis_rgn)
+        {
+            struct region *exposed_rgn = expose_window( win, &win->window_rect, vis_rgn );
+            if (exposed_rgn) free_region( exposed_rgn );
+            free_region( vis_rgn );
+        }
+        validate_whole_window( win );
+        validate_children( win );
+    }
+
+    /* destroy all children */
+    while (!list_empty(&win->children))
+        destroy_window( LIST_ENTRY( list_head(&win->children), struct window, entry ));
+    while (!list_empty(&win->unlinked))
+        destroy_window( LIST_ENTRY( list_head(&win->unlinked), struct window, entry ));
+
+    /* reset global window pointers, if the corresponding window is destroyed */
+    if (win == shell_window) shell_window = NULL;
+    if (win == shell_listview) shell_listview = NULL;
+    if (win == progman_window) progman_window = NULL;
+    if (win == taskman_window) taskman_window = NULL;
+    free_user_handle( win->handle );
+    destroy_properties( win );
+    list_remove( &win->entry );
+    if (is_desktop_window(win))
+    {
+        struct desktop *desktop = win->desktop;
+        assert( desktop->top_window == win || desktop->msg_window == win );
+        if (desktop->top_window == win) desktop->top_window = NULL;
+        else desktop->msg_window = NULL;
+    }
+    detach_window_thread( win );
+    if (win->win_region) free_region( win->win_region );
+    if (win->update_region) free_region( win->update_region );
+    if (win->class) release_class( win->class );
+    free( win->text );
+    memset( win, 0x55, sizeof(*win) + win->nb_extra_bytes - 1 );
+    free( win );
+}
+
+
 /* create a window */
 DECL_HANDLER(create_window)
 {




More information about the wine-cvs mailing list