Fix render resolution at different UI scales (#514)

This commit is contained in:
goeiecool9999 2022-11-30 13:39:32 +01:00 committed by GitHub
parent a3476c7b7c
commit d3721c3f46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 128 additions and 57 deletions

View file

@ -157,6 +157,7 @@ wxBEGIN_EVENT_TABLE(MainWindow, wxFrame)
EVT_TIMER(MAINFRAME_ID_TIMER1, MainWindow::OnTimer)
EVT_CLOSE(MainWindow::OnClose)
EVT_SIZE(MainWindow::OnSizeEvent)
EVT_DPI_CHANGED(MainWindow::OnDPIChangedEvent)
EVT_MOVE(MainWindow::OnMove)
// file menu
EVT_MENU(MAINFRAME_MENU_ID_FILE_LOAD, MainWindow::OnFileMenu)
@ -1310,7 +1311,8 @@ void MainWindow::OnMouseMove(wxMouseEvent& event)
auto& instance = InputManager::instance();
std::unique_lock lock(instance.m_main_mouse.m_mutex);
instance.m_main_mouse.position = { event.GetPosition().x, event.GetPosition().y };
auto physPos = ToPhys(event.GetPosition());
instance.m_main_mouse.position = { physPos.x, physPos.y };
lock.unlock();
if (!IsFullScreen())
@ -1328,7 +1330,8 @@ void MainWindow::OnMouseLeft(wxMouseEvent& event)
std::scoped_lock lock(instance.m_main_mouse.m_mutex);
instance.m_main_mouse.left_down = event.ButtonDown(wxMOUSE_BTN_LEFT);
instance.m_main_mouse.position = { event.GetPosition().x, event.GetPosition().y };
auto physPos = ToPhys(event.GetPosition());
instance.m_main_mouse.position = { physPos.x, physPos.y };
if (event.ButtonDown(wxMOUSE_BTN_LEFT))
instance.m_main_mouse.left_down_toggle = true;
@ -1341,7 +1344,8 @@ void MainWindow::OnMouseRight(wxMouseEvent& event)
std::scoped_lock lock(instance.m_main_mouse.m_mutex);
instance.m_main_mouse.right_down = event.ButtonDown(wxMOUSE_BTN_RIGHT);
instance.m_main_mouse.position = { event.GetPosition().x, event.GetPosition().y };
auto physPos = ToPhys(event.GetPosition());
instance.m_main_mouse.position = { physPos.x, physPos.y };
if(event.ButtonDown(wxMOUSE_BTN_RIGHT))
instance.m_main_mouse.right_down_toggle = true;
@ -1441,7 +1445,8 @@ void MainWindow::OnGesturePan(wxPanGestureEvent& event)
{
auto& instance = InputManager::instance();
std::scoped_lock lock(instance.m_main_touch.m_mutex);
instance.m_main_touch.position = { event.GetPosition().x, event.GetPosition().y };
auto physPos = ToPhys(event.GetPosition());
instance.m_main_touch.position = { physPos.x, physPos.y };
instance.m_main_touch.left_down = event.IsGestureStart() || !event.IsGestureEnd();
if (event.IsGestureStart() || !event.IsGestureEnd())
instance.m_main_touch.left_down_toggle = true;
@ -1516,6 +1521,8 @@ void MainWindow::OnSizeEvent(wxSizeEvent& event)
const wxSize client_size = GetClientSize();
g_window_info.width = client_size.GetWidth();
g_window_info.height = client_size.GetHeight();
g_window_info.phys_width = ToPhys(client_size.GetWidth());
g_window_info.phys_height = ToPhys(client_size.GetHeight());
if (m_debugger_window && m_debugger_window->IsShown())
m_debugger_window->OnParentMove(GetPosition(), event.GetSize());
@ -1525,6 +1532,16 @@ void MainWindow::OnSizeEvent(wxSizeEvent& event)
VsyncDriver_notifyWindowPosChanged();
}
void MainWindow::OnDPIChangedEvent(wxDPIChangedEvent& event)
{
event.Skip();
const wxSize client_size = GetClientSize();
g_window_info.width = client_size.GetWidth();
g_window_info.height = client_size.GetHeight();
g_window_info.phys_width = ToPhys(client_size.GetWidth());
g_window_info.phys_height = ToPhys(client_size.GetHeight());
}
void MainWindow::OnMove(wxMoveEvent& event)
{
if (!IsMaximized() && !gui_isFullScreen())