MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Init

Method Init

Source/Engine/Platform/SDL/SDLPlatform.cpp:41–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41bool SDLPlatform::Init()
42{
43#if PLATFORM_LINUX
44 bool waylandSession = false;
45 if (!GetEnvironmentVariable(String("WAYLAND_DISPLAY"), SDLImpl::WaylandDisplayEnv))
46 waylandSession = true;
47 GetEnvironmentVariable(String("XDG_CURRENT_DESKTOP"), SDLImpl::XDGCurrentDesktop);
48
49 if (CommandLine::Options.X11.IsTrue())
50 {
51 SDL_SetHintWithPriority(SDL_HINT_VIDEO_DRIVER, "x11", SDL_HINT_OVERRIDE);
52 waylandSession = false;
53 }
54 else if (CommandLine::Options.Wayland.IsTrue())
55 SDL_SetHintWithPriority(SDL_HINT_VIDEO_DRIVER, "wayland", SDL_HINT_OVERRIDE);
56 else if (waylandSession)
57 {
58 // Override the X11 preference when running in Wayland session
59 SDL_SetHintWithPriority(SDL_HINT_VIDEO_DRIVER, "wayland", SDL_HINT_OVERRIDE);
60 }
61
62 // Workaround for libdecor in Gnome+Wayland causing freezes when interacting with the native decorations
63 if (waylandSession && SDLImpl::XDGCurrentDesktop.Compare(String("GNOME"), StringSearchCase::IgnoreCase) == 0)
64 {
65 SDL_SetHint(SDL_HINT_VIDEO_WAYLAND_ALLOW_LIBDECOR, "0");
66 SDLImpl::WindowDecorationsSupported = false;
67 }
68 if (waylandSession)
69 SDLImpl::SupportsDecorationDragging = false;
70#endif
71
72#if PLATFORM_LINUX
73 // The name follows the .desktop entry specification, this is used to get a fallback icon on Wayland:
74 // https://specifications.freedesktop.org/desktop-entry-spec/latest/file-naming.html
75#if USE_EDITOR
76 SDL_SetHint(SDL_HINT_APP_ID, StringAnsi("com.FlaxEngine.FlaxEditor").Get());
77#else
78 // TODO: This should be read from the platform configuration (needed for desktop icon handling)
79 SDL_SetHint(SDL_HINT_APP_ID, StringAnsi("com.FlaxEngine.FlaxGame").Get());
80#endif
81#else
82 SDL_SetHint(SDL_HINT_APP_ID, StringAnsi(ApplicationClassName).Get());
83#endif
84
85 SDL_SetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN, "0");
86 SDL_SetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, "0");
87 SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); // Fixes context menu focus issues when clicking unfocused menus
88 SDL_SetHint(SDL_HINT_WINDOWS_ERASE_BACKGROUND_MODE, "0");
89 SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "0"); // Already handled during platform initialization
90 SDL_SetHint("SDL_BORDERLESS_RESIZABLE_STYLE", "1"); // Allow borderless windows to be resizable on Windows
91 //SDL_SetHint("SDL_BORDERLESS_WINDOWED_STYLE", "1");
92
93 SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_WARP_MOTION, "0");
94 SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_CURSOR_VISIBLE, "1"); // Needed for tracking mode
95 SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_CENTER, "0"); // Relative mode can be active when cursor is shown and clipped
96 SDL_SetHint(SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS, "8"); // Reduce the default mouse double-click radius
97
98 //SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1"); // Disables raw mouse input

Callers

nothing calls this directly

Calls 9

StringClass · 0.50
StringAnsiFunction · 0.50
FormatFunction · 0.50
StringAnsiViewClass · 0.50
InitFunction · 0.50
IsTrueMethod · 0.45
CompareMethod · 0.45
GetMethod · 0.45
StartsWithMethod · 0.45

Tested by

no test coverage detected