diff options
author | bunnei <bunneidev@gmail.com> | 2015-10-06 19:05:15 -0400 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2015-10-06 19:05:15 -0400 |
commit | 87eca546b29e841f85810a7134e5fca022d165c2 (patch) | |
tree | 1dc4567c08b98ffe799af973f28b20d237d210ab | |
parent | addef06081c368928f1e76d929a8f176a6209eb2 (diff) | |
parent | ba5d0f594d9c9cc0dbadb4720511c76de93e6d0d (diff) |
Merge pull request #1164 from kemenaran/qt-high-dpi-fixes
citra-qt: high-DPI fixes and Retina on OS X
-rw-r--r-- | src/citra_qt/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/citra_qt/Info.plist | 40 | ||||
-rw-r--r-- | src/citra_qt/bootmanager.cpp | 31 | ||||
-rw-r--r-- | src/citra_qt/bootmanager.h | 2 |
4 files changed, 63 insertions, 12 deletions
diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index 51a574629b..747ad55198 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -24,6 +24,7 @@ set(SRCS hotkeys.cpp main.cpp citra-qt.rc + Info.plist ) set(HEADERS @@ -72,6 +73,7 @@ endif() if (APPLE) add_executable(citra-qt MACOSX_BUNDLE ${SRCS} ${HEADERS} ${UI_HDRS}) + set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) else() add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS}) endif() diff --git a/src/citra_qt/Info.plist b/src/citra_qt/Info.plist new file mode 100644 index 0000000000..4c89e128b8 --- /dev/null +++ b/src/citra_qt/Info.plist @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleExecutable</key> + <string>$(EXECUTABLE_NAME)</string> + <key>CFBundleGetInfoString</key> + <string></string> + <key>CFBundleIconFile</key> + <string>citra.icns</string> + <key>CFBundleIdentifier</key> + <string>com.citra-emu.citra</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleLongVersionString</key> + <string></string> + <key>CFBundleName</key> + <string>Citra</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string></string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string></string> + <key>CSResourcesFileMapped</key> + <true/> + <key>LSRequiresCarbon</key> + <true/> + <key>NSHumanReadableCopyright</key> + <string></string> + <key>NSPrincipalClass</key> + <string>NSApplication</string> + <key>NSHighResolutionCapable</key> + <string>True</string> +</dict> +</plist> diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index b19b367e1c..8e60b9cadb 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -181,16 +181,9 @@ void GRenderWindow::PollEvents() { void GRenderWindow::OnFramebufferSizeChanged() { // Screen changes potentially incur a change in screen DPI, hence we should update the framebuffer size -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - // windowHandle() might not be accessible until the window is displayed to screen. - auto pixel_ratio = windowHandle() ? (windowHandle()->screen()->devicePixelRatio()) : 1.0; - - unsigned width = child->QPaintDevice::width() * pixel_ratio; - unsigned height = child->QPaintDevice::height() * pixel_ratio; -#else - unsigned width = child->QPaintDevice::width(); - unsigned height = child->QPaintDevice::height(); -#endif + qreal pixelRatio = windowPixelRatio(); + unsigned width = child->QPaintDevice::width() * pixelRatio; + unsigned height = child->QPaintDevice::height() * pixelRatio; NotifyFramebufferLayoutChanged(EmuWindow::FramebufferLayout::DefaultScreenLayout(width, height)); } @@ -223,6 +216,16 @@ QByteArray GRenderWindow::saveGeometry() return geometry; } +qreal GRenderWindow::windowPixelRatio() +{ +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + // windowHandle() might not be accessible until the window is displayed to screen. + return windowHandle() ? windowHandle()->screen()->devicePixelRatio() : 1.0f; +#else + return 1.0f; +#endif +} + void GRenderWindow::closeEvent(QCloseEvent* event) { emit Closed(); QWidget::closeEvent(event); @@ -243,14 +246,18 @@ void GRenderWindow::mousePressEvent(QMouseEvent *event) if (event->button() == Qt::LeftButton) { auto pos = event->pos(); - this->TouchPressed(static_cast<unsigned>(pos.x()), static_cast<unsigned>(pos.y())); + qreal pixelRatio = windowPixelRatio(); + this->TouchPressed(static_cast<unsigned>(pos.x() * pixelRatio), + static_cast<unsigned>(pos.y() * pixelRatio)); } } void GRenderWindow::mouseMoveEvent(QMouseEvent *event) { auto pos = event->pos(); - this->TouchMoved(static_cast<unsigned>(std::max(pos.x(), 0)), static_cast<unsigned>(std::max(pos.y(), 0))); + qreal pixelRatio = windowPixelRatio(); + this->TouchMoved(std::max(static_cast<unsigned>(pos.x() * pixelRatio), 0u), + std::max(static_cast<unsigned>(pos.y() * pixelRatio), 0u)); } void GRenderWindow::mouseReleaseEvent(QMouseEvent *event) diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h index 0a9d263b8f..0dcf3e5ebc 100644 --- a/src/citra_qt/bootmanager.h +++ b/src/citra_qt/bootmanager.h @@ -111,6 +111,8 @@ public: void restoreGeometry(const QByteArray& geometry); // overridden QByteArray saveGeometry(); // overridden + qreal windowPixelRatio(); + void closeEvent(QCloseEvent* event) override; void keyPressEvent(QKeyEvent* event) override; |