feat: add processmanager.create to diskutil and notepad
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
- diskutil: add proc_pid global, diskutil_entry idle proc, create process on launch with setWindowOwner, kill on close, zero proc_pid in init - notepad: add pid field to TNotepadState, notepad_entry idle proc, create process on launch with setWindowOwner, kill pid in doCloseWindow - both apps now appear in PS and are manageable via KILL/TERMINATE
This commit is contained in:
@@ -23,6 +23,8 @@ uses
|
||||
lmemorymanager,
|
||||
lvgl,
|
||||
MBR,
|
||||
processmanager,
|
||||
proctypes,
|
||||
storagemanager,
|
||||
storagetypes,
|
||||
strings,
|
||||
@@ -43,6 +45,7 @@ const
|
||||
|
||||
var
|
||||
win_id : uint32;
|
||||
proc_pid : uint32;
|
||||
sidebar : Plv_obj;
|
||||
detail : Plv_obj;
|
||||
{ Current selection }
|
||||
@@ -64,6 +67,7 @@ var
|
||||
Forward declarations
|
||||
============================================================ }
|
||||
procedure launch; forward;
|
||||
procedure diskutil_entry(ctx : PProcessContext); forward;
|
||||
procedure onClose(wid: uint32); forward;
|
||||
procedure refreshSidebar; forward;
|
||||
procedure showDeviceDetail(devIdx: uint32); forward;
|
||||
@@ -1278,10 +1282,20 @@ end;
|
||||
{ ============================================================
|
||||
Window close handler
|
||||
============================================================ }
|
||||
procedure diskutil_entry(ctx : PProcessContext);
|
||||
begin
|
||||
while (ctx^.State <> psFinished) and (ctx^.PendingMsg <> smKill) and (ctx^.PendingMsg <> smTerminate) do
|
||||
processmanager.proc_yield;
|
||||
end;
|
||||
|
||||
procedure onClose(wid: uint32);
|
||||
begin
|
||||
tracer.push_trace('diskutil.onClose');
|
||||
closeMsgBox;
|
||||
if proc_pid <> 0 then begin
|
||||
processmanager.kill(proc_pid);
|
||||
proc_pid := 0;
|
||||
end;
|
||||
windows.destroyWindow(wid);
|
||||
win_id := 0;
|
||||
sidebar := nil;
|
||||
@@ -1299,6 +1313,7 @@ var
|
||||
wx, wy : sint32;
|
||||
content : Plv_obj;
|
||||
lbl : Plv_obj;
|
||||
ctx : PProcessContext;
|
||||
begin
|
||||
tracer.push_trace('diskutil.launch');
|
||||
|
||||
@@ -1387,6 +1402,13 @@ begin
|
||||
|
||||
refreshSidebar;
|
||||
|
||||
{ Create process so diskutil appears in PS and is manageable }
|
||||
ctx := processmanager.create('Disk Utility', @diskutil_entry, nil, 1);
|
||||
if ctx <> nil then begin
|
||||
proc_pid := ctx^.ProcessID;
|
||||
windows.setWindowOwner(win_id, ctx^.ProcessID);
|
||||
end;
|
||||
|
||||
tracer.pop_trace;
|
||||
end;
|
||||
|
||||
@@ -1397,6 +1419,7 @@ procedure init();
|
||||
begin
|
||||
tracer.push_trace('diskutil.init');
|
||||
win_id := 0;
|
||||
proc_pid := 0;
|
||||
sidebar := nil;
|
||||
detail := nil;
|
||||
sel_mode := SEL_NONE;
|
||||
|
||||
@@ -34,6 +34,8 @@ uses
|
||||
keyboard,
|
||||
lmemorymanager,
|
||||
lvgl,
|
||||
processmanager,
|
||||
proctypes,
|
||||
storagetypes,
|
||||
strings,
|
||||
syslog,
|
||||
@@ -74,6 +76,7 @@ type
|
||||
PNotepadState = ^TNotepadState;
|
||||
TNotepadState = record
|
||||
win_id : uint32;
|
||||
pid : uint32;
|
||||
ta : Plv_obj;
|
||||
status_label : Plv_obj;
|
||||
dirty_label : Plv_obj;
|
||||
@@ -92,6 +95,7 @@ var
|
||||
{ ============================================================
|
||||
Forward declarations
|
||||
============================================================ }
|
||||
procedure notepad_entry(ctx: PProcessContext); forward;
|
||||
procedure launch; forward;
|
||||
procedure onClose(wid: uint32); forward;
|
||||
procedure updateStatusBar(state: PNotepadState); forward;
|
||||
@@ -281,9 +285,19 @@ end;
|
||||
doCloseWindow — unconditionally destroy window + free state.
|
||||
Called by discard-confirm dialogs and by onClose when clean.
|
||||
============================================================ }
|
||||
procedure notepad_entry(ctx : PProcessContext);
|
||||
begin
|
||||
while (ctx^.State <> psFinished) and (ctx^.PendingMsg <> smKill) and (ctx^.PendingMsg <> smTerminate) do
|
||||
processmanager.proc_yield;
|
||||
end;
|
||||
|
||||
procedure doCloseWindow;
|
||||
begin
|
||||
if g_state <> nil then begin
|
||||
if g_state^.pid <> 0 then begin
|
||||
processmanager.kill(g_state^.pid);
|
||||
g_state^.pid := 0;
|
||||
end;
|
||||
freeState(g_state);
|
||||
g_state := nil;
|
||||
end;
|
||||
@@ -834,6 +848,7 @@ var
|
||||
sl : Plv_obj;
|
||||
dl : Plv_obj;
|
||||
state : PNotepadState;
|
||||
ctx : PProcessContext;
|
||||
begin
|
||||
tracer.push_trace('notepad.launch');
|
||||
|
||||
@@ -956,6 +971,13 @@ begin
|
||||
lv_obj_set_style_text_font(dl, @lv_font_montserrat_14, 0);
|
||||
state^.dirty_label := dl;
|
||||
|
||||
{ Create process so notepad appears in PS and is manageable }
|
||||
ctx := processmanager.create('Notepad', @notepad_entry, void(state), 1);
|
||||
if ctx <> nil then begin
|
||||
state^.pid := ctx^.ProcessID;
|
||||
windows.setWindowOwner(win_id, ctx^.ProcessID);
|
||||
end;
|
||||
|
||||
tracer.pop_trace;
|
||||
end;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user