xlib: Use trace usage.
diff --git a/src/gallium/winsys/xlib/xm_api.c b/src/gallium/winsys/xlib/xm_api.c
index 4e5441a..d2f92a0 100644
--- a/src/gallium/winsys/xlib/xm_api.c
+++ b/src/gallium/winsys/xlib/xm_api.c
@@ -67,6 +67,7 @@
 #include "state_tracker/st_public.h"
 #include "state_tracker/st_context.h"
 #include "pipe/p_defines.h"
+#include "pipe/p_screen.h"
 #include "pipe/p_context.h"
 
 #include "xm_winsys_aub.h"
@@ -833,7 +834,7 @@
  fail:
    if (c->st)
       st_destroy_context(c->st);
-   if (pipe)
+   else if (pipe)
       pipe->destroy(pipe);
    FREE(c);
    return NULL;
@@ -844,7 +845,9 @@
 PUBLIC
 void XMesaDestroyContext( XMesaContext c )
 {
+   struct pipe_screen *screen = c->st->pipe->screen;
    st_destroy_context(c->st);
+   screen->destroy(screen);
    _mesa_free(c);
 }
 
diff --git a/src/gallium/winsys/xlib/xm_winsys.c b/src/gallium/winsys/xlib/xm_winsys.c
index 6071a5a..3ab4c67 100644
--- a/src/gallium/winsys/xlib/xm_winsys.c
+++ b/src/gallium/winsys/xlib/xm_winsys.c
@@ -55,7 +55,6 @@
 #endif
 
 #ifdef GALLIUM_TRACE
-#include "trace/tr_winsys.h"
 #include "trace/tr_screen.h"
 #include "trace/tr_context.h"
 #endif
@@ -651,11 +650,7 @@
       ws->base.get_name = xm_get_name;
    }
 
-#ifdef GALLIUM_TRACE
-      return trace_winsys_create(&ws->base);
-#else
-      return &ws->base;
-#endif
+   return &ws->base;
 }
 
 
@@ -684,14 +679,12 @@
    {
       struct pipe_screen *screen = softpipe_create_screen(pws);
 
-#ifdef GALLIUM_TRACE
-      screen = trace_screen_create(screen);
-#endif
-      
       pipe = softpipe_create(screen, pws, NULL);
 
 #ifdef GALLIUM_TRACE
-      pipe = trace_context_create(pipe);
+      screen = trace_screen_create(screen);
+      
+      pipe = trace_context_create(screen, pipe);
 #endif
    }