shithub: ft²

Download patch

ref: 46becee7d2a7ecfcd1bdedaa1b07c84deeec5a84
parent: ba7827f46f5471a47556e74cc4cf7ddfce111041
author: Olav Sørensen <olav.sorensen@live.no>
date: Mon Oct 30 09:45:45 EDT 2023

Some window event handling changes

--- a/src/ft2_events.c
+++ b/src/ft2_events.c
@@ -220,9 +220,6 @@
 
 static void handleSysMsg(SDL_Event inputEvent)
 {
-	if (inputEvent.type != SDL_SYSWMEVENT)
-		return;
-
 	SDL_SysWMmsg *wmMsg = inputEvent.syswm.msg;
 	if (wmMsg->subsystem == SDL_SYSWM_WINDOWS && wmMsg->msg.win.msg == SYSMSG_FILE_ARG)
 	{
@@ -233,16 +230,19 @@
 			if (sharedMemBuf != NULL)
 			{
 				editor.autoPlayOnDrop = true;
-				loadDroppedFile((char *)sharedMemBuf, true);
 
-				UnmapViewOfFile(sharedMemBuf);
-				sharedMemBuf = NULL;
-
-				if (video.window != NULL)
+				if (video.window != NULL && !video.fullscreen)
 				{
-					SDL_RestoreWindow(video.window);
+					if (SDL_GetWindowFlags(video.window) & SDL_WINDOW_MINIMIZED)
+						SDL_RestoreWindow(video.window);
+
 					SDL_RaiseWindow(video.window);
 				}
+
+				loadDroppedFile((char *)sharedMemBuf, true);
+
+				UnmapViewOfFile(sharedMemBuf);
+				sharedMemBuf = NULL;
 			}
 
 			CloseHandle(hMapFile);
@@ -419,7 +419,8 @@
 		}
 
 #ifdef _WIN32
-		handleSysMsg(event);
+		if (event.type == SDL_SYSWMEVENT)
+			handleSysMsg(event);
 #endif
 		// text input when editing texts
 		if (event.type == SDL_TEXTINPUT)
@@ -452,11 +453,17 @@
 		else if (event.type == SDL_DROPFILE)
 		{
 			editor.autoPlayOnDrop = false;
+
+			if (!video.fullscreen)
+			{
+				if (SDL_GetWindowFlags(video.window) & SDL_WINDOW_MINIMIZED)
+					SDL_RestoreWindow(video.window);
+
+				SDL_RaiseWindow(video.window);
+			}
+
 			loadDroppedFile(event.drop.file, true);
 			SDL_free(event.drop.file);
-
-			SDL_RestoreWindow(video.window);
-			SDL_RaiseWindow(video.window);
 		}
 		else if (event.type == SDL_QUIT)
 		{
@@ -475,7 +482,9 @@
 				if (!video.fullscreen)
 				{
 					// de-minimize window and set focus so that the user sees the message box
-					SDL_RestoreWindow(video.window);
+					if (SDL_GetWindowFlags(video.window) & SDL_WINDOW_MINIMIZED)
+						SDL_RestoreWindow(video.window);
+
 					SDL_RaiseWindow(video.window);
 				}
 
--- a/src/ft2_module_loader.c
+++ b/src/ft2_module_loader.c
@@ -694,14 +694,8 @@
 	}
 	else if (fileIsModule(fullPathU))
 	{
-		SDL_RestoreWindow(video.window);
-
 		if (songModifiedCheck && song.isModified)
 		{
-			// de-minimize window and set focus so that the user sees the message box
-			SDL_RestoreWindow(video.window);
-			SDL_RaiseWindow(video.window);
-
 			if (!askUnsavedChanges(ASK_TYPE_LOAD_SONG))
 			{
 				free(fullPathU);