Skip to content

Commit

Permalink
directvt#86 WIP: Implement RunScript desktop action
Browse files Browse the repository at this point in the history
  • Loading branch information
o-sdn-o committed Dec 20, 2024
1 parent 4343907 commit 2ba82d0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
8 changes: 8 additions & 0 deletions doc/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,13 @@ Action | Arguments (`data=`)
`FocusNextWindow` | | Desktop | Switch focus to the previous desktop window.
`Disconnect` | | Desktop | Disconnect from the desktop.
`RunApplication` | _`Taskbar item id`_ | Desktop | Run application. Run the default application if no arguments are specified.
`RunScript` | _`Script body`_ | Desktop | Run script.
`AlwaysOnTopWindow` | `on` \| `off` | Desktop | Toggle AlwaysOnTop window flag.
`CloseWindow` | | Desktop | Close window.
`MinimizeWindow` | | Desktop | Minimize window.
`MaximizeWindow` | | Desktop | Maximize window.
`FullscreenWindow` | | Desktop | Maximize window to full screen.
`WarpWindow` | _`IntL, IntR, IntT, IntB`_ | Desktop | Warp desktop window. The data parameter specifies four deltas for the left, right, top and bottom window sides.
`TryToQuit` | | Desktop | Shut down the desktop server if no applications are running.
`ExclusiveKeyboardMode` | `on` \| `off` | Application | Toggle exclusive keyboard mode.
`TerminalFindNext` | | Application | Highlight next match of selected text fragment. Clipboard content is used if no active selection.
Expand Down Expand Up @@ -908,6 +915,7 @@ Notes
<key="" action=MinimizeWindow/> <!-- Minimize window. -->
<key="Esc+F11" action=MaximizeWindow/> <!-- Maximize window. -->
<key="Esc+F12" action=FullscreenWindow/> <!-- Maximize window to full screen. -->
<key="Esc+F1"> <action=RunScript data="vtm.run(title='Info-page' hidden=true label=Info type=info)"/></key> <!-- Run Info-page. -->

<key=""><action=WarpWindow data="0,0,0,0"/></key> <!-- Warp desktop window. The data parameter specifies four deltas for the left, right, top and bottom window sides. -->
<key="Esc+'=' | Esc+'+'"> <action=WarpWindow data=" 1, 1, 1, 1"/></key> <!-- Increase window size. -->
Expand Down
1 change: 1 addition & 0 deletions doc/user-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
<td colspan="7">Horizontal scrolling</td>
<td colspan="2"></td>
</tr>
<tr><th>Esc+F1</th> <td colspan="3"></td><td colspan="7">Open Info-page</td></tr>
<tr><th>Esc+F11</th> <td colspan="3"></td><td colspan="7">Maximize window</td></tr>
<tr><th>Esc+F12</th> <td colspan="3"></td><td colspan="7">Maximize window to full screen</td></tr>
<tr><th>Esc+'=' | Esc+'+'</th> <td colspan="3"></td><td colspan="7">Increase window size</td></tr>
Expand Down
1 change: 1 addition & 0 deletions src/netxs/desktopio/baseui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ namespace netxs::events::userland
};
SUBSET_XS( action )
{
EVENT_XS( runscript , input::hids ),
EVENT_XS( alwaysontop, input::hids ),
EVENT_XS( warp , input::hids ),
EVENT_XS( close , input::hids ),
Expand Down
20 changes: 20 additions & 0 deletions src/vtm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ namespace netxs::app::vtm
keybd.proc("Disconnect", [&](hids& gear){ disconnect(gear); });
keybd.proc("TryToQuit", [&](hids& gear){ try_quit(gear); });
keybd.proc("RunApplication", [&](hids& gear){ create_app(gear); gear.set_handled(); });
keybd.proc("RunScript", [&](hids& gear){ base::riseup(tier::preview, e2::form::proceed::action::runscript , gear); });
keybd.proc("AlwaysOnTopWindow", [&](hids& gear){ base::riseup(tier::preview, e2::form::proceed::action::alwaysontop, gear); });
keybd.proc("WarpWindow", [&](hids& gear){ base::riseup(tier::preview, e2::form::proceed::action::warp , gear); });
keybd.proc("CloseWindow", [&](hids& gear){ base::riseup(tier::preview, e2::form::proceed::action::close , gear); });
Expand Down Expand Up @@ -1793,6 +1794,21 @@ namespace netxs::app::vtm
bell::signal(tier::general, e2::shutdown, utf::concat(prompt::repl, "Server shutdown"));
return "ok"s;
}
void run_script(hids& gear)
{
if (gear.args_ptr)
{
auto& args = *gear.args_ptr;
for (auto cmd : args)
{
bell::enqueue(this->This(), [cmd, gear_id = gear.id](auto& boss) // Keep the focus tree intact while processing key events.
{
boss.bell::signal(tier::release, scripting::events::invoke, { .cmd = cmd, .hid = gear_id });
});
}
gear.set_handled();
}
}
void always_on_top_focused_windows(hids& gear)
{
if (gear.args_ptr)
Expand Down Expand Up @@ -2269,6 +2285,10 @@ namespace netxs::app::vtm
}
};

LISTEN(tier::preview, e2::form::proceed::action::runscript, gear)
{
run_script(gear);
};
LISTEN(tier::preview, e2::form::proceed::action::alwaysontop, gear)
{
always_on_top_focused_windows(gear);
Expand Down
1 change: 1 addition & 0 deletions src/vtm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ R"==(
<key="" action=MinimizeWindow/> <!-- Minimize window. -->
<key="Esc+F11" action=MaximizeWindow/> <!-- Maximize window. -->
<key="Esc+F12" action=FullscreenWindow/> <!-- Maximize window to full screen. -->
<key="Esc+F1"> <action=RunScript data="vtm.run(title='Info-page' hidden=true label=Info type=info)"/></key> <!-- Run Info-page. -->

<key=""><action=WarpWindow data="0,0,0,0"/></key> <!-- Warp desktop window. The data parameter specifies four deltas for the left, right, top and bottom window sides. -->
<key="Esc+'=' | Esc+'+'"> <action=WarpWindow data=" 1, 1, 1, 1"/></key> <!-- Increase window size. -->
Expand Down

0 comments on commit 2ba82d0

Please sign in to comment.