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:
1 parent
3a733b1559
commit
3d9c4cb49a
2 files changed
+45
No files matched your search
@@ -23,6 +23,8 @@ uses
|
|||||||
lmemorymanager,
|
lmemorymanager,
|
||||||
lvgl,
|
lvgl,
|
||||||
MBR,
|
MBR,
|
||||||
|
processmanager,
|
||||||
|
proctypes,
|
||||||
storagemanager,
|
storagemanager,
|
||||||
storagetypes,
|
storagetypes,
|
||||||
strings,
|
strings,
|
||||||
@@ -43,6 +45,7 @@ const
|
|||||||
|
|
||||||
var
|
var
|
||||||
win_id : uint32;
|
win_id : uint32;
|
||||||
|
proc_pid : uint32;
|
||||||
sidebar : Plv_obj;
|
sidebar : Plv_obj;
|
||||||
detail : Plv_obj;
|
detail : Plv_obj;
|
||||||
{ Current selection }
|
{ Current selection }
|
||||||
@@ -64,6 +67,7 @@ var
|
|||||||
Forward declarations
|
Forward declarations
|
||||||
============================================================ }
|
============================================================ }
|
||||||
procedure launch; forward;
|
procedure launch; forward;
|
||||||
|
procedure diskutil_entry(ctx : PProcessContext); forward;
|
||||||
procedure onClose(wid: uint32); forward;
|
procedure onClose(wid: uint32); forward;
|
||||||
procedure refreshSidebar; forward;
|
procedure refreshSidebar; forward;
|
||||||
procedure showDeviceDetail(devIdx: uint32); forward;
|
procedure showDeviceDetail(devIdx: uint32); forward;
|
||||||
@@ -1278,10 +1282,20 @@ end;
|
|||||||
{ ============================================================
|
{ ============================================================
|
||||||
Window close handler
|
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);
|
procedure onClose(wid: uint32);
|
||||||
begin
|
begin
|
||||||
tracer.push_trace('diskutil.onClose');
|
tracer.push_trace('diskutil.onClose');
|
||||||
closeMsgBox;
|
closeMsgBox;
|
||||||
|
if proc_pid <> 0 then begin
|
||||||
|
processmanager.kill(proc_pid);
|
||||||
|
proc_pid := 0;
|
||||||
|
end;
|
||||||
windows.destroyWindow(wid);
|
windows.destroyWindow(wid);
|
||||||
win_id := 0;
|
win_id := 0;
|
||||||
sidebar := nil;
|
sidebar := nil;
|
||||||
@@ -1299,6 +1313,7 @@ var
|
|||||||
wx, wy : sint32;
|
wx, wy : sint32;
|
||||||
content : Plv_obj;
|
content : Plv_obj;
|
||||||
lbl : Plv_obj;
|
lbl : Plv_obj;
|
||||||
|
ctx : PProcessContext;
|
||||||
begin
|
begin
|
||||||
tracer.push_trace('diskutil.launch');
|
tracer.push_trace('diskutil.launch');
|
||||||
|
|
||||||
@@ -1387,6 +1402,13 @@ begin
|
|||||||
|
|
||||||
refreshSidebar;
|
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;
|
tracer.pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -1397,6 +1419,7 @@ procedure init();
|
|||||||
begin
|
begin
|
||||||
tracer.push_trace('diskutil.init');
|
tracer.push_trace('diskutil.init');
|
||||||
win_id := 0;
|
win_id := 0;
|
||||||
|
proc_pid := 0;
|
||||||
sidebar := nil;
|
sidebar := nil;
|
||||||
detail := nil;
|
detail := nil;
|
||||||
sel_mode := SEL_NONE;
|
sel_mode := SEL_NONE;
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ uses
|
|||||||
keyboard,
|
keyboard,
|
||||||
lmemorymanager,
|
lmemorymanager,
|
||||||
lvgl,
|
lvgl,
|
||||||
|
processmanager,
|
||||||
|
proctypes,
|
||||||
storagetypes,
|
storagetypes,
|
||||||
strings,
|
strings,
|
||||||
syslog,
|
syslog,
|
||||||
@@ -74,6 +76,7 @@ type
|
|||||||
PNotepadState = ^TNotepadState;
|
PNotepadState = ^TNotepadState;
|
||||||
TNotepadState = record
|
TNotepadState = record
|
||||||
win_id : uint32;
|
win_id : uint32;
|
||||||
|
pid : uint32;
|
||||||
ta : Plv_obj;
|
ta : Plv_obj;
|
||||||
status_label : Plv_obj;
|
status_label : Plv_obj;
|
||||||
dirty_label : Plv_obj;
|
dirty_label : Plv_obj;
|
||||||
@@ -92,6 +95,7 @@ var
|
|||||||
{ ============================================================
|
{ ============================================================
|
||||||
Forward declarations
|
Forward declarations
|
||||||
============================================================ }
|
============================================================ }
|
||||||
|
procedure notepad_entry(ctx: PProcessContext); forward;
|
||||||
procedure launch; forward;
|
procedure launch; forward;
|
||||||
procedure onClose(wid: uint32); forward;
|
procedure onClose(wid: uint32); forward;
|
||||||
procedure updateStatusBar(state: PNotepadState); forward;
|
procedure updateStatusBar(state: PNotepadState); forward;
|
||||||
@@ -281,9 +285,19 @@ end;
|
|||||||
doCloseWindow — unconditionally destroy window + free state.
|
doCloseWindow — unconditionally destroy window + free state.
|
||||||
Called by discard-confirm dialogs and by onClose when clean.
|
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;
|
procedure doCloseWindow;
|
||||||
begin
|
begin
|
||||||
if g_state <> nil then 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);
|
freeState(g_state);
|
||||||
g_state := nil;
|
g_state := nil;
|
||||||
end;
|
end;
|
||||||
@@ -834,6 +848,7 @@ var
|
|||||||
sl : Plv_obj;
|
sl : Plv_obj;
|
||||||
dl : Plv_obj;
|
dl : Plv_obj;
|
||||||
state : PNotepadState;
|
state : PNotepadState;
|
||||||
|
ctx : PProcessContext;
|
||||||
begin
|
begin
|
||||||
tracer.push_trace('notepad.launch');
|
tracer.push_trace('notepad.launch');
|
||||||
|
|
||||||
@@ -956,6 +971,13 @@ begin
|
|||||||
lv_obj_set_style_text_font(dl, @lv_font_montserrat_14, 0);
|
lv_obj_set_style_text_font(dl, @lv_font_montserrat_14, 0);
|
||||||
state^.dirty_label := dl;
|
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;
|
tracer.pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user