aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2023-01-25 21:16:05 -0500
committerMorph <39850852+Morph1984@users.noreply.github.com>2023-01-25 21:16:05 -0500
commitad6cec71ecd61aa2533d9efa89b68837516f8464 (patch)
treef5f2831ee518cf2bbaf6010ed3e6306a69755e92 /src
parent5be85c556ed05cd9d751fb7b3f8a331800ee573d (diff)
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.
Diffstat (limited to 'src')
-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 734b0ea40c..4ae49506d8 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) {
QDialog::resize(size);
// High DPI
- const float dpi_scale = qApp->screenAt(pos)->logicalDotsPerInch() / 96.0f;
+ const float dpi_scale = screen()->logicalDotsPerInch() / 96.0f;
RescaleKeyboardElements(size.width(), size.height(), dpi_scale);
}
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 53249426c0..ee8ea82fd7 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -680,8 +680,10 @@ void GMainWindow::SoftwareKeyboardShowNormal() {
const auto y = layout.screen.top;
const auto w = layout.screen.GetWidth();
const auto h = layout.screen.GetHeight();
+ const auto scale_ratio = devicePixelRatioF();
- software_keyboard->ShowNormalKeyboard(render_window->mapToGlobal(QPoint(x, y)), QSize(w, h));
+ software_keyboard->ShowNormalKeyboard(render_window->mapToGlobal(QPoint(x, y) / scale_ratio),
+ QSize(w, h) / scale_ratio);
}
void GMainWindow::SoftwareKeyboardShowTextCheck(
@@ -714,9 +716,11 @@ void GMainWindow::SoftwareKeyboardShowInline(
(1.0f - appear_parameters.key_top_scale_y))));
const auto w = static_cast<int>(layout.screen.GetWidth() * appear_parameters.key_top_scale_x);
const auto h = static_cast<int>(layout.screen.GetHeight() * appear_parameters.key_top_scale_y);
+ const auto scale_ratio = devicePixelRatioF();
software_keyboard->ShowInlineKeyboard(std::move(appear_parameters),
- render_window->mapToGlobal(QPoint(x, y)), QSize(w, h));
+ render_window->mapToGlobal(QPoint(x, y) / scale_ratio),
+ QSize(w, h) / scale_ratio);
}
void GMainWindow::SoftwareKeyboardHideInline() {
@@ -796,10 +800,11 @@ void GMainWindow::WebBrowserOpenWebPage(const std::string& main_url,
}
const auto& layout = render_window->GetFramebufferLayout();
- web_browser_view.resize(layout.screen.GetWidth(), layout.screen.GetHeight());
- web_browser_view.move(layout.screen.left, layout.screen.top + menuBar()->height());
- web_browser_view.setZoomFactor(static_cast<qreal>(layout.screen.GetWidth()) /
- static_cast<qreal>(Layout::ScreenUndocked::Width));
+ const auto scale_ratio = devicePixelRatioF();
+ web_browser_view.resize(layout.screen.GetWidth() / scale_ratio,
+ layout.screen.GetHeight() / scale_ratio);
+ web_browser_view.move(layout.screen.left / scale_ratio,
+ (layout.screen.top / scale_ratio) + menuBar()->height());
web_browser_view.setFocus();
web_browser_view.show();
diff --git a/src/yuzu/util/overlay_dialog.cpp b/src/yuzu/util/overlay_dialog.cpp
index 796f5bf41e..ee35a3e151 100644
--- a/src/yuzu/util/overlay_dialog.cpp
+++ b/src/yuzu/util/overlay_dialog.cpp
@@ -163,7 +163,7 @@ void OverlayDialog::MoveAndResizeWindow() {
const auto height = static_cast<float>(parentWidget()->height());
// High DPI
- const float dpi_scale = parentWidget()->windowHandle()->screen()->logicalDotsPerInch() / 96.0f;
+ const float dpi_scale = screen()->logicalDotsPerInch() / 96.0f;
const auto title_text_font_size = BASE_TITLE_FONT_SIZE * (height / BASE_HEIGHT) / dpi_scale;
const auto body_text_font_size =