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.cpp53
1 files changed, 34 insertions, 19 deletions
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp
index 516e115fd..34a79b306 100644
--- a/src/citra_qt/bootmanager.cpp
+++ b/src/citra_qt/bootmanager.cpp
@@ -88,20 +88,20 @@ void EmuThread::Stop()
88class GGLWidgetInternal : public QGLWidget 88class GGLWidgetInternal : public QGLWidget
89{ 89{
90public: 90public:
91 GGLWidgetInternal(QGLFormat fmt, GRenderWindow* parent) : QGLWidget(fmt, parent) 91 GGLWidgetInternal(QGLFormat fmt, GRenderWindow* parent)
92 { 92 : QGLWidget(fmt, parent), parent(parent) {
93 parent_ = parent;
94 } 93 }
95 94
96 void paintEvent(QPaintEvent* ev) override 95 void paintEvent(QPaintEvent* ev) override {
97 {
98 } 96 }
97
99 void resizeEvent(QResizeEvent* ev) override { 98 void resizeEvent(QResizeEvent* ev) override {
100 parent_->SetClientAreaWidth(size().width()); 99 parent->OnClientAreaResized(ev->size().width(), ev->size().height());
101 parent_->SetClientAreaHeight(size().height()); 100 parent->OnFramebufferSizeChanged();
102 } 101 }
102
103private: 103private:
104 GRenderWindow* parent_; 104 GRenderWindow* parent;
105}; 105};
106 106
107EmuThread& GRenderWindow::GetEmuThread() 107EmuThread& GRenderWindow::GetEmuThread()
@@ -120,16 +120,23 @@ GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this
120 fmt.setProfile(QGLFormat::CoreProfile); 120 fmt.setProfile(QGLFormat::CoreProfile);
121 // Requests a forward-compatible context, which is required to get a 3.2+ context on OS X 121 // Requests a forward-compatible context, which is required to get a 3.2+ context on OS X
122 fmt.setOption(QGL::NoDeprecatedFunctions); 122 fmt.setOption(QGL::NoDeprecatedFunctions);
123 123
124 child = new GGLWidgetInternal(fmt, this); 124 child = new GGLWidgetInternal(fmt, this);
125 QBoxLayout* layout = new QHBoxLayout(this); 125 QBoxLayout* layout = new QHBoxLayout(this);
126 resize(VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight); 126 resize(VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight);
127 layout->addWidget(child); 127 layout->addWidget(child);
128 layout->setMargin(0); 128 layout->setMargin(0);
129 setLayout(layout); 129 setLayout(layout);
130 QObject::connect(&emu_thread, SIGNAL(started()), this, SLOT(moveContext())); 130 connect(&emu_thread, SIGNAL(started()), this, SLOT(moveContext()));
131
132 OnFramebufferSizeChanged();
133 NotifyClientAreaSizeChanged(std::pair<unsigned,unsigned>(child->width(), child->height()));
131 134
132 BackupGeometry(); 135 BackupGeometry();
136
137#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
138 connect(this->windowHandle(), SIGNAL(screenChanged(QScreen*)), this, SLOT(OnFramebufferSizeChanged()));
139#endif
133} 140}
134 141
135void GRenderWindow::moveContext() 142void GRenderWindow::moveContext()
@@ -182,22 +189,26 @@ void GRenderWindow::PollEvents() {
182 */ 189 */
183} 190}
184 191
185// On Qt 5.1+, this correctly gets the size of the framebuffer (pixels). 192// On Qt 5.0+, this correctly gets the size of the framebuffer (pixels).
186// 193//
187// Older versions get the window size (density independent pixels), 194// Older versions get the window size (density independent pixels),
188// and hence, do not support DPI scaling ("retina" displays). 195// and hence, do not support DPI scaling ("retina" displays).
189// The result will be a viewport that is smaller than the extent of the window. 196// The result will be a viewport that is smaller than the extent of the window.
190void GRenderWindow::GetFramebufferSize(int* fbWidth, int* fbHeight) 197void GRenderWindow::OnFramebufferSizeChanged()
191{ 198{
192#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) 199 // Screen changes potentially incur a change in screen DPI, hence we should update the framebuffer size
193 int pixelRatio = child->QPaintDevice::devicePixelRatio(); 200#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
194 201 // windowHandle() might not be accessible until the window is displayed to screen.
195 *fbWidth = child->QPaintDevice::width() * pixelRatio; 202 auto pixel_ratio = windowHandle() ? (windowHandle()->screen()->devicePixelRatio()) : 1.0;
196 *fbHeight = child->QPaintDevice::height() * pixelRatio; 203
204 unsigned width = child->QPaintDevice::width() * pixel_ratio;
205 unsigned height = child->QPaintDevice::height() * pixel_ratio;
197#else 206#else
198 *fbWidth = child->QPaintDevice::width(); 207 unsigned width = child->QPaintDevice::width();
199 *fbHeight = child->QPaintDevice::height(); 208 unsigned height = child->QPaintDevice::height();
200#endif 209#endif
210
211 NotifyFramebufferSizeChanged(std::make_pair(width, height));
201} 212}
202 213
203void GRenderWindow::BackupGeometry() 214void GRenderWindow::BackupGeometry()
@@ -260,3 +271,7 @@ void GRenderWindow::ReloadSetKeymaps()
260 KeyMap::SetKeyMapping({Settings::values.pad_sdown_key, keyboard_id}, HID_User::PAD_CIRCLE_DOWN); 271 KeyMap::SetKeyMapping({Settings::values.pad_sdown_key, keyboard_id}, HID_User::PAD_CIRCLE_DOWN);
261} 272}
262 273
274void GRenderWindow::OnClientAreaResized(unsigned width, unsigned height)
275{
276 NotifyClientAreaSizeChanged(std::make_pair(width, height));
277}