From 567c60040e0328dd1dd16e74d6969569709b8afc Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Thu, 18 Apr 2019 18:03:17 -0500 Subject: [PATCH] Allow double-clicking on disks in the list to mount them. --- browserevents.c | 29 +++++++++++++++++++++++++++-- browserevents.h | 1 + browserwindow.c | 2 ++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/browserevents.c b/browserevents.c index 450b27d..308e9b7 100644 --- a/browserevents.c +++ b/browserevents.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -23,13 +24,15 @@ #include "disksearch.h" #include "diskmount.h" +/* Task record used for TaskMasterDA */ +static WmTaskRec taskRec; + static void HandleEvent(int eventCode, WmTaskRec *taskRec); static boolean DoLEEdit (int editAction); /* NDA-style action routine for our window */ #pragma databank 1 static int ActionProc(EventRecord *eventRec, int actionCode) { - static WmTaskRec taskRec; int handledAction = 0; if (!windowOpened) @@ -41,7 +44,6 @@ static int ActionProc(EventRecord *eventRec, int actionCode) { switch (actionCode) { case eventAction: /* Copy basic event rec & use our own wmTaskMask, as per IIgs TN 84 */ - memset(&taskRec, sizeof(taskRec), 0); memmove(&taskRec, eventRec, 16); taskRec.wmTaskMask = 0x1F7FFF; /* everything except tmInfo */ @@ -76,6 +78,8 @@ asm void actionProcWrapper(void) { /* Handle an event after TaskMasterDA processing */ static void HandleEvent(int eventCode, WmTaskRec *taskRec) { + static unsigned int lastSelection; + switch (eventCode) { case wInControl: switch (taskRec->wmTaskData4) { @@ -93,6 +97,22 @@ static void HandleEvent(int eventCode, WmTaskRec *taskRec) { case mountDiskButton: DoMount(); break; + + case disksList: + if (taskRec->what == mouseDownEvt) { + if (taskRec->wmClickCount == 2) { + SubPt(&taskRec->wmLastClickPt, &taskRec->where); + if (taskRec->where.h >= -5 && taskRec->where.h <= 5 && + taskRec->where.v >= -3 && taskRec->where.v <= 3 && + NextMember2(0, (Handle)disksListHandle) == lastSelection) + { + DoMount(); + } + } else { + lastSelection = NextMember2(0, (Handle)disksListHandle); + } + } + break; } break; @@ -144,3 +164,8 @@ static boolean DoLEEdit (int editAction) { }; return (id == searchLine); } + +void InitEventState(void) { + memset(&taskRec, sizeof(taskRec), 0); +} + diff --git a/browserevents.h b/browserevents.h index 897da10..3d60c26 100644 --- a/browserevents.h +++ b/browserevents.h @@ -2,5 +2,6 @@ #define BROWSEREVENTS_H asm void actionProcWrapper(void); +void InitEventState(void); #endif diff --git a/browserwindow.c b/browserwindow.c index 92f3934..6dc6659 100644 --- a/browserwindow.c +++ b/browserwindow.c @@ -108,6 +108,8 @@ void ShowBrowserWindow(void) { defaultButtonIsSearch = true; wantToOpenWindow = 0; + + InitEventState(); cleanup: if (resourceFileOpened && !windowOpened) {