Fix for opening files with program association; shouldn't open popup anymore

This commit is contained in:
2025-12-06 22:47:01 -05:00
parent 63c0ffe166
commit 10b37e9854
2 changed files with 8 additions and 5 deletions

View File

@@ -231,7 +231,7 @@ namespace anm2ed
{ {
if (path.empty()) continue; if (path.empty()) continue;
SDL_Event event{}; SDL_Event event{};
event.type = SDL_EVENT_DROP_FILE; event.type = SDL_EVENT_USER;
event.drop.data = SDL_strdup(path.c_str()); event.drop.data = SDL_strdup(path.c_str());
event.drop.windowID = window ? SDL_GetWindowID(window) : 0; event.drop.windowID = window ? SDL_GetWindowID(window) : 0;
SDL_PushEvent(&event); SDL_PushEvent(&event);

View File

@@ -36,7 +36,6 @@ namespace anm2ed
void State::update(SDL_Window*& window, Settings& settings) void State::update(SDL_Window*& window, Settings& settings)
{ {
SDL_Event event{}; SDL_Event event{};
bool openDroppedDocumentsImmediately = manager.documents.empty();
while (SDL_PollEvent(&event)) while (SDL_PollEvent(&event))
{ {
@@ -49,10 +48,8 @@ namespace anm2ed
if (filesystem::path_is_extension(droppedFile, "anm2")) if (filesystem::path_is_extension(droppedFile, "anm2"))
{ {
std::filesystem::path droppedPath{droppedFile}; std::filesystem::path droppedPath{droppedFile};
if (openDroppedDocumentsImmediately) if (manager.documents.empty())
{
manager.open(droppedPath); manager.open(droppedPath);
}
else else
{ {
if (std::find(manager.anm2DragDropPaths.begin(), manager.anm2DragDropPaths.end(), droppedPath) == if (std::find(manager.anm2DragDropPaths.begin(), manager.anm2DragDropPaths.end(), droppedPath) ==
@@ -85,6 +82,12 @@ namespace anm2ed
} }
break; break;
} }
case SDL_EVENT_USER:
{
auto droppedFile = event.drop.data;
if (filesystem::path_is_extension(droppedFile, "anm2")) manager.open(droppedFile);
break;
}
case SDL_EVENT_QUIT: case SDL_EVENT_QUIT:
isQuitting = true; isQuitting = true;
break; break;