Skip to content

Commit

Permalink
directvt#583 Implement AlwaysOnTopWindow desktop action
Browse files Browse the repository at this point in the history
  • Loading branch information
o-sdn-o committed Dec 18, 2024
1 parent b1572d2 commit 0745be1
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 19 deletions.
21 changes: 10 additions & 11 deletions src/netxs/apps/tile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,17 +778,16 @@ namespace netxs::app::tile
static constexpr auto applet = __COUNTER__ - _counter;
static constexpr auto grip = __COUNTER__ - _counter;
}
auto is_focused = [](auto item_ptr, auto gear_id){ return !gear_id || !!item_ptr->bell::signal(tier::request, e2::form::state::keybd::find, { gear_id, 0 }).second; };
auto _foreach = [](auto _foreach, sptr& root_veer_ptr, id_t gear_id, auto proc) -> void
{
if (auto node_veer_ptr = std::dynamic_pointer_cast<ui::veer>(root_veer_ptr))
{
if (is_focused(node_veer_ptr, gear_id))
if (pro::focus::is_focused(node_veer_ptr, gear_id))
{
auto item_ptr = node_veer_ptr->back();
if (node_veer_ptr->count() == 1) // Empty slot.
{
if (is_focused(item_ptr, gear_id))
if (pro::focus::is_focused(item_ptr, gear_id))
{
proc(item_ptr, item_type::empty_slot, node_veer_ptr);
if (!item_ptr)
Expand All @@ -800,7 +799,7 @@ namespace netxs::app::tile
else if (item_ptr->root()) // App window.
{
auto applet_ptr = item_ptr->base::subset[1];
if (is_focused(applet_ptr, gear_id))
if (pro::focus::is_focused(applet_ptr, gear_id))
{
proc(applet_ptr, item_type::applet, node_veer_ptr); // Applet.
if (!applet_ptr)
Expand All @@ -816,7 +815,7 @@ namespace netxs::app::tile
if (!root_veer_ptr) return;

auto grip_ptr = item_ptr->base::subset[2];
if (is_focused(grip_ptr, gear_id))
if (pro::focus::is_focused(grip_ptr, gear_id))
{
proc(grip_ptr, item_type::grip, node_veer_ptr); // Grip.
if (!grip_ptr)
Expand Down Expand Up @@ -944,7 +943,7 @@ namespace netxs::app::tile
auto next_item_ptr = sptr{};
foreach(root_veer_ptr, id_t{}, [&](auto& item_ptr, si32 /*item_type*/, auto)
{
if (is_focused(item_ptr, gear.id))
if (pro::focus::is_focused(item_ptr, gear.id))
{
prev_item_ptr = next_item_ptr;
}
Expand Down Expand Up @@ -991,7 +990,7 @@ namespace netxs::app::tile
{
std::swap(next_item_ptr, item_ptr); // Interrupt foreach (empty item_ptr).
}
else if (is_focused(item_ptr, gear.id))
else if (pro::focus::is_focused(item_ptr, gear.id))
{
prev_item_ptr = item_ptr;
}
Expand Down Expand Up @@ -1030,7 +1029,7 @@ namespace netxs::app::tile
{
if (item_type != item_type::grip)
{
if (is_focused(item_ptr, gear.id))
if (pro::focus::is_focused(item_ptr, gear.id))
{
prev_item_ptr = next_item_ptr;
}
Expand Down Expand Up @@ -1080,7 +1079,7 @@ namespace netxs::app::tile
{
std::swap(next_item_ptr, item_ptr); // Interrupt foreach (empty item_ptr).
}
else if (is_focused(item_ptr, gear.id))
else if (pro::focus::is_focused(item_ptr, gear.id))
{
prev_item_ptr = item_ptr;
}
Expand Down Expand Up @@ -1120,7 +1119,7 @@ namespace netxs::app::tile
{
if (item_type == item_type::grip)
{
if (is_focused(item_ptr, gear.id))
if (pro::focus::is_focused(item_ptr, gear.id))
{
prev_grip_ptr = next_grip_ptr;
}
Expand Down Expand Up @@ -1161,7 +1160,7 @@ namespace netxs::app::tile
{
std::swap(next_grip_ptr, item_ptr); // Interrupt foreach (empty item_ptr).
}
else if (is_focused(item_ptr, gear.id))
else if (pro::focus::is_focused(item_ptr, gear.id))
{
prev_grip_ptr = item_ptr;
}
Expand Down
10 changes: 10 additions & 0 deletions src/netxs/desktopio/baseui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,21 @@ namespace netxs::events::userland
EVENT_XS( functor , ui::functor ), // Exec functor (see pro::focus).
EVENT_XS( onbehalf , ui::proc ), // Exec functor on behalf (see gate).
GROUP_XS( quit , bool ), // Request to quit/detach (arg: fast or not).
GROUP_XS( action , input::hids ), // Request to proceed action.

SUBSET_XS( quit )
{
EVENT_XS( one, bool ), // Signal to close (fast or not).
};
SUBSET_XS( action )
{
EVENT_XS( alwaysontop, input::hids ),
EVENT_XS( warp , input::hids ),
EVENT_XS( close , input::hids ),
EVENT_XS( minimize , input::hids ),
EVENT_XS( maximize , input::hids ),
EVENT_XS( fullscreen , input::hids ),
};
};
SUBSET_XS( cursor )
{
Expand Down
4 changes: 4 additions & 0 deletions src/netxs/desktopio/controls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,10 @@ namespace netxs::ui
auto gear_test = item.base::riseup(tier::request, e2::form::state::keybd::find, { gear.id, 0 });
return gear_test.second;
}
static auto is_focused(sptr item_ptr, id_t gear_id)
{
return !gear_id || !!item_ptr->bell::signal(tier::request, e2::form::state::keybd::find, { gear_id, 0 }).second;
}
auto is_focused(id_t gear_id)
{
auto iter = gears.find(gear_id);
Expand Down
58 changes: 50 additions & 8 deletions src/vtm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,12 +750,12 @@ 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("AlwaysOnTopWindow", [&](hids& gear){ always_on_top_focused_windows(gear); });
//keybd.proc("WarpWindow", [&](hids& gear){ warp_focused_windows(gear); });
//keybd.proc("CloseWindow", [&](hids& gear){ close_focused_windows(gear); });
//keybd.proc("MinimizeWindow", [&](hids& gear){ minimize_focused_windows(gear); });
//keybd.proc("MaximizeWindow", [&](hids& gear){ maximize_focused_windows(gear); });
//keybd.proc("FullscreenWindow", [&](hids& gear){ fullscreen_first_focused_window(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); });
keybd.proc("MinimizeWindow", [&](hids& gear){ base::riseup(tier::preview, e2::form::proceed::action::minimize , gear); });
keybd.proc("MaximizeWindow", [&](hids& gear){ base::riseup(tier::preview, e2::form::proceed::action::maximize , gear); });
keybd.proc("FullscreenWindow", [&](hids& gear){ base::riseup(tier::preview, e2::form::proceed::action::fullscreen , gear); });
auto bindings = pro::keybd::load(config, "desktop");
keybd.bind(bindings);

Expand Down Expand Up @@ -1249,6 +1249,17 @@ namespace netxs::app::vtm
items.pop_back();
return items.back();
}
auto foreach(id_t gear_id, auto function)
{
for (auto& item : items)
{
if (item && pro::focus::is_focused(item->object, gear_id))
{
function(item);
if (!item) break;
}
}
}
};
struct depo // hall: Actors registry.
{
Expand Down Expand Up @@ -1776,8 +1787,14 @@ namespace netxs::app::vtm
{
if (gear.args_ptr)
{
auto state = gear.args_ptr->empty() ? -1 : (si32)xml::take_or<bool>(gear.args_ptr->front(), faux);
log("always_on_top_focused_windows");
auto arg = gear.args_ptr->empty() ? -1 : (si32)xml::take_or<bool>(gear.args_ptr->front(), faux);
items.foreach(gear.id, [&](auto& item_ptr)
{
auto order = arg == 0 ? zpos::plain
: arg == 1 ? zpos::topmost
: item_ptr->z_order != zpos::topmost ? zpos::topmost : zpos::plain;
item_ptr->object->bell::signal(tier::preview, e2::form::prop::zorder, order);
});
gear.set_handled();
}
}
Expand Down Expand Up @@ -2190,6 +2207,31 @@ namespace netxs::app::vtm
}
}
};

LISTEN(tier::preview, e2::form::proceed::action::alwaysontop, gear)
{
always_on_top_focused_windows(gear);
};
LISTEN(tier::preview, e2::form::proceed::action::warp , gear)
{
close_focused_windows(gear);
};
LISTEN(tier::preview, e2::form::proceed::action::close , gear)
{
minimize_focused_windows(gear);
};
LISTEN(tier::preview, e2::form::proceed::action::minimize , gear)
{
maximize_focused_windows(gear);
};
LISTEN(tier::preview, e2::form::proceed::action::maximize , gear)
{
fullscreen_first_focused_window(gear);
};
LISTEN(tier::preview, e2::form::proceed::action::fullscreen , gear)
{
warp_focused_windows(gear);
};
}

// hall: Autorun apps from config.
Expand Down

0 comments on commit 0745be1

Please sign in to comment.