diff --git a/dvx/dvxApp.c b/dvx/dvxApp.c index 0bc1fb2..c286687 100644 --- a/dvx/dvxApp.c +++ b/dvx/dvxApp.c @@ -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: - wmDragBegin(&ctx->stack, hitIdx, mx, my); + { + 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: diff --git a/dvx/dvxApp.h b/dvx/dvxApp.h index cc0c1eb..61bb186 100644 --- a/dvx/dvxApp.h +++ b/dvx/dvxApp.h @@ -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.