1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-12-25 19:33:55 +02:00

Quit GMenu2X when window is closed in main screen

This helps when testing on PC.

I didn't bother to implement the same functionality for all dialog
event loops, since that would be a lot of extra work and not necessary
for the scenario that I need it for: clean exit when running under
Valgrind.
This commit is contained in:
Maarten ter Huurne 2015-04-24 18:07:10 +02:00
parent ef6d378c5e
commit cb1b26e5e6
3 changed files with 10 additions and 1 deletions

View File

@ -636,6 +636,9 @@ void GMenu2X::mainLoop() {
gotEvent = input.getButton(&button, wait);
} while (wait && !gotEvent);
if (gotEvent) {
if (button == InputManager::QUIT) {
break;
}
for (auto it = layers.rbegin(); it != layers.rend(); ++it) {
if ((*it)->handleButtonPress(button)) {
break;

View File

@ -275,6 +275,10 @@ bool InputManager::getButton(Button *button, bool wait) {
*button = REPAINT;
return true;
case SDL_QUIT:
*button = QUIT;
return true;
default:
return false;
}

View File

@ -58,7 +58,9 @@ public:
ACCEPT, CANCEL,
ALTLEFT, ALTRIGHT,
MENU, SETTINGS,
REPAINT,
// Events that are not actually buttons:
// (not included in BUTTON_TYPE_SIZE)
REPAINT, QUIT,
};
#define BUTTON_TYPE_SIZE 10