server: Don't attach the thread input when changing parents if the new
parent is the desktop (i.e. it is becoming a top-level window).
diff --git a/server/window.c b/server/window.c
index a83ce09..f2017ec 100644
--- a/server/window.c
+++ b/server/window.c
@@ -114,6 +114,12 @@
     return ret;
 }
 
+/* check if window is the desktop */
+static inline int is_desktop_window( const struct window *win )
+{
+    return !win->parent;  /* only desktop windows have no parent */
+}
+
 /* change the parent of a window (or unlink the window if the new parent is NULL) */
 static int set_parent_window( struct window *win, struct window *parent )
 {
@@ -136,8 +142,9 @@
         win->parent = parent;
         list_add_head( &parent->children, &win->entry );
 
-        /* if parent belongs to a different thread, attach the two threads */
-        if (parent->thread && parent->thread != win->thread)
+        /* if parent belongs to a different thread and the window isn't */
+        /* top-level, attach the two threads */
+        if (parent->thread && parent->thread != win->thread && !is_desktop_window(parent))
             attach_thread_input( win->thread, parent->thread );
     }
     else  /* move it to parent unlinked list */
@@ -177,12 +184,6 @@
     return ptr ? LIST_ENTRY( ptr, struct window, entry ) : NULL;
 }
 
-/* check if window is the desktop */
-static inline int is_desktop_window( const struct window *win )
-{
-    return !win->parent;  /* only desktop windows have no parent */
-}
-
 /* append a user handle to a handle array */
 static int add_handle_to_array( struct user_handle_array *array, user_handle_t handle )
 {
@@ -425,7 +426,8 @@
         goto failed;
     }
 
-    /* if parent belongs to a different thread, attach the two threads */
+    /* if parent belongs to a different thread and the window isn't */
+    /* top-level, attach the two threads */
     if (parent && parent->thread && parent->thread != current && !is_desktop_window(parent))
     {
         if (!attach_thread_input( current, parent->thread )) goto failed;