mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-28 17:53:08 +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:
parent
ef6d378c5e
commit
cb1b26e5e6
@ -636,6 +636,9 @@ void GMenu2X::mainLoop() {
|
|||||||
gotEvent = input.getButton(&button, wait);
|
gotEvent = input.getButton(&button, wait);
|
||||||
} while (wait && !gotEvent);
|
} while (wait && !gotEvent);
|
||||||
if (gotEvent) {
|
if (gotEvent) {
|
||||||
|
if (button == InputManager::QUIT) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
for (auto it = layers.rbegin(); it != layers.rend(); ++it) {
|
for (auto it = layers.rbegin(); it != layers.rend(); ++it) {
|
||||||
if ((*it)->handleButtonPress(button)) {
|
if ((*it)->handleButtonPress(button)) {
|
||||||
break;
|
break;
|
||||||
|
@ -275,6 +275,10 @@ bool InputManager::getButton(Button *button, bool wait) {
|
|||||||
*button = REPAINT;
|
*button = REPAINT;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case SDL_QUIT:
|
||||||
|
*button = QUIT;
|
||||||
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,9 @@ public:
|
|||||||
ACCEPT, CANCEL,
|
ACCEPT, CANCEL,
|
||||||
ALTLEFT, ALTRIGHT,
|
ALTLEFT, ALTRIGHT,
|
||||||
MENU, SETTINGS,
|
MENU, SETTINGS,
|
||||||
REPAINT,
|
// Events that are not actually buttons:
|
||||||
|
// (not included in BUTTON_TYPE_SIZE)
|
||||||
|
REPAINT, QUIT,
|
||||||
};
|
};
|
||||||
#define BUTTON_TYPE_SIZE 10
|
#define BUTTON_TYPE_SIZE 10
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user