diff --git a/apps/misc.c b/apps/misc.c
index a08dac3..49141fe 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -256,12 +256,6 @@ static void system_restore(void)
static bool clean_shutdown(void (*callback)(void *), void *parameter)
{
-#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
- (void)callback;
- (void)parameter;
- bookmark_autobookmark(false);
- call_storage_idle_notifys(true);
-#else
long msg_id = -1;
int i;
@@ -372,7 +366,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
shutdown_hw();
}
-#endif
+
return false;
}
diff --git a/firmware/target/hosted/maemo/maemo-thread.c b/firmware/target/hosted/maemo/maemo-thread.c
index f655ed5..3ec0151 100644
--- a/firmware/target/hosted/maemo/maemo-thread.c
+++ b/firmware/target/hosted/maemo/maemo-thread.c
@@ -23,6 +23,7 @@
#include <libhal.h>
#include <libosso.h>
#include <SDL_thread.h>
+#include <SDL_events.h>
#include "config.h"
#include "system.h"
@@ -205,16 +206,26 @@ bool battery_level_safe(void)
void set_poweroff_timeout(int timeout)
{
(void)timeout;
+ printf("TOMJ: Called set_poweroff_timer: %d\n", timeout);
}
void reset_poweroff_timer(void)
{
+ printf("TOMJ: Called reset_poweroff_timer\n");
}
void shutdown_hw(void)
{
+ printf("TOMJ: Called shutdown_hw\n");
+
+ /* Shut down SDL gui loop */
+ SDL_Event event;
+ memset(&event, 0, sizeof(SDL_Event));
+ event.type = SDL_USEREVENT;
+ SDL_PushEvent(&event);
}
void cancel_shutdown(void)
{
+ printf("TOMJ: Called cancel_shutdown\n");
}
diff --git a/firmware/target/hosted/sdl/button-sdl.c b/firmware/target/hosted/sdl/button-sdl.c
index 25dad09..2d6ef70 100644
--- a/firmware/target/hosted/sdl/button-sdl.c
+++ b/firmware/target/hosted/sdl/button-sdl.c
@@ -261,7 +261,12 @@ static bool event_handler(SDL_Event *event)
break;
}
case SDL_QUIT:
+ /* Post poweroff. Will post SDL user event in shutdown_hw() if succesful. */
+ queue_broadcast(SYS_POWEROFF, 0);
+ break;
+ case SDL_USEREVENT:
return true;
+ break;
}
return false;