diff --git a/src/ui/frames.c b/src/ui/frames.c
index 01e5027..366ad0f 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -373,11 +373,6 @@ queue_recalc_func (gpointer key, gpointer value, gpointer data)
                                 frame->xwindow);
   if (frame->layout)
     {
-      /* save title to recreate layout */
-      g_free (frame->title);
-      
-      frame->title = g_strdup (pango_layout_get_text (frame->layout));
-
       g_object_unref (G_OBJECT (frame->layout));
       frame->layout = NULL;
     }
@@ -452,6 +447,37 @@ meta_frames_style_set  (GtkWidget *widget,
 }
 
 static void
+ellipsize_or_hide_layout (MetaFrames  *frames,
+                          MetaUIFrame *frame)
+{
+  MetaFrameGeometry fgeom;
+  int size, min_width, layout_width;
+  const PangoFontDescription *font_desc;
+
+  if (frame->layout == NULL)
+    return;
+
+  meta_frames_calc_geometry (frames, frame, &fgeom);
+
+  font_desc = pango_layout_get_font_description (frame->layout);
+  size = PANGO_PIXELS (pango_font_description_get_size (font_desc));
+  min_width = MAX(10, size);
+
+  layout_width = fgeom.width - 2 * MAX(fgeom.title_rect.x, fgeom.width - fgeom.title_rect.x - fgeom.title_rect.width) - 2;
+  if (layout_width < min_width)
+    {
+      frame->title_hidden = TRUE;
+      pango_layout_set_text (frame->layout, "", -1);
+    }
+  else
+    {
+      frame->title_hidden = FALSE;
+      pango_layout_set_text (frame->layout, frame->title, -1);
+      pango_layout_set_width (frame->layout, layout_width * PANGO_SCALE);
+    }
+}
+
+static void
 meta_frames_ensure_layout (MetaFrames  *frames,
                            MetaUIFrame *frame)
 {
@@ -476,18 +502,13 @@ meta_frames_ensure_layout (MetaFrames  *frames,
     {
       if (frame->layout)
         {
-          /* save title to recreate layout */
-          g_free (frame->title);
-          
-          frame->title = g_strdup (pango_layout_get_text (frame->layout));
-
           g_object_unref (G_OBJECT (frame->layout));
           frame->layout = NULL;
         }
     }
 
   frame->cache_style = style;
-  
+
   if (frame->layout == NULL)
     {
       gpointer key, value;
@@ -499,10 +520,11 @@ meta_frames_ensure_layout (MetaFrames  *frames,
                                           type,
                                           flags);
       
-      frame->layout = gtk_widget_create_pango_layout (widget, frame->title);
+      frame->layout = gtk_widget_create_pango_layout (widget, frame->title_hidden ? "" : frame->title);
 
       pango_layout_set_auto_dir (frame->layout, FALSE);
-      
+      pango_layout_set_ellipsize (frame->layout, PANGO_ELLIPSIZE_END);
+
       font_desc = meta_gtk_widget_get_font_desc (widget, scale,
                                                  meta_prefs_get_titlebar_font ());
 
@@ -529,10 +551,6 @@ meta_frames_ensure_layout (MetaFrames  *frames,
                                          font_desc);
       
       pango_font_description_free (font_desc);
-
-      /* Save some RAM */
-      g_free (frame->title);
-      frame->title = NULL;
     }
 }
 
@@ -2454,6 +2472,8 @@ meta_frames_paint_to_drawable (MetaFrames   *frames,
 
       gdk_region_get_rectangles (edges, &areas, &n_areas);
 
+      ellipsize_or_hide_layout (frames, frame);
+
       for (i = 0; i < n_areas; i++)
         {
           /* Bug 399529: clamp areas[i] so that it doesn't go too far
diff --git a/src/ui/frames.h b/src/ui/frames.h
index ad8d361..d855710 100644
--- a/src/ui/frames.h
+++ b/src/ui/frames.h
@@ -79,7 +79,8 @@ struct _MetaUIFrame
   MetaFrameStyle *cache_style;
   PangoLayout *layout;
   int text_height;
-  char *title; /* NULL once we have a layout */
+  char *title;
+  guint title_hidden : 1;
   guint expose_delayed : 1;
   guint shape_applied : 1;
   
