Qt: move fullscreen cli arg from global to gs_frame

This commit is contained in:
Megamouse 2023-02-13 20:57:25 +01:00
parent 3a68b7ac0d
commit b1b92e95ab
7 changed files with 28 additions and 18 deletions

View File

@ -81,7 +81,6 @@ static atomic_t<bool> s_headless = false;
static atomic_t<bool> s_no_gui = false;
static atomic_t<char*> s_argv0;
atomic_t<bool> g_start_games_fullscreen = false;
std::string g_pad_profile_override;
extern thread_local std::string(*g_tls_log_prefix)();
@ -935,14 +934,8 @@ int main(int argc, char** argv)
}
s_no_gui = parser.isSet(arg_no_gui);
g_start_games_fullscreen = parser.isSet(arg_fullscreen);
if (g_start_games_fullscreen && !s_no_gui)
{
report_fatal_error(fmt::format("The option '%s' can only be used in combination with '%s'.", arg_fullscreen, arg_no_gui));
}
if (auto gui_app = qobject_cast<gui_application*>(app.data()))
if (gui_application* gui_app = qobject_cast<gui_application*>(app.data()))
{
gui_app->setAttribute(Qt::AA_UseHighDpiPixmaps);
gui_app->setAttribute(Qt::AA_DisableWindowContextHelpButton);
@ -953,13 +946,23 @@ int main(int argc, char** argv)
gui_app->SetWithCliBoot(parser.isSet(arg_installfw) || parser.isSet(arg_installpkg) || !parser.positionalArguments().isEmpty());
gui_app->SetActiveUser(active_user);
if (parser.isSet(arg_fullscreen))
{
if (!s_no_gui)
{
report_fatal_error(fmt::format("The option '%s' can only be used in combination with '%s'.", arg_fullscreen, arg_no_gui));
}
gui_app->SetStartGamesFullscreen(true);
}
if (!gui_app->Init())
{
Emu.Quit(true);
return 0;
}
}
else if (auto headless_app = qobject_cast<headless_application*>(app.data()))
else if (headless_application* headless_app = qobject_cast<headless_application*>(app.data()))
{
s_headless = true;

View File

@ -5,8 +5,8 @@
#include <QOpenGLContext>
#include <QOffscreenSurface>
gl_gs_frame::gl_gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, std::shared_ptr<gui_settings> gui_settings)
: gs_frame(screen, geometry, appIcon, std::move(gui_settings))
gl_gs_frame::gl_gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, std::shared_ptr<gui_settings> gui_settings, bool force_fullscreen)
: gs_frame(screen, geometry, appIcon, std::move(gui_settings), force_fullscreen)
{
setSurfaceType(QSurface::OpenGLSurface);

View File

@ -18,7 +18,7 @@ private:
GLContext *m_primary_context = nullptr;
public:
explicit gl_gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, std::shared_ptr<gui_settings> gui_settings);
explicit gl_gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, std::shared_ptr<gui_settings> gui_settings, bool force_fullscreen);
draw_context_t make_context() override;
void set_current(draw_context_t ctx) override;

View File

@ -50,7 +50,6 @@ extern atomic_t<bool> g_user_asked_for_recording;
extern atomic_t<bool> g_user_asked_for_screenshot;
extern atomic_t<bool> g_user_asked_for_frame_capture;
extern atomic_t<bool> g_disable_frame_limit;
extern atomic_t<bool> g_start_games_fullscreen;
extern atomic_t<recording_mode> g_recording_mode;
atomic_t<bool> g_game_window_focused = false;
@ -62,10 +61,11 @@ bool is_input_allowed()
constexpr auto qstr = QString::fromStdString;
gs_frame::gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, std::shared_ptr<gui_settings> gui_settings)
gs_frame::gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, std::shared_ptr<gui_settings> gui_settings, bool force_fullscreen)
: QWindow()
, m_initial_geometry(geometry)
, m_gui_settings(std::move(gui_settings))
, m_start_games_fullscreen(force_fullscreen)
{
m_disable_mouse = m_gui_settings->GetValue(gui::gs_disableMouse).toBool();
m_disable_kb_hotkeys = m_gui_settings->GetValue(gui::gs_disableKbHotkeys).toBool();
@ -611,7 +611,7 @@ void gs_frame::show()
Emu.CallFromMainThread([this]()
{
QWindow::show();
if (g_cfg.misc.start_fullscreen || g_start_games_fullscreen)
if (g_cfg.misc.start_fullscreen || m_start_games_fullscreen)
{
setVisibility(FullScreen);
}

View File

@ -43,11 +43,12 @@ private:
bool m_hide_mouse_after_idletime = false;
u32 m_hide_mouse_idletime = 2000; // ms
bool m_flip_showed_frame = false;
bool m_start_games_fullscreen = false;
std::shared_ptr<utils::video_encoder> m_video_encoder{};
public:
explicit gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, std::shared_ptr<gui_settings> gui_settings);
explicit gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, std::shared_ptr<gui_settings> gui_settings, bool force_fullscreen);
~gs_frame();
draw_context_t make_context() override;

View File

@ -299,13 +299,13 @@ std::unique_ptr<gs_frame> gui_application::get_gs_frame()
{
case video_renderer::opengl:
{
frame = new gl_gs_frame(screen, frame_geometry, app_icon, m_gui_settings);
frame = new gl_gs_frame(screen, frame_geometry, app_icon, m_gui_settings, m_start_games_fullscreen);
break;
}
case video_renderer::null:
case video_renderer::vulkan:
{
frame = new gs_frame(screen, frame_geometry, app_icon, m_gui_settings);
frame = new gs_frame(screen, frame_geometry, app_icon, m_gui_settings, m_start_games_fullscreen);
break;
}
}

View File

@ -44,6 +44,11 @@ public:
m_with_cli_boot = with_cli_boot;
}
void SetStartGamesFullscreen(bool start_games_fullscreen = false)
{
m_start_games_fullscreen = start_games_fullscreen;
}
/** Call this method before calling app.exec */
bool Init() override;
@ -82,6 +87,7 @@ private:
bool m_show_gui = true;
bool m_use_cli_style = false;
bool m_with_cli_boot = false;
bool m_start_games_fullscreen = false;
private Q_SLOTS:
void OnChangeStyleSheetRequest();