More magic numbers replaced with named defines.

This commit is contained in:
Scott Duensing 2026-03-18 01:50:51 -05:00
parent 1e59499529
commit 862590c40a
10 changed files with 102 additions and 75 deletions

View file

@ -67,7 +67,7 @@ AppDescriptorT appDescriptor = {
.name = "Clock", .name = "Clock",
.hasMainLoop = true, .hasMainLoop = true,
.multiInstance = true, .multiInstance = true,
.stackSize = 0, .stackSize = SHELL_STACK_DEFAULT,
.priority = TS_PRIORITY_LOW .priority = TS_PRIORITY_LOW
}; };

View file

@ -96,7 +96,7 @@ static DxeAppContextT *sDxeCtx = NULL;
AppDescriptorT appDescriptor = { AppDescriptorT appDescriptor = {
.name = "DVX Demo", .name = "DVX Demo",
.hasMainLoop = false, .hasMainLoop = false,
.stackSize = 0, .stackSize = SHELL_STACK_DEFAULT,
.priority = TS_PRIORITY_NORMAL .priority = TS_PRIORITY_NORMAL
}; };

View file

@ -77,7 +77,7 @@ static void onMenu(WindowT *win, int32_t menuId);
AppDescriptorT appDescriptor = { AppDescriptorT appDescriptor = {
.name = "Notepad", .name = "Notepad",
.hasMainLoop = false, .hasMainLoop = false,
.stackSize = 0, .stackSize = SHELL_STACK_DEFAULT,
.priority = TS_PRIORITY_NORMAL .priority = TS_PRIORITY_NORMAL
}; };

View file

@ -113,7 +113,7 @@ static void refreshTaskList(void);
AppDescriptorT appDescriptor = { AppDescriptorT appDescriptor = {
.name = "Program Manager", .name = "Program Manager",
.hasMainLoop = false, .hasMainLoop = false,
.stackSize = 0, .stackSize = SHELL_STACK_DEFAULT,
.priority = TS_PRIORITY_NORMAL .priority = TS_PRIORITY_NORMAL
}; };

View file

@ -783,7 +783,7 @@ static void dispatchEvents(AppContextT *ctx) {
// Handle active drag // Handle active drag
if (ctx->stack.dragWindow >= 0) { 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); wmDragMove(&ctx->stack, &ctx->dirty, mx, my, ctx->display.width, ctx->display.height);
} else { } else {
wmDragEnd(&ctx->stack); wmDragEnd(&ctx->stack);
@ -793,7 +793,7 @@ static void dispatchEvents(AppContextT *ctx) {
// Handle active resize // Handle active resize
if (ctx->stack.resizeWindow >= 0) { if (ctx->stack.resizeWindow >= 0) {
if (buttons & 1) { if (buttons & MOUSE_LEFT) {
wmResizeMove(&ctx->stack, &ctx->dirty, &ctx->display, mx, my); wmResizeMove(&ctx->stack, &ctx->dirty, &ctx->display, mx, my);
} else { } else {
wmResizeEnd(&ctx->stack); wmResizeEnd(&ctx->stack);
@ -803,7 +803,7 @@ static void dispatchEvents(AppContextT *ctx) {
// Handle active scrollbar thumb drag // Handle active scrollbar thumb drag
if (ctx->stack.scrollWindow >= 0) { if (ctx->stack.scrollWindow >= 0) {
if (buttons & 1) { if (buttons & MOUSE_LEFT) {
wmScrollbarDrag(&ctx->stack, &ctx->dirty, mx, my); wmScrollbarDrag(&ctx->stack, &ctx->dirty, mx, my);
} else { } else {
wmScrollbarEnd(&ctx->stack); wmScrollbarEnd(&ctx->stack);
@ -830,7 +830,7 @@ static void dispatchEvents(AppContextT *ctx) {
} }
// Click on item // Click on item
if ((buttons & 1) && !(prevBtn & 1)) { if ((buttons & MOUSE_LEFT) && !(prevBtn & MOUSE_LEFT)) {
if (itemIdx >= 0 && itemIdx < ctx->sysMenu.itemCount) { if (itemIdx >= 0 && itemIdx < ctx->sysMenu.itemCount) {
SysMenuItemT *item = &ctx->sysMenu.items[itemIdx]; 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 // Click outside system menu — close it, let event fall through
if ((buttons & 1) && !(prevBtn & 1)) { if ((buttons & MOUSE_LEFT) && !(prevBtn & MOUSE_LEFT)) {
closeSysMenu(ctx); closeSysMenu(ctx);
} }
} }
@ -900,7 +900,7 @@ static void dispatchEvents(AppContextT *ctx) {
} }
// Click on item in current level // 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) { if (ctx->popup.menu && itemIdx >= 0 && itemIdx < ctx->popup.menu->itemCount) {
MenuItemT *item = &ctx->popup.menu->items[itemIdx]; MenuItemT *item = &ctx->popup.menu->items[itemIdx];
@ -978,7 +978,7 @@ static void dispatchEvents(AppContextT *ctx) {
if (!inParent) { if (!inParent) {
if (ctx->popup.isContextMenu) { if (ctx->popup.isContextMenu) {
// Context menu: any click outside closes it // Context menu: any click outside closes it
if ((buttons & 1) && !(prevBtn & 1)) { if ((buttons & MOUSE_LEFT) && !(prevBtn & MOUSE_LEFT)) {
closeAllPopups(ctx); closeAllPopups(ctx);
} }
} else { } else {
@ -998,7 +998,7 @@ static void dispatchEvents(AppContextT *ctx) {
MenuT *menu = &win->menuBar->menus[i]; MenuT *menu = &win->menuBar->menus[i];
if (relX >= menu->barX && relX < menu->barX + menu->barW) { 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 // Clicking the same menu bar entry closes the menu
closeAllPopups(ctx); closeAllPopups(ctx);
} else if (i != ctx->popup.menuIdx || ctx->popup.depth > 0) { } else if (i != ctx->popup.menuIdx || ctx->popup.depth > 0) {
@ -1008,10 +1008,10 @@ static void dispatchEvents(AppContextT *ctx) {
break; break;
} }
} }
} else if ((buttons & 1) && !(prevBtn & 1)) { } else if ((buttons & MOUSE_LEFT) && !(prevBtn & MOUSE_LEFT)) {
closeAllPopups(ctx); closeAllPopups(ctx);
} }
} else if ((buttons & 1) && !(prevBtn & 1)) { } else if ((buttons & MOUSE_LEFT) && !(prevBtn & MOUSE_LEFT)) {
closeAllPopups(ctx); closeAllPopups(ctx);
} }
} }
@ -1022,7 +1022,7 @@ static void dispatchEvents(AppContextT *ctx) {
} }
// Handle left button press // Handle left button press
if ((buttons & 1) && !(prevBtn & 1)) { if ((buttons & MOUSE_LEFT) && !(prevBtn & MOUSE_LEFT)) {
handleMouseButton(ctx, mx, my, buttons); 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 // to the window-level context menu. This lets containers provide menus
// that apply to all their children without requiring each child to have // that apply to all their children without requiring each child to have
// its own menu, while still allowing per-widget overrides. // 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 hitPart;
int32_t hitIdx = wmHitTest(&ctx->stack, mx, my, &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]; WindowT *win = ctx->stack.windows[hitIdx];
if (hitIdx != ctx->stack.focusedIdx) { if (hitIdx != ctx->stack.focusedIdx) {
@ -1073,7 +1073,7 @@ static void dispatchEvents(AppContextT *ctx) {
} }
// Handle button release on content — send to focused window // 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) { if (ctx->stack.focusedIdx >= 0) {
WindowT *win = ctx->stack.windows[ctx->stack.focusedIdx]; 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 // Mouse movement in content area — send to focused window
if ((mx != ctx->prevMouseX || my != ctx->prevMouseY) && 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]; WindowT *win = ctx->stack.windows[ctx->stack.focusedIdx];
if (win->onMouse) { if (win->onMouse) {
@ -2230,7 +2230,7 @@ static void handleMouseButton(AppContextT *ctx, int32_t mx, int32_t my, int32_t
} }
switch (hitPart) { switch (hitPart) {
case 0: // content case HIT_CONTENT:
if (win->onMouse) { if (win->onMouse) {
int32_t relX = mx - win->x - win->contentX; int32_t relX = mx - win->x - win->contentX;
int32_t relY = my - win->y - win->contentY; 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; break;
case 1: // title bar — start drag case HIT_TITLE:
wmDragBegin(&ctx->stack, hitIdx, mx, my); wmDragBegin(&ctx->stack, hitIdx, mx, my);
break; break;
case 2: // close button (double-click to close, single-click opens system menu) case HIT_CLOSE:
{ {
clock_t now = clock(); clock_t now = clock();
@ -2264,14 +2264,14 @@ static void handleMouseButton(AppContextT *ctx, int32_t mx, int32_t my, int32_t
} }
break; break;
case 3: // resize edge case HIT_RESIZE:
{ {
int32_t edge = wmResizeEdgeHit(win, mx, my); int32_t edge = wmResizeEdgeHit(win, mx, my);
wmResizeBegin(&ctx->stack, hitIdx, edge, mx, my); wmResizeBegin(&ctx->stack, hitIdx, edge, mx, my);
} }
break; break;
case 4: // menu bar case HIT_MENU:
{ {
if (!win->menuBar) { if (!win->menuBar) {
break; break;
@ -2290,15 +2290,15 @@ static void handleMouseButton(AppContextT *ctx, int32_t mx, int32_t my, int32_t
} }
break; break;
case 5: // vertical scrollbar case HIT_VSCROLL:
wmScrollbarClick(&ctx->stack, &ctx->dirty, hitIdx, 0, mx, my); wmScrollbarClick(&ctx->stack, &ctx->dirty, hitIdx, SCROLL_VERTICAL, mx, my);
break; break;
case 6: // horizontal scrollbar case HIT_HSCROLL:
wmScrollbarClick(&ctx->stack, &ctx->dirty, hitIdx, 1, mx, my); wmScrollbarClick(&ctx->stack, &ctx->dirty, hitIdx, SCROLL_HORIZONTAL, mx, my);
break; break;
case 7: // minimize (not allowed for modal windows) case HIT_MINIMIZE:
if (ctx->modalWindow != win) { if (ctx->modalWindow != win) {
wmMinimize(&ctx->stack, &ctx->dirty, win); wmMinimize(&ctx->stack, &ctx->dirty, win);
// Dirty the icon strip area so the new icon gets drawn // 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; break;
case 8: // maximize / restore case HIT_MAXIMIZE:
if (win->maximized) { if (win->maximized) {
wmRestore(&ctx->stack, &ctx->dirty, &ctx->display, win); wmRestore(&ctx->stack, &ctx->dirty, &ctx->display, win);
} else { } else {
@ -3513,7 +3513,7 @@ static void updateCursorShape(AppContextT *ctx) {
int32_t hitPart; int32_t hitPart;
int32_t hitIdx = wmHitTest(&ctx->stack, mx, my, &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 // Hovering over a resize edge
WindowT *win = ctx->stack.windows[hitIdx]; WindowT *win = ctx->stack.windows[hitIdx];
int32_t edge = wmResizeEdgeHit(win, mx, my); int32_t edge = wmResizeEdgeHit(win, mx, my);
@ -3532,7 +3532,7 @@ static void updateCursorShape(AppContextT *ctx) {
} else if (vert) { } else if (vert) {
newCursor = CURSOR_RESIZE_V; 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 // Hovering over content area — check for ListView column border
WindowT *win = ctx->stack.windows[hitIdx]; WindowT *win = ctx->stack.windows[hitIdx];

View file

@ -420,8 +420,26 @@ typedef struct {
#define RESIZE_TOP 4 #define RESIZE_TOP 4
#define RESIZE_BOTTOM 8 #define RESIZE_BOTTOM 8
// Window size limits
#define MIN_WINDOW_W 80 #define MIN_WINDOW_W 80
#define MIN_WINDOW_H 60 #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, // Minimized windows display as icons at the bottom of the screen,
// similar to DESQview/X's original icon bar behavior. // similar to DESQview/X's original icon bar behavior.
@ -449,8 +467,8 @@ typedef struct WindowT {
bool resizable; bool resizable;
bool modal; bool modal;
bool contentDirty; // true when contentBuf has changed since last icon refresh bool contentDirty; // true when contentBuf has changed since last icon refresh
int32_t maxW; // maximum width (-1 = screen width) int32_t maxW; // maximum width (WM_MAX_FROM_SCREEN = use screen width)
int32_t maxH; // maximum height (-1 = screen height) int32_t maxH; // maximum height (WM_MAX_FROM_SCREEN = use screen height)
// Pre-maximize geometry is saved so wmRestore() can put the window // Pre-maximize geometry is saved so wmRestore() can put the window
// back exactly where it was. This matches Windows 3.x behavior. // back exactly where it was. This matches Windows 3.x behavior.
int32_t preMaxX; // saved position before maximize int32_t preMaxX; // saved position before maximize
@ -525,11 +543,16 @@ typedef struct {
int32_t dragOffY; int32_t dragOffY;
int32_t resizeWindow; int32_t resizeWindow;
int32_t resizeEdge; int32_t resizeEdge;
int32_t scrollWindow; // window being scroll-dragged (-1 = none) int32_t scrollWindow; // window being scroll-dragged (HIT_NONE = none)
int32_t scrollOrient; // 0 = vertical, 1 = horizontal int32_t scrollOrient; // SCROLL_VERTICAL or SCROLL_HORIZONTAL
int32_t scrollDragOff; // mouse offset from thumb start int32_t scrollDragOff; // mouse offset from thumb start
} WindowStackT; } 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 // Mouse cursor
// ============================================================ // ============================================================

View file

@ -1065,8 +1065,8 @@ WindowT *wmCreateWindow(WindowStackT *stack, DisplayT *d, const char *title, int
win->minimized = false; win->minimized = false;
win->maximized = false; win->maximized = false;
win->resizable = resizable; win->resizable = resizable;
win->maxW = -1; win->maxW = WM_MAX_FROM_SCREEN;
win->maxH = -1; win->maxH = WM_MAX_FROM_SCREEN;
strncpy(win->title, title, MAX_TITLE_LEN - 1); strncpy(win->title, title, MAX_TITLE_LEN - 1);
win->title[MAX_TITLE_LEN - 1] = '\0'; 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) // Close gadget (top-left)
if (mx >= g.closeX && mx < g.closeX + g.gadgetS && if (mx >= g.closeX && mx < g.closeX + g.gadgetS &&
my >= g.gadgetY && my < g.gadgetY + g.gadgetS) { my >= g.gadgetY && my < g.gadgetY + g.gadgetS) {
*hitPart = 2; *hitPart = HIT_CLOSE;
return i; 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 && if (g.maxX >= 0 &&
mx >= g.maxX && mx < g.maxX + g.gadgetS && mx >= g.maxX && mx < g.maxX + g.gadgetS &&
my >= g.gadgetY && my < g.gadgetY + g.gadgetS) { my >= g.gadgetY && my < g.gadgetY + g.gadgetS) {
*hitPart = 8; *hitPart = HIT_MAXIMIZE;
return i; 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 && if (g.minX >= 0 &&
mx >= g.minX && mx < g.minX + g.gadgetS && mx >= g.minX && mx < g.minX + g.gadgetS &&
my >= g.gadgetY && my < g.gadgetY + g.gadgetS) { my >= g.gadgetY && my < g.gadgetY + g.gadgetS) {
*hitPart = 7; *hitPart = HIT_MINIMIZE;
return i; return i;
} }
// Title bar (drag area — between gadgets) // Title bar (drag area — between gadgets)
if (my >= g.titleY && my < g.titleY + CHROME_TITLE_HEIGHT && if (my >= g.titleY && my < g.titleY + CHROME_TITLE_HEIGHT &&
mx >= g.titleX && mx < g.titleX + g.titleW) { mx >= g.titleX && mx < g.titleX + g.titleW) {
*hitPart = 1; *hitPart = HIT_TITLE;
return i; return i;
} }
@ -1524,7 +1524,7 @@ int32_t wmHitTest(const WindowStackT *stack, int32_t mx, int32_t my, int32_t *hi
if (win->menuBar && if (win->menuBar &&
my >= win->y + CHROME_BORDER_WIDTH + CHROME_TITLE_HEIGHT && my >= win->y + CHROME_BORDER_WIDTH + CHROME_TITLE_HEIGHT &&
my < win->y + CHROME_BORDER_WIDTH + CHROME_TITLE_HEIGHT + CHROME_MENU_HEIGHT) { my < win->y + CHROME_BORDER_WIDTH + CHROME_TITLE_HEIGHT + CHROME_MENU_HEIGHT) {
*hitPart = 4; *hitPart = HIT_MENU;
return i; 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 && if (mx >= sbX && mx < sbX + SCROLLBAR_WIDTH &&
my >= sbY && my < sbY + win->vScroll->length) { my >= sbY && my < sbY + win->vScroll->length) {
*hitPart = 5; *hitPart = HIT_VSCROLL;
return i; 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 && if (mx >= sbX && mx < sbX + win->hScroll->length &&
my >= sbY && my < sbY + SCROLLBAR_WIDTH) { my >= sbY && my < sbY + SCROLLBAR_WIDTH) {
*hitPart = 6; *hitPart = HIT_HSCROLL;
return i; 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); int32_t edge = wmResizeEdgeHit(win, mx, my);
if (edge != RESIZE_NONE) { if (edge != RESIZE_NONE) {
*hitPart = 3; *hitPart = HIT_RESIZE;
return i; 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 && mx < win->x + win->contentX + win->contentW &&
my >= win->y + win->contentY && my >= win->y + win->contentY &&
my < win->y + win->contentY + win->contentH) { my < win->y + win->contentY + win->contentH) {
*hitPart = 0; *hitPart = HIT_CONTENT;
return i; return i;
} }
// Somewhere on the chrome but not a specific part // Somewhere on the chrome but not a specific part
*hitPart = 1; *hitPart = HIT_TITLE;
return i; return i;
} }
*hitPart = -1; *hitPart = HIT_NONE;
return -1; 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); 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 newW = (win->maxW == WM_MAX_FROM_SCREEN) ? d->width : DVX_MIN(win->maxW, d->width);
int32_t newH = (win->maxH < 0) ? d->height : DVX_MIN(win->maxH, d->height); int32_t newH = (win->maxH == WM_MAX_FROM_SCREEN) ? d->height : DVX_MIN(win->maxH, d->height);
win->x = 0; win->x = 0;
win->y = 0; win->y = 0;
@ -2026,8 +2026,8 @@ void wmResizeMove(WindowStackT *stack, DirtyListT *dl, const DisplayT *d, int32_
wmMinWindowSize(win, &minW, &minH); wmMinWindowSize(win, &minW, &minH);
// Compute effective maximum size // Compute effective maximum size
int32_t maxW = (win->maxW < 0) ? d->width : DVX_MIN(win->maxW, d->width); int32_t maxW = (win->maxW == WM_MAX_FROM_SCREEN) ? d->width : DVX_MIN(win->maxW, d->width);
int32_t maxH = (win->maxH < 0) ? d->height : DVX_MIN(win->maxH, d->height); int32_t maxH = (win->maxH == WM_MAX_FROM_SCREEN) ? d->height : DVX_MIN(win->maxH, d->height);
// Mark old position dirty // Mark old position dirty
dirtyListAdd(dl, win->x, win->y, win->w, win->h); 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]; WindowT *win = stack->windows[idx];
ScrollbarT *sb = (orient == 0) ? win->vScroll : win->hScroll; ScrollbarT *sb = (orient == SCROLL_VERTICAL) ? win->vScroll : win->hScroll;
if (!sb) { if (!sb) {
return; return;

View file

@ -118,8 +118,8 @@ void wmDrawMinimizedIcons(DisplayT *d, const BlitOpsT *ops, const ColorSchemeT *
// screen coordinates. Iterates the stack front-to-back (highest Z first) // 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 // 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: // was hit (i.e. the desktop). hitPart identifies the chrome region:
// 0=content, 1=title bar, 2=close button, 3=resize edge, // HIT_CONTENT, HIT_TITLE, HIT_CLOSE, HIT_RESIZE,
// 4=menu bar, 5=vscroll, 6=hscroll, 7=minimize, 8=maximize // 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); 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) // For a point within a window's border zone, determine which edge(s)

View file

@ -216,13 +216,13 @@ void widgetOnMouse(WindowT *win, int32_t x, int32_t y, int32_t buttons) {
} }
// Handle text drag-select release // Handle text drag-select release
if (sDragTextSelect && !(buttons & 1)) { if (sDragTextSelect && !(buttons & MOUSE_LEFT)) {
sDragTextSelect = NULL; sDragTextSelect = NULL;
return; return;
} }
// Handle text drag-select (mouse move while pressed) // Handle text drag-select (mouse move while pressed)
if (sDragTextSelect && (buttons & 1)) { if (sDragTextSelect && (buttons & MOUSE_LEFT)) {
widgetTextDragUpdate(sDragTextSelect, root, x, y); widgetTextDragUpdate(sDragTextSelect, root, x, y);
if (sDragTextSelect->type == WidgetAnsiTermE) { 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 // Handle canvas drawing release
if (sDrawingCanvas && !(buttons & 1)) { if (sDrawingCanvas && !(buttons & MOUSE_LEFT)) {
sDrawingCanvas->as.canvas.lastX = -1; sDrawingCanvas->as.canvas.lastX = -1;
sDrawingCanvas->as.canvas.lastY = -1; sDrawingCanvas->as.canvas.lastY = -1;
sDrawingCanvas = NULL; 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) // Handle canvas drawing (mouse move while pressed)
if (sDrawingCanvas && (buttons & 1)) { if (sDrawingCanvas && (buttons & MOUSE_LEFT)) {
widgetCanvasOnMouse(sDrawingCanvas, root, x, y); widgetCanvasOnMouse(sDrawingCanvas, root, x, y);
wgtInvalidatePaint(root); wgtInvalidatePaint(root);
return; return;
} }
// Handle slider drag release // Handle slider drag release
if (sDragSlider && !(buttons & 1)) { if (sDragSlider && !(buttons & MOUSE_LEFT)) {
sDragSlider = NULL; sDragSlider = NULL;
wgtInvalidatePaint(root); wgtInvalidatePaint(root);
return; return;
} }
// Handle slider drag (mouse move while pressed) // 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; int32_t range = sDragSlider->as.slider.maxValue - sDragSlider->as.slider.minValue;
if (range > 0) { 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 // Handle ListView column resize release
if (sResizeListView && !(buttons & 1)) { if (sResizeListView && !(buttons & MOUSE_LEFT)) {
sResizeListView = NULL; sResizeListView = NULL;
sResizeCol = -1; sResizeCol = -1;
return; return;
} }
// Handle ListView column resize drag // Handle ListView column resize drag
if (sResizeListView && (buttons & 1)) { if (sResizeListView && (buttons & MOUSE_LEFT)) {
int32_t delta = x - sResizeStartX; int32_t delta = x - sResizeStartX;
int32_t newW = sResizeOrigW + delta; 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 // Handle drag-reorder release
if (sDragReorder && !(buttons & 1)) { if (sDragReorder && !(buttons & MOUSE_LEFT)) {
widgetReorderDrop(sDragReorder); widgetReorderDrop(sDragReorder);
sDragReorder = NULL; sDragReorder = NULL;
wgtInvalidatePaint(root); wgtInvalidatePaint(root);
@ -351,20 +351,20 @@ void widgetOnMouse(WindowT *win, int32_t x, int32_t y, int32_t buttons) {
} }
// Handle drag-reorder move // Handle drag-reorder move
if (sDragReorder && (buttons & 1)) { if (sDragReorder && (buttons & MOUSE_LEFT)) {
widgetReorderUpdate(sDragReorder, root, x, y); widgetReorderUpdate(sDragReorder, root, x, y);
wgtInvalidatePaint(root); wgtInvalidatePaint(root);
return; return;
} }
// Handle splitter drag release // Handle splitter drag release
if (sDragSplitter && !(buttons & 1)) { if (sDragSplitter && !(buttons & MOUSE_LEFT)) {
sDragSplitter = NULL; sDragSplitter = NULL;
return; return;
} }
// Handle splitter drag // Handle splitter drag
if (sDragSplitter && (buttons & 1)) { if (sDragSplitter && (buttons & MOUSE_LEFT)) {
int32_t pos; int32_t pos;
if (sDragSplitter->as.splitter.vertical) { 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 // Handle button press release
if (sPressedButton && !(buttons & 1)) { if (sPressedButton && !(buttons & MOUSE_LEFT)) {
if (sPressedButton->type == WidgetImageButtonE) { if (sPressedButton->type == WidgetImageButtonE) {
sPressedButton->as.imageButton.pressed = false; sPressedButton->as.imageButton.pressed = false;
} else { } 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) // Handle button press tracking (mouse move while held)
if (sPressedButton && (buttons & 1)) { if (sPressedButton && (buttons & MOUSE_LEFT)) {
bool over = false; bool over = false;
if (sPressedButton->window == win) { 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 // Handle open popup clicks
if (sOpenPopup && (buttons & 1)) { if (sOpenPopup && (buttons & MOUSE_LEFT)) {
AppContextT *ctx = (AppContextT *)root->userData; AppContextT *ctx = (AppContextT *)root->userData;
const BitmapFontT *font = &ctx->font; 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 // Fall through to normal click handling
} }
if (!(buttons & 1)) { if (!(buttons & MOUSE_LEFT)) {
return; return;
} }

View file

@ -41,11 +41,15 @@
// Every DXE app exports a global AppDescriptorT named "appDescriptor". // Every DXE app exports a global AppDescriptorT named "appDescriptor".
// The shell reads it at load time to determine how to launch the app. // 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 { typedef struct {
char name[SHELL_APP_NAME_MAX]; char name[SHELL_APP_NAME_MAX];
bool hasMainLoop; bool hasMainLoop;
bool multiInstance; // true = allow multiple instances via temp copy 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 int32_t priority; // TS_PRIORITY_* or custom
} AppDescriptorT; } AppDescriptorT;