Files
AskaEth ddc8d35eb9 fix: M6.41批 — 启动失败原因透传 + 阅读器左缘返回/阅读页接入view栈 + 后台管理按钮点不动 + 阅读器瘦身(fonts common+页位图释放) + files txt换行
- launcher(453): app_launcher.c g_launch_fail_reason+launch_fail()统一出口(5失败点 fork OOM/exec/no such file/missing dep/execpipe)+main_menu.c launch_fail_toast(缺依赖/CANNOT START: name(reason))+toast256
- launcher(457): bg_page.c bgm_enumerate跳过term_at_ms(杀后当下消失)+不可杀行按钮置灰+row_tap/top_action返回1; subpage.c 消warning
- reader(454): reader_on_swipe LEFT/RIGHT→返回(先关overlay否则page_pop回书架)+app.c书架根LEFT→exit
- reader(458瘦身A+B): app.json fonts full→common(省13MB atlas)+reader.c RD_PAGE_CACHE 3→2+g_anim_old懒分配/anim_done释放+on_enter/on_leave页位图离开释放重建
- reader(459导航): reader_open返回int+shelf点书push ACT_READER(阅读页接入view栈,on_enter/on_leave驱动) — 使454左缘返回+458瘦身B真正生效
- files(455): viewer.c viewer_cp_len+按码位折行(txt中文不冲出右缘)

0warning;宿主测试全过;files二进制已热更
2026-09-04 19:43:28 +08:00

82 lines
2.8 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* app.c — os.meow.reader 应用装配层:main + 初始化 + 事件分发。
*
* 职责(SDK_VIEW_FRAMEWORK_DESIGN.md §B.2):main 只做 init/建页/跑事件循环/清理;把
* meow_ui_run 的平铺输入回调(key/tap/swipe/tick/touch)路由到当前活动页(shelf/reader)。
* 页面切换走 meow_view_page_push/pop(on_enter/on_leave 唯一入口)。
*/
#include "reader_internal.h"
#include "meow_ui_internal.h" /* 阅读页 blit 需要 back_buf 访问器(决策见报告) */
#include "app/reader_ipc.h"
#include <signal.h>
static meow_view *g_shelf_view;
static meow_view *g_reader_view;
static meow_view *g_settings_view;
static void on_sigterm(int s) { (void)s; meow_ui_request_exit(); }
static void app_on_key(int keycode, int is_down) { (void)keycode; (void)is_down; }
static void app_on_tap(int x, int y)
{
if (settings_is_active()) { settings_on_tap(x, y); return; }
if (reader_is_active()) { reader_on_tap(x, y); return; }
shelf_on_tap(x, y);
}
static void app_on_swipe(int dir, int dx, int dy)
{
(void)dy; (void)dx;
if (settings_is_active()) { return; } /* 设置页滑动不翻页 */
if (reader_is_active()) { reader_on_swipe(dir, dx, dy); return; }
if (shelf_is_active()) {
/* 书架根页左缘右滑(返回手势)→ 退出 App(镜像 hello_app/files_app 的 LEFT→返回)。 */
if (dir == MEOW_SWIPE_LEFT) { meow_ui_request_exit(); return; }
shelf_on_swipe(dir, dx, dy); return;
}
if (dir == MEOW_SWIPE_LEFT) { meow_ui_request_exit(); }
}
static void app_on_tick(void)
{
uint64_t now = meow_ui_time_ms();
if (reader_is_active()) { reader_on_tick(now); return; }
}
static void app_on_touch_down(int x, int y)
{
if (reader_is_active()) { reader_on_touch_down(x, y); return; }
}
static void app_on_touch_move(int x, int y)
{
if (reader_is_active()) { reader_on_touch_move(x, y); return; }
}
int main(void)
{
meow_log(MEOW_LOG_INFO, "start");
meow_ui_opts o = { 480, 720 };
if (meow_ui_init(&o) != 0) { meow_log(MEOW_LOG_ERROR, "init failed"); return 1; }
meow_theme_add_listener(NULL);
signal(SIGTERM, on_sigterm);
g_shelf_view = shelf_view_create();
g_reader_view = reader_view_create();
g_settings_view = settings_view_create();
meow_view_page_push(ACT_SHELF);
reader_ipc_start(); /* E:系统翻页信号接收(后台线程,best-effort) */
meow_ui_events ev = { app_on_key, app_on_tap, app_on_swipe, app_on_tick,
NULL, app_on_touch_down, app_on_touch_move };
meow_ui_run(&ev);
reader_ipc_stop();
meow_view_free(g_settings_view);
meow_view_free(g_reader_view);
meow_view_free(g_shelf_view);
meow_ui_shutdown();
meow_log(MEOW_LOG_INFO, "exit");
return 0;
}