summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2015-10-06 19:05:15 -0400
committerGravatar bunnei2015-10-06 19:05:15 -0400
commit87eca546b29e841f85810a7134e5fca022d165c2 (patch)
tree1dc4567c08b98ffe799af973f28b20d237d210ab /src
parentOS X build uploading: auto-confirm SSH host key (diff)
parentcitra-qt: Fix mouse events coordinates on high-DPI screens (diff)
downloadyuzu-87eca546b29e841f85810a7134e5fca022d165c2.tar.gz
yuzu-87eca546b29e841f85810a7134e5fca022d165c2.tar.xz
yuzu-87eca546b29e841f85810a7134e5fca022d165c2.zip
Merge pull request #1164 from kemenaran/qt-high-dpi-fixes
citra-qt: high-DPI fixes and Retina on OS X
Diffstat (limited to 'src')
-rw-r--r--src/citra_qt/CMakeLists.txt2
-rw-r--r--src/citra_qt/Info.plist40
-rw-r--r--src/citra_qt/bootmanager.cpp31
-rw-r--r--src/citra_qt/bootmanager.h2
4 files changed, 63 insertions, 12 deletions
diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt
index 51a574629..747ad5519 100644
--- a/src/citra_qt/CMakeLists.txt
+++ b/src/citra_qt/CMakeLists.txt
@@ -24,6 +24,7 @@ set(SRCS
24 hotkeys.cpp 24 hotkeys.cpp
25 main.cpp 25 main.cpp
26 citra-qt.rc 26 citra-qt.rc
27 Info.plist
27 ) 28 )
28 29
29set(HEADERS 30set(HEADERS
@@ -72,6 +73,7 @@ endif()
72 73
73if (APPLE) 74if (APPLE)
74 add_executable(citra-qt MACOSX_BUNDLE ${SRCS} ${HEADERS} ${UI_HDRS}) 75 add_executable(citra-qt MACOSX_BUNDLE ${SRCS} ${HEADERS} ${UI_HDRS})
76 set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
75else() 77else()
76 add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS}) 78 add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS})
77endif() 79endif()
diff --git a/src/citra_qt/Info.plist b/src/citra_qt/Info.plist
new file mode 100644
index 000000000..4c89e128b
--- /dev/null
+++ b/src/citra_qt/Info.plist
@@ -0,0 +1,40 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>CFBundleDevelopmentRegion</key>
6 <string>English</string>
7 <key>CFBundleExecutable</key>
8 <string>$(EXECUTABLE_NAME)</string>
9 <key>CFBundleGetInfoString</key>
10 <string></string>
11 <key>CFBundleIconFile</key>
12 <string>citra.icns</string>
13 <key>CFBundleIdentifier</key>
14 <string>com.citra-emu.citra</string>
15 <key>CFBundleInfoDictionaryVersion</key>
16 <string>6.0</string>
17 <key>CFBundleLongVersionString</key>
18 <string></string>
19 <key>CFBundleName</key>
20 <string>Citra</string>
21 <key>CFBundlePackageType</key>
22 <string>APPL</string>
23 <key>CFBundleShortVersionString</key>
24 <string></string>
25 <key>CFBundleSignature</key>
26 <string>????</string>
27 <key>CFBundleVersion</key>
28 <string></string>
29 <key>CSResourcesFileMapped</key>
30 <true/>
31 <key>LSRequiresCarbon</key>
32 <true/>
33 <key>NSHumanReadableCopyright</key>
34 <string></string>
35 <key>NSPrincipalClass</key>
36 <string>NSApplication</string>
37 <key>NSHighResolutionCapable</key>
38 <string>True</string>
39</dict>
40</plist>
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)
diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h
index 0a9d263b8..0dcf3e5eb 100644
--- a/src/citra_qt/bootmanager.h
+++ b/src/citra_qt/bootmanager.h
@@ -111,6 +111,8 @@ public:
111 void restoreGeometry(const QByteArray& geometry); // overridden 111 void restoreGeometry(const QByteArray& geometry); // overridden
112 QByteArray saveGeometry(); // overridden 112 QByteArray saveGeometry(); // overridden
113 113
114 qreal windowPixelRatio();
115
114 void closeEvent(QCloseEvent* event) override; 116 void closeEvent(QCloseEvent* event) override;
115 117
116 void keyPressEvent(QKeyEvent* event) override; 118 void keyPressEvent(QKeyEvent* event) override;