summaryrefslogtreecommitdiff
path: root/src/citra_qt/bootmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/citra_qt/bootmanager.cpp')
-rw-r--r--src/citra_qt/bootmanager.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp
index b19b367e1..8e60b9cad 100644
--- a/src/citra_qt/bootmanager.cpp
+++ b/src/citra_qt/bootmanager.cpp
@@ -181,16 +181,9 @@ void GRenderWindow::PollEvents() {
181void GRenderWindow::OnFramebufferSizeChanged() 181void GRenderWindow::OnFramebufferSizeChanged()
182{ 182{
183 // Screen changes potentially incur a change in screen DPI, hence we should update the framebuffer size 183 // Screen changes potentially incur a change in screen DPI, hence we should update the framebuffer size
184#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 184 qreal pixelRatio = windowPixelRatio();
185 // windowHandle() might not be accessible until the window is displayed to screen. 185 unsigned width = child->QPaintDevice::width() * pixelRatio;
186 auto pixel_ratio = windowHandle() ? (windowHandle()->screen()->devicePixelRatio()) : 1.0; 186 unsigned height = child->QPaintDevice::height() * pixelRatio;
187
188 unsigned width = child->QPaintDevice::width() * pixel_ratio;
189 unsigned height = child->QPaintDevice::height() * pixel_ratio;
190#else
191 unsigned width = child->QPaintDevice::width();
192 unsigned height = child->QPaintDevice::height();
193#endif
194 187
195 NotifyFramebufferLayoutChanged(EmuWindow::FramebufferLayout::DefaultScreenLayout(width, height)); 188 NotifyFramebufferLayoutChanged(EmuWindow::FramebufferLayout::DefaultScreenLayout(width, height));
196} 189}
@@ -223,6 +216,16 @@ QByteArray GRenderWindow::saveGeometry()
223 return geometry; 216 return geometry;
224} 217}
225 218
219qreal GRenderWindow::windowPixelRatio()
220{
221#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
222 // windowHandle() might not be accessible until the window is displayed to screen.
223 return windowHandle() ? windowHandle()->screen()->devicePixelRatio() : 1.0f;
224#else
225 return 1.0f;
226#endif
227}
228
226void GRenderWindow::closeEvent(QCloseEvent* event) { 229void GRenderWindow::closeEvent(QCloseEvent* event) {
227 emit Closed(); 230 emit Closed();
228 QWidget::closeEvent(event); 231 QWidget::closeEvent(event);
@@ -243,14 +246,18 @@ void GRenderWindow::mousePressEvent(QMouseEvent *event)
243 if (event->button() == Qt::LeftButton) 246 if (event->button() == Qt::LeftButton)
244 { 247 {
245 auto pos = event->pos(); 248 auto pos = event->pos();
246 this->TouchPressed(static_cast<unsigned>(pos.x()), static_cast<unsigned>(pos.y())); 249 qreal pixelRatio = windowPixelRatio();
250 this->TouchPressed(static_cast<unsigned>(pos.x() * pixelRatio),
251 static_cast<unsigned>(pos.y() * pixelRatio));
247 } 252 }
248} 253}
249 254
250void GRenderWindow::mouseMoveEvent(QMouseEvent *event) 255void GRenderWindow::mouseMoveEvent(QMouseEvent *event)
251{ 256{
252 auto pos = event->pos(); 257 auto pos = event->pos();
253 this->TouchMoved(static_cast<unsigned>(std::max(pos.x(), 0)), static_cast<unsigned>(std::max(pos.y(), 0))); 258 qreal pixelRatio = windowPixelRatio();
259 this->TouchMoved(std::max(static_cast<unsigned>(pos.x() * pixelRatio), 0u),
260 std::max(static_cast<unsigned>(pos.y() * pixelRatio), 0u));
254} 261}
255 262
256void GRenderWindow::mouseReleaseEvent(QMouseEvent *event) 263void GRenderWindow::mouseReleaseEvent(QMouseEvent *event)