Skip to content

Commit

Permalink
Enhanced Unlock size behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Kimjio committed Sep 24, 2022
1 parent ef491d2 commit 8cf0075
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ namespace
int last_hriz_window_width = 0, last_hriz_window_height = 0;

bool fullScreenFl = g_force_landscape && g_auto_fullscreen;
bool fullScreenFlOverride = false;

Resolution_t* (*get_resolution)(Resolution_t* buffer);

Expand Down Expand Up @@ -544,14 +545,16 @@ namespace
if (is_virt() && fullScreenFl)
{
fullScreenFl = false;
fullScreenFlOverride = false;
return reinterpret_cast<decltype(set_resolution_hook)*>(set_resolution_orig)(last_virt_window_width, last_virt_window_height, false);
}

auto display = display_get_main();

if (reqVirt && (get_rendering_width(display) > get_rendering_height(display)))
{
cout << last_virt_window_width << " " << last_virt_window_height << "\n";
fullScreenFl = false;
fullScreenFlOverride = false;
if (last_virt_window_width > last_virt_window_height)
{
return reinterpret_cast<decltype(set_resolution_hook)*>(set_resolution_orig)(last_virt_window_height, last_virt_window_width, false);
Expand All @@ -574,6 +577,12 @@ namespace
{
last_virt_window_width = get_rendering_width(display);
last_virt_window_height = get_rendering_height(display);
if (need_fullscreen && (!last_hriz_window_width || !last_hriz_window_height)) {
float new_ratio = static_cast<float>(r.width) / r.height;

last_hriz_window_width = r.width - 400;
last_hriz_window_height = last_hriz_window_width / new_ratio;
}
}
else
{
Expand All @@ -582,16 +591,18 @@ namespace
}
}

fullScreenFl = need_fullscreen;
if (!fullScreenFlOverride) {
fullScreenFl = need_fullscreen;
}

if (!reqVirt && !need_fullscreen && last_hriz_window_width && last_hriz_window_height)
if (!reqVirt && !fullScreenFl && last_hriz_window_width && last_hriz_window_height)
{
width = last_hriz_window_width;
height = last_hriz_window_height;
}

return reinterpret_cast<decltype(set_resolution_hook)*>(set_resolution_orig)(
need_fullscreen ? r.width : width, need_fullscreen ? r.height : height, need_fullscreen
need_fullscreen ? r.width : width, need_fullscreen ? r.height : height, fullScreenFl
);
}

Expand Down Expand Up @@ -752,6 +763,10 @@ namespace
altEnterPressed = true;
if (!is_virt())
{
if (!fullScreenFlOverride)
{
fullScreenFlOverride = true;
}
fullScreenFl = !fullScreenFl;
Resolution_t r;
get_resolution_stub(&r);
Expand Down

0 comments on commit 8cf0075

Please sign in to comment.