From a72b44080839b2c3428f51ea8b557da972b74402 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Mon, 30 Apr 2012 10:43:49 +0200 Subject: [PATCH] Added top_border_size property in themerc file. If this property is specified to N, the top N pixels of the top border will be hidden when the window is maximized and borderless maximize is enabled. --- src/frame.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++---------- src/settings.c | 4 ++++ src/settings.h | 1 + 3 files changed, 58 insertions(+), 11 deletions(-) diff --git a/src/frame.c b/src/frame.c index 7f4cbd3..6ef2d15 100644 --- a/src/frame.c +++ b/src/frame.c @@ -115,15 +115,57 @@ frameRight (Client * c) } int +frameTopHidden (Client *c) +{ + TRACE ("entering frameTopHidden"); + + 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_ALL (c->flags, CLIENT_FLAG_MAXIMIZED) + && (c->screen_info->params->borderless_maximize)) + { + return c->screen_info->params->top_border_size; + } + return 0; + +} + +int +frameTopTotal (Client * c) +{ + TRACE ("entering frameTopTotal"); + + 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)) + { + return c->screen_info->title[TITLE_3][ACTIVE].height; + } + return 0; +} + +int frameTop (Client * c) { TRACE ("entering frameTop"); + // this would be the same as doing a + // return frameTopTotal (c) - frameTopHidden (c); + 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)) { - return c->screen_info->title[TITLE_3][ACTIVE].height; + if (FLAG_TEST_ALL (c->flags, CLIENT_FLAG_MAXIMIZED) + && (c->screen_info->params->borderless_maximize)) + { + return c->screen_info->title[TITLE_3][ACTIVE].height - c->screen_info->params->top_border_size; + } + else + { + return c->screen_info->title[TITLE_3][ACTIVE].height; + } } return 0; } @@ -274,7 +316,7 @@ frameFillTitlePixmap (Client * c, int state, int part, int x, int w, int h, xfwm { xfwmPixmapFill (&screen_info->title[part][state], top_pm, x, 0, w, h); } - xfwmPixmapFill (&screen_info->title[part][state], title_pm, x, 0, w, frameTop (c)); + xfwmPixmapFill (&screen_info->title[part][state], title_pm, x, 0, w, frameTopTotal (c)); } static void @@ -351,10 +393,10 @@ frameCreateTitlePixmap (Client * c, int state, int left, int right, xfwmPixmap * */ title_height = logical_rect.height; } - title_y = voffset + (frameTop (c) - title_height) / 2; - if (title_y + title_height > frameTop (c)) + title_y = voffset + (frameTopTotal (c) - title_height) / 2; + if (title_y + title_height > frameTopTotal (c)) { - title_y = MAX (0, frameTop (c) - title_height); + title_y = MAX (0, frameTopTotal (c) - title_height); } if (!xfwmPixmapNone(&screen_info->top[3][ACTIVE])) @@ -363,7 +405,7 @@ frameCreateTitlePixmap (Client * c, int state, int left, int right, xfwmPixmap * } else { - top_height = frameTop (c) / 10 + 1; + top_height = frameTopTotal (c) / 10 + 1; if (top_height > title_y - 1) { top_height = MAX (title_y - 1, 0); @@ -431,7 +473,7 @@ frameCreateTitlePixmap (Client * c, int state, int left, int right, xfwmPixmap * } xfwmPixmapCreate (screen_info, top_pm, width, top_height); - xfwmPixmapCreate (screen_info, title_pm, width, frameTop (c)); + xfwmPixmapCreate (screen_info, title_pm, width, frameTopTotal (c)); gpixmap = gdk_pixmap_foreign_new (title_pm->pixmap); gdk_drawable_set_colormap (gpixmap, gdk_screen_get_rgb_colormap (screen_info->gscr)); gc = gdk_gc_new (gpixmap); @@ -991,7 +1033,7 @@ frameDrawWin (Client * c) xfwmWindowSetBG (&c->buttons[button], my_pixmap); } xfwmWindowShow (&c->buttons[button], x, - (frameTop (c) - screen_info->buttons[button][state].height + 1) / 2, + (frameTopTotal (c) - screen_info->buttons[button][state].height + 1) / 2 - frameTopHidden (c), screen_info->buttons[button][state].width, screen_info->buttons[button][state].height, TRUE); button_x[button] = x; @@ -1028,7 +1070,7 @@ frameDrawWin (Client * c) 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, + (frameTopTotal (c) - screen_info->buttons[button][state].height + 1) / 2 - frameTopHidden (c), screen_info->buttons[button][state].width, screen_info->buttons[button][state].height, TRUE); button_x[button] = x; @@ -1061,8 +1103,8 @@ frameDrawWin (Client * c) 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)); + frameTopLeftWidth (c, state), 0 - frameTopHidden (c), top_width, + frameTopTotal (c), (requires_clearing | width_changed)); /* Corners are never resized, we need to update them separately */ if (requires_clearing) diff --git a/src/settings.c b/src/settings.c index 607bb7b..6e96bc9 100644 --- a/src/settings.c +++ b/src/settings.c @@ -558,6 +558,9 @@ loadTheme (ScreenInfo *screen_info, Settings *rc) screen_info->params->title_horizontal_offset = getIntValue ("title_horizontal_offset", rc); + screen_info->params->top_border_size = + getIntValue ("top_border_size", rc); + g_free (theme); } @@ -729,6 +732,7 @@ loadSettings (ScreenInfo *screen_info) {"title_shadow_inactive", NULL, G_TYPE_STRING, TRUE}, {"title_vertical_offset_active", NULL, G_TYPE_INT, TRUE}, {"title_vertical_offset_inactive", NULL, G_TYPE_INT, TRUE}, + {"top_border_size", NULL, G_TYPE_INT, FALSE}, {"toggle_workspaces", NULL, G_TYPE_BOOLEAN, TRUE}, {"unredirect_overlays", NULL, G_TYPE_BOOLEAN, TRUE}, {"urgent_blink", NULL, G_TYPE_BOOLEAN, TRUE}, diff --git a/src/settings.h b/src/settings.h index be01b6b..8eeb4ba 100644 --- a/src/settings.h +++ b/src/settings.h @@ -195,6 +195,7 @@ struct _XfwmParams int title_alignment; int title_horizontal_offset; int title_shadow[2]; + int top_border_size; int wrap_resistance; gboolean borderless_maximize; gboolean box_move; -- 1.7.10