Skip to content

Commit

Permalink
directvt#86 WIP: Replace TryToQuit with RunScript (breaking changes)
Browse files Browse the repository at this point in the history
  • Loading branch information
o-sdn-o committed Dec 21, 2024
1 parent 8b1e8ad commit 2050532
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 35 deletions.
2 changes: 1 addition & 1 deletion doc/command-line-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Script Command | Description
`vtm.del([<item_id>])` | Delete the taskbar menu item by `<id>`.<br>Delete all menu items if no `<id>` specified.
`vtm.dtvt(<dtvt_app...>)` | Create a temporary menu item and run the specified dtvt-executable.
`vtm.selected(<item_id>)` | Set selected menu item using specified `<id>` (affected to the desktop RightDrag gesture and Tile's `+` button).
`vtm.shutdown()` | Terminate the running desktop session.
`vtm.shutdown([try])` | Terminate the running desktop session. If `try` is specified, the server will only shut down if there are no running windows.

### Character escaping

Expand Down
21 changes: 10 additions & 11 deletions doc/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ Action | Arguments (`data=`)
`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.
`TerminalFindPrev` | | Application | Highlight previous match of selected text fragment. Clipboard content is used if no active selection.
Expand Down Expand Up @@ -903,16 +902,16 @@ Notes
<key="Space-Backspace | Backspace-Space" action=ToggleDebugOverlay/> <!-- Toggle debug overlay. -->
</tui>
<desktop key*> <!-- Desktop layer key bindings. -->
<key="Ctrl+PageUp"> <action=FocusNextWindow data=0/></key> <!-- Switch focus to the previous desktop window. -->
<key="Ctrl+PageDown"><action=FocusNextWindow data=1/></key> <!-- Switch focus to the next desktop window. -->
<key="Shift+F7" action=Disconnect/> <!-- Disconnect from the desktop. -->
<key="F10" preview action=TryToQuit/> <!-- Shut down the desktop server if no applications are running. -->
<key="Alt+Shift+N"> <action=RunScript data="vtm.run()"/></key> <!-- Run default application. -->
<key="" action=AlwaysOnTopWindow/> <!-- Toggle AlwaysOnTop window flag. -->
<key="" action=CloseWindow/> <!-- Close window. -->
<key="" action=MinimizeWindow/> <!-- Minimize window. -->
<key="Esc+F11" action=MaximizeWindow/> <!-- Maximize window. -->
<key="Esc+F12" action=FullscreenWindow/> <!-- Maximize window to full screen. -->
<key="Ctrl+PageUp"> <action=FocusNextWindow data=0/></key> <!-- Switch focus to the previous desktop window. -->
<key="Ctrl+PageDown"><action=FocusNextWindow data=1/></key> <!-- Switch focus to the next desktop window. -->
<key="Shift+F7" action=Disconnect/> <!-- Disconnect from the desktop. -->
<key="F10" preview> <action=RunScript data="vtm.shutdown(try)"/></key> <!-- Shut down the desktop server if no applications are running. -->
<key="Alt+Shift+N"> <action=RunScript data="vtm.run()"/></key> <!-- Run default application. -->
<key="" action=AlwaysOnTopWindow/> <!-- Toggle AlwaysOnTop window flag. -->
<key="" action=CloseWindow/> <!-- Close window. -->
<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. -->
Expand Down
22 changes: 9 additions & 13 deletions src/vtm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,6 @@ namespace netxs::app::vtm
//todo local=>nexthop
local = faux;
keybd.proc("Disconnect", [&](hids& gear){ disconnect(gear); });
keybd.proc("TryToQuit", [&](hids& gear){ try_quit(gear); });
keybd.proc("FocusNextWindow", [&](hids& gear){ base::riseup(tier::preview, e2::form::proceed::action::nextwindow , gear); });
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); });
Expand Down Expand Up @@ -912,17 +911,6 @@ namespace netxs::app::vtm
world_ptr->base::riseup(tier::request, e2::form::proceed::createby, gear);
}
}
void try_quit(hids& gear)
{
auto window_ptr = e2::form::layout::go::item.param();
this->base::riseup(tier::request, e2::form::layout::go::item, window_ptr); // Take current window.
if (!window_ptr)
{
this->bell::signal(tier::general, e2::shutdown, utf::concat(prompt::gate, "Server shutdown"));
this->bell::expire(tier::preview);
gear.set_handled();
}
}
void disconnect(hids& gear)
{
gear.owner.bell::signal(tier::preview, e2::conio::quit);
Expand Down Expand Up @@ -1763,8 +1751,16 @@ namespace netxs::app::vtm
bell::signal(tier::request, desk::events::exec, appspec);
return "ok " + appspec.appcfg.cmd;
}
auto vtm_shutdown(eccc& /*script*/, qiew /*args*/)
auto vtm_shutdown(eccc& /*script*/, qiew args)
{
if (args) // Shut down if there are no windows.
{
auto window_ptr = bell::signal(tier::request, e2::form::layout::go::item); // Take current window.
if (window_ptr)
{
return "aborted"s;
}
}
bell::signal(tier::general, e2::shutdown, utf::concat(prompt::repl, "Server shutdown"));
return "ok"s;
}
Expand Down
20 changes: 10 additions & 10 deletions src/vtm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -449,16 +449,16 @@ R"==(
<key="Space-Backspace | Backspace-Space" action=ToggleDebugOverlay/> <!-- Toggle debug overlay. -->
</tui>
<desktop key*> <!-- Desktop layer key bindings. -->
<key="Ctrl+PageUp"> <action=FocusNextWindow data=0/></key> <!-- Switch focus to the previous desktop window. -->
<key="Ctrl+PageDown"><action=FocusNextWindow data=1/></key> <!-- Switch focus to the next desktop window. -->
<key="Shift+F7" action=Disconnect/> <!-- Disconnect from the desktop. -->
<key="F10" preview action=TryToQuit/> <!-- Shut down the desktop server if no applications are running. -->
<key="Alt+Shift+N"> <action=RunScript data="vtm.run()"/></key> <!-- Run default application. -->
<key="" action=AlwaysOnTopWindow/> <!-- Toggle AlwaysOnTop window flag. -->
<key="" action=CloseWindow/> <!-- Close window. -->
<key="" action=MinimizeWindow/> <!-- Minimize window. -->
<key="Esc+F11" action=MaximizeWindow/> <!-- Maximize window. -->
<key="Esc+F12" action=FullscreenWindow/> <!-- Maximize window to full screen. -->
<key="Ctrl+PageUp"> <action=FocusNextWindow data=0/></key> <!-- Switch focus to the previous desktop window. -->
<key="Ctrl+PageDown"><action=FocusNextWindow data=1/></key> <!-- Switch focus to the next desktop window. -->
<key="Shift+F7" action=Disconnect/> <!-- Disconnect from the desktop. -->
<key="F10" preview> <action=RunScript data="vtm.shutdown(try)"/></key> <!-- Shut down the desktop server if no applications are running. -->
<key="Alt+Shift+N"> <action=RunScript data="vtm.run()"/></key> <!-- Run default application. -->
<key="" action=AlwaysOnTopWindow/> <!-- Toggle AlwaysOnTop window flag. -->
<key="" action=CloseWindow/> <!-- Close window. -->
<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. -->
Expand Down

0 comments on commit 2050532

Please sign in to comment.