This commit is contained in:
gambas 2020-12-22 03:39:25 +01:00
commit daafba28dc
3 changed files with 48 additions and 1 deletions

View file

@ -451,9 +451,22 @@ static void hook_main(int *argc, char ***argv)
{
static bool init = false;
char *env;
if (init)
return;
env = getenv("GB_GUI_PLATFORM");
if (env && *env)
{
if (!strcasecmp(env, "X11"))
putenv((char *)"GDK_BACKEND=x11");
else if (!strcasecmp(env, "WAYLAND"))
putenv((char *)"GDK_BACKEND=wayland");
else
fprintf(stderr, "gb.gtk3: warning: unknown platform: %s\n", env);
}
gApplication::init(argc, argv);
load_platform();

View file

@ -718,11 +718,23 @@ static void hook_main(int *argc, char ***argv)
{
QString platform;
const char *comp;
char *env;
env = getenv("GB_GUI_PLATFORM");
if (env && *env)
{
if (!strcasecmp(env, "X11"))
putenv((char *)"QT_QPA_PLATFORM=xcb");
else if (!strcasecmp(env, "WAYLAND"))
putenv((char *)"QT_QPA_PLATFORM=wayland");
else
fprintf(stderr, QT_NAME ": warning: unknown platform: %s\n", env);
}
new MyApplication(*argc, *argv);
platform = qApp->platformName();
fprintf(stderr, "platform = %s\n", TO_UTF8(platform));
if (platform == "wayland")
{
comp = "gb.qt5.wayland";

View file

@ -131,6 +131,28 @@ static bool event_loop()
static void my_main(int *argc, char **argv)
{
char *env;
const char *driver = NULL;
env = getenv("GB_GUI_PLATFORM");
if (env && *env)
{
if (!strcasecmp(env, "wayland"))
driver = "SDL_VIDEODRIVER=wayland";
else if (!strcasecmp(env, "x11"))
driver = "SDL_VIDEODRIVER=x11";
else
fprintf(stderr, "gb.sdl2: warning: unsupported platform: %s\n", env);
}
if (!driver)
{
if (getenv("WAYLAND_DISPLAY"))
putenv("SDL_VIDEODRIVER=wayland");
}
else
putenv((char *)driver);
init_sdl();
CLASS_Window = GB.FindClass("Window");