diff options
Diffstat (limited to 'src/citra_qt')
| -rw-r--r-- | src/citra_qt/bootmanager.cpp | 80 | ||||
| -rw-r--r-- | src/citra_qt/bootmanager.hxx | 22 | ||||
| -rw-r--r-- | src/citra_qt/config/controller_config_util.cpp | 4 | ||||
| -rw-r--r-- | src/citra_qt/debugger/callstack.cpp | 6 | ||||
| -rw-r--r-- | src/citra_qt/debugger/registers.cpp | 28 | ||||
| -rw-r--r-- | src/citra_qt/debugger/registers.hxx | 10 | ||||
| -rw-r--r-- | src/citra_qt/main.cpp | 3 |
7 files changed, 102 insertions, 51 deletions
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 20824692d..9bf079919 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -2,6 +2,12 @@ #include <QKeyEvent> #include <QApplication> +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +// Required for screen DPI information +#include <QScreen> +#include <QWindow> +#endif + #include "common/common.h" #include "bootmanager.hxx" @@ -17,7 +23,7 @@ #define APP_TITLE APP_NAME " " APP_VERSION #define COPYRIGHT "Copyright (C) 2013-2014 Citra Team" -EmuThread::EmuThread(GRenderWindow* render_window) : +EmuThread::EmuThread(GRenderWindow* render_window) : filename(""), exec_cpu_step(false), cpu_running(false), stop_run(false), render_window(render_window) { @@ -36,7 +42,7 @@ void EmuThread::run() if (cpu_running) { Core::RunLoop(); - } + } else if (exec_cpu_step) { exec_cpu_step = false; @@ -82,20 +88,20 @@ void EmuThread::Stop() class GGLWidgetInternal : public QGLWidget { public: - GGLWidgetInternal(QGLFormat fmt, GRenderWindow* parent) : QGLWidget(fmt, parent) - { - parent_ = parent; + GGLWidgetInternal(QGLFormat fmt, GRenderWindow* parent) + : QGLWidget(fmt, parent), parent(parent) { } - void paintEvent(QPaintEvent* ev) override - { + void paintEvent(QPaintEvent* ev) override { } + void resizeEvent(QResizeEvent* ev) override { - parent_->SetClientAreaWidth(size().width()); - parent_->SetClientAreaHeight(size().height()); + parent->OnClientAreaResized(ev->size().width(), ev->size().height()); + parent->OnFramebufferSizeChanged(); } + private: - GRenderWindow* parent_; + GRenderWindow* parent; }; EmuThread& GRenderWindow::GetEmuThread() @@ -105,6 +111,9 @@ EmuThread& GRenderWindow::GetEmuThread() GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this), keyboard_id(0) { + std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc); + setWindowTitle(QString::fromStdString(window_title)); + keyboard_id = KeyMap::NewDeviceId(); ReloadSetKeymaps(); @@ -114,16 +123,25 @@ GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this fmt.setProfile(QGLFormat::CoreProfile); // Requests a forward-compatible context, which is required to get a 3.2+ context on OS X fmt.setOption(QGL::NoDeprecatedFunctions); - + child = new GGLWidgetInternal(fmt, this); QBoxLayout* layout = new QHBoxLayout(this); resize(VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight); layout->addWidget(child); layout->setMargin(0); setLayout(layout); - QObject::connect(&emu_thread, SIGNAL(started()), this, SLOT(moveContext())); + connect(&emu_thread, SIGNAL(started()), this, SLOT(moveContext())); + + OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size); + + OnFramebufferSizeChanged(); + NotifyClientAreaSizeChanged(std::pair<unsigned,unsigned>(child->width(), child->height())); BackupGeometry(); + +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + connect(this->windowHandle(), SIGNAL(screenChanged(QScreen*)), this, SLOT(OnFramebufferSizeChanged())); +#endif } void GRenderWindow::moveContext() @@ -166,14 +184,28 @@ void GRenderWindow::DoneCurrent() } void GRenderWindow::PollEvents() { - // TODO(ShizZy): Does this belong here? This is a reasonable place to update the window title - // from the main thread, but this should probably be in an event handler... - /* - static char title[128]; - sprintf(title, "%s (FPS: %02.02f)", window_title_.c_str(), - video_core::g_renderer->current_fps()); - setWindowTitle(title); - */ +} + +// On Qt 5.0+, this correctly gets the size of the framebuffer (pixels). +// +// Older versions get the window size (density independent pixels), +// and hence, do not support DPI scaling ("retina" displays). +// The result will be a viewport that is smaller than the extent of the window. +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 + + NotifyFramebufferSizeChanged(std::make_pair(width, height)); } void GRenderWindow::BackupGeometry() @@ -236,3 +268,11 @@ void GRenderWindow::ReloadSetKeymaps() KeyMap::SetKeyMapping({Settings::values.pad_sdown_key, keyboard_id}, HID_User::PAD_CIRCLE_DOWN); } +void GRenderWindow::OnClientAreaResized(unsigned width, unsigned height) +{ + NotifyClientAreaSizeChanged(std::make_pair(width, height)); +} + +void GRenderWindow::OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) { + setMinimumSize(minimal_size.first, minimal_size.second); +} diff --git a/src/citra_qt/bootmanager.hxx b/src/citra_qt/bootmanager.hxx index f8afc403e..5f69f15ea 100644 --- a/src/citra_qt/bootmanager.hxx +++ b/src/citra_qt/bootmanager.hxx @@ -1,12 +1,16 @@ +#include <atomic> + #include <QThread> #include <QGLWidget> -#include <atomic> + #include "common/common.h" #include "common/emu_window.h" -class GRenderWindow; +class QScreen; class QKeyEvent; +class GRenderWindow; + class EmuThread : public QThread { Q_OBJECT @@ -14,7 +18,7 @@ class EmuThread : public QThread public: /** * Set image filename - * + * * @param filename * @warning Only call when not running! */ @@ -74,7 +78,7 @@ private: signals: /** * Emitted when CPU when we've finished processing a single Gekko instruction - * + * * @warning This will only be emitted when the CPU is not running (SetCpuRunning(false)) * @warning When connecting to this signal from other threads, make sure to specify either Qt::QueuedConnection (invoke slot within the destination object's message thread) or even Qt::BlockingQueuedConnection (additionally block source thread until slot returns) */ @@ -100,7 +104,7 @@ public: void BackupGeometry(); void RestoreGeometry(); void restoreGeometry(const QByteArray& geometry); // overridden - QByteArray saveGeometry(); // overridden + QByteArray saveGeometry(); // overridden EmuThread& GetEmuThread(); @@ -109,10 +113,16 @@ public: void ReloadSetKeymaps() override; + void OnClientAreaResized(unsigned width, unsigned height); + + void OnFramebufferSizeChanged(); + public slots: - void moveContext(); + void moveContext(); // overridden private: + void OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) override; + QGLWidget* child; EmuThread emu_thread; diff --git a/src/citra_qt/config/controller_config_util.cpp b/src/citra_qt/config/controller_config_util.cpp index c5426570b..aee3f8616 100644 --- a/src/citra_qt/config/controller_config_util.cpp +++ b/src/citra_qt/config/controller_config_util.cpp @@ -48,7 +48,7 @@ void GKeyConfigButton::OnActivePortChanged(const common::Config::ControllerPort& else if (config.keys.key_code[id] == Qt::Key_Control) text = tr("Control"); else if (config.keys.key_code[id] == Qt::Key_Alt) text = tr("Alt"); else if (config.keys.key_code[id] == Qt::Key_Meta) text = tr("Meta"); - setText(text); + setText(text); } void GKeyConfigButton::OnClicked() @@ -118,4 +118,4 @@ GButtonConfigGroup::GButtonConfigGroup(const QString& name, common::Config::Cont setLayout(layout); } -*/
\ No newline at end of file +*/ diff --git a/src/citra_qt/debugger/callstack.cpp b/src/citra_qt/debugger/callstack.cpp index 77fb0c9ed..895851be3 100644 --- a/src/citra_qt/debugger/callstack.cpp +++ b/src/citra_qt/debugger/callstack.cpp @@ -28,7 +28,7 @@ void CallstackWidget::OnCPUStepped() u32 sp = app_core->GetReg(13); //stack pointer u32 addr, ret_addr, call_addr, func_addr; - + int counter = 0; for (int addr = 0x10000000; addr >= sp; addr -= 4) { @@ -55,7 +55,7 @@ void CallstackWidget::OnCPUStepped() callstack_model->setItem(counter, 0, new QStandardItem(QString("0x%1").arg(addr, 8, 16, QLatin1Char('0')))); callstack_model->setItem(counter, 1, new QStandardItem(QString("0x%1").arg(ret_addr, 8, 16, QLatin1Char('0')))); callstack_model->setItem(counter, 2, new QStandardItem(QString("0x%1").arg(call_addr, 8, 16, QLatin1Char('0')))); - + name = Symbols::HasSymbol(func_addr) ? Symbols::GetSymbol(func_addr).name : "unknown"; callstack_model->setItem(counter, 3, new QStandardItem(QString("%1_%2").arg(QString::fromStdString(name)) .arg(QString("0x%1").arg(func_addr, 8, 16, QLatin1Char('0'))))); @@ -63,4 +63,4 @@ void CallstackWidget::OnCPUStepped() counter++; } } -}
\ No newline at end of file +} diff --git a/src/citra_qt/debugger/registers.cpp b/src/citra_qt/debugger/registers.cpp index 96ceed480..ed17ee4b4 100644 --- a/src/citra_qt/debugger/registers.cpp +++ b/src/citra_qt/debugger/registers.cpp @@ -46,18 +46,18 @@ void RegistersWidget::OnCPUStepped() CSPR->setText(1, QString("0x%1").arg(app_core->GetCPSR(), 8, 16, QLatin1Char('0'))); CSPR->child(0)->setText(1, QString("b%1").arg(app_core->GetCPSR() & 0x1F, 5, 2, QLatin1Char('0'))); // M - Mode - CSPR->child(1)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 5) & 0x1)); // T - State - CSPR->child(2)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 6) & 0x1)); // F - FIQ disable - CSPR->child(3)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 7) & 0x1)); // I - IRQ disable - CSPR->child(4)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 8) & 0x1)); // A - Imprecise abort - CSPR->child(5)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 9) & 0x1)); // E - Data endianess - CSPR->child(6)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 10) & 0x3F)); // IT - If-Then state (DNM) - CSPR->child(7)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 16) & 0xF)); // GE - Greater-than-or-Equal - CSPR->child(8)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 20) & 0xF)); // DNM - Do not modify - CSPR->child(9)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 24) & 0x1)); // J - Java state - CSPR->child(10)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 27) & 0x1)); // Q - Sticky overflow - CSPR->child(11)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 28) & 0x1)); // V - Overflow - CSPR->child(12)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 29) & 0x1)); // C - Carry/Borrow/Extend - CSPR->child(13)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 30) & 0x1)); // Z - Zero - CSPR->child(14)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 31) & 0x1)); // N - Negative/Less than + CSPR->child(1)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 5) & 0x1)); // T - State + CSPR->child(2)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 6) & 0x1)); // F - FIQ disable + CSPR->child(3)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 7) & 0x1)); // I - IRQ disable + CSPR->child(4)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 8) & 0x1)); // A - Imprecise abort + CSPR->child(5)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 9) & 0x1)); // E - Data endianess + CSPR->child(6)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 10) & 0x3F)); // IT - If-Then state (DNM) + CSPR->child(7)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 16) & 0xF)); // GE - Greater-than-or-Equal + CSPR->child(8)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 20) & 0xF)); // DNM - Do not modify + CSPR->child(9)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 24) & 0x1)); // J - Java state + CSPR->child(10)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 27) & 0x1)); // Q - Sticky overflow + CSPR->child(11)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 28) & 0x1)); // V - Overflow + CSPR->child(12)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 29) & 0x1)); // C - Carry/Borrow/Extend + CSPR->child(13)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 30) & 0x1)); // Z - Zero + CSPR->child(14)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 31) & 0x1)); // N - Negative/Less than } diff --git a/src/citra_qt/debugger/registers.hxx b/src/citra_qt/debugger/registers.hxx index 9645feb2a..4cca957ce 100644 --- a/src/citra_qt/debugger/registers.hxx +++ b/src/citra_qt/debugger/registers.hxx @@ -16,10 +16,10 @@ public slots: void OnCPUStepped(); private: - Ui::ARMRegisters cpu_regs_ui; + Ui::ARMRegisters cpu_regs_ui; - QTreeWidget* tree; - - QTreeWidgetItem* registers; - QTreeWidgetItem* CSPR; + QTreeWidget* tree; + + QTreeWidgetItem* registers; + QTreeWidgetItem* CSPR; }; diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 9a4e36adf..d5554d917 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -117,7 +117,8 @@ GMainWindow::GMainWindow() connect(GetHotkey("Main Window", "Load File", this), SIGNAL(activated()), this, SLOT(OnMenuLoadFile())); connect(GetHotkey("Main Window", "Start Emulation", this), SIGNAL(activated()), this, SLOT(OnStartGame())); - setWindowTitle(render_window->GetWindowTitle().c_str()); + std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc); + setWindowTitle(window_title.c_str()); show(); |
