From 40421af6e6571b58b97b3e3372641de3b3ba60d8 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Sat, 25 Jul 2020 14:23:46 +0300 Subject: Fixed event processing for menus and dialogs --- src/app.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/app.c') diff --git a/src/app.c b/src/app.c index e0037f0c..6bf62dc7 100644 --- a/src/app.c +++ b/src/app.c @@ -241,10 +241,11 @@ const iString *execPath_App(void) { return executablePath_CommandLine(&app_.args); } -void processEvents_App(void) { +void processEvents_App(enum iAppEventMode eventMode) { iApp *d = &app_; SDL_Event ev; - while (SDL_WaitEvent(&ev)) { + while ((eventMode == waitForNewEvents_AppEventMode && SDL_WaitEvent(&ev)) || + (eventMode == postedEventsOnly_AppEventMode && SDL_PollEvent(&ev))) { switch (ev.type) { case SDL_QUIT: // if (isModified_Song(d->song)) { @@ -303,7 +304,7 @@ static int run_App_(iApp *d) { SDL_EventState(SDL_DROPFILE, SDL_ENABLE); /* open files via drag'n'drop */ while (d->running) { runTickers_App_(d); - processEvents_App(); /* may wait here for a while */ + processEvents_App(waitForNewEvents_AppEventMode); refresh_App(); } return 0; @@ -429,14 +430,17 @@ iBool handleCommand_App(const char *cmd) { d->historyPos = 0; } /* Insert new item. */ - iHistoryItem item; - init_HistoryItem(&item); - set_String(&item.url, url); - pushBack_Array(&d->history, &item); - /* Don't make it too long. */ - if (size_Array(&d->history) > historyMax_App_) { - deinit_HistoryItem(front_Array(&d->history)); - remove_Array(&d->history, 0); + const iHistoryItem *lastItem = historyItem_App_(d, 0); + if (!lastItem || cmpString_String(&lastItem->url, url) != 0) { + iHistoryItem item; + init_HistoryItem(&item); + set_String(&item.url, url); + pushBack_Array(&d->history, &item); + /* Don't make it too long. */ + if (size_Array(&d->history) > historyMax_App_) { + deinit_HistoryItem(front_Array(&d->history)); + remove_Array(&d->history, 0); + } } } } -- cgit v1.2.3