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.cpp76
1 files changed, 58 insertions, 18 deletions
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp
index 20824692d..758f71fda 100644
--- a/src/citra_qt/bootmanager.cpp
+++ b/src/citra_qt/bootmanager.cpp
@@ -2,6 +2,12 @@
2#include <QKeyEvent> 2#include <QKeyEvent>
3#include <QApplication> 3#include <QApplication>
4 4
5#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
6// Required for screen DPI information
7#include <QScreen>
8#include <QWindow>
9#endif
10
5#include "common/common.h" 11#include "common/common.h"
6#include "bootmanager.hxx" 12#include "bootmanager.hxx"
7 13
@@ -82,20 +88,20 @@ void EmuThread::Stop()
82class GGLWidgetInternal : public QGLWidget 88class GGLWidgetInternal : public QGLWidget
83{ 89{
84public: 90public:
85 GGLWidgetInternal(QGLFormat fmt, GRenderWindow* parent) : QGLWidget(fmt, parent) 91 GGLWidgetInternal(QGLFormat fmt, GRenderWindow* parent)
86 { 92 : QGLWidget(fmt, parent), parent(parent) {
87 parent_ = parent;
88 } 93 }
89 94
90 void paintEvent(QPaintEvent* ev) override 95 void paintEvent(QPaintEvent* ev) override {
91 {
92 } 96 }
97
93 void resizeEvent(QResizeEvent* ev) override { 98 void resizeEvent(QResizeEvent* ev) override {
94 parent_->SetClientAreaWidth(size().width()); 99 parent->OnClientAreaResized(ev->size().width(), ev->size().height());
95 parent_->SetClientAreaHeight(size().height()); 100 parent->OnFramebufferSizeChanged();
96 } 101 }
102
97private: 103private:
98 GRenderWindow* parent_; 104 GRenderWindow* parent;
99}; 105};
100 106
101EmuThread& GRenderWindow::GetEmuThread() 107EmuThread& GRenderWindow::GetEmuThread()
@@ -105,6 +111,9 @@ EmuThread& GRenderWindow::GetEmuThread()
105 111
106GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this), keyboard_id(0) 112GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this), keyboard_id(0)
107{ 113{
114 std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc);
115 setWindowTitle(QString::fromStdString(window_title));
116
108 keyboard_id = KeyMap::NewDeviceId(); 117 keyboard_id = KeyMap::NewDeviceId();
109 ReloadSetKeymaps(); 118 ReloadSetKeymaps();
110 119
@@ -114,16 +123,25 @@ GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this
114 fmt.setProfile(QGLFormat::CoreProfile); 123 fmt.setProfile(QGLFormat::CoreProfile);
115 // Requests a forward-compatible context, which is required to get a 3.2+ context on OS X 124 // Requests a forward-compatible context, which is required to get a 3.2+ context on OS X
116 fmt.setOption(QGL::NoDeprecatedFunctions); 125 fmt.setOption(QGL::NoDeprecatedFunctions);
117 126
118 child = new GGLWidgetInternal(fmt, this); 127 child = new GGLWidgetInternal(fmt, this);
119 QBoxLayout* layout = new QHBoxLayout(this); 128 QBoxLayout* layout = new QHBoxLayout(this);
120 resize(VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight); 129 resize(VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight);
121 layout->addWidget(child); 130 layout->addWidget(child);
122 layout->setMargin(0); 131 layout->setMargin(0);
123 setLayout(layout); 132 setLayout(layout);
124 QObject::connect(&emu_thread, SIGNAL(started()), this, SLOT(moveContext())); 133 connect(&emu_thread, SIGNAL(started()), this, SLOT(moveContext()));
134
135 OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size);
136
137 OnFramebufferSizeChanged();
138 NotifyClientAreaSizeChanged(std::pair<unsigned,unsigned>(child->width(), child->height()));
125 139
126 BackupGeometry(); 140 BackupGeometry();
141
142#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
143 connect(this->windowHandle(), SIGNAL(screenChanged(QScreen*)), this, SLOT(OnFramebufferSizeChanged()));
144#endif
127} 145}
128 146
129void GRenderWindow::moveContext() 147void GRenderWindow::moveContext()
@@ -166,14 +184,28 @@ void GRenderWindow::DoneCurrent()
166} 184}
167 185
168void GRenderWindow::PollEvents() { 186void GRenderWindow::PollEvents() {
169 // TODO(ShizZy): Does this belong here? This is a reasonable place to update the window title 187}
170 // from the main thread, but this should probably be in an event handler... 188
171 /* 189// On Qt 5.0+, this correctly gets the size of the framebuffer (pixels).
172 static char title[128]; 190//
173 sprintf(title, "%s (FPS: %02.02f)", window_title_.c_str(), 191// Older versions get the window size (density independent pixels),
174 video_core::g_renderer->current_fps()); 192// and hence, do not support DPI scaling ("retina" displays).
175 setWindowTitle(title); 193// The result will be a viewport that is smaller than the extent of the window.
176 */ 194void GRenderWindow::OnFramebufferSizeChanged()
195{
196 // Screen changes potentially incur a change in screen DPI, hence we should update the framebuffer size
197#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
198 // windowHandle() might not be accessible until the window is displayed to screen.
199 auto pixel_ratio = windowHandle() ? (windowHandle()->screen()->devicePixelRatio()) : 1.0;
200
201 unsigned width = child->QPaintDevice::width() * pixel_ratio;
202 unsigned height = child->QPaintDevice::height() * pixel_ratio;
203#else
204 unsigned width = child->QPaintDevice::width();
205 unsigned height = child->QPaintDevice::height();
206#endif
207
208 NotifyFramebufferSizeChanged(std::make_pair(width, height));
177} 209}
178 210
179void GRenderWindow::BackupGeometry() 211void GRenderWindow::BackupGeometry()
@@ -236,3 +268,11 @@ void GRenderWindow::ReloadSetKeymaps()
236 KeyMap::SetKeyMapping({Settings::values.pad_sdown_key, keyboard_id}, HID_User::PAD_CIRCLE_DOWN); 268 KeyMap::SetKeyMapping({Settings::values.pad_sdown_key, keyboard_id}, HID_User::PAD_CIRCLE_DOWN);
237} 269}
238 270
271void GRenderWindow::OnClientAreaResized(unsigned width, unsigned height)
272{
273 NotifyClientAreaSizeChanged(std::make_pair(width, height));
274}
275
276void GRenderWindow::OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) {
277 setMinimumSize(minimal_size.first, minimal_size.second);
278}