RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent) { setWindowTitle(QStringLiteral("Dolphin")); setWindowIcon(Resources::GetAppIcon()); setAcceptDrops(true); QPalette p; p.setColor(QPalette::Background, Qt::black); setPalette(p); connect(Host::GetInstance(), &Host::RequestTitle, this, &RenderWidget::setWindowTitle); connect(Host::GetInstance(), &Host::RequestRenderSize, this, [this](int w, int h) { if (!Config::Get(Config::MAIN_RENDER_WINDOW_AUTOSIZE) || isFullScreen() || isMaximized()) return; resize(w, h); }); connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this](Core::State state) { // Stop filling the background once emulation starts, but fill it until then (Bug 10958) SetFillBackground(Config::Get(Config::MAIN_RENDER_TO_MAIN) && state == Core::State::Uninitialized); if (state == Core::State::Running) SetImGuiKeyMap(); }); // We have to use Qt::DirectConnection here because we don't want those signals to get queued // (which results in them not getting called) connect(this, &RenderWidget::StateChanged, Host::GetInstance(), &Host::SetRenderFullscreen, Qt::DirectConnection); connect(this, &RenderWidget::HandleChanged, Host::GetInstance(), &Host::SetRenderHandle, Qt::DirectConnection); connect(this, &RenderWidget::SizeChanged, Host::GetInstance(), &Host::ResizeSurface, Qt::DirectConnection); connect(this, &RenderWidget::FocusChanged, Host::GetInstance(), &Host::SetRenderFocus, Qt::DirectConnection); m_mouse_timer = new QTimer(this); connect(m_mouse_timer, &QTimer::timeout, this, &RenderWidget::HandleCursorTimer); m_mouse_timer->setSingleShot(true); setMouseTracking(true); connect(&Settings::Instance(), &Settings::HideCursorChanged, this, &RenderWidget::OnHideCursorChanged); OnHideCursorChanged(); connect(&Settings::Instance(), &Settings::KeepWindowOnTopChanged, this, &RenderWidget::OnKeepOnTopChanged); OnKeepOnTopChanged(Settings::Instance().IsKeepWindowOnTopEnabled()); m_mouse_timer->start(MOUSE_HIDE_DELAY); // We need a native window to render into. setAttribute(Qt::WA_NativeWindow); SetFillBackground(true); }
RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent) { setAttribute(Qt::WA_OpaquePaintEvent, true); setAttribute(Qt::WA_NoSystemBackground, true); connect(Host::GetInstance(), &Host::RequestTitle, this, &RenderWidget::setWindowTitle); connect(this, &RenderWidget::FocusChanged, Host::GetInstance(), &Host::SetRenderFocus); connect(this, &RenderWidget::StateChanged, Host::GetInstance(), &Host::SetRenderFullscreen); connect(this, &RenderWidget::HandleChanged, Host::GetInstance(), &Host::SetRenderHandle); emit HandleChanged((void*)winId()); connect(&Settings::Instance(), &Settings::HideCursorChanged, this, &RenderWidget::OnHideCursorChanged); OnHideCursorChanged(); }