| 92 | } |
| 93 | |
| 94 | SDLWindow::SDLWindow(const CreateWindowSettings& settings) |
| 95 | : WindowBase(settings) |
| 96 | , _handle(nullptr) |
| 97 | , _cachedClientRectangle(Rectangle::Empty) |
| 98 | #if PLATFORM_LINUX |
| 99 | , _dragOver(false) |
| 100 | #endif |
| 101 | { |
| 102 | Int2 clientSize(Math::TruncToInt(settings.Size.X), Math::TruncToInt(settings.Size.Y)); |
| 103 | _clientSize = Float2(clientSize); |
| 104 | |
| 105 | if (SDLPlatform::UsesWayland()) |
| 106 | { |
| 107 | // The compositor seems to crash when something is rendered to the hidden popup window surface |
| 108 | _settings.ShowAfterFirstPaint = _showAfterFirstPaint = false; |
| 109 | } |
| 110 | |
| 111 | uint32 flags = SDL_WINDOW_HIDDEN; |
| 112 | if (_settings.Type == WindowType::Utility) |
| 113 | flags |= SDL_WINDOW_UTILITY; |
| 114 | else if (_settings.Type == WindowType::Regular && !_settings.ShowInTaskbar) |
| 115 | flags |= SDL_WINDOW_UTILITY; |
| 116 | else if (_settings.Type == WindowType::Tooltip) |
| 117 | flags |= SDL_WINDOW_TOOLTIP; |
| 118 | else if (_settings.Type == WindowType::Popup) |
| 119 | flags |= SDL_WINDOW_POPUP_MENU; |
| 120 | |
| 121 | if (!_settings.HasBorder) |
| 122 | flags |= SDL_WINDOW_BORDERLESS; |
| 123 | if (_settings.AllowInput) |
| 124 | flags |= SDL_WINDOW_INPUT_FOCUS; |
| 125 | else |
| 126 | flags |= SDL_WINDOW_NOT_FOCUSABLE; |
| 127 | if (_settings.HasSizingFrame) |
| 128 | flags |= SDL_WINDOW_RESIZABLE; |
| 129 | if (_settings.IsTopmost) |
| 130 | flags |= SDL_WINDOW_ALWAYS_ON_TOP; |
| 131 | if (_settings.SupportsTransparency) |
| 132 | flags |= SDL_WINDOW_TRANSPARENT; |
| 133 | |
| 134 | #if !PLATFORM_WINDOWS // Fixed on Windows by adding WS_EX_APPWINDOW flag down below |
| 135 | // Disable parenting of child windows as those are always on top of the parent window and never show up in taskbar |
| 136 | if (_settings.Parent != nullptr && (_settings.Type != WindowType::Tooltip && _settings.Type != WindowType::Popup)) |
| 137 | _settings.Parent = nullptr; |
| 138 | #endif |
| 139 | #if PLATFORM_WEB |
| 140 | // Control canvas size |
| 141 | // TODO: try using SDL_SetWindowFillDocument (min SDL 3.4) |
| 142 | flags |= SDL_WINDOW_RESIZABLE; |
| 143 | #endif |
| 144 | |
| 145 | // The window position needs to be relative to the parent window |
| 146 | Int2 relativePosition(Math::TruncToInt(settings.Position.X), Math::TruncToInt(settings.Position.Y)); |
| 147 | GetRelativeWindowOffset(_settings.Type, _settings.Parent, relativePosition); |
| 148 | |
| 149 | SDL_PropertiesID props = SDL_CreateProperties(); |
| 150 | SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_FLAGS_NUMBER, flags); |
| 151 | SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, settings.Title.ToStringAnsi().Get()); |
nothing calls this directly
no test coverage detected