From 862590c40a7eb0895f59d4485e8c42174d908924 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Wed, 18 Mar 2026 01:50:51 -0500 Subject: [PATCH] More magic numbers replaced with named defines. --- apps/clock/clock.c | 2 +- apps/dvxdemo/dvxdemo.c | 2 +- apps/notepad/notepad.c | 2 +- apps/progman/progman.c | 2 +- dvx/dvxApp.c | 56 +++++++++++++++++++-------------------- dvx/dvxTypes.h | 35 +++++++++++++++++++----- dvx/dvxWm.c | 36 ++++++++++++------------- dvx/dvxWm.h | 4 +-- dvx/widgets/widgetEvent.c | 32 +++++++++++----------- dvxshell/shellApp.h | 6 ++++- 10 files changed, 102 insertions(+), 75 deletions(-) diff --git a/apps/clock/clock.c b/apps/clock/clock.c index 88d9a64..c634cdc 100644 --- a/apps/clock/clock.c +++ b/apps/clock/clock.c @@ -67,7 +67,7 @@ AppDescriptorT appDescriptor = { .name = "Clock", .hasMainLoop = true, .multiInstance = true, - .stackSize = 0, + .stackSize = SHELL_STACK_DEFAULT, .priority = TS_PRIORITY_LOW }; diff --git a/apps/dvxdemo/dvxdemo.c b/apps/dvxdemo/dvxdemo.c index 6d2e687..4841f4b 100644 --- a/apps/dvxdemo/dvxdemo.c +++ b/apps/dvxdemo/dvxdemo.c @@ -96,7 +96,7 @@ static DxeAppContextT *sDxeCtx = NULL; AppDescriptorT appDescriptor = { .name = "DVX Demo", .hasMainLoop = false, - .stackSize = 0, + .stackSize = SHELL_STACK_DEFAULT, .priority = TS_PRIORITY_NORMAL }; diff --git a/apps/notepad/notepad.c b/apps/notepad/notepad.c index 30b0533..b068535 100644 --- a/apps/notepad/notepad.c +++ b/apps/notepad/notepad.c @@ -77,7 +77,7 @@ static void onMenu(WindowT *win, int32_t menuId); AppDescriptorT appDescriptor = { .name = "Notepad", .hasMainLoop = false, - .stackSize = 0, + .stackSize = SHELL_STACK_DEFAULT, .priority = TS_PRIORITY_NORMAL }; diff --git a/apps/progman/progman.c b/apps/progman/progman.c index 1d0d612..2de5067 100644 --- a/apps/progman/progman.c +++ b/apps/progman/progman.c @@ -113,7 +113,7 @@ static void refreshTaskList(void); AppDescriptorT appDescriptor = { .name = "Program Manager", .hasMainLoop = false, - .stackSize = 0, + .stackSize = SHELL_STACK_DEFAULT, .priority = TS_PRIORITY_NORMAL }; diff --git a/dvx/dvxApp.c b/dvx/dvxApp.c index 3ec18e9..eeee3b4 100644 --- a/dvx/dvxApp.c +++ b/dvx/dvxApp.c @@ -783,7 +783,7 @@ static void dispatchEvents(AppContextT *ctx) { // Handle active drag if (ctx->stack.dragWindow >= 0) { - if (buttons & 1) { + if (buttons & MOUSE_LEFT) { wmDragMove(&ctx->stack, &ctx->dirty, mx, my, ctx->display.width, ctx->display.height); } else { wmDragEnd(&ctx->stack); @@ -793,7 +793,7 @@ static void dispatchEvents(AppContextT *ctx) { // Handle active resize if (ctx->stack.resizeWindow >= 0) { - if (buttons & 1) { + if (buttons & MOUSE_LEFT) { wmResizeMove(&ctx->stack, &ctx->dirty, &ctx->display, mx, my); } else { wmResizeEnd(&ctx->stack); @@ -803,7 +803,7 @@ static void dispatchEvents(AppContextT *ctx) { // Handle active scrollbar thumb drag if (ctx->stack.scrollWindow >= 0) { - if (buttons & 1) { + if (buttons & MOUSE_LEFT) { wmScrollbarDrag(&ctx->stack, &ctx->dirty, mx, my); } else { wmScrollbarEnd(&ctx->stack); @@ -830,7 +830,7 @@ static void dispatchEvents(AppContextT *ctx) { } // Click on item - if ((buttons & 1) && !(prevBtn & 1)) { + if ((buttons & MOUSE_LEFT) && !(prevBtn & MOUSE_LEFT)) { if (itemIdx >= 0 && itemIdx < ctx->sysMenu.itemCount) { SysMenuItemT *item = &ctx->sysMenu.items[itemIdx]; @@ -844,7 +844,7 @@ static void dispatchEvents(AppContextT *ctx) { } // Click outside system menu — close it, let event fall through - if ((buttons & 1) && !(prevBtn & 1)) { + if ((buttons & MOUSE_LEFT) && !(prevBtn & MOUSE_LEFT)) { closeSysMenu(ctx); } } @@ -900,7 +900,7 @@ static void dispatchEvents(AppContextT *ctx) { } // Click on item in current level - if ((buttons & 1) && !(prevBtn & 1)) { + if ((buttons & MOUSE_LEFT) && !(prevBtn & MOUSE_LEFT)) { if (ctx->popup.menu && itemIdx >= 0 && itemIdx < ctx->popup.menu->itemCount) { MenuItemT *item = &ctx->popup.menu->items[itemIdx]; @@ -978,7 +978,7 @@ static void dispatchEvents(AppContextT *ctx) { if (!inParent) { if (ctx->popup.isContextMenu) { // Context menu: any click outside closes it - if ((buttons & 1) && !(prevBtn & 1)) { + if ((buttons & MOUSE_LEFT) && !(prevBtn & MOUSE_LEFT)) { closeAllPopups(ctx); } } else { @@ -998,7 +998,7 @@ static void dispatchEvents(AppContextT *ctx) { MenuT *menu = &win->menuBar->menus[i]; if (relX >= menu->barX && relX < menu->barX + menu->barW) { - if ((buttons & 1) && !(prevBtn & 1) && i == ctx->popup.menuIdx && ctx->popup.depth == 0) { + if ((buttons & MOUSE_LEFT) && !(prevBtn & MOUSE_LEFT) && i == ctx->popup.menuIdx && ctx->popup.depth == 0) { // Clicking the same menu bar entry closes the menu closeAllPopups(ctx); } else if (i != ctx->popup.menuIdx || ctx->popup.depth > 0) { @@ -1008,10 +1008,10 @@ static void dispatchEvents(AppContextT *ctx) { break; } } - } else if ((buttons & 1) && !(prevBtn & 1)) { + } else if ((buttons & MOUSE_LEFT) && !(prevBtn & MOUSE_LEFT)) { closeAllPopups(ctx); } - } else if ((buttons & 1) && !(prevBtn & 1)) { + } else if ((buttons & MOUSE_LEFT) && !(prevBtn & MOUSE_LEFT)) { closeAllPopups(ctx); } } @@ -1022,7 +1022,7 @@ static void dispatchEvents(AppContextT *ctx) { } // Handle left button press - if ((buttons & 1) && !(prevBtn & 1)) { + if ((buttons & MOUSE_LEFT) && !(prevBtn & MOUSE_LEFT)) { handleMouseButton(ctx, mx, my, buttons); } @@ -1032,11 +1032,11 @@ static void dispatchEvents(AppContextT *ctx) { // to the window-level context menu. This lets containers provide menus // that apply to all their children without requiring each child to have // its own menu, while still allowing per-widget overrides. - if ((buttons & 2) && !(prevBtn & 2)) { + if ((buttons & MOUSE_RIGHT) && !(prevBtn & MOUSE_RIGHT)) { int32_t hitPart; int32_t hitIdx = wmHitTest(&ctx->stack, mx, my, &hitPart); - if (hitIdx >= 0 && hitPart == 0) { + if (hitIdx >= 0 && hitPart == HIT_CONTENT) { WindowT *win = ctx->stack.windows[hitIdx]; if (hitIdx != ctx->stack.focusedIdx) { @@ -1073,7 +1073,7 @@ static void dispatchEvents(AppContextT *ctx) { } // Handle button release on content — send to focused window - if (!(buttons & 1) && (prevBtn & 1)) { + if (!(buttons & MOUSE_LEFT) && (prevBtn & MOUSE_LEFT)) { if (ctx->stack.focusedIdx >= 0) { WindowT *win = ctx->stack.windows[ctx->stack.focusedIdx]; @@ -1087,7 +1087,7 @@ static void dispatchEvents(AppContextT *ctx) { // Mouse movement in content area — send to focused window if ((mx != ctx->prevMouseX || my != ctx->prevMouseY) && - ctx->stack.focusedIdx >= 0 && (buttons & 1)) { + ctx->stack.focusedIdx >= 0 && (buttons & MOUSE_LEFT)) { WindowT *win = ctx->stack.windows[ctx->stack.focusedIdx]; if (win->onMouse) { @@ -2230,7 +2230,7 @@ static void handleMouseButton(AppContextT *ctx, int32_t mx, int32_t my, int32_t } switch (hitPart) { - case 0: // content + case HIT_CONTENT: if (win->onMouse) { int32_t relX = mx - win->x - win->contentX; int32_t relY = my - win->y - win->contentY; @@ -2238,11 +2238,11 @@ static void handleMouseButton(AppContextT *ctx, int32_t mx, int32_t my, int32_t } break; - case 1: // title bar — start drag + case HIT_TITLE: wmDragBegin(&ctx->stack, hitIdx, mx, my); break; - case 2: // close button (double-click to close, single-click opens system menu) + case HIT_CLOSE: { clock_t now = clock(); @@ -2264,14 +2264,14 @@ static void handleMouseButton(AppContextT *ctx, int32_t mx, int32_t my, int32_t } break; - case 3: // resize edge + case HIT_RESIZE: { int32_t edge = wmResizeEdgeHit(win, mx, my); wmResizeBegin(&ctx->stack, hitIdx, edge, mx, my); } break; - case 4: // menu bar + case HIT_MENU: { if (!win->menuBar) { break; @@ -2290,15 +2290,15 @@ static void handleMouseButton(AppContextT *ctx, int32_t mx, int32_t my, int32_t } break; - case 5: // vertical scrollbar - wmScrollbarClick(&ctx->stack, &ctx->dirty, hitIdx, 0, mx, my); + case HIT_VSCROLL: + wmScrollbarClick(&ctx->stack, &ctx->dirty, hitIdx, SCROLL_VERTICAL, mx, my); break; - case 6: // horizontal scrollbar - wmScrollbarClick(&ctx->stack, &ctx->dirty, hitIdx, 1, mx, my); + case HIT_HSCROLL: + wmScrollbarClick(&ctx->stack, &ctx->dirty, hitIdx, SCROLL_HORIZONTAL, mx, my); break; - case 7: // minimize (not allowed for modal windows) + case HIT_MINIMIZE: if (ctx->modalWindow != win) { wmMinimize(&ctx->stack, &ctx->dirty, win); // Dirty the icon strip area so the new icon gets drawn @@ -2308,7 +2308,7 @@ static void handleMouseButton(AppContextT *ctx, int32_t mx, int32_t my, int32_t } break; - case 8: // maximize / restore + case HIT_MAXIMIZE: if (win->maximized) { wmRestore(&ctx->stack, &ctx->dirty, &ctx->display, win); } else { @@ -3513,7 +3513,7 @@ static void updateCursorShape(AppContextT *ctx) { int32_t hitPart; int32_t hitIdx = wmHitTest(&ctx->stack, mx, my, &hitPart); - if (hitIdx >= 0 && hitPart == 3) { + if (hitIdx >= 0 && hitPart == HIT_RESIZE) { // Hovering over a resize edge WindowT *win = ctx->stack.windows[hitIdx]; int32_t edge = wmResizeEdgeHit(win, mx, my); @@ -3532,7 +3532,7 @@ static void updateCursorShape(AppContextT *ctx) { } else if (vert) { newCursor = CURSOR_RESIZE_V; } - } else if (hitIdx >= 0 && hitPart == 0) { + } else if (hitIdx >= 0 && hitPart == HIT_CONTENT) { // Hovering over content area — check for ListView column border WindowT *win = ctx->stack.windows[hitIdx]; diff --git a/dvx/dvxTypes.h b/dvx/dvxTypes.h index 3503447..fffbd16 100644 --- a/dvx/dvxTypes.h +++ b/dvx/dvxTypes.h @@ -420,8 +420,26 @@ typedef struct { #define RESIZE_TOP 4 #define RESIZE_BOTTOM 8 -#define MIN_WINDOW_W 80 -#define MIN_WINDOW_H 60 +// Window size limits +#define MIN_WINDOW_W 80 +#define MIN_WINDOW_H 60 +#define WM_MAX_FROM_SCREEN (-1) // use screen dimension as max (for maxW/maxH) + +// Hit test region identifiers (returned via hitPart from wmHitTest) +#define HIT_CONTENT 0 +#define HIT_TITLE 1 +#define HIT_CLOSE 2 +#define HIT_RESIZE 3 +#define HIT_MENU 4 +#define HIT_VSCROLL 5 +#define HIT_HSCROLL 6 +#define HIT_MINIMIZE 7 +#define HIT_MAXIMIZE 8 +#define HIT_NONE (-1) + +// Scroll drag orientation +#define SCROLL_VERTICAL 0 +#define SCROLL_HORIZONTAL 1 // Minimized windows display as icons at the bottom of the screen, // similar to DESQview/X's original icon bar behavior. @@ -449,8 +467,8 @@ typedef struct WindowT { bool resizable; bool modal; bool contentDirty; // true when contentBuf has changed since last icon refresh - int32_t maxW; // maximum width (-1 = screen width) - int32_t maxH; // maximum height (-1 = screen height) + int32_t maxW; // maximum width (WM_MAX_FROM_SCREEN = use screen width) + int32_t maxH; // maximum height (WM_MAX_FROM_SCREEN = use screen height) // Pre-maximize geometry is saved so wmRestore() can put the window // back exactly where it was. This matches Windows 3.x behavior. int32_t preMaxX; // saved position before maximize @@ -525,11 +543,16 @@ typedef struct { int32_t dragOffY; int32_t resizeWindow; int32_t resizeEdge; - int32_t scrollWindow; // window being scroll-dragged (-1 = none) - int32_t scrollOrient; // 0 = vertical, 1 = horizontal + int32_t scrollWindow; // window being scroll-dragged (HIT_NONE = none) + int32_t scrollOrient; // SCROLL_VERTICAL or SCROLL_HORIZONTAL int32_t scrollDragOff; // mouse offset from thumb start } WindowStackT; +// Mouse button bitmask flags (used in onMouse callbacks, dvxUpdate, etc.) +#define MOUSE_LEFT 1 +#define MOUSE_RIGHT 2 +#define MOUSE_MIDDLE 4 + // ============================================================ // Mouse cursor // ============================================================ diff --git a/dvx/dvxWm.c b/dvx/dvxWm.c index 107d1e5..3972fc6 100644 --- a/dvx/dvxWm.c +++ b/dvx/dvxWm.c @@ -1065,8 +1065,8 @@ WindowT *wmCreateWindow(WindowStackT *stack, DisplayT *d, const char *title, int win->minimized = false; win->maximized = false; win->resizable = resizable; - win->maxW = -1; - win->maxH = -1; + win->maxW = WM_MAX_FROM_SCREEN; + win->maxH = WM_MAX_FROM_SCREEN; strncpy(win->title, title, MAX_TITLE_LEN - 1); win->title[MAX_TITLE_LEN - 1] = '\0'; @@ -1493,7 +1493,7 @@ int32_t wmHitTest(const WindowStackT *stack, int32_t mx, int32_t my, int32_t *hi // Close gadget (top-left) if (mx >= g.closeX && mx < g.closeX + g.gadgetS && my >= g.gadgetY && my < g.gadgetY + g.gadgetS) { - *hitPart = 2; + *hitPart = HIT_CLOSE; return i; } @@ -1501,7 +1501,7 @@ int32_t wmHitTest(const WindowStackT *stack, int32_t mx, int32_t my, int32_t *hi if (g.maxX >= 0 && mx >= g.maxX && mx < g.maxX + g.gadgetS && my >= g.gadgetY && my < g.gadgetY + g.gadgetS) { - *hitPart = 8; + *hitPart = HIT_MAXIMIZE; return i; } @@ -1509,14 +1509,14 @@ int32_t wmHitTest(const WindowStackT *stack, int32_t mx, int32_t my, int32_t *hi if (g.minX >= 0 && mx >= g.minX && mx < g.minX + g.gadgetS && my >= g.gadgetY && my < g.gadgetY + g.gadgetS) { - *hitPart = 7; + *hitPart = HIT_MINIMIZE; return i; } // Title bar (drag area — between gadgets) if (my >= g.titleY && my < g.titleY + CHROME_TITLE_HEIGHT && mx >= g.titleX && mx < g.titleX + g.titleW) { - *hitPart = 1; + *hitPart = HIT_TITLE; return i; } @@ -1524,7 +1524,7 @@ int32_t wmHitTest(const WindowStackT *stack, int32_t mx, int32_t my, int32_t *hi if (win->menuBar && my >= win->y + CHROME_BORDER_WIDTH + CHROME_TITLE_HEIGHT && my < win->y + CHROME_BORDER_WIDTH + CHROME_TITLE_HEIGHT + CHROME_MENU_HEIGHT) { - *hitPart = 4; + *hitPart = HIT_MENU; return i; } @@ -1535,7 +1535,7 @@ int32_t wmHitTest(const WindowStackT *stack, int32_t mx, int32_t my, int32_t *hi if (mx >= sbX && mx < sbX + SCROLLBAR_WIDTH && my >= sbY && my < sbY + win->vScroll->length) { - *hitPart = 5; + *hitPart = HIT_VSCROLL; return i; } } @@ -1547,7 +1547,7 @@ int32_t wmHitTest(const WindowStackT *stack, int32_t mx, int32_t my, int32_t *hi if (mx >= sbX && mx < sbX + win->hScroll->length && my >= sbY && my < sbY + SCROLLBAR_WIDTH) { - *hitPart = 6; + *hitPart = HIT_HSCROLL; return i; } } @@ -1557,7 +1557,7 @@ int32_t wmHitTest(const WindowStackT *stack, int32_t mx, int32_t my, int32_t *hi int32_t edge = wmResizeEdgeHit(win, mx, my); if (edge != RESIZE_NONE) { - *hitPart = 3; + *hitPart = HIT_RESIZE; return i; } } @@ -1567,16 +1567,16 @@ int32_t wmHitTest(const WindowStackT *stack, int32_t mx, int32_t my, int32_t *hi mx < win->x + win->contentX + win->contentW && my >= win->y + win->contentY && my < win->y + win->contentY + win->contentH) { - *hitPart = 0; + *hitPart = HIT_CONTENT; return i; } // Somewhere on the chrome but not a specific part - *hitPart = 1; + *hitPart = HIT_TITLE; return i; } - *hitPart = -1; + *hitPart = HIT_NONE; return -1; } @@ -1630,8 +1630,8 @@ void wmMaximize(WindowStackT *stack, DirtyListT *dl, const DisplayT *d, WindowT dirtyListAdd(dl, win->x, win->y, win->w, win->h); - int32_t newW = (win->maxW < 0) ? d->width : DVX_MIN(win->maxW, d->width); - int32_t newH = (win->maxH < 0) ? d->height : DVX_MIN(win->maxH, d->height); + int32_t newW = (win->maxW == WM_MAX_FROM_SCREEN) ? d->width : DVX_MIN(win->maxW, d->width); + int32_t newH = (win->maxH == WM_MAX_FROM_SCREEN) ? d->height : DVX_MIN(win->maxH, d->height); win->x = 0; win->y = 0; @@ -2026,8 +2026,8 @@ void wmResizeMove(WindowStackT *stack, DirtyListT *dl, const DisplayT *d, int32_ wmMinWindowSize(win, &minW, &minH); // Compute effective maximum size - int32_t maxW = (win->maxW < 0) ? d->width : DVX_MIN(win->maxW, d->width); - int32_t maxH = (win->maxH < 0) ? d->height : DVX_MIN(win->maxH, d->height); + int32_t maxW = (win->maxW == WM_MAX_FROM_SCREEN) ? d->width : DVX_MIN(win->maxW, d->width); + int32_t maxH = (win->maxH == WM_MAX_FROM_SCREEN) ? d->height : DVX_MIN(win->maxH, d->height); // Mark old position dirty dirtyListAdd(dl, win->x, win->y, win->w, win->h); @@ -2250,7 +2250,7 @@ void wmScrollbarClick(WindowStackT *stack, DirtyListT *dl, int32_t idx, int32_t } WindowT *win = stack->windows[idx]; - ScrollbarT *sb = (orient == 0) ? win->vScroll : win->hScroll; + ScrollbarT *sb = (orient == SCROLL_VERTICAL) ? win->vScroll : win->hScroll; if (!sb) { return; diff --git a/dvx/dvxWm.h b/dvx/dvxWm.h index a5bd115..5960c41 100644 --- a/dvx/dvxWm.h +++ b/dvx/dvxWm.h @@ -118,8 +118,8 @@ void wmDrawMinimizedIcons(DisplayT *d, const BlitOpsT *ops, const ColorSchemeT * // screen coordinates. Iterates the stack front-to-back (highest Z first) // so the topmost window wins. Returns the stack index, or -1 if no window // was hit (i.e. the desktop). hitPart identifies the chrome region: -// 0=content, 1=title bar, 2=close button, 3=resize edge, -// 4=menu bar, 5=vscroll, 6=hscroll, 7=minimize, 8=maximize +// HIT_CONTENT, HIT_TITLE, HIT_CLOSE, HIT_RESIZE, +// HIT_MENU, HIT_VSCROLL, HIT_HSCROLL, HIT_MINIMIZE, HIT_MAXIMIZE int32_t wmHitTest(const WindowStackT *stack, int32_t mx, int32_t my, int32_t *hitPart); // For a point within a window's border zone, determine which edge(s) diff --git a/dvx/widgets/widgetEvent.c b/dvx/widgets/widgetEvent.c index 942c026..d88ac96 100644 --- a/dvx/widgets/widgetEvent.c +++ b/dvx/widgets/widgetEvent.c @@ -216,13 +216,13 @@ void widgetOnMouse(WindowT *win, int32_t x, int32_t y, int32_t buttons) { } // Handle text drag-select release - if (sDragTextSelect && !(buttons & 1)) { + if (sDragTextSelect && !(buttons & MOUSE_LEFT)) { sDragTextSelect = NULL; return; } // Handle text drag-select (mouse move while pressed) - if (sDragTextSelect && (buttons & 1)) { + if (sDragTextSelect && (buttons & MOUSE_LEFT)) { widgetTextDragUpdate(sDragTextSelect, root, x, y); if (sDragTextSelect->type == WidgetAnsiTermE) { @@ -248,7 +248,7 @@ void widgetOnMouse(WindowT *win, int32_t x, int32_t y, int32_t buttons) { } // Handle canvas drawing release - if (sDrawingCanvas && !(buttons & 1)) { + if (sDrawingCanvas && !(buttons & MOUSE_LEFT)) { sDrawingCanvas->as.canvas.lastX = -1; sDrawingCanvas->as.canvas.lastY = -1; sDrawingCanvas = NULL; @@ -257,21 +257,21 @@ void widgetOnMouse(WindowT *win, int32_t x, int32_t y, int32_t buttons) { } // Handle canvas drawing (mouse move while pressed) - if (sDrawingCanvas && (buttons & 1)) { + if (sDrawingCanvas && (buttons & MOUSE_LEFT)) { widgetCanvasOnMouse(sDrawingCanvas, root, x, y); wgtInvalidatePaint(root); return; } // Handle slider drag release - if (sDragSlider && !(buttons & 1)) { + if (sDragSlider && !(buttons & MOUSE_LEFT)) { sDragSlider = NULL; wgtInvalidatePaint(root); return; } // Handle slider drag (mouse move while pressed) - if (sDragSlider && (buttons & 1)) { + if (sDragSlider && (buttons & MOUSE_LEFT)) { int32_t range = sDragSlider->as.slider.maxValue - sDragSlider->as.slider.minValue; if (range > 0) { @@ -310,14 +310,14 @@ void widgetOnMouse(WindowT *win, int32_t x, int32_t y, int32_t buttons) { } // Handle ListView column resize release - if (sResizeListView && !(buttons & 1)) { + if (sResizeListView && !(buttons & MOUSE_LEFT)) { sResizeListView = NULL; sResizeCol = -1; return; } // Handle ListView column resize drag - if (sResizeListView && (buttons & 1)) { + if (sResizeListView && (buttons & MOUSE_LEFT)) { int32_t delta = x - sResizeStartX; int32_t newW = sResizeOrigW + delta; @@ -343,7 +343,7 @@ void widgetOnMouse(WindowT *win, int32_t x, int32_t y, int32_t buttons) { } // Handle drag-reorder release - if (sDragReorder && !(buttons & 1)) { + if (sDragReorder && !(buttons & MOUSE_LEFT)) { widgetReorderDrop(sDragReorder); sDragReorder = NULL; wgtInvalidatePaint(root); @@ -351,20 +351,20 @@ void widgetOnMouse(WindowT *win, int32_t x, int32_t y, int32_t buttons) { } // Handle drag-reorder move - if (sDragReorder && (buttons & 1)) { + if (sDragReorder && (buttons & MOUSE_LEFT)) { widgetReorderUpdate(sDragReorder, root, x, y); wgtInvalidatePaint(root); return; } // Handle splitter drag release - if (sDragSplitter && !(buttons & 1)) { + if (sDragSplitter && !(buttons & MOUSE_LEFT)) { sDragSplitter = NULL; return; } // Handle splitter drag - if (sDragSplitter && (buttons & 1)) { + if (sDragSplitter && (buttons & MOUSE_LEFT)) { int32_t pos; if (sDragSplitter->as.splitter.vertical) { @@ -389,7 +389,7 @@ void widgetOnMouse(WindowT *win, int32_t x, int32_t y, int32_t buttons) { } // Handle button press release - if (sPressedButton && !(buttons & 1)) { + if (sPressedButton && !(buttons & MOUSE_LEFT)) { if (sPressedButton->type == WidgetImageButtonE) { sPressedButton->as.imageButton.pressed = false; } else { @@ -412,7 +412,7 @@ void widgetOnMouse(WindowT *win, int32_t x, int32_t y, int32_t buttons) { } // Handle button press tracking (mouse move while held) - if (sPressedButton && (buttons & 1)) { + if (sPressedButton && (buttons & MOUSE_LEFT)) { bool over = false; if (sPressedButton->window == win) { @@ -438,7 +438,7 @@ void widgetOnMouse(WindowT *win, int32_t x, int32_t y, int32_t buttons) { } // Handle open popup clicks - if (sOpenPopup && (buttons & 1)) { + if (sOpenPopup && (buttons & MOUSE_LEFT)) { AppContextT *ctx = (AppContextT *)root->userData; const BitmapFontT *font = &ctx->font; @@ -509,7 +509,7 @@ void widgetOnMouse(WindowT *win, int32_t x, int32_t y, int32_t buttons) { // Fall through to normal click handling } - if (!(buttons & 1)) { + if (!(buttons & MOUSE_LEFT)) { return; } diff --git a/dvxshell/shellApp.h b/dvxshell/shellApp.h index 3afdeb7..6d07918 100644 --- a/dvxshell/shellApp.h +++ b/dvxshell/shellApp.h @@ -41,11 +41,15 @@ // Every DXE app exports a global AppDescriptorT named "appDescriptor". // The shell reads it at load time to determine how to launch the app. + +// Use in AppDescriptorT.stackSize to get the default task stack size +#define SHELL_STACK_DEFAULT 0 + typedef struct { char name[SHELL_APP_NAME_MAX]; bool hasMainLoop; bool multiInstance; // true = allow multiple instances via temp copy - int32_t stackSize; // 0 = TS_DEFAULT_STACK_SIZE + int32_t stackSize; // SHELL_STACK_DEFAULT or explicit byte count int32_t priority; // TS_PRIORITY_* or custom } AppDescriptorT;