--- xfwm4-4.6.0/src/frame.c	2009-01-26 19:43:51.000000000 +0100
+++ xfwm4-4.6.0-patched/src/frame.c	2009-04-15 19:07:15.000000000 +0200
@@ -121,7 +121,9 @@
 
     g_return_val_if_fail (c != NULL, 0);
     if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_BORDER)
-        && !FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN))
+        && !FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN)
+        && (!FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED)
+            || !(c->screen_info->params->borderless_maximize)))
     {
         return c->screen_info->title[TITLE_3][ACTIVE].height;
     }
@@ -167,7 +169,9 @@
 
     g_return_val_if_fail (c != NULL, 0);
     if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_BORDER)
-         && !FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN))
+        && !FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN)
+        && (!FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED)
+            || !(c->screen_info->params->borderless_maximize)))
     {
         return c->y - frameTop (c);
     }
@@ -198,7 +202,9 @@
     g_return_val_if_fail (c != NULL, 0);
     if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_BORDER)
         && FLAG_TEST (c->flags, CLIENT_FLAG_SHADED)
-        && !FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN))
+        && !FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN)
+        && (!FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED)
+            || !(c->screen_info->params->borderless_maximize)))
     {
         return frameTop (c) + frameBottom (c);
     }
@@ -952,27 +958,35 @@
                 break;
             }
             else if (button >= 0)
-            {
-                if (x + screen_info->buttons[button][state].width + screen_info->params->button_spacing < right)
-                {
-                    my_pixmap = clientGetButtonPixmap (c, button, clientGetButtonState (c, button, state));
-                    if (!xfwmPixmapNone(my_pixmap))
-                    {
-                        xfwmWindowSetBG (&c->buttons[button], my_pixmap);
-                    }
-                    xfwmWindowShow (&c->buttons[button], x,
-                        (frameTop (c) - screen_info->buttons[button][state].height + 1) / 2,
-                        screen_info->buttons[button][state].width,
-                        screen_info->buttons[button][state].height, TRUE);
-                    button_x[button] = x;
-                    x = x + screen_info->buttons[button][state].width +
-                        screen_info->params->button_spacing;
-                }
+              {
+                if (!(FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED)
+                      && (c->screen_info->params->borderless_maximize)))
+                  {
+                    if (x + screen_info->buttons[button][state].width + screen_info->params->button_spacing < right)
+                      {
+                        my_pixmap = clientGetButtonPixmap (c, button, clientGetButtonState (c, button, state));
+                        if (!xfwmPixmapNone(my_pixmap))
+                          {
+                            xfwmWindowSetBG (&c->buttons[button], my_pixmap);
+                          }
+                        xfwmWindowShow (&c->buttons[button], x,
+                                        (frameTop (c) - screen_info->buttons[button][state].height + 1) / 2,
+                                        screen_info->buttons[button][state].width,
+                                        screen_info->buttons[button][state].height, TRUE);
+                        button_x[button] = x;
+                        x = x + screen_info->buttons[button][state].width +
+                          screen_info->params->button_spacing;
+                      }
+                    else
+                      {
+                        xfwmWindowHide (&c->buttons[button]);
+                      }
+                  }
                 else
-                {
+                  {
                     xfwmWindowHide (&c->buttons[button]);
-                }
-            }
+                  }
+              }
         }
         left = x + screen_info->params->button_spacing;
 
@@ -984,30 +998,38 @@
             button = getButtonFromLetter (screen_info->params->button_layout[j], c);
             if (button == TITLE_SEPARATOR)
             {
-                break;
+              break;
             }
             else if (button >= 0)
-            {
-                if (x - screen_info->buttons[button][state].width - screen_info->params->button_spacing > left)
-                {
-                    my_pixmap = clientGetButtonPixmap (c, button, clientGetButtonState (c, button, state));
-                    if (!xfwmPixmapNone(my_pixmap))
-                    {
-                        xfwmWindowSetBG (&c->buttons[button], my_pixmap);
-                    }
-                    x = x - screen_info->buttons[button][state].width -
-                        screen_info->params->button_spacing;
-                    xfwmWindowShow (&c->buttons[button], x,
-                        (frameTop (c) - screen_info->buttons[button][state].height + 1) / 2,
-                        screen_info->buttons[button][state].width,
-                        screen_info->buttons[button][state].height, TRUE);
-                    button_x[button] = x;
-                }
+              {
+                if (!(FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED)
+                      && (c->screen_info->params->borderless_maximize)))
+                  {
+                    if (x - screen_info->buttons[button][state].width - screen_info->params->button_spacing > left)
+                      {
+                        my_pixmap = clientGetButtonPixmap (c, button, clientGetButtonState (c, button, state));
+                        if (!xfwmPixmapNone(my_pixmap))
+                          {
+                            xfwmWindowSetBG (&c->buttons[button], my_pixmap);
+                          }
+                        x = x - screen_info->buttons[button][state].width -
+                          screen_info->params->button_spacing;
+                        xfwmWindowShow (&c->buttons[button], x,
+                                        (frameTop (c) - screen_info->buttons[button][state].height + 1) / 2,
+                                        screen_info->buttons[button][state].width,
+                                        screen_info->buttons[button][state].height, TRUE);
+                        button_x[button] = x;
+                      }
+                    else
+                      {
+                        xfwmWindowHide (&c->buttons[button]);
+                      }
+                  }
                 else
-                {
+                  {
                     xfwmWindowHide (&c->buttons[button]);
-                }
-            }
+                  }
+              }
         }
         left = left - 2 * screen_info->params->button_spacing;
         right = x;
@@ -1027,12 +1049,16 @@
         xfwmPixmapInit (screen_info, &frame_pix.pm_sides[SIDE_LEFT]);
         xfwmPixmapInit (screen_info, &frame_pix.pm_sides[SIDE_RIGHT]);
 
-        /* The title is always visible */
-        frameCreateTitlePixmap (c, state, left, right, &frame_pix.pm_title, &frame_pix.pm_sides[SIDE_TOP]);
-        xfwmWindowSetBG (&c->title, &frame_pix.pm_title);
-        xfwmWindowShow (&c->title,
-            frameTopLeftWidth (c, state), 0, top_width,
-            frameTop (c), (requires_clearing | width_changed));
+        /* The title is _not_ always visible */
+        if (!(FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED)
+              && (c->screen_info->params->borderless_maximize)))
+          {
+            frameCreateTitlePixmap (c, state, left, right, &frame_pix.pm_title, &frame_pix.pm_sides[SIDE_TOP]);
+            xfwmWindowSetBG (&c->title, &frame_pix.pm_title);
+            xfwmWindowShow (&c->title,
+                            frameTopLeftWidth (c, state), 0, top_width,
+                            frameTop (c), (requires_clearing | width_changed));
+          }
 
         /* Corners are never resized, we need to update them separately */
         if (requires_clearing)
@@ -1058,6 +1084,7 @@
             xfwmWindowHide (&c->corners[CORNER_TOP_RIGHT]);
             xfwmWindowHide (&c->corners[CORNER_BOTTOM_LEFT]);
             xfwmWindowHide (&c->corners[CORNER_BOTTOM_RIGHT]);
+            xfwmWindowHide (&c->title);
         }
         else
         {
