mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-19 06:45:39 +00:00
CommonHostInterface: Add a method to get top-level window handle
This commit is contained in:
parent
a894b295b6
commit
a3e4c61a0b
|
@ -32,6 +32,8 @@ int main(int argc, char* argv[])
|
||||||
if (!host_interface->ParseCommandLineParameters(argc, argv, &boot_params))
|
if (!host_interface->ParseCommandLineParameters(argc, argv, &boot_params))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
std::unique_ptr<MainWindow> window = std::make_unique<MainWindow>(host_interface.get());
|
||||||
|
|
||||||
if (!host_interface->Initialize())
|
if (!host_interface->Initialize())
|
||||||
{
|
{
|
||||||
host_interface->Shutdown();
|
host_interface->Shutdown();
|
||||||
|
@ -40,8 +42,7 @@ int main(int argc, char* argv[])
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<MainWindow> window = std::make_unique<MainWindow>(host_interface.get());
|
window->initializeAndShow();
|
||||||
window->show();
|
|
||||||
|
|
||||||
// if we're in batch mode, don't bother refreshing the game list as it won't be used
|
// if we're in batch mode, don't bother refreshing the game list as it won't be used
|
||||||
if (!host_interface->inBatchMode())
|
if (!host_interface->inBatchMode())
|
||||||
|
|
|
@ -47,6 +47,20 @@ MainWindow::MainWindow(QtHostInterface* host_interface)
|
||||||
{
|
{
|
||||||
m_host_interface->setMainWindow(this);
|
m_host_interface->setMainWindow(this);
|
||||||
|
|
||||||
|
// force creation of native window
|
||||||
|
winId();
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::~MainWindow()
|
||||||
|
{
|
||||||
|
Assert(!m_display_widget);
|
||||||
|
m_host_interface->setMainWindow(nullptr);
|
||||||
|
|
||||||
|
Assert(!m_debugger_window);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::initializeAndShow()
|
||||||
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
setupAdditionalUi();
|
setupAdditionalUi();
|
||||||
connectSignals();
|
connectSignals();
|
||||||
|
@ -56,14 +70,8 @@ MainWindow::MainWindow(QtHostInterface* host_interface)
|
||||||
|
|
||||||
restoreStateFromConfig();
|
restoreStateFromConfig();
|
||||||
switchToGameListView();
|
switchToGameListView();
|
||||||
}
|
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
show();
|
||||||
{
|
|
||||||
Assert(!m_display_widget);
|
|
||||||
m_host_interface->setMainWindow(nullptr);
|
|
||||||
|
|
||||||
Assert(!m_debugger_window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::reportError(const QString& message)
|
void MainWindow::reportError(const QString& message)
|
||||||
|
|
|
@ -31,6 +31,9 @@ public:
|
||||||
explicit MainWindow(QtHostInterface* host_interface);
|
explicit MainWindow(QtHostInterface* host_interface);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
|
/// Initializes the window. Call once at startup.
|
||||||
|
void initializeAndShow();
|
||||||
|
|
||||||
/// Performs update check if enabled in settings.
|
/// Performs update check if enabled in settings.
|
||||||
void startupUpdateCheck();
|
void startupUpdateCheck();
|
||||||
|
|
||||||
|
|
|
@ -619,6 +619,11 @@ bool QtHostInterface::RequestRenderWindowSize(s32 new_window_width, s32 new_wind
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* QtHostInterface::GetTopLevelWindowHandle() const
|
||||||
|
{
|
||||||
|
return reinterpret_cast<void*>(m_main_window->winId());
|
||||||
|
}
|
||||||
|
|
||||||
void QtHostInterface::PollAndUpdate()
|
void QtHostInterface::PollAndUpdate()
|
||||||
{
|
{
|
||||||
CommonHostInterface::PollAndUpdate();
|
CommonHostInterface::PollAndUpdate();
|
||||||
|
|
|
@ -72,6 +72,7 @@ public:
|
||||||
std::string TranslateStdString(const char* context, const char* str) const override;
|
std::string TranslateStdString(const char* context, const char* str) const override;
|
||||||
|
|
||||||
bool RequestRenderWindowSize(s32 new_window_width, s32 new_window_height) override;
|
bool RequestRenderWindowSize(s32 new_window_width, s32 new_window_height) override;
|
||||||
|
void* GetTopLevelWindowHandle() const override;
|
||||||
|
|
||||||
ALWAYS_INLINE const GameList* getGameList() const { return m_game_list.get(); }
|
ALWAYS_INLINE const GameList* getGameList() const { return m_game_list.get(); }
|
||||||
ALWAYS_INLINE GameList* getGameList() { return m_game_list.get(); }
|
ALWAYS_INLINE GameList* getGameList() { return m_game_list.get(); }
|
||||||
|
|
|
@ -2672,6 +2672,11 @@ bool CommonHostInterface::RequestRenderWindowScale(float scale)
|
||||||
return RequestRenderWindowSize(static_cast<s32>(requested_width), static_cast<s32>(requested_height));
|
return RequestRenderWindowSize(static_cast<s32>(requested_width), static_cast<s32>(requested_height));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* CommonHostInterface::GetTopLevelWindowHandle() const
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<ByteStream> CommonHostInterface::OpenPackageFile(const char* path, u32 flags)
|
std::unique_ptr<ByteStream> CommonHostInterface::OpenPackageFile(const char* path, u32 flags)
|
||||||
{
|
{
|
||||||
const u32 allowed_flags = (BYTESTREAM_OPEN_READ | BYTESTREAM_OPEN_SEEKABLE | BYTESTREAM_OPEN_STREAMED);
|
const u32 allowed_flags = (BYTESTREAM_OPEN_READ | BYTESTREAM_OPEN_SEEKABLE | BYTESTREAM_OPEN_STREAMED);
|
||||||
|
|
|
@ -192,6 +192,9 @@ public:
|
||||||
/// Requests a resize to a multiple of the render window size.
|
/// Requests a resize to a multiple of the render window size.
|
||||||
bool RequestRenderWindowScale(float scale);
|
bool RequestRenderWindowScale(float scale);
|
||||||
|
|
||||||
|
/// Returns a pointer to the top-level window, needed by some controller interfaces.
|
||||||
|
virtual void* GetTopLevelWindowHandle() const;
|
||||||
|
|
||||||
/// Opens a file in the DuckStation "package".
|
/// Opens a file in the DuckStation "package".
|
||||||
/// This is the APK for Android builds, or the program directory for standalone builds.
|
/// This is the APK for Android builds, or the program directory for standalone builds.
|
||||||
virtual std::unique_ptr<ByteStream> OpenPackageFile(const char* path, u32 flags) override;
|
virtual std::unique_ptr<ByteStream> OpenPackageFile(const char* path, u32 flags) override;
|
||||||
|
|
Loading…
Reference in a new issue