modeless dialogs fix

This commit is contained in:
chombier 2001-04-19 12:22:56 +00:00
parent 273ca0c109
commit b736d748fd
6 changed files with 123 additions and 70 deletions

View File

@ -21,6 +21,7 @@ extern void ssh2_sched();
extern MenuHandle myMenus[];
int gSetUpMovableModal = 0;
int gMovableModal = 0;
pascal void movableModalDialog(ModalFilterUPP filter, short *theItem)
@ -28,6 +29,8 @@ pascal void movableModalDialog(ModalFilterUPP filter, short *theItem)
EventRecord theEvent;
DialogPtr d,thisDialog;
GrafPtr oldPort;
WindowPeek front;
WindowPtr dialog;
thisDialog = FrontWindow();
GetPort(&oldPort);
@ -35,6 +38,12 @@ pascal void movableModalDialog(ModalFilterUPP filter, short *theItem)
++gMovableModal;
for(;;) {
/* ssh2_sched can process terminal opening... */
if (thisDialog != FrontWindow()) {
SelectWindow(thisDialog);
}
WaitNextEvent(everyEvent, &theEvent, gApplicationPrefs->TimeSlice, 0L);
DoNetEvents();
@ -188,78 +197,82 @@ void diskEvent(EventRecord *theEvent)
void SetUpMovableModalMenus(void)
{
DisableItem(myMenus[Fil], 0);
DisableItem(myMenus[0], 1);
DisableItem(myMenus[Emul], 0);
DisableItem(myMenus[Conn], 0);
DisableItem(myMenus[Net], 0);
DisableItem(myMenus[OpSpec], 0);
DisableItem(myMenus[Keypad], 0);
DisableItem(myMenus[Function], 0);
if (++gSetUpMovableModal == 1) {
DisableItem(myMenus[Fil], 0);
DisableItem(myMenus[0], 1);
DisableItem(myMenus[Emul], 0);
DisableItem(myMenus[Conn], 0);
DisableItem(myMenus[Net], 0);
DisableItem(myMenus[OpSpec], 0);
DisableItem(myMenus[Keypad], 0);
DisableItem(myMenus[Function], 0);
DisableItem(myMenus[Edit], EDundo);
EnableItem(myMenus[Edit], EDcut);
EnableItem(myMenus[Edit], EDcopy);
EnableItem(myMenus[Edit], EDpaste);
EnableItem(myMenus[Edit], EDclear);
DisableItem(myMenus[Edit], EDcopyt);
DisableItem(myMenus[Edit], EDretype);
DisableItem(myMenus[Edit], EDmacros);
DisableItem(myMenus[Edit], EDprefs+1);
DisableItem(myMenus[Edit], EDprefs+2);
DisableItem(myMenus[Edit], EDprefs+4);
DisableItem(myMenus[Edit], EDprefs+5);
DisableItem(myMenus[Edit], EDundo);
EnableItem(myMenus[Edit], EDcut);
EnableItem(myMenus[Edit], EDcopy);
EnableItem(myMenus[Edit], EDpaste);
EnableItem(myMenus[Edit], EDclear);
DisableItem(myMenus[Edit], EDcopyt);
DisableItem(myMenus[Edit], EDretype);
DisableItem(myMenus[Edit], EDmacros);
DisableItem(myMenus[Edit], EDprefs+1);
DisableItem(myMenus[Edit], EDprefs+2);
DisableItem(myMenus[Edit], EDprefs+4);
DisableItem(myMenus[Edit], EDprefs+5);
DrawMenuBar();
HiliteMenu(0);
DrawMenuBar();
HiliteMenu(0);
}
}
void ResetMenus(void)
{
short i;
EnableItem(myMenus[Fil], 0);
EnableItem(myMenus[0], 1);
EnableItem(myMenus[Net], 0);
EnableItem(myMenus[OpSpec], 0);
if (--gSetUpMovableModal == 0) {
EnableItem(myMenus[Fil], 0);
EnableItem(myMenus[0], 1);
EnableItem(myMenus[Net], 0);
EnableItem(myMenus[OpSpec], 0);
DisableItem(myMenus[Edit], EDcut);
DisableItem(myMenus[Edit], EDclear);
EnableItem(myMenus[Edit], EDcopyt);
EnableItem(myMenus[Edit], EDretype);
EnableItem(myMenus[Edit], EDmacros);
EnableItem(myMenus[Edit], EDprefs+1);
EnableItem(myMenus[Edit], EDprefs+2);
EnableItem(myMenus[Edit], EDprefs+4);
EnableItem(myMenus[Edit], EDprefs+5);
DisableItem(myMenus[Edit], EDcut);
DisableItem(myMenus[Edit], EDclear);
EnableItem(myMenus[Edit], EDcopyt);
EnableItem(myMenus[Edit], EDretype);
EnableItem(myMenus[Edit], EDmacros);
EnableItem(myMenus[Edit], EDprefs+1);
EnableItem(myMenus[Edit], EDprefs+2);
EnableItem(myMenus[Edit], EDprefs+4);
EnableItem(myMenus[Edit], EDprefs+5);
AdjustMenus();
DoTheMenuChecks();
DrawMenuBar();
AdjustMenus();
DoTheMenuChecks();
DrawMenuBar();
if (!FrontWindow()) return;
if (!FrontWindow()) return;
if ((i=RSfindvwind(FrontWindow()))>=0)
{
if (RSTextSelected(i))
{
EnableItem(myMenus[Edit],EDcopy);
EnableItem(myMenus[Edit],EDcopyt);
if ((i=RSfindvwind(FrontWindow()))>=0)
{
if (RSTextSelected(i))
{
EnableItem(myMenus[Edit],EDcopy);
EnableItem(myMenus[Edit],EDcopyt);
}
else
{
DisableItem(myMenus[Edit],EDcopy);
DisableItem(myMenus[Edit],EDcopyt);
}
}
else
{
DisableItem(myMenus[Edit],EDcopy);
DisableItem(myMenus[Edit],EDcopyt);
}
}
else
{
if ( (i = RGgetdnum(FrontWindow())) >-1)
{
if (( i = RGgetVS( i)) >-1)
{
if ( (i = RGgetdnum(FrontWindow())) >-1)
{
EnableItem(myMenus[Edit],EDcopy); // - enable copying
DisableItem(myMenus[Edit],EDcopyt);
if (( i = RGgetVS( i)) >-1)
{
EnableItem(myMenus[Edit],EDcopy); // - enable copying
DisableItem(myMenus[Edit],EDcopyt);
}
}
}
}

View File

@ -821,10 +821,15 @@ void CancelMacros(NewMacroInfo *macrost, DialogPtr dtemp)
{
DisposeDialog(dtemp);
DisposeHandle(macrost->handle);
*macrost = oldMacroIndexes;
macrost->handle = oldMacros;
AdjustMenus();
DoTheMenuChecks();
if ( TelInfo->macrosModeless ) {
TelInfo->macrosModeless = 0;
AdjustMenus();
DoTheMenuChecks();
}
}
void CloseMacros(NewMacroInfo *macrost, DialogPtr dtemp)
@ -844,9 +849,12 @@ void CloseMacros(NewMacroInfo *macrost, DialogPtr dtemp)
DisposeHandle(oldMacros);
DisposeDialog(dtemp);
AdjustMenus();
DoTheMenuChecks();
if ( TelInfo->macrosModeless ) {
TelInfo->macrosModeless = 0;
AdjustMenus();
DoTheMenuChecks();
}
}
#if 0

View File

@ -62,6 +62,10 @@ extern Boolean encryptOK;
extern unsigned char *gReadspace;
extern short gBlocksize;
/*
extern void LockDialog();
extern void UnlockDialog();
*/
static void setSessStates(DialogPtr dptr);
static short FindMenuItemText(MenuHandle hMenu, StringPtr itemString);
@ -208,12 +212,16 @@ Boolean PresentOpenConnectionDialog(void)
SetCursor(theCursors[normcurs]);
//LockDialog();
SetUpMovableModalMenus();
dptr = GetNewMyDialog(NewCnxnDLOG, NULL, kInFront, (void *)ThirdCenterDialog);
if (dptr == NULL) {
//UnlockDialog();
ResetMenus();
OutOfMemory(1000);
return;
}
}
SetDialogDefaultItem(dptr, 1);
SetDialogCancelItem(dptr, 2);
@ -225,9 +233,11 @@ Boolean PresentOpenConnectionDialog(void)
SessPopupHdl = NewMenu(668, scratchPstring);
if (SessPopupHdl == NULL) {
DisposeDialog(dptr);
//UnlockDialog();
ResetMenus();
OutOfMemory(1000);
return;
}
}
UseResFile(TelInfo->SettingsFile);
numberOfTerms = Count1Resources(SESSIONPREFS_RESTYPE);
theHead = createSortedList(SESSIONPREFS_RESTYPE,numberOfTerms,"\p<Default>");
@ -245,6 +255,8 @@ Boolean PresentOpenConnectionDialog(void)
// if (TermPopupHdl == NULL) {
// DisposeHandle((Handle)SessPopupHdl);
// DisposeDialog(dptr);
// //UnlockDialog();
// ResetMenus();
// OutOfMemory(1000);
// return;
// }
@ -472,6 +484,7 @@ Boolean PresentOpenConnectionDialog(void)
DisposeMenu(SessPopupHdl); // drh Ñ Bug fix: memory leak
DisposeDialog(dptr);
ResetMenus();
//UnlockDialog();
return;
}
@ -481,6 +494,7 @@ Boolean PresentOpenConnectionDialog(void)
DisposeMenu(SessPopupHdl); // drh Ñ Bug fix: memory leak
DisposeDialog(dptr);
ResetMenus();
//UnlockDialog();
return;
}
@ -502,6 +516,7 @@ Boolean PresentOpenConnectionDialog(void)
DisposeMenu(SessPopupHdl); // drh Ñ Bug fix: memory leak
DisposeDialog(dptr);
ResetMenus();
//UnlockDialog();
OutOfMemory(1000);
return;
}
@ -514,6 +529,8 @@ Boolean PresentOpenConnectionDialog(void)
// if (InitParams == NULL) {
// OutOfMemory(1000);
// DisposeDialog(dptr);
// ResetMenus();
// //UnlockDialog();
// return;
// }
// }
@ -564,6 +581,7 @@ Boolean PresentOpenConnectionDialog(void)
DisposeMenu(SessPopupHdl); // drh Ñ Bug fix: memory leak
DisposeDialog(dptr);
ResetMenus();
//UnlockDialog();
success = CreateConnectionFromParams(InitParams);
return success;

View File

@ -61,6 +61,7 @@ extern WindRec *screens,
extern Cursor *theCursors[];
extern Boolean gHaveDragMgr;
static gHaveInstalledNotification = 0;
NMRec *nRecPtr;
@ -1085,8 +1086,10 @@ void HandleEvent(EventRecord *myEvent) //CCP split this from DoEvents so we can
KeyScript(smRoman);
haveChangedKCHR = FALSE;
}
AdjustMenus();
DrawMenuBar();
i=WindowPtr2ScreenIndex((GrafPtr) myEvent->message); /* We need to know who */
if (i>=0)
{
@ -1135,7 +1138,6 @@ void HandleEvent(EventRecord *myEvent) //CCP split this from DoEvents so we can
}
}
}
}
else //its a disable event
{
@ -1328,11 +1330,9 @@ void HandleModeless(EventRecord *theEvent, DialogPtr dlogp, short theItem)
if (theItem == 1) {
updateCursor(1);
CloseMacros(&TelInfo->newMacros, dlogp);
TelInfo->macrosModeless = 0;
} else if (theItem == 2) {
updateCursor(1);
CancelMacros(&TelInfo->newMacros, dlogp);
TelInfo->macrosModeless = 0;
}
/* NONO */
} else if (dlogp == key_dlog) {

View File

@ -65,6 +65,7 @@ static short lastMenyCommandKeys = -1; //whether last menu set had command keys
//char *tempspot; /* temporary storage ~255 bytes malloc-ed */
extern int gMovableModal;
/*
* External variable declarations (those which we borrow )
@ -129,7 +130,11 @@ void AdjustMenus(void)
{
short i;
WindowPtr wind;
if (gMovableModal) {
return;
}
if ((wind = FrontWindow()) != NULL &&
((((WindowPeek)wind)->windowKind >= userKind)
|| (((WindowPeek)wind)->windowKind == dialogKind)))
@ -2033,6 +2038,10 @@ void DoTheMenuChecks(void)
short active;
short windownum;
if (gMovableModal) {
return;
}
if (TelInfo->numwindows>0)
{
EnableItem( myMenus[Conn],0);
@ -2143,6 +2152,7 @@ long SetOtherFontSize(short currentSize)
if (ditem == DLOGCancel) {
DisposeDialog( dtemp);
ResetMenus();
return currentSize;
}
@ -2199,6 +2209,7 @@ void SetScreenDimensions(short scrn, short modifiers)
if (ditem == DLOGCancel) {
DisposeDialog( dtemp);
ResetMenus();
return;
}

View File

@ -67,6 +67,7 @@
extern ApplicationPrefs *gApplicationPrefs;
extern int gMovableModal;
extern int gSetUpMovableModal;
extern int appl_main(int argc, char **argv);
extern char *applname;
@ -786,6 +787,8 @@ Boolean gThreadModal = false;
void LockDialog()
{
while (gSetUpMovableModal)
ssh2_sched();
pthread_mutex_lock( &dialock );
gThreadModal = true;
}
@ -1009,7 +1012,7 @@ void ssh2_doevent(long sleepTime)
extern Boolean haveNotifiedLowMemory;
if ( key_gen == 0 ) {
if (!gThreadModal && !gMovableModal) {
if (!gThreadModal && !gSetUpMovableModal) {
DoEvents(NULL);
}
if (!TelInfo->done) {
@ -1023,7 +1026,7 @@ void ssh2_doevent(long sleepTime)
haveNotifiedLowMemory = true;
}
} else {
if (!gThreadModal && !gMovableModal) {
if (!gThreadModal && !gSetUpMovableModal) {
static unsigned long lastTicks = 0L;
if ( (LMGetTicks() - lastTicks) >= 10 ) {
EventRecord myEvent;