Skip to content

Commit

Permalink
Merge pull request #634 from Taylor-Finch/master
Browse files Browse the repository at this point in the history
Make custom title bar icons fill Button
  • Loading branch information
joewing authored Aug 4, 2024
2 parents 63b2ff5 + b48fb5d commit b79b8c5
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/border.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ XPoint DrawBorderButtons(const ClientNode *np, Pixmap canvas, GC gc)
/* Draw buttons to the right of the title. */
rightOffset = np->width + west;
while(index > titleIndex) {
const int nextOffset = rightOffset - titleHeight - 1;
const int nextOffset = rightOffset - titleHeight;
const MouseContextType context = settings.titleBarLayout[index];
if(context == MC_MOVE) {
/* Hit the title bar from the right. */
Expand All @@ -924,7 +924,7 @@ XPoint DrawBorderButtons(const ClientNode *np, Pixmap canvas, GC gc)

if(IsContextEnabled(context, np)) {
rightOffset = nextOffset;
DrawLeftButton(np, context, rightOffset, yoffset, canvas, gc, fg);
DrawLeftButton(np, context, rightOffset - 1, yoffset, canvas, gc, fg);
}

index -= 1;
Expand All @@ -948,7 +948,7 @@ char DrawBorderIcon(BorderIconType t,
#ifdef USE_ICONS
const unsigned titleHeight = GetTitleHeight();
PutIcon(buttonIcons[t], canvas, fg, xoffset + 2, yoffset + 2,
titleHeight - 4, titleHeight - 4);
titleHeight - 2, titleHeight - 2);
#endif
return 1;
} else {
Expand Down Expand Up @@ -1151,12 +1151,15 @@ void DrawIconButton(const ClientNode *np, int x, int y,
Pixmap canvas, GC gc, long fg)
{
#ifdef USE_ICONS
const int iconSize = GetBorderIconSize();
const char hasIcon = np->icon ? 1 : 0;
const int titleHeight = GetTitleHeight();
IconNode *icon = np->icon ? np->icon : buttonIcons[BI_MENU];
const int iconSize = hasIcon ? GetBorderIconSize() : Max((int)titleHeight - 2, 0);
const int iconXOffset = (titleHeight - iconSize) / 2;
const int iconYOffset = hasIcon ? iconXOffset : iconXOffset + 1;
IconNode *icon = hasIcon ? np->icon : buttonIcons[BI_MENU];
PutIcon(icon, canvas, fg,
x + (titleHeight - iconSize) / 2,
y + (titleHeight - iconSize) / 2,
x + iconXOffset,
y + iconYOffset,
iconSize, iconSize);
#endif
}
Expand Down

0 comments on commit b79b8c5

Please sign in to comment.