commit 46becee7d2a7ecfcd1bdedaa1b07c84deeec5a84
parent ba7827f46f5471a47556e74cc4cf7ddfce111041
Author: Olav Sørensen <olav.sorensen@live.no>
Date: Mon, 30 Oct 2023 13:45:18 +0100
Some window event handling changes
Diffstat:
2 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/src/ft2_events.c b/src/ft2_events.c
@@ -220,9 +220,6 @@ bool handleSingleInstancing(int32_t argc, char **argv)
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 @@ static void handleSysMsg(SDL_Event inputEvent)
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 @@ static void handleSDLEvents(void)
}
#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 @@ static void handleSDLEvents(void)
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 @@ static void handleSDLEvents(void)
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);
}
diff --git a/src/ft2_module_loader.c b/src/ft2_module_loader.c
@@ -694,14 +694,8 @@ void loadDroppedFile(char *fullPathUTF8, bool songModifiedCheck)
}
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);