Base rc.title_height on font vertical extents

This commit is contained in:
Johan Malm 2020-08-05 20:14:17 +01:00
parent 4d1363dcae
commit 2297e43cc0
11 changed files with 123 additions and 26 deletions

View file

@ -6,18 +6,18 @@
#include "labwc.h"
#include "theme/theme.h"
#include "config/rcxml.h"
/* Based on expected font height of Sans 8 */
#define TITLE_HEIGHT (14)
#define BORDER_WIDTH (1)
struct wlr_box deco_max_extents(struct view *view)
{
struct wlr_box box = {
.x = view->x - BORDER_WIDTH,
.y = view->y - TITLE_HEIGHT - BORDER_WIDTH,
.y = view->y - rc.title_height - BORDER_WIDTH,
.width = view->surface->current.width + 2 * BORDER_WIDTH,
.height = view->surface->current.height + TITLE_HEIGHT +
.height = view->surface->current.height + rc.title_height +
2 * BORDER_WIDTH,
};
return box;
@ -33,44 +33,44 @@ struct wlr_box deco_box(struct view *view, enum deco_part deco_part)
switch (deco_part) {
case LAB_DECO_BUTTON_CLOSE:
wlr_texture_get_size(theme.xbm_close, &box.width, &box.height);
margin = (TITLE_HEIGHT - box.height) / 2;
margin = (rc.title_height - box.height) / 2;
box.x = view->x + view->surface->current.width + margin -
TITLE_HEIGHT;
box.y = view->y - TITLE_HEIGHT + margin;
rc.title_height;
box.y = view->y - rc.title_height + margin;
break;
case LAB_DECO_BUTTON_MAXIMIZE:
wlr_texture_get_size(theme.xbm_maximize, &box.width,
&box.height);
margin = (TITLE_HEIGHT - box.height) / 2;
margin = (rc.title_height - box.height) / 2;
box.x = view->x + view->surface->current.width + margin -
TITLE_HEIGHT * 2;
box.y = view->y - TITLE_HEIGHT + margin;
rc.title_height * 2;
box.y = view->y - rc.title_height + margin;
break;
case LAB_DECO_BUTTON_ICONIFY:
wlr_texture_get_size(theme.xbm_iconify, &box.width,
&box.height);
margin = (TITLE_HEIGHT - box.height) / 2;
margin = (rc.title_height - box.height) / 2;
box.x = view->x + view->surface->current.width + margin -
TITLE_HEIGHT * 3;
box.y = view->y - TITLE_HEIGHT + margin;
rc.title_height * 3;
box.y = view->y - rc.title_height + margin;
break;
case LAB_DECO_PART_TITLE:
box.x = view->x;
box.y = view->y - TITLE_HEIGHT;
box.y = view->y - rc.title_height;
box.width = view->surface->current.width;
box.height = TITLE_HEIGHT;
box.height = rc.title_height;
break;
case LAB_DECO_PART_TOP:
box.x = view->x - BORDER_WIDTH;
box.y = view->y - TITLE_HEIGHT - BORDER_WIDTH;
box.y = view->y - rc.title_height - BORDER_WIDTH;
box.width = view->surface->current.width + 2 * BORDER_WIDTH;
box.height = BORDER_WIDTH;
break;
case LAB_DECO_PART_RIGHT:
box.x = view->x + view->surface->current.width;
box.y = view->y - TITLE_HEIGHT;
box.y = view->y - rc.title_height;
box.width = BORDER_WIDTH;
box.height = view->surface->current.height + TITLE_HEIGHT;
box.height = view->surface->current.height + rc.title_height;
break;
case LAB_DECO_PART_BOTTOM:
box.x = view->x - BORDER_WIDTH;
@ -80,9 +80,9 @@ struct wlr_box deco_box(struct view *view, enum deco_part deco_part)
break;
case LAB_DECO_PART_LEFT:
box.x = view->x - BORDER_WIDTH;
box.y = view->y - TITLE_HEIGHT;
box.y = view->y - rc.title_height;
box.width = BORDER_WIDTH;
box.height = view->surface->current.height + TITLE_HEIGHT;
box.height = view->surface->current.height + rc.title_height;
break;
default:
break;