Double-clicking title bar now maximizes/restores window.

This commit is contained in:
Scott Duensing 2026-03-18 22:22:22 -05:00
parent fa8ab9da27
commit f599ea8c0d
2 changed files with 24 additions and 1 deletions

View file

@ -1593,6 +1593,8 @@ int32_t dvxInit(AppContextT *ctx, int32_t requestedW, int32_t requestedH, int32_
ctx->lastIconClickTime = 0;
ctx->lastCloseClickId = -1;
ctx->lastCloseClickTime = 0;
ctx->lastTitleClickId = -1;
ctx->lastTitleClickTime = 0;
// Pre-compute fixed-point 16.16 reciprocal of character height so
// popup menu item index calculation can use multiply+shift instead
@ -2273,7 +2275,26 @@ static void handleMouseButton(AppContextT *ctx, int32_t mx, int32_t my, int32_t
break;
case HIT_TITLE:
{
clock_t now = clock();
if (win->resizable &&
ctx->lastTitleClickId == win->id &&
(now - ctx->lastTitleClickTime) < DBLCLICK_THRESHOLD) {
// Double-click: toggle maximize/restore
ctx->lastTitleClickId = -1;
if (win->maximized) {
wmRestore(&ctx->stack, &ctx->dirty, &ctx->display, win);
} else {
wmMaximize(&ctx->stack, &ctx->dirty, &ctx->display, win);
}
} else {
ctx->lastTitleClickTime = now;
ctx->lastTitleClickId = win->id;
wmDragBegin(&ctx->stack, hitIdx, mx, my);
}
}
break;
case HIT_CLOSE:

View file

@ -65,6 +65,8 @@ typedef struct AppContextT {
int32_t lastIconClickId; // window ID of last-clicked minimized icon (-1 = none)
clock_t lastCloseClickTime;
int32_t lastCloseClickId; // window ID of last-clicked close gadget (-1 = none)
clock_t lastTitleClickTime;
int32_t lastTitleClickId; // window ID of last-clicked title bar (-1 = none)
// Minimized icon thumbnails are refreshed one per frame (round-robin)
// rather than all at once, to amortize the cost of scaling the content
// buffer down to icon size.