diff --git a/src/ui/theme.c b/src/ui/theme.c
index 4184b1f..0ac84ef 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -58,6 +58,7 @@
 #include "util.h"
 #include "gradient.h"
 #include <gtk/gtk.h>
+#include <cairo/cairo-xlib.h>
 #include <string.h>
 #include <stdlib.h>
 #define __USE_XOPEN
@@ -3424,20 +3425,46 @@ meta_draw_op_draw_with_env (const MetaDrawOp    *op,
     case META_DRAW_LINE:
       {
         int x1, x2, y1, y2;
+        cairo_surface_t *surface;
+        GC gc;
+        Drawable drawable;
+        XRectangle rectangle;
+        Display *display;
 
         meta_color_spec_render (op->data.line.color_spec, widget, &color);
-        gdk_cairo_set_source_color (cr, &color);
 
-        if (op->data.line.width > 0)
-          cairo_set_line_width (cr, op->data.line.width);
+        surface = cairo_get_target (cr);
+        cairo_surface_flush (surface);
+        
+        display = cairo_xlib_surface_get_display (surface);
+        drawable = cairo_xlib_surface_get_drawable (surface);
 
+        gc = XCreateGC (display, drawable, 0, NULL);
+  
+        XSetForeground (display, gc, GDK_COLOR_RGB (color));
+        XSetLineAttributes (display, 
+                            gc, 
+                            op->data.line.width,
+                            (op->data.line.dash_on_length > 0 &&
+                              op->data.line.dash_off_length > 0) ?
+                                LineOnOffDash : LineSolid,
+                            CapButt,
+                            0);
+                            
+        rectangle.x = clip->x;
+        rectangle.y = clip->y;
+        rectangle.width = clip->width;
+        rectangle.height = clip->height;
+                            
+        XSetClipRectangles (display, gc, 0, 0, &rectangle, 1, Unsorted);
+        
         if (op->data.line.dash_on_length > 0 &&
             op->data.line.dash_off_length > 0)
           {
-            double dash_list[2];
+            char dash_list[2];
             dash_list[0] = op->data.line.dash_on_length;
             dash_list[1] = op->data.line.dash_off_length;
-            cairo_set_dash (cr, dash_list, 2, 0);
+            XSetDashes (display, gc, 0, dash_list, 2);
           }
 
         x1 = parse_x_position_unchecked (op->data.line.x1, env);
@@ -3446,10 +3473,7 @@ meta_draw_op_draw_with_env (const MetaDrawOp    *op,
         if (!op->data.line.x2 &&
             !op->data.line.y2 &&
             op->data.line.width==0)
-          {
-            cairo_rectangle (cr, x1, y1, 1, 1);
-            cairo_fill (cr);
-          }
+          XDrawPoint (display, drawable, gc, x1, y1);
         else
           {
             if (op->data.line.x2)
@@ -3462,34 +3486,11 @@ meta_draw_op_draw_with_env (const MetaDrawOp    *op,
             else
               y2 = y1;
 
-            /* This is one of the cases where we are matching the exact
-             * pixel aligned rectangle produced by X.
-             */
-            if (y1 == y2 || x1 == x2)
-              {
-                double offset = (op->data.line.width == 0 ||
-                                 op->data.line.width % 2) ? .5 : 0;
-                /* X includes end points for lines of width 0 */
-                double line_extend = op->data.line.width == 0 ? 1. : 0.;
-
-                if (y1 == y2)
-                  {
-                    cairo_move_to (cr, x1, y1 + offset);
-                    cairo_line_to (cr, x2 + line_extend, y2 + offset);
-                  }
-                else
-                  {
-                    cairo_move_to (cr, x1 + offset, y1);
-                    cairo_line_to (cr, x2 + offset, y2 + line_extend);
-                  }
-              }
-            else
-              {
-                cairo_move_to (cr, x1 + .5, y1 + .5);
-                cairo_line_to (cr, x2 + .5, y2 + .5);
-              }
-            cairo_stroke (cr);
+            XDrawLine (display, drawable, gc, x1, y1, x2, y2);
           }
+
+        XFreeGC (display, gc);
+        
       }
       break;
 
