Skip to content

Commit

Permalink
Merge pull request #701 from o-sdn-o/gui-bridge
Browse files Browse the repository at this point in the history
Implement RunScript desktop action
  • Loading branch information
o-sdn-o authored Dec 20, 2024
2 parents 47f68b2 + 2e55d94 commit 66998a9
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 85 deletions.
7 changes: 0 additions & 7 deletions doc/apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,6 @@ Tiling Window Manager is a window container that organizes the workspace into mu
</menu>
</tile>
<hotkeys> <!-- The required key combination sequence can be generated on the Info page, accessible by clicking on the label in the lower right corner of the vtm desktop. -->
<desktop key*> <!-- Desktop layer key bindings. -->
<key="Ctrl+PageUp" action=FocusPrevWindow/> <!-- Switch focus to the next desktop window. -->
<key="Ctrl+PageDown" action=FocusNextWindow/> <!-- Switch focus to the previous 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=RunApplication/> <!-- Run default application. -->
</desktop>
<tile key*>
<key="Ctrl+PageUp" action=TileFocusPrev /> <!-- Focus the previous pane or the split grip. -->
<key="Ctrl+PageDown" action=TileFocusNext /> <!-- Focus the next pane or the split grip. -->
Expand Down
45 changes: 19 additions & 26 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 @@ -903,38 +910,24 @@ Notes
<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=RunApplication/> <!-- Run default application. -->
<key="" action=AlwaysOnTopWindow/><!-- Toggle AlwaysOnTop flag on all focused windows. -->
<key="" action=CloseWindow/> <!-- Close all focused desktop windows. -->
<key="" action=MinimizeWindow/> <!-- Minimize all focused desktop windows. -->
<key="Esc+F11" action=MaximizeWindow/> <!-- Maximize all focused desktop windows. -->
<key="Esc+F12" action=FullscreenWindow/> <!-- Fullscreen the first focused desktop window. -->
<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. -->
<key="Esc+'=' | Esc+'+'"> <action=WarpWindow data=" 1, 1, 1, 1"/></key> <!-- Increase window size. -->
<key="Esc+'-'"> <action=WarpWindow data="-1,-1,-1,-1"/></key> <!-- Reduce window size. --> </desktop>
<key="Esc+LeftArrow"> <action=WarpWindow data=" 1,-1, 0, 0"/></key> <!-- Move window to the left. -->
<key="Esc+RightArrow"> <action=WarpWindow data="-1, 1, 0, 0"/></key> <!-- Move window to the right. -->
<key="Esc+UpArrow"> <action=WarpWindow data=" 0, 0, 1,-1"/></key> <!-- Move window up. -->
<key="Esc+DownArrow"> <action=WarpWindow data=" 0, 0,-1, 1"/></key> <!-- Move window down. -->

<key="Esc+LeftArrow+UpArrow"> <action=WarpWindow data=" 0, 0, 0,-1"/></key> <!-- Move bottom side of window up. -->
<key="Esc+LeftArrow+DownArrow"> <action=WarpWindow data=" 0, 0, 0, 1"/></key> <!-- Move bottom side of window down. -->
<key="Esc+RightArrow+UpArrow"> <action=WarpWindow data=" 0, 0, 1, 0"/></key> <!-- Move top side of window up. -->
<key="Esc+RightArrow+DownArrow"> <action=WarpWindow data=" 0, 0,-1, 0"/></key> <!-- Move top side of window down. -->

<key="Esc+UpArrow+LeftArrow"> <action=WarpWindow data=" 1, 0, 0, 0"/></key> <!-- Move left side of window to left. -->
<key="Esc+UpArrow+RightArrow"> <action=WarpWindow data="-1, 0, 0, 0"/></key> <!-- Move left side of window to right. -->
<key="Esc+DownArrow+RightArrow"> <action=WarpWindow data=" 0, 1, 0, 0"/></key> <!-- Move right side of window to right. -->
<key="Esc+DownArrow+LeftArrow"> <action=WarpWindow data=" 0,-1, 0, 0"/></key> <!-- Move right side of window to left. -->

<key="Ctrl+LeftArrow+DownArrow | Ctrl+DownArrow+LeftArrow"> <action=WarpWindow data=" 1, 0, 0, 1"/></key> <!-- Move the bottom left corner of the window outward. -->
<key="Ctrl+RightArrow+DownArrow | Ctrl+DownArrow+RightArrow"><action=WarpWindow data=" 0, 1, 0, 1"/></key> <!-- Move the bottom right corner outside. -->
<key="Ctrl+LeftArrow+UpArrow | Ctrl+UpArrow+LeftArrow"> <action=WarpWindow data=" 1, 0, 1, 0"/></key> <!-- Move the top left corner of the window outward. -->
<key="Ctrl+RightArrow+UpArrow | Ctrl+UpArrow+RightArrow"> <action=WarpWindow data=" 0, 1, 1, 0"/></key> <!-- Move the top right corner of the window outward. -->

<key="Alt+LeftArrow+DownArrow | Alt+DownArrow+LeftArrow"> <action=WarpWindow data=" 0,-1,-1, 0"/></key> <!-- Move the top left corner of the window inward. -->
<key="Alt+RightArrow+DownArrow | Alt+DownArrow+RightArrow"> <action=WarpWindow data="-1, 0,-1, 0"/></key> <!-- Move the top right corner of the window inward. -->
<key="Alt+LeftArrow+UpArrow | Alt+UpArrow+LeftArrow"> <action=WarpWindow data=" 0,-1, 0,-1"/></key> <!-- Move the bottom left corner of the window inward. -->
<key="Alt+RightArrow+UpArrow | Alt+UpArrow+RightArrow"> <action=WarpWindow data="-1, 0, 0,-1"/></key> <!-- Move the bottom right corner of the window inward. -->
</desktop>
<key="Esc+LeftArrow+UpArrow | Esc+UpArrow+LeftArrow"> <action=WarpWindow data=" 2,-2, 1,-1"/></key> <!-- Move window to the top-left. -->
<key="Esc+LeftArrow+DownArrow | Esc+DownArrow+LeftArrow"> <action=WarpWindow data=" 2,-2,-1, 1"/></key> <!-- Move window to the bottom-left. -->
<key="Esc+RightArrow+UpArrow | Esc+UpArrow+RightArrow"> <action=WarpWindow data="-2, 2, 1,-1"/></key> <!-- Move window to the top-right. -->
<key="Esc+RightArrow+DownArrow | Esc+DownArrow+RightArrow"> <action=WarpWindow data="-2, 2,-1, 1"/></key> <!-- Move window to the bottom-right. -->
<tile key*>
<key="Ctrl+PageUp" action=TileFocusPrev /> <!-- Focus the previous pane or the split grip. -->
<key="Ctrl+PageDown" action=TileFocusNext /> <!-- Focus the next pane or the split grip. -->
Expand Down
35 changes: 13 additions & 22 deletions doc/user-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,28 +154,19 @@
<td colspan="7">Horizontal scrolling</td>
<td colspan="2"></td>
</tr>
<tr><th>Esc+F11</th> <td colspan="3"></td><td colspan="7">Maximize all focused desktop windows</td></tr>
<tr><th>Esc+F12</th> <td colspan="3"></td><td colspan="7">Fullscreen the first focused desktop window</td></tr>
<tr><th>Esc+LeftArrow</th> <td colspan="3"></td><td colspan="7">Move window to the left</td></tr>
<tr><th>Esc+RightArrow</th> <td colspan="3"></td><td colspan="7">Move window to the right</td></tr>
<tr><th>Esc+UpArrow</th> <td colspan="3"></td><td colspan="7">Move window up</td></tr>
<tr><th>Esc+DownArrow</th> <td colspan="3"></td><td colspan="7">Move window down</td></tr>
<tr><th>Esc+LeftArrow+UpArrow</th> <td colspan="3"></td><td colspan="7">Move bottom side of window up</td></tr>
<tr><th>Esc+LeftArrow+DownArrow</th> <td colspan="3"></td><td colspan="7">Move bottom side of window down</td></tr>
<tr><th>Esc+RightArrow+UpArrow</th> <td colspan="3"></td><td colspan="7">Move top side of window up</td></tr>
<tr><th>Esc+RightArrow+DownArrow</th> <td colspan="3"></td><td colspan="7">Move top side of window down</td></tr>
<tr><th>Esc+UpArrow+LeftArrow</th> <td colspan="3"></td><td colspan="7">Move left side of window to left</td></tr>
<tr><th>Esc+UpArrow+RightArrow</th> <td colspan="3"></td><td colspan="7">Move left side of window to right</td></tr>
<tr><th>Esc+DownArrow+RightArrow</th> <td colspan="3"></td><td colspan="7">Move right side of window to right</td></tr>
<tr><th>Esc+DownArrow+LeftArrow</th> <td colspan="3"></td><td colspan="7">Move right side of window to left</td></tr>
<tr><th>Ctrl+LeftArrow+DownArrow<br>Ctrl+DownArrow+LeftArrow</th> <td colspan="3"></td><td colspan="7">Move the bottom left corner of the window outward</td></tr>
<tr><th>Ctrl+RightArrow+DownArrow<br>Ctrl+DownArrow+RightArrow</th><td colspan="3"></td><td colspan="7">Move the bottom right corner outside</td></tr>
<tr><th>Ctrl+LeftArrow+UpArrow<br>Ctrl+UpArrow+LeftArrow</th> <td colspan="3"></td><td colspan="7">Move the top left corner of the window outward</td></tr>
<tr><th>Ctrl+RightArrow+UpArrow<br>Ctrl+UpArrow+RightArrow</th> <td colspan="3"></td><td colspan="7">Move the top right corner of the window outward</td></tr>
<tr><th>Alt+LeftArrow+DownArrow<br>Alt+DownArrow+LeftArrow</th> <td colspan="3"></td><td colspan="7">Move the top left corner of the window inward</td></tr>
<tr><th>Alt+RightArrow+DownArrow<br>Alt+DownArrow+RightArrow</th> <td colspan="3"></td><td colspan="7">Move the top right corner of the window inward</td></tr>
<tr><th>Alt+LeftArrow+UpArrow<br>Alt+UpArrow+LeftArrow</th> <td colspan="3"></td><td colspan="7">Move the bottom left corner of the window inward</td></tr>
<tr><th>Alt+RightArrow+UpArrow<br>Alt+UpArrow+RightArrow</th> <td colspan="3"></td><td colspan="7">Move the bottom right corner of the window inward</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>
<tr><th>Esc+'-'</th> <td colspan="3"></td><td colspan="7">Reduce window size</td></tr>
<tr><th>Esc+LeftArrow</th> <td colspan="3"></td><td colspan="7">Move window to the left</td></tr>
<tr><th>Esc+RightArrow</th> <td colspan="3"></td><td colspan="7">Move window to the right</td></tr>
<tr><th>Esc+UpArrow</th> <td colspan="3"></td><td colspan="7">Move window up</td></tr>
<tr><th>Esc+DownArrow</th> <td colspan="3"></td><td colspan="7">Move window down</td></tr>
<tr><th>Esc+LeftArrow+UpArrow | Esc+UpArrow+LeftArrow</th> <td colspan="3"></td><td colspan="7">Move window to the top-left</td></tr>
<tr><th>Esc+LeftArrow+DownArrow | Esc+DownArrow+LeftArrow</th> <td colspan="3"></td><td colspan="7">Move window to the bottom-left</td></tr>
<tr><th>Esc+RightArrow+UpArrow | Esc+UpArrow+RightArrow</th> <td colspan="3"></td><td colspan="7">Move window to the top-right</td></tr>
<tr><th>Esc+RightArrow+DownArrow | Esc+DownArrow+RightArrow</th><td colspan="3"></td><td colspan="7">Move window to the bottom-right</td></tr>
</tbody>
</table>

Expand Down
2 changes: 1 addition & 1 deletion src/netxs/desktopio/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace netxs::app

namespace netxs::app::shared
{
static const auto version = "v0.9.99.58";
static const auto version = "v0.9.99.59";
static const auto repository = "https://github.com/directvt/vtm";
static const auto usr_config = "~/.config/vtm/settings.xml"s;
static const auto sys_config = "/etc/vtm/settings.xml"s;
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
2 changes: 1 addition & 1 deletion src/netxs/desktopio/controls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ namespace netxs::ui
{
auto& c = iter++->bgc();
auto x0 = (x - area.size.x / 2) / (area.size.x - 4 - 2 * 1.6f);
auto dr = std::sqrt(x0 * x0 + y0);
auto dr = std::sqrt(std::abs(x0 * x0 + y0));
if (dr > 1) c.chan.a = 0;
else
{
Expand Down
3 changes: 0 additions & 3 deletions src/netxs/desktopio/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,7 @@ namespace netxs
state.block.clear();
}
};
}

namespace
{
template<bool Newline = true, class ...Args>
void log(netxs::view format, Args&&... args)
{
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
Loading

0 comments on commit 66998a9

Please sign in to comment.