From b50d6ae225ab04e598a7a625cefc427e1a045263 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Wed, 1 Jan 2025 03:33:51 +0200 Subject: [PATCH] _focus and logging --- Source/Engine/Platform/SDL/SDLWindow.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/Engine/Platform/SDL/SDLWindow.cpp b/Source/Engine/Platform/SDL/SDLWindow.cpp index ba71aff45..d58d2f60e 100644 --- a/Source/Engine/Platform/SDL/SDLWindow.cpp +++ b/Source/Engine/Platform/SDL/SDLWindow.cpp @@ -570,10 +570,12 @@ 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 @@ -589,6 +591,7 @@ void SDLWindow::HandleEvent(SDL_Event& event) } case SDL_EVENT_WINDOW_FOCUS_LOST: { + LOG(Info, "Focus lost {}", GetTitle()); #if PLATFORM_LINUX _forcedFocus = false; #endif @@ -834,8 +837,8 @@ bool SDLWindow::IsClosed() const bool SDLWindow::IsForegroundWindow() const { #if PLATFORM_LINUX - if (_forcedFocus) - return true; + //if (_forcedFocus) + // return true; #endif SDL_WindowFlags flags = SDL_GetWindowFlags(_window); return (flags & SDL_WINDOW_INPUT_FOCUS) != 0; @@ -996,6 +999,7 @@ void SDLWindow::SetOpacity(const float opacity) void SDLWindow::Focus() { +#if PLATFORM_WINDOWS auto activateWhenRaised = SDL_GetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED); SDL_SetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, "1"); @@ -1007,6 +1011,9 @@ void SDLWindow::Focus() SDL_SetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, activateWhenRaised); //SDL_SetHint(SDL_HINT_FORCE_RAISEWINDOW, forceRaiseWindow); +#else + SDL_RaiseWindow(_window); +#endif } String SDLWindow::GetTitle() const