|
6 | 6 | * @author Martin Bela <492789@mail.muni.cz> |
7 | 7 | */ |
8 | 8 | /* |
9 | | - * Copyright (c) 2018-2025 CESNET |
| 9 | + * Copyright (c) 2018-2026 CESNET, zájmové sdružení právnických osob |
10 | 10 | * All rights reserved. |
11 | 11 | * |
12 | 12 | * Redistribution and use in source and binary forms, with or without |
|
49 | 49 | #include <cstdio> // for sscanf |
50 | 50 | #include <cstdlib> // for calloc |
51 | 51 | #include <cstring> // for strchr, strcmp |
| 52 | +#include <map> // for map |
52 | 53 |
|
53 | 54 | #include "debug.h" |
54 | 55 | #include "host.h" |
@@ -486,6 +487,7 @@ void show_help() { |
486 | 487 | col() << SBOLD("\t pos=<x>,<y>") << " - set window position\n"; |
487 | 488 | col() << SBOLD("\t size=<W>x<H>") << " - set window size\n"; |
488 | 489 | col() << SBOLD("\twindow_flags=<f>") << " - flags to be passed to SDL_CreateWindow (use prefix 0x for hex)\n"; |
| 490 | + col() << SBOLD("\thint=<key>=<val>") << " - set SDL hint (eg. SDL_VIDEO_WAYLAND_PREFER_LIBDECOR=0): hint can be used repeatedly\n"; |
489 | 491 |
|
490 | 492 | print_gpus(); |
491 | 493 |
|
@@ -607,6 +609,7 @@ struct command_line_arguments { |
607 | 609 | uint32_t window_flags = 0 ; ///< user requested flags |
608 | 610 | uint32_t gpu_idx = vkd::no_gpu_selected; |
609 | 611 | std::string driver{}; |
| 612 | + std::map<std::string, std::string> hints; |
610 | 613 | }; |
611 | 614 |
|
612 | 615 | bool parse_command_line_arguments(command_line_arguments& args, state_vulkan_sdl3& s, char *fmt) { |
@@ -687,6 +690,12 @@ bool parse_command_line_arguments(command_line_arguments& args, state_vulkan_sdl |
687 | 690 | } else if (IS_KEY_PREFIX(token, "window_flags")) { |
688 | 691 | token = strchr(token, '=') + 1; |
689 | 692 | args.window_flags |= cstoi(strchr(token, '=') + 1); |
| 693 | + } else if (IS_KEY_PREFIX(token, "hint") && strchr(token, '=') != strrchr(token, '=')) { |
| 694 | + char *key = strchr(token, '=') + 1; |
| 695 | + char *val = strchr(key, '='); |
| 696 | + *val = '\0'; |
| 697 | + val++; |
| 698 | + args.hints[key] = val; |
690 | 699 | } else { |
691 | 700 | LOG(LOG_LEVEL_ERROR) << wrong_option_msg << token << '\n'; |
692 | 701 | return false; |
@@ -793,6 +802,11 @@ void* display_vulkan_init(module* parent, const char* fmt, unsigned int flags) { |
793 | 802 | if (!args.driver.empty()) { |
794 | 803 | SDL_CHECK(SDL_SetHint(SDL_HINT_VIDEO_DRIVER, args.driver.c_str())); |
795 | 804 | } |
| 805 | + for (auto &it : args.hints) { |
| 806 | + SDL_CHECK(SDL_SetHint(it.first.c_str(), it.second.c_str())); |
| 807 | + MSG(INFO, "Setting %s to %s\n", it.first.c_str(), it.second.c_str()); |
| 808 | + } |
| 809 | + |
796 | 810 | bool ret = SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_EVENTS); |
797 | 811 | if (!ret) { |
798 | 812 | log_msg(LOG_LEVEL_ERROR, "Unable to initialize SDL3: %s\n", SDL_GetError()); |
|
0 commit comments