summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Morph2023-01-25 21:16:05 -0500
committerGravatar Morph2023-01-25 21:16:05 -0500
commitad6cec71ecd61aa2533d9efa89b68837516f8464 (patch)
treef5f2831ee518cf2bbaf6010ed3e6306a69755e92
parentmain: Use passthrough scaling for non-windows OSes (diff)
downloadyuzu-ad6cec71ecd61aa2533d9efa89b68837516f8464.tar.gz
yuzu-ad6cec71ecd61aa2533d9efa89b68837516f8464.tar.xz
yuzu-ad6cec71ecd61aa2533d9efa89b68837516f8464.zip
main: Convert to device independent coordinates for scaling
devicePixelRatioF() returns the scaling ratio when high dpi scaling is enabled. When high dpi scaling is enabled, the raw screen coordinate system is scaled to device independent coordinates.
-rw-r--r--src/yuzu/applets/qt_software_keyboard.cpp2
-rw-r--r--src/yuzu/main.cpp17
-rw-r--r--src/yuzu/util/overlay_dialog.cpp2
3 files changed, 13 insertions, 8 deletions
diff --git a/src/yuzu/applets/qt_software_keyboard.cpp b/src/yuzu/applets/qt_software_keyboard.cpp
index 734b0ea40..4ae49506d 100644
--- a/src/yuzu/applets/qt_software_keyboard.cpp
+++ b/src/yuzu/applets/qt_software_keyboard.cpp
@@ -575,7 +575,7 @@ void QtSoftwareKeyboardDialog::MoveAndResizeWindow(QPoint pos, QSize size) {
575 QDialog::resize(size); 575 QDialog::resize(size);
576 576
577 // High DPI 577 // High DPI
578 const float dpi_scale = qApp->screenAt(pos)->logicalDotsPerInch() / 96.0f; 578 const float dpi_scale = screen()->logicalDotsPerInch() / 96.0f;
579 579
580 RescaleKeyboardElements(size.width(), size.height(), dpi_scale); 580 RescaleKeyboardElements(size.width(), size.height(), dpi_scale);
581} 581}
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 53249426c..ee8ea82fd 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -680,8 +680,10 @@ void GMainWindow::SoftwareKeyboardShowNormal() {
680 const auto y = layout.screen.top; 680 const auto y = layout.screen.top;
681 const auto w = layout.screen.GetWidth(); 681 const auto w = layout.screen.GetWidth();
682 const auto h = layout.screen.GetHeight(); 682 const auto h = layout.screen.GetHeight();
683 const auto scale_ratio = devicePixelRatioF();
683 684
684 software_keyboard->ShowNormalKeyboard(render_window->mapToGlobal(QPoint(x, y)), QSize(w, h)); 685 software_keyboard->ShowNormalKeyboard(render_window->mapToGlobal(QPoint(x, y) / scale_ratio),
686 QSize(w, h) / scale_ratio);
685} 687}
686 688
687void GMainWindow::SoftwareKeyboardShowTextCheck( 689void GMainWindow::SoftwareKeyboardShowTextCheck(
@@ -714,9 +716,11 @@ void GMainWindow::SoftwareKeyboardShowInline(
714 (1.0f - appear_parameters.key_top_scale_y)))); 716 (1.0f - appear_parameters.key_top_scale_y))));
715 const auto w = static_cast<int>(layout.screen.GetWidth() * appear_parameters.key_top_scale_x); 717 const auto w = static_cast<int>(layout.screen.GetWidth() * appear_parameters.key_top_scale_x);
716 const auto h = static_cast<int>(layout.screen.GetHeight() * appear_parameters.key_top_scale_y); 718 const auto h = static_cast<int>(layout.screen.GetHeight() * appear_parameters.key_top_scale_y);
719 const auto scale_ratio = devicePixelRatioF();
717 720
718 software_keyboard->ShowInlineKeyboard(std::move(appear_parameters), 721 software_keyboard->ShowInlineKeyboard(std::move(appear_parameters),
719 render_window->mapToGlobal(QPoint(x, y)), QSize(w, h)); 722 render_window->mapToGlobal(QPoint(x, y) / scale_ratio),
723 QSize(w, h) / scale_ratio);
720} 724}
721 725
722void GMainWindow::SoftwareKeyboardHideInline() { 726void GMainWindow::SoftwareKeyboardHideInline() {
@@ -796,10 +800,11 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
796 } 800 }
797 801
798 const auto& layout = render_window->GetFramebufferLayout(); 802 const auto& layout = render_window->GetFramebufferLayout();
799 web_browser_view.resize(layout.screen.GetWidth(), layout.screen.GetHeight()); 803 const auto scale_ratio = devicePixelRatioF();
800 web_browser_view.move(layout.screen.left, layout.screen.top + menuBar()->height()); 804 web_browser_view.resize(layout.screen.GetWidth() / scale_ratio,
801 web_browser_view.setZoomFactor(static_cast<qreal>(layout.screen.GetWidth()) / 805 layout.screen.GetHeight() / scale_ratio);
802 static_cast<qreal>(Layout::ScreenUndocked::Width)); 806 web_browser_view.move(layout.screen.left / scale_ratio,
807 (layout.screen.top / scale_ratio) + menuBar()->height());
803 808
804 web_browser_view.setFocus(); 809 web_browser_view.setFocus();
805 web_browser_view.show(); 810 web_browser_view.show();
diff --git a/src/yuzu/util/overlay_dialog.cpp b/src/yuzu/util/overlay_dialog.cpp
index 796f5bf41..ee35a3e15 100644
--- a/src/yuzu/util/overlay_dialog.cpp
+++ b/src/yuzu/util/overlay_dialog.cpp
@@ -163,7 +163,7 @@ void OverlayDialog::MoveAndResizeWindow() {
163 const auto height = static_cast<float>(parentWidget()->height()); 163 const auto height = static_cast<float>(parentWidget()->height());
164 164
165 // High DPI 165 // High DPI
166 const float dpi_scale = parentWidget()->windowHandle()->screen()->logicalDotsPerInch() / 96.0f; 166 const float dpi_scale = screen()->logicalDotsPerInch() / 96.0f;
167 167
168 const auto title_text_font_size = BASE_TITLE_FONT_SIZE * (height / BASE_HEIGHT) / dpi_scale; 168 const auto title_text_font_size = BASE_TITLE_FONT_SIZE * (height / BASE_HEIGHT) / dpi_scale;
169 const auto body_text_font_size = 169 const auto body_text_font_size =