Merge pull request #7519 from stenzek/controller-window

Core: Switch controller interface to render surface on booting
This commit is contained in:
Pierre Bourdon
2018-11-12 17:26:03 +01:00
committed by GitHub
6 changed files with 63 additions and 19 deletions

View File

@ -19,6 +19,8 @@
#include "DolphinQt/QtUtils/QueueOnObject.h"
#include "DolphinQt/Settings.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/VideoConfig.h"
@ -32,8 +34,16 @@ Host* Host::GetInstance()
void Host::SetRenderHandle(void* handle)
{
if (m_render_handle == handle)
return;
m_render_handle = handle;
if (g_renderer)
{
g_renderer->ChangeSurface(handle);
if (g_controller_interface.IsInit())
g_controller_interface.ChangeWindow(handle);
}
}
bool Host::GetRenderFocus()

View File

@ -169,6 +169,7 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters) : QMainW
setWindowIcon(Resources::GetAppIcon());
setUnifiedTitleAndToolBarOnMac(true);
setAcceptDrops(true);
setAttribute(Qt::WA_NativeWindow);
InitControllers();
@ -237,7 +238,7 @@ void MainWindow::InitControllers()
if (g_controller_interface.IsInit())
return;
g_controller_interface.Initialize(reinterpret_cast<void*>(winId()));
g_controller_interface.Initialize(GetWindowSystemInfo(windowHandle()));
Pad::Initialize();
Keyboard::Initialize();
Wiimote::Initialize(Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES);
@ -874,7 +875,8 @@ void MainWindow::SetFullScreenResolution(bool fullscreen)
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
ChangeDisplaySettings(&screen_settings, CDS_FULLSCREEN);
#elif defined(HAVE_XRANDR) && HAVE_XRANDR
m_xrr_config->ToggleDisplayMode(fullscreen);
if (m_xrr_config)
m_xrr_config->ToggleDisplayMode(fullscreen);
#endif
}
@ -938,6 +940,11 @@ void MainWindow::HideRenderWidget(bool reinit)
if (m_render_widget->isFullScreen())
SetFullScreenResolution(focus);
});
// The controller interface will still be registered to the old render widget, if the core
// has booted. Therefore, we should re-bind it to the main window for now. When the core
// is next started, it will be swapped back to the new render widget.
g_controller_interface.ChangeWindow(GetWindowSystemInfo(windowHandle()).render_surface);
}
}
@ -1003,14 +1010,18 @@ void MainWindow::ShowGraphicsWindow()
if (!m_graphics_window)
{
#if defined(HAVE_XRANDR) && HAVE_XRANDR
m_xrr_config = std::make_unique<X11Utils::XRRConfiguration>(
static_cast<Display*>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow(
"display", windowHandle())),
winId());
if (GetWindowSystemType() == WindowSystemType::X11)
{
m_xrr_config = std::make_unique<X11Utils::XRRConfiguration>(
static_cast<Display*>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow(
"display", windowHandle())),
winId());
}
m_graphics_window = new GraphicsWindow(m_xrr_config.get(), this);
#else
m_graphics_window = new GraphicsWindow(nullptr, this);
#endif
InstallHotkeyFilter(m_graphics_window);
}
m_graphics_window->show();
@ -1273,7 +1284,8 @@ void MainWindow::NetPlayQuit()
void MainWindow::EnableScreenSaver(bool enable)
{
#if defined(HAVE_XRANDR) && HAVE_XRANDR
UICommon::EnableScreenSaver(winId(), enable);
if (GetWindowSystemType() == WindowSystemType::X11)
UICommon::EnableScreenSaver(winId(), enable);
#else
UICommon::EnableScreenSaver(enable);
#endif

View File

@ -173,7 +173,7 @@ private:
MenuBar* m_menu_bar;
SearchBar* m_search_bar;
GameList* m_game_list;
RenderWidget* m_render_widget;
RenderWidget* m_render_widget = nullptr;
bool m_rendering_to_main;
bool m_stop_requested = false;
bool m_exit_requested = false;