summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2022-01-16 08:36:36 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2022-01-16 08:36:36 +0200
commit88a15ca1069f079d3d584a34a4d03c1d0b22c79a (patch)
treeeaf5622134538da2fed65495de2014dde727169a
parent3a1865d2d14710fda4f97ff83d6147104d9a5ae0 (diff)
Event processing issue that causes menus to be dismissed immediately
This seems like a regression in SDL. SDL_PollEvent() doesn't behave like before. As a workaround, wait for events with a very short timeout. IssueID #436
-rw-r--r--src/app.c7
-rw-r--r--src/ui/util.c5
2 files changed, 11 insertions, 1 deletions
diff --git a/src/app.c b/src/app.c
index 229fde75..d4e09d6f 100644
--- a/src/app.c
+++ b/src/app.c
@@ -1260,7 +1260,14 @@ static iBool nextEvent_App_(iApp *d, enum iAppEventMode eventMode, SDL_Event *ev
1260 return SDL_WaitEvent(event); 1260 return SDL_WaitEvent(event);
1261 } 1261 }
1262 } 1262 }
1263 /* SDL regression circa 2.0.18? SDL_PollEvent() doesn't always return
1264 events posted immediately beforehand. Waiting with a very short timeout
1265 seems to work better. */
1266#if defined (iPlatformLinux)
1267 return SDL_WaitEventTimeout(event, 1);
1268#else
1263 return SDL_PollEvent(event); 1269 return SDL_PollEvent(event);
1270#endif
1264} 1271}
1265 1272
1266static iPtrArray *listWindows_App_(const iApp *d, iPtrArray *windows) { 1273static iPtrArray *listWindows_App_(const iApp *d, iPtrArray *windows) {
diff --git a/src/ui/util.c b/src/ui/util.c
index bdbbb98e..0adaebb6 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -705,6 +705,9 @@ static iBool menuHandler_(iWidget *menu, const char *cmd) {
705 closeMenu_Widget(menu); 705 closeMenu_Widget(menu);
706 return iTrue; 706 return iTrue;
707 } 707 }
708 if (equal_Command(cmd, "cancel") && pointerLabel_Command(cmd, "menu") == menu) {
709 return iFalse;
710 }
708 if (equal_Command(cmd, "contextclick") && pointer_Command(cmd) == menu) { 711 if (equal_Command(cmd, "contextclick") && pointer_Command(cmd) == menu) {
709 return iFalse; 712 return iFalse;
710 } 713 }
@@ -1074,7 +1077,7 @@ void openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, int menuOpenFlags) {
1074 const iBool isPortraitPhone = (isPhone && isPortrait_App()); 1077 const iBool isPortraitPhone = (isPhone && isPortrait_App());
1075 const iBool isSlidePanel = (flags_Widget(d) & horizontalOffset_WidgetFlag) != 0; 1078 const iBool isSlidePanel = (flags_Widget(d) & horizontalOffset_WidgetFlag) != 0;
1076 if (postCommands) { 1079 if (postCommands) {
1077 postCommand_App("cancel"); /* dismiss any other menus */ 1080 postCommandf_App("cancel menu:%p", d); /* dismiss any other menus */
1078 } 1081 }
1079 /* Menu closes when commands are emitted, so handle any pending ones beforehand. */ 1082 /* Menu closes when commands are emitted, so handle any pending ones beforehand. */
1080 processEvents_App(postedEventsOnly_AppEventMode); 1083 processEvents_App(postedEventsOnly_AppEventMode);