Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions src/netxs/apps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,10 @@ namespace netxs::app::shared
auto build_dtty = [](eccc appcfg, settings& /*config*/)
{
auto window_clr = skin::color(tone::window_clr);
auto window_ptr = ui::veer::ctor()
auto window_ptr = ui::veer::ctor(true /* Notify everyone on resize. */)
->limits(dot_11)
->plugin<pro::focus>();
auto& order = window_ptr->base::field(true); // True: term; faux: dtvt.
auto term_cake = ui::cake::ctor()
->plugin<pro::focus>()
->active(window_clr);
Expand All @@ -446,6 +447,7 @@ namespace netxs::app::shared
->invoke([&](auto& boss)
{
auto& dtvt_inst = *dtvt;
auto& term_inst = boss;
boss.defcfg.def_atexit = ui::term::commands::atexit::ask;
if constexpr (!debugmode) // Forced disabling of logging for the controlling terminal.
{
Expand All @@ -454,7 +456,16 @@ namespace netxs::app::shared
}
boss.LISTEN(tier::anycast, e2::form::proceed::quit::any, fast)
{
boss.base::signal(tier::preview, e2::form::proceed::quit::one, fast);
auto nodtvt = order || dtvt_inst.is_nodtvt();
if (nodtvt || fast)
{
dtvt_inst.stop(fast, faux);
term_inst.close(fast, faux);
}
else
{
dtvt_inst.stop(fast, faux);
}
};
boss.LISTEN(tier::preview, e2::form::proceed::quit::one, fast)
{
Expand All @@ -473,10 +484,6 @@ namespace netxs::app::shared
{
boss.base::riseup(tier::release, e2::config::plugins::sizer::alive, state);
};
boss.LISTEN(tier::anycast, e2::form::proceed::quit::any, fast)
{
boss.base::signal(tier::preview, e2::form::proceed::quit::one, fast);
};
boss.LISTEN(tier::preview, e2::form::proceed::quit::one, fast)
{
boss.stop(fast, faux);
Expand All @@ -496,18 +503,21 @@ namespace netxs::app::shared
{
if (root_ptr) // root_ptr is empty when d_n_d.
{
dtvt_inst.start(appcfg.cfg, [&, appcfg](auto fds)
boss.base::enqueue([&](auto& /*boss*/) // Dtvt::start must be run strictly after the window reflow (to synchronize the initial size).
{
term_inst.start(appcfg, fds);
return appcfg.cmd;
dtvt_inst.start(appcfg.cfg, [&](auto fds)
{
term_inst.start(appcfg, fds);
return appcfg.cmd;
});
});
}
};
boss.LISTEN(tier::anycast, e2::form::upon::started, root_ptr)
{
boss.base::signal(tier::release, e2::form::upon::started, root_ptr);
};
boss.LISTEN(tier::release, e2::form::global::sysstart, started, -, (order = true))
boss.LISTEN(tier::release, e2::form::global::sysstart, started)
{
if (!!started == order)
{
Expand All @@ -522,7 +532,7 @@ namespace netxs::app::shared
}
boss.bell::passover();
};
boss.LISTEN(tier::release, e2::form::proceed::quit::any, fast, -, (count = 2))
boss.LISTEN(tier::release, e2::form::proceed::quit::any, fast, -, (count = 2)) // count = 2: Wait for term and dtvt.
{
if (--count == 0)
if (auto parent = boss.base::parent())
Expand Down
9 changes: 8 additions & 1 deletion src/netxs/desktopio/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace netxs::app

namespace netxs::app::shared
{
static const auto version = "v2025.10.25";
static const auto version = "v2025.10.27";
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 Expand Up @@ -964,6 +964,8 @@ namespace netxs::app::shared
{
if (os::dtvt::active || !(os::dtvt::vtmode & ui::console::gui))
{
os::dtvt::flagsz = true;
os::dtvt::flagsz.notify_all();
os::tty::splice(client);
}
else
Expand Down Expand Up @@ -1002,6 +1004,10 @@ namespace netxs::app::shared
{
app::shared::splice(client, gui_config);
}};
if (os::dtvt::vtmode & ui::console::gui)
{
os::dtvt::flagsz.wait(faux); // Sync with gui window. Waiting for os::dtvt::gridsz update.
}
auto gate_ptr = ui::gate::ctor(server, os::dtvt::vtmode);
auto& gate = *gate_ptr;
gate.base::resize(os::dtvt::gridsz);
Expand All @@ -1012,6 +1018,7 @@ namespace netxs::app::shared
applet.base::kind(base::reflow_root);
app::shared::applet_kb_navigation(config, applet_ptr);
gate.attach(std::move(applet_ptr));
gate.base::reflow(); // Fit applet_ptr to the gate size. Resize all nested objects to set base::region instead of base::socket (see dtty's ui::veer).
ui_lock.unlock();
gate.launch(ui_lock);
gate.base::dequeue();
Expand Down
22 changes: 18 additions & 4 deletions src/netxs/desktopio/controls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4199,6 +4199,8 @@ namespace netxs::ui
class veer
: public form<veer>
{
bool inform_all;

protected:
// veer: .
void deform(rect& new_area) override
Expand All @@ -4212,16 +4214,28 @@ namespace netxs::ui
// veer: .
void inform(rect new_area) override
{
if (base::subset.size())
if (auto object = base::subset.back())
if (inform_all)
{
object->base::notify(new_area);
for (auto object : base::subset)
{
object->base::notify(new_area);
}
}
else
{
if (base::subset.size())
if (auto object = base::subset.back())
{
object->base::notify(new_area);
}
}
}

public:
static constexpr auto classname = basename::veer;
veer()

veer(bool inform_all = faux)
: inform_all{ inform_all }
{
LISTEN(tier::release, e2::render::any, parent_canvas)
{
Expand Down
10 changes: 9 additions & 1 deletion src/netxs/desktopio/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3561,9 +3561,17 @@ namespace netxs::gui
&& layer_create(blinky)
&& layer_create(header)
&& layer_create(footer)
&& layer_create(tooltip_layer))) return;
&& layer_create(tooltip_layer)))
{
os::dtvt::flagsz = true;
os::dtvt::flagsz.notify_all();
return;
}
else
{
os::dtvt::gridsz = (master.area.size - border) / std::max(cellsz, dot_11);
os::dtvt::flagsz = true; // Notify app::shared::splice.
os::dtvt::flagsz.notify_all();
auto lock = bell::sync();
normsz = master.area;
size_window();
Expand Down
24 changes: 12 additions & 12 deletions src/netxs/desktopio/system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3794,6 +3794,7 @@ namespace netxs::os
static auto leadin = text{}; // dtvt: The first block read from stdin.
static auto backup = tios{}; // dtvt: Saved console state to restore at exit.
static auto gridsz = twod{}; // dtvt: Initial window grid size.
static auto flagsz = flag{}; // dtvt: Initial window grid size updating flag.
static auto client = xipc{}; // dtvt: Internal IO link.
static auto wheelrate = 3; // dtvt: Lines per mouse wheel step (legacy mode).

Expand Down Expand Up @@ -4289,15 +4290,19 @@ namespace netxs::os
text writebuf{};
std::mutex writemtx{};
std::condition_variable writesyn{};
fd_t serverfd{};
fd_t clientfd{};
sptr<sock> std_link{};

operator bool () { return attached; }

void abort()
void abort() // Hard terminate the connection.
{
os::close(serverfd); // Hard terminate connection.
os::close(clientfd); //
if (std_link)
{
auto& server_fd = std_link->w;
os::close(server_fd);
}
auto& client_fd = termlink.handle.w;
os::close(client_fd);
}
void payoff()
{
Expand Down Expand Up @@ -4348,16 +4353,12 @@ namespace netxs::os
writebuf = config + writebuf;
}
termlink = ipc::stdcon{ m_pipe_r, m_pipe_w };

auto cmd = connect(ptr::shared<sock>(s_pipe_r, s_pipe_w));

std_link = ptr::shared<sock>(s_pipe_r, s_pipe_w);
auto cmd = connect(std_link);
attached.exchange(!!termlink);
if (attached)
{
serverfd = s_pipe_w;
clientfd = m_pipe_w;
if constexpr (debugmode) log("%%DirectVT Gateway created for process '%cmd%'", prompt::dtvt, ansi::hi(utf::debase437(cmd)));
writesyn.notify_one(); // Flush temp buffer.
auto stdwrite = std::thread{ [&]{ writer(); } };

if constexpr (debugmode) log(prompt::dtvt, "Reading thread started", ' ', utf::to_hex_0x(std::this_thread::get_id()));
Expand Down Expand Up @@ -4445,7 +4446,6 @@ namespace netxs::os
" cmd: "s + cfg.cmd + " "s);
}
attached.exchange(!errcode);
writesyn.notify_one(); // Flush temp buffer.
}
void writer(auto& terminal)
{
Expand Down
15 changes: 8 additions & 7 deletions src/netxs/desktopio/terminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9332,20 +9332,21 @@ namespace netxs::ui
};
ipccon.runapp(config, base::size(), connect, receiver, [&]{ onexit(); });
}
// dtvt: Return true if application has never sent its canvas.
auto is_nodtvt()
{
auto lock = stream.bitmap_dtvt.freeze();
auto& canvas = lock.thing.image;
return !canvas.hash(); // Canvas never resized/received.
}
// dtvt: Close dtvt-object.
void stop(bool fast, bool notify = true)
{
if (notify)
{
base::signal(tier::request, e2::form::proceed::quit::one, fast);
}
auto nodtvt = [&]
{
auto lock = stream.bitmap_dtvt.freeze();
auto& canvas = lock.thing.image;
return !canvas.hash(); // Canvas never resized/received.
}();
if (nodtvt) // Terminate a non-dtvt-aware application that has never sent its canvas.
if (is_nodtvt()) // Terminate a non-dtvt-aware application that has never sent its canvas.
{
ipccon.abort();
}
Expand Down