Skip to content

Commit

Permalink
directvt#86 WIP: directvt#86 Implement MaximizeWindow/FullscreenWindo…
Browse files Browse the repository at this point in the history
…w desktop action
  • Loading branch information
o-sdn-o committed Dec 18, 2024
1 parent f7f53e7 commit 363715f
Showing 1 changed file with 50 additions and 19 deletions.
69 changes: 50 additions & 19 deletions src/vtm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace netxs::app::vtm
link what; // align: Original window properties.
rect prev; // align: Window size before the fullscreen has applied.
twod coor; // align: Coor tracking.
hook maxs; // align: Fullscreen event subscription token.
subs maxs; // align: Fullscreen event subscription token.

align(base&&) = delete;
align(base& boss, wptr& nexthop, bool /*maximize*/ = true)
Expand All @@ -109,6 +109,10 @@ namespace netxs::app::vtm
if (what.applet) unbind();
if (is_new) follow(new_what);
};
boss.LISTEN(tier::request, vtm::events::gate::fullscreen, ask_what, maxs)
{
ask_what = what;
};
}
~align()
{
Expand Down Expand Up @@ -1249,14 +1253,20 @@ namespace netxs::app::vtm
items.pop_back();
return items.back();
}
auto foreach(id_t gear_id, auto function)
auto foreach(hids& gear, auto function)
{
for (auto& item : items)
auto what = gear.owner.bell::signal(tier::request, vtm::events::gate::fullscreen); // Check if there is a fullscreen window.
if (what.applet)
{
function(what.applet);
}
else for (auto item : items)
{
if (item && pro::focus::is_focused(item->object, gear_id))
if (item && pro::focus::is_focused(item->object, gear.id))
{
function(item);
if (!item) break;
auto window_ptr = item->object;
function(window_ptr);
if (!window_ptr) break;
}
}
}
Expand Down Expand Up @@ -1788,21 +1798,21 @@ namespace netxs::app::vtm
if (gear.args_ptr)
{
auto arg = gear.args_ptr->empty() ? -1 : (si32)xml::take_or<bool>(gear.args_ptr->front(), faux);
items.foreach(gear.id, [&](auto& item_ptr)
items.foreach(gear, [&](auto window_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);
auto zorder = arg == 0 ? zpos::plain
: arg == 1 ? zpos::topmost
: window_ptr->bell::signal(tier::request, e2::form::prop::zorder) != zpos::topmost ? zpos::topmost : zpos::plain;
window_ptr->bell::signal(tier::preview, e2::form::prop::zorder, zorder);
});
gear.set_handled();
}
}
void close_focused_windows(hids& gear)
{
items.foreach(gear.id, [&](auto& item_ptr)
items.foreach(gear, [&](auto window_ptr)
{
bell::enqueue(item_ptr->object, [](auto& boss) // Keep the focus tree intact while processing key events.
bell::enqueue(window_ptr, [](auto& boss) // Keep the focus tree intact while processing key events.
{
boss.bell::signal(tier::anycast, e2::form::proceed::quit::one, true);
});
Expand All @@ -1811,9 +1821,9 @@ namespace netxs::app::vtm
}
void minimize_focused_windows(hids& gear)
{
items.foreach(gear.id, [&](auto& item_ptr)
items.foreach(gear, [&](auto window_ptr)
{
bell::enqueue(item_ptr->object, [gear_id = gear.id](auto& boss) // Keep the focus tree intact while processing key events.
bell::enqueue(window_ptr, [gear_id = gear.id](auto& boss) // Keep the focus tree intact while processing key events.
{
if (auto gear_ptr = boss.bell::getref<hids>(gear_id))
{
Expand All @@ -1826,13 +1836,34 @@ namespace netxs::app::vtm
}
void maximize_focused_windows(hids& gear)
{
log("maximize_focused_windows");
gear.set_handled();
items.foreach(gear, [&](auto window_ptr)
{
bell::enqueue(window_ptr, [gear_id = gear.id](auto& boss) // Keep the focus tree intact while processing key events.
{
if (auto gear_ptr = boss.bell::getref<hids>(gear_id))
{
auto& gear = *gear_ptr;
boss.bell::signal(tier::preview, e2::form::size::enlarge::maximize, gear);
}
});
gear.set_handled();
});
}
void fullscreen_first_focused_window(hids& gear)
{
log("fullscreen_first_focused_window");
gear.set_handled();
items.foreach(gear, [&](auto window_ptr)
{
bell::enqueue(window_ptr, [gear_id = gear.id](auto& boss) // Keep the focus tree intact while processing key events.
{
if (auto gear_ptr = boss.bell::getref<hids>(gear_id))
{
auto& gear = *gear_ptr;
boss.bell::signal(tier::preview, e2::form::size::enlarge::fullscreen, gear);
}
});
gear.set_handled();
window_ptr.reset(); // Break iterating.
});
}
void warp_focused_windows(hids& gear)
{
Expand Down

0 comments on commit 363715f

Please sign in to comment.