shithub: pt2-clone

Download patch

ref: f4ba52e6835e5935ad294b7dbbfbce3fc36d40c1
parent: 2daf0a078ff8cd44d59c114bfaba6190af7bbfe3
author: Olav Sørensen <[email protected]>
date: Fri May 19 14:33:20 EDT 2023

mac: Don't make cmd+q quit (used for transpose)

--- a/src/pt2_keyboard.c
+++ b/src/pt2_keyboard.c
@@ -2675,6 +2675,13 @@
 			if (keyb.leftAmigaPressed)
 			{
 				trackNoteDown(TRANSPOSE_ALL, 0, MOD_ROWS - 1);
+#ifdef __APPLE__
+				/* On Mac, command+Q sends a quit signal to the program.
+				** However, command+Q is also one of the transpose keys in this ProTracker port.
+				** Ignore the signal if command+Q was pressed.
+				*/
+				editor.macCmdQIssued = true;
+#endif
 			}
 			else if (keyb.leftCtrlPressed)
 			{
--- a/src/pt2_main.c
+++ b/src/pt2_main.c
@@ -415,9 +415,20 @@
 			loadDroppedFile(event.drop.file, (uint32_t)strlen(event.drop.file), false, true);
 			SDL_free(event.drop.file);
 		}
-		if (event.type == SDL_QUIT)
+		else if (event.type == SDL_QUIT)
 		{
-			handleSigTerm();
+#ifdef __APPLE__
+			/* On Mac, command+Q sends a quit signal to the program.
+			** However, command+Q is also one of the transpose keys in this ProTracker port.
+			** Ignore the signal if command+Q was pressed.
+			*/
+			if (!editor.macCmdQIssued)
+#endif
+				handleSigTerm();
+
+#ifdef __APPLE__
+			editor.macCmdQIssued = false; // read note above
+#endif
 		}
 		else if (event.type == SDL_KEYUP)
 		{
--- a/src/pt2_structs.h
+++ b/src/pt2_structs.h
@@ -188,6 +188,10 @@
 	note_t trackBuffer[MOD_ROWS], cmdsBuffer[MOD_ROWS], blockBuffer[MOD_ROWS];
 	note_t patternBuffer[MOD_ROWS * PAULA_VOICES], undoBuffer[MOD_ROWS * PAULA_VOICES];
 	SDL_Thread *mod2WavThread, *pat2SmpThread;
+
+#ifdef __APPLE__
+	bool macCmdQIssued;
+#endif
 } editor_t;
 
 typedef struct diskop_t