--- nono/wx/wxapp.cpp 2026/04/29 17:04:36 1.1.1.3 +++ nono/wx/wxapp.cpp 2026/04/29 17:04:53 1.1.1.7 @@ -7,10 +7,11 @@ #include "wxmainframe.h" #include "wxmainview.h" #include "wxtextpanel.h" +#include "wxversion.h" #include "mainapp.h" #include "mpu680x0.h" #include "mpu88xx0.h" -#include "vm.h" +#include "scheduler.h" #include // イベントタイプの定義 @@ -20,8 +21,10 @@ wxDEFINE_EVENT(WXW_EVT_HALT_NOTIFY, wxCo class WXApp : public wxApp { + using inherited = wxApp; public: bool OnInit(); + int OnRun() override; private: bool ParseMonitors(const wxString& str); int SearchMonitorName(const char *name); @@ -42,8 +45,17 @@ IMPLEMENT_APP(WXApp) bool WXApp::OnInit() { - if (!gMainApp.Init(false, argc, argv)) { - return false; + return true; +} + +int +WXApp::OnRun() +{ + int rv; + + rv = gMainApp.Init1(false, argc, argv); + if (rv != MainApp::PASS) { + return rv; } // 環境変数 $NONO_BUILD_HOME が定義されていればカタログ検索パスに @@ -60,41 +72,51 @@ WXApp::OnInit() // --fontsize テキスト系コントロールのフォントサイズ // 紛らわしいが ::global_fontsize は 12, 16 とかいう値。 - // WXTextPanel::global_fontsize (fontsize_t) は enum 値。 - fontsize_t fontsize; + // WXTextPanel::global_fontsize (FontId) は enum 値。 + FontId fontid; switch (gMainApp.fontsize) { case 12: - fontsize = FONT_6x12; + fontid = FontId::_6x12; break; case 16: - fontsize = FONT_8x16; + fontid = FontId::_8x16; break; default: warnx("invalid fontsize: %d", gMainApp.fontsize); - return false; + return EXIT_FAILURE; } - WXTextPanel::global_fontsize = fontsize; + WXTextPanel::global_fontid = fontid; + + // グローバルオブジェクト (どこでやるのがいいか) + gHostInfo.reset(new HostInfoMonitor()); // -M 起動時に表示するモニタ if (!gMainApp.monitor_opt.empty()) { if (!ParseMonitors(gMainApp.monitor_opt)) { - return false; + return EXIT_FAILURE; } } // -s screen scale WXMainView::screen_scale = gMainApp.screen_scale; - // 引数処理が終わったので VM 開始。 - if (!gMainApp.Start()) { - return false; + // 引数処理が終わったので、スレッド作成を伴う初期化。 + if (!gMainApp.Init2()) { + return EXIT_FAILURE; + } + + // VM にコールバックを登録 + gScheduler->SetPowerOffCallback(wxmainframe_poweroff_callback); + if (gMPU680x0) { + gMPU680x0->SetHaltCallback(wxmainframe_halt_callback, this); } // メインウィンドウ gMainFrame = new WXMainFrame(NULL); gMainFrame->Show(true); SetTopWindow(gMainFrame); - return true; + + return inherited::OnRun(); } // -M オプションの解析。書式は