From bc51d4bd52b5d0a7bb4feddea7bb9d73e449f7d8 Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Thu, 24 Oct 2024 02:28:19 -0400 Subject: [PATCH] fix: notepad save issue --- src/gui/src/helpers/launch_app.js | 23 ++++++++++++++++++++++- src/gui/src/services/ExecService.js | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/gui/src/helpers/launch_app.js b/src/gui/src/helpers/launch_app.js index 7c3f144a..36367664 100644 --- a/src/gui/src/helpers/launch_app.js +++ b/src/gui/src/helpers/launch_app.js @@ -18,7 +18,7 @@ */ import path from "../lib/path.js" -import { PROCESS_RUNNING, PortalProcess, PseudoProcess } from "../definitions.js"; +import { PROCESS_IPC_ATTACHED, PROCESS_RUNNING, PortalProcess, PseudoProcess } from "../definitions.js"; import UIWindow from "../UI/UIWindow.js"; /** @@ -361,6 +361,26 @@ const launch_app = async (options)=>{ const el = await el_win; process.references.el_win = el; + + if ( ! options.launched_by_exec_service ) { + process.onchange('ipc_status', value => { + if ( value !== PROCESS_IPC_ATTACHED ) return; + + $(process.references.iframe).attr('data-appUsesSDK', 'true'); + + send_child_launched_msg({ uses_sdk: true }); + + // Send any saved broadcasts to the new app + globalThis.services.get('broadcast').sendSavedBroadcastsTo(child_instance_id); + + // If `window-active` is set (meanign the window is focused), focus the window one more time + // this is to ensure that the iframe is `definitely` focused and can receive keyboard events (e.g. keydown) + if($(process.references.el_win).hasClass('window-active')){ + $(process.references.el_win).focusWindow(); + } + }); + } + process.chstatus(PROCESS_RUNNING); $(el).on('remove', () => { @@ -368,6 +388,7 @@ const launch_app = async (options)=>{ svc_process.unregister(process.uuid); }); + return process; } diff --git a/src/gui/src/services/ExecService.js b/src/gui/src/services/ExecService.js index f3478b64..69ecd170 100644 --- a/src/gui/src/services/ExecService.js +++ b/src/gui/src/services/ExecService.js @@ -32,6 +32,7 @@ export class ExecService extends Service { // The "body" of this method is in a separate file const child_process = await launch_app({ + launched_by_exec_service: true, name: app_name, pseudonym, args: args ?? {},