Skip to content

Commit c981440

Browse files
Fix "Home" button in top menu not stopping apps
1 parent 142eb1d commit c981440

File tree

5 files changed

+14
-17
lines changed

5 files changed

+14
-17
lines changed

internal_filesystem/lib/mpos/apps.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ def start_app(fullname):
131131
# Starts the first launcher that's found
132132
def restart_launcher():
133133
print("restart_launcher")
134-
mpos.ui.empty_screen_stack()
134+
# Stop all apps
135+
mpos.ui.remove_and_stop_all_activities()
135136
# No need to stop the other launcher first, because it exits after building the screen
136137
for app in PackageManager.get_app_list():
137138
if app.is_valid_launcher():
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# lib/mpos/ui/__init__.py
21
from .view import (
3-
setContentView, back_screen, empty_screen_stack,
4-
screen_stack, remove_and_stop_current_activity
2+
setContentView, back_screen,
3+
screen_stack, remove_and_stop_current_activity, remove_and_stop_all_activities
54
)
65
from .gesture_navigation import handle_back_swipe, handle_top_swipe
76
from .topmenu import open_bar, close_bar, open_drawer, drawer_open, NOTIFICATION_BAR_HEIGHT
@@ -13,10 +12,10 @@
1312
get_pointer_xy # ← now correct
1413
)
1514
from .event import get_event_name, print_event
16-
from .util import shutdown, set_foreground_app, get_foreground_app, show_launcher
15+
from .util import shutdown, set_foreground_app, get_foreground_app
1716

1817
__all__ = [
19-
"setContentView", "back_screen", "empty_screen_stack", "remove_and_stop_current_activity"
18+
"setContentView", "back_screen", "remove_and_stop_current_activity", "remove_and_stop_all_activities"
2019
"handle_back_swipe", "handle_top_swipe",
2120
"open_bar", "close_bar", "open_drawer", "drawer_open", "NOTIFICATION_BAR_HEIGHT",
2221
"save_and_clear_current_focusgroup",
@@ -25,5 +24,5 @@
2524
"min_resolution", "max_resolution",
2625
"get_pointer_xy",
2726
"get_event_name", "print_event",
28-
"shutdown", "set_foreground_app", "get_foreground_app", "show_launcher"
27+
"shutdown", "set_foreground_app", "get_foreground_app"
2928
]

internal_filesystem/lib/mpos/ui/topmenu.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def settings_event(e):
276276
def launcher_event(e):
277277
print("Home button pressed!")
278278
close_drawer(True)
279-
mpos.ui.show_launcher()
279+
mpos.apps.restart_launcher()
280280
launcher_btn.add_event_cb(launcher_event,lv.EVENT.CLICKED,None)
281281
'''
282282
sleep_btn=lv.button(drawer)
@@ -295,7 +295,7 @@ def sleep_event(e):
295295
else: # assume unix:
296296
# maybe do a system suspend here? or at least show a popup toast "not supported"
297297
close_drawer(True)
298-
show_launcher()
298+
mpos.apps.restart_launcher()
299299
sleep_btn.add_event_cb(sleep_event,lv.EVENT.CLICKED,None)
300300
'''
301301
restart_btn=lv.button(drawer)

internal_filesystem/lib/mpos/ui/util.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ def get_foreground_app():
1414
global _foreground_app_name
1515
return _foreground_app_name
1616

17-
def show_launcher():
18-
restart_launcher()
19-
2017
def shutdown():
2118
print("Shutting down...")
2219
lv.deinit()

internal_filesystem/lib/mpos/ui/view.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
# lib/mpos/ui/view.py
21
import lvgl as lv
32
from ..apps import restart_launcher
43
from .focus import save_and_clear_current_focusgroup
54
from .topmenu import open_bar
65

76
screen_stack = []
87

9-
def empty_screen_stack():
10-
global screen_stack
11-
screen_stack.clear()
12-
138
def setContentView(new_activity, new_screen):
149
global screen_stack
1510
if screen_stack:
@@ -28,6 +23,11 @@ def setContentView(new_activity, new_screen):
2823
if new_activity:
2924
new_activity.onResume(new_screen)
3025

26+
def remove_and_stop_all_activities():
27+
global screen_stack
28+
while len(screen_stack):
29+
remove_and_stop_current_activity()
30+
3131
def remove_and_stop_current_activity():
3232
current_activity, current_screen, current_focusgroup, _ = screen_stack.pop()
3333
if current_activity:

0 commit comments

Comments
 (0)