_misc windowing
Some checks failed
Build Android / Game (Android, Release ARM64) (push) Has been cancelled
Build iOS / Game (iOS, Release ARM64) (push) Has been cancelled
Build Linux / Editor (Linux, Development x64) (push) Has been cancelled
Build Linux / Game (Linux, Release x64) (push) Has been cancelled
Build macOS / Editor (Mac, Development ARM64) (push) Has been cancelled
Build macOS / Game (Mac, Release ARM64) (push) Has been cancelled
Build Windows / Editor (Windows, Development x64) (push) Has been cancelled
Build Windows / Game (Windows, Release x64) (push) Has been cancelled
Cooker / Cook (Mac) (push) Has been cancelled
Tests / Tests (Linux) (push) Has been cancelled
Tests / Tests (Windows) (push) Has been cancelled

This commit is contained in:
2025-01-07 17:58:43 +02:00
parent 75c44122c6
commit d41f5bd3e6
2 changed files with 17 additions and 20 deletions

View File

@@ -43,8 +43,8 @@ bool SDLPlatform::Init()
SDL_SetHintWithPriority(SDL_HINT_VIDEO_DRIVER, "x11", SDL_HINT_OVERRIDE);
else if (CommandLine::Options.Wayland)
SDL_SetHintWithPriority(SDL_HINT_VIDEO_DRIVER, "wayland", SDL_HINT_OVERRIDE);
//SDL_SetHintWithPriority(SDL_HINT_VIDEO_DRIVER, "wayland", SDL_HINT_OVERRIDE);
// If the hint is not present, SDL will prefer more stable X11 driver over Wayland
else
SDL_SetHintWithPriority(SDL_HINT_VIDEO_DRIVER, "wayland", SDL_HINT_OVERRIDE);
#endif
#if PLATFORM_LINUX
@@ -85,6 +85,9 @@ bool SDLPlatform::Init()
SDL_SetEventEnabled(SDL_EVENT_DROP_COMPLETE, false);
SDL_SetEventEnabled(SDL_EVENT_DROP_POSITION, false);
if (InitPlatform())
return true;
if (!SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD))
Platform::Fatal(String::Format(TEXT("Failed to initialize SDL: {0}."), String(SDL_GetError())));
@@ -105,8 +108,6 @@ bool SDLPlatform::Init()
}
SDL_free(locales);
if (InitPlatform())
return true;
SDLInput::Init();
@@ -264,7 +265,16 @@ void SDLPlatform::OpenUrl(const StringView& url)
Float2 SDLPlatform::GetMousePosition()
{
Float2 pos;
SDL_GetGlobalMouseState(&pos.X, &pos.Y);
#if PLATFORM_LINUX
if (UsesWayland())
{
// Wayland doesn't support reporting global mouse position.
// Use the last known reported position we got from window events.
pos = Input::GetMouseScreenPosition();
}
else
SDL_GetGlobalMouseState(&pos.X, &pos.Y);
#endif
return pos;
}

View File

@@ -203,7 +203,6 @@ SDLWindow::SDLWindow(const CreateWindowSettings& settings)
}
#endif
SDL_DisplayID display = SDL_GetDisplayForWindow(_window);
_dpiScale = SDL_GetWindowDisplayScale(_window);
_dpi = Math::TruncToInt(_dpiScale * DefaultDPI);
@@ -256,9 +255,9 @@ void* GetNativeWindowPointer(SDL_Window* window)
#if PLATFORM_WINDOWS
windowPtr = SDL_GetPointerProperty(props, SDL_PROP_WINDOW_WIN32_HWND_POINTER, nullptr);
#elif PLATFORM_LINUX
windowPtr = SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, nullptr);
windowPtr = SDL_GetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, nullptr);
if (windowPtr == nullptr)
windowPtr = (void*)SDL_GetNumberProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0);
windowPtr = (void*)SDL_GetNumberProperty(props, SDL_PROP_WINDOW_X11_WINDOW_NUMBER, 0);
#elif PLATFORM_MAC
windowPtr = SDL_GetPointerProperty(props, SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, nullptr);
#elif PLATFORM_ANDROID
@@ -585,12 +584,10 @@ void SDLWindow::HandleEvent(SDL_Event& event)
// Check if window size has been changed
if (width > 0 && height > 0 && (_swapChain == nullptr || width != _swapChain->GetWidth() || height != _swapChain->GetHeight()))
OnResize(width, height);
LOG(Info, "Resized {}x{}", width, height);
return;
}
case SDL_EVENT_WINDOW_FOCUS_GAINED:
{
LOG(Info, "Focus gained {}", GetTitle());
#if PLATFORM_LINUX
_forcedFocus = false;
#endif
@@ -606,7 +603,6 @@ void SDLWindow::HandleEvent(SDL_Event& event)
}
case SDL_EVENT_WINDOW_FOCUS_LOST:
{
LOG(Info, "Focus lost {}", GetTitle());
#if PLATFORM_LINUX
_forcedFocus = false;
#endif
@@ -922,15 +918,6 @@ Int2 GetSDLWindowScreenPosition(const SDLWindow* window)
void SetSDLWindowScreenPosition(const SDLWindow* window, const int x, const int y)
{
#if PLATFORM_LINUX
/*if (SDLPlatform::UsesWayland())
{
int oldX, oldY;
SDL_GetWindowPosition(window->GetSDLWindow(), &oldX, &oldY);
if (x == oldX && y == oldY)
return;
}*/
#endif
Int2 relativePosition(x, y);
GetRelativeWindowOffset(window->GetSettings().Type, window->GetSettings().Parent, relativePosition);
SDL_SetWindowPosition(window->GetSDLWindow(), relativePosition.X, relativePosition.Y);