diff options
-rw-r--r-- | src/border.c | 68 | ||||
-rw-r--r-- | src/border.h | 3 | ||||
-rw-r--r-- | src/event.c | 19 |
3 files changed, 58 insertions, 32 deletions
diff --git a/src/border.c b/src/border.c index cfe6b93..135392c 100644 --- a/src/border.c +++ b/src/border.c @@ -58,7 +58,7 @@ static GC borderGC; static void DrawBorderHelper(const ClientNode *np, unsigned int width, unsigned int height, int drawIcon); static void DrawButtonBorder(const ClientNode *np, int offset, - Pixmap canvas, GC gc); + Pixmap canvas, GC gc, BorderActionType button); static int DrawBorderButtons(const ClientNode *np, Pixmap canvas, GC gc); /**************************************************************************** @@ -66,6 +66,7 @@ static int DrawBorderButtons(const ClientNode *np, Pixmap canvas, GC gc); void InitializeBorders() { + PressedBorderButton = BA_NONE; } /**************************************************************************** @@ -394,27 +395,6 @@ DrawBorderHelper(const ClientNode *np, JXSetForeground(display, gc, borderPixel); JXFillRectangle(display, canvas, gc, 0, 0, width + 1, height + 1); - buttonCount = DrawBorderButtons(np, canvas, gc); - titleWidth = width - (titleHeight + 2) * buttonCount - bsize - - (titleHeight + bsize + 4) - 2; - - if(np->state.border & BORDER_TITLE) { - - if(np->icon && np->width >= titleHeight && drawIcon) { - PutIcon(np->icon, canvas, bsize + 2, - bsize + titleHeight / 2 - iconSize / 2, - iconSize, iconSize); - } - - if(np->name && np->name[0] && titleWidth > 0) { - RenderString(canvas, FONT_BORDER, borderTextColor, - titleHeight + bsize + 4, bsize + titleHeight / 2 - - GetStringHeight(FONT_BORDER) / 2, - titleWidth, borderRegion, np->name); - } - - } - if(np->state.border & BORDER_OUTLINE) { /* Draw title outline */ @@ -529,13 +509,34 @@ DrawBorderHelper(const ClientNode *np, } + buttonCount = DrawBorderButtons(np, canvas, gc); + titleWidth = width - (titleHeight + 2) * buttonCount - bsize + - (titleHeight + bsize + 4) - 2; + + if(np->state.border & BORDER_TITLE) { + + if(np->icon && np->width >= titleHeight && drawIcon) { + PutIcon(np->icon, canvas, bsize + 2, + bsize + titleHeight / 2 - iconSize / 2, + iconSize, iconSize); + } + + if(np->name && np->name[0] && titleWidth > 0) { + RenderString(canvas, FONT_BORDER, borderTextColor, + titleHeight + bsize + 4, bsize + titleHeight / 2 + - GetStringHeight(FONT_BORDER) / 2, + titleWidth, borderRegion, np->name); + } + + } + } /**************************************************************************** ****************************************************************************/ void DrawButtonBorder(const ClientNode *np, int offset, - Pixmap canvas, GC gc) + Pixmap canvas, GC gc, BorderActionType button) { long up, down; @@ -559,12 +560,21 @@ DrawButtonBorder(const ClientNode *np, int offset, JXSetForeground(display, gc, up); JXDrawLine(display, canvas, gc, offset, bsize + 1, - offset, titleHeight + bsize - 2); + offset, titleHeight + bsize - 2); JXSetForeground(display, gc, down); JXDrawLine(display, canvas, gc, offset - 1, bsize + 1, offset - 1, titleHeight + bsize - 2); + if (PressedBorderButton == button) { + JXSetForeground(display, gc, down); + JXDrawLine(display, canvas, gc, offset, bsize + 1, + offset, titleHeight + bsize - 2); + JXSetForeground(display, gc, down); + JXDrawLine(display, canvas, gc, offset - 1, bsize, + offset + titleHeight - 1, bsize); + } + } /**************************************************************************** @@ -597,8 +607,6 @@ DrawBorderButtons(const ClientNode *np, Pixmap canvas, GC gc) if(np->state.border & BORDER_CLOSE) { - DrawButtonBorder(np, offset, canvas, gc); - if(np->state.status & STAT_ACTIVE) { pixmap = pixmaps[BP_ACTIVE_CLOSE]; } else { @@ -608,6 +616,8 @@ DrawBorderButtons(const ClientNode *np, Pixmap canvas, GC gc) JXCopyArea(display, pixmap, canvas, gc, 0, 0, 16, 16, offset + titleHeight / 2 - 8, bsize + titleHeight / 2 - 8); + DrawButtonBorder(np, offset, canvas, gc, BA_CLOSE); + offset -= titleHeight; ++count; @@ -635,7 +645,7 @@ DrawBorderButtons(const ClientNode *np, Pixmap canvas, GC gc) JXCopyArea(display, pixmap, canvas, gc, 0, 0, 16, 16, offset + titleHeight / 2 - 8, bsize + titleHeight / 2 - 8); - DrawButtonBorder(np, offset, canvas, gc); + DrawButtonBorder(np, offset, canvas, gc, BA_MAXIMIZE); offset -= titleHeight; ++count; @@ -648,8 +658,6 @@ DrawBorderButtons(const ClientNode *np, Pixmap canvas, GC gc) if(np->state.border & BORDER_MIN) { - DrawButtonBorder(np, offset, canvas, gc); - if(np->state.status & STAT_ACTIVE) { pixmap = pixmaps[BP_ACTIVE_MINIMIZE]; } else { @@ -659,6 +667,8 @@ DrawBorderButtons(const ClientNode *np, Pixmap canvas, GC gc) JXCopyArea(display, pixmap, canvas, gc, 0, 0, 16, 16, offset + titleHeight / 2 - 8, bsize + titleHeight / 2 - 8); + DrawButtonBorder(np, offset, canvas, gc, BA_MINIMIZE); + ++count; } diff --git a/src/border.h b/src/border.h index 55458db..052492d 100644 --- a/src/border.h +++ b/src/border.h @@ -27,6 +27,9 @@ typedef enum { BA_RESIZE_W = 0x80 /**< Resize west. */ } BorderActionType; +/** Currently pressed border button. */ +BorderActionType PressedBorderButton; + /*@{*/ void InitializeBorders(); void StartupBorders(); diff --git a/src/event.c b/src/event.c index b508a1e..e1529ab 100644 --- a/src/event.c +++ b/src/event.c @@ -306,6 +306,10 @@ HandleButtonEvent(const XButtonEvent *event) default: break; } + if(event->type == ButtonRelease) { + PressedBorderButton = BA_NONE; + DrawBorder(np, NULL); + } } else if(event->window == rootWindow && event->type == ButtonPress) { if(!ShowRootMenu(event->button, event->x, event->y)) { if(event->button == 4) { @@ -1214,17 +1218,26 @@ DispatchBorderButtonEvent(const XButtonEvent *event, ClientNode *np) } break; case BA_CLOSE: - if(event->type == ButtonRelease) { + if(event->type == ButtonPress) { + PressedBorderButton = BA_CLOSE; + DrawBorder(np, NULL); + } else { DeleteClient(np); } break; case BA_MAXIMIZE: - if(event->type == ButtonRelease) { + if(event->type == ButtonPress) { + PressedBorderButton = BA_MAXIMIZE; + DrawBorder(np, NULL); + } else { MaximizeClient(np); } break; case BA_MINIMIZE: - if(event->type == ButtonRelease) { + if(event->type == ButtonPress) { + PressedBorderButton = BA_MINIMIZE; + DrawBorder(np, NULL); + } else { MinimizeClient(np); } break; |