Fix "Home" button in top menu not stopping apps

This commit is contained in:
Thomas Farstrike
2025-11-08 07:08:17 +01:00
parent 142eb1dd4d
commit c9814403ab
5 changed files with 14 additions and 17 deletions
+2 -1
View File
@@ -131,7 +131,8 @@ def start_app(fullname):
# Starts the first launcher that's found
def restart_launcher():
print("restart_launcher")
mpos.ui.empty_screen_stack()
# Stop all apps
mpos.ui.remove_and_stop_all_activities()
# No need to stop the other launcher first, because it exits after building the screen
for app in PackageManager.get_app_list():
if app.is_valid_launcher():
+5 -6
View File
@@ -1,7 +1,6 @@
# lib/mpos/ui/__init__.py
from .view import (
setContentView, back_screen, empty_screen_stack,
screen_stack, remove_and_stop_current_activity
setContentView, back_screen,
screen_stack, remove_and_stop_current_activity, remove_and_stop_all_activities
)
from .gesture_navigation import handle_back_swipe, handle_top_swipe
from .topmenu import open_bar, close_bar, open_drawer, drawer_open, NOTIFICATION_BAR_HEIGHT
@@ -13,10 +12,10 @@ from .display import (
get_pointer_xy # ← now correct
)
from .event import get_event_name, print_event
from .util import shutdown, set_foreground_app, get_foreground_app, show_launcher
from .util import shutdown, set_foreground_app, get_foreground_app
__all__ = [
"setContentView", "back_screen", "empty_screen_stack", "remove_and_stop_current_activity"
"setContentView", "back_screen", "remove_and_stop_current_activity", "remove_and_stop_all_activities"
"handle_back_swipe", "handle_top_swipe",
"open_bar", "close_bar", "open_drawer", "drawer_open", "NOTIFICATION_BAR_HEIGHT",
"save_and_clear_current_focusgroup",
@@ -25,5 +24,5 @@ __all__ = [
"min_resolution", "max_resolution",
"get_pointer_xy",
"get_event_name", "print_event",
"shutdown", "set_foreground_app", "get_foreground_app", "show_launcher"
"shutdown", "set_foreground_app", "get_foreground_app"
]
+2 -2
View File
@@ -276,7 +276,7 @@ def create_drawer(display=None):
def launcher_event(e):
print("Home button pressed!")
close_drawer(True)
mpos.ui.show_launcher()
mpos.apps.restart_launcher()
launcher_btn.add_event_cb(launcher_event,lv.EVENT.CLICKED,None)
'''
sleep_btn=lv.button(drawer)
@@ -295,7 +295,7 @@ def create_drawer(display=None):
else: # assume unix:
# maybe do a system suspend here? or at least show a popup toast "not supported"
close_drawer(True)
show_launcher()
mpos.apps.restart_launcher()
sleep_btn.add_event_cb(sleep_event,lv.EVENT.CLICKED,None)
'''
restart_btn=lv.button(drawer)
-3
View File
@@ -14,9 +14,6 @@ def get_foreground_app():
global _foreground_app_name
return _foreground_app_name
def show_launcher():
restart_launcher()
def shutdown():
print("Shutting down...")
lv.deinit()
+5 -5
View File
@@ -1,4 +1,3 @@
# lib/mpos/ui/view.py
import lvgl as lv
from ..apps import restart_launcher
from .focus import save_and_clear_current_focusgroup
@@ -6,10 +5,6 @@ from .topmenu import open_bar
screen_stack = []
def empty_screen_stack():
global screen_stack
screen_stack.clear()
def setContentView(new_activity, new_screen):
global screen_stack
if screen_stack:
@@ -28,6 +23,11 @@ def setContentView(new_activity, new_screen):
if new_activity:
new_activity.onResume(new_screen)
def remove_and_stop_all_activities():
global screen_stack
while len(screen_stack):
remove_and_stop_current_activity()
def remove_and_stop_current_activity():
current_activity, current_screen, current_focusgroup, _ = screen_stack.pop()
if current_activity: