_windoze
Some checks are pending
Build Android / Game (Android, Release ARM64) (push) Waiting to run
Build iOS / Game (iOS, Release ARM64) (push) Waiting to run
Build Linux / Editor (Linux, Development x64) (push) Waiting to run
Build Linux / Game (Linux, Release x64) (push) Waiting to run
Build macOS / Editor (Mac, Development ARM64) (push) Waiting to run
Build macOS / Game (Mac, Release ARM64) (push) Waiting to run
Build Windows / Editor (Windows, Development x64) (push) Waiting to run
Build Windows / Game (Windows, Release x64) (push) Waiting to run
Cooker / Cook (Mac) (push) Waiting to run
Tests / Tests (Linux) (push) Waiting to run
Tests / Tests (Windows) (push) Waiting to run
Some checks are pending
Build Android / Game (Android, Release ARM64) (push) Waiting to run
Build iOS / Game (iOS, Release ARM64) (push) Waiting to run
Build Linux / Editor (Linux, Development x64) (push) Waiting to run
Build Linux / Game (Linux, Release x64) (push) Waiting to run
Build macOS / Editor (Mac, Development ARM64) (push) Waiting to run
Build macOS / Game (Mac, Release ARM64) (push) Waiting to run
Build Windows / Editor (Windows, Development x64) (push) Waiting to run
Build Windows / Game (Windows, Release x64) (push) Waiting to run
Cooker / Cook (Mac) (push) Waiting to run
Tests / Tests (Linux) (push) Waiting to run
Tests / Tests (Windows) (push) Waiting to run
This commit is contained in:
@@ -12,20 +12,24 @@
|
|||||||
#include "Engine/Platform/Win32/IncludeWindowsHeaders.h"
|
#include "Engine/Platform/Win32/IncludeWindowsHeaders.h"
|
||||||
#include "Engine/Input/Mouse.h"
|
#include "Engine/Input/Mouse.h"
|
||||||
#include "Engine/Core/Log.h"
|
#include "Engine/Core/Log.h"
|
||||||
|
#include "Engine/Engine/Engine.h"
|
||||||
|
|
||||||
#include <SDL3/SDL_hints.h>
|
#include <SDL3/SDL_hints.h>
|
||||||
#include <SDL3/SDL_init.h>
|
#include <SDL3/SDL_init.h>
|
||||||
#include <SDL3/SDL_system.h>
|
#include <SDL3/SDL_system.h>
|
||||||
#include <SDL3/SDL_timer.h>
|
#include <SDL3/SDL_timer.h>
|
||||||
|
|
||||||
|
#if USE_EDITOR
|
||||||
|
#include <oleidl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define STYLE_RESIZABLE (WS_THICKFRAME | WS_MAXIMIZEBOX)
|
||||||
|
|
||||||
namespace WinImpl
|
namespace WinImpl
|
||||||
{
|
{
|
||||||
Window* DraggedWindow;
|
Window* DraggedWindow;
|
||||||
Float2 DraggedWindowStartPosition = Float2::Zero;
|
Float2 DraggedWindowStartPosition = Float2::Zero;
|
||||||
Float2 DraggedWindowMousePosition = Float2::Zero;
|
Float2 DraggedWindowMousePosition = Float2::Zero;
|
||||||
#if BORDERLESS_MAXIMIZE_WORKAROUND == 2
|
|
||||||
int SkipMaximizeEventsCount = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The events for releasing the mouse during window dragging are missing, handle the mouse release event here
|
// The events for releasing the mouse during window dragging are missing, handle the mouse release event here
|
||||||
@@ -47,11 +51,6 @@ bool SDLCALL SDLPlatform::EventMessageHook(void* userdata, MSG* msg)
|
|||||||
ASSERT((window) != nullptr); \
|
ASSERT((window) != nullptr); \
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
if (WinImpl::DraggedWindow != nullptr)
|
|
||||||
{
|
|
||||||
LOG(Info, "event hook message: {}", msg->message);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg->message == WM_NCLBUTTONDOWN)
|
if (msg->message == WM_NCLBUTTONDOWN)
|
||||||
{
|
{
|
||||||
Window* window;
|
Window* window;
|
||||||
@@ -117,7 +116,7 @@ bool SDLPlatform::InitInternal()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EventFilterCallback(void* userdata, SDL_Event* event)
|
bool SDLPlatform::EventFilterCallback(void* userdata, SDL_Event* event)
|
||||||
{
|
{
|
||||||
Window* draggedWindow = *(Window**)userdata;
|
Window* draggedWindow = *(Window**)userdata;
|
||||||
if (draggedWindow == nullptr)
|
if (draggedWindow == nullptr)
|
||||||
@@ -184,7 +183,7 @@ void SDLPlatform::PreHandleEvents()
|
|||||||
|
|
||||||
void SDLPlatform::PostHandleEvents()
|
void SDLPlatform::PostHandleEvents()
|
||||||
{
|
{
|
||||||
SDL_RemoveEventWatch(watch, &WinImpl::DraggedWindow);
|
SDL_RemoveEventWatch(EventFilterCallback, &WinImpl::DraggedWindow);
|
||||||
|
|
||||||
// Handle window dragging release here
|
// Handle window dragging release here
|
||||||
if (WinImpl::DraggedWindow != nullptr)
|
if (WinImpl::DraggedWindow != nullptr)
|
||||||
@@ -221,48 +220,6 @@ bool SDLWindow::HandleEventInternal(SDL_Event& event)
|
|||||||
if (result != S_OK)
|
if (result != S_OK)
|
||||||
LOG(Warning, "Window drag and drop service error: 0x{0:x}:{1}", result, 2);
|
LOG(Warning, "Window drag and drop service error: 0x{0:x}:{1}", result, 2);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SDL_EVENT_WINDOW_MAXIMIZED:
|
|
||||||
{
|
|
||||||
#if BORDERLESS_MAXIMIZE_WORKAROUND == 2
|
|
||||||
if (SkipMaximizeEventsCount > 0)
|
|
||||||
{
|
|
||||||
SkipMaximizeEventsCount--;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_settings.HasBorder && _settings.HasSizingFrame)
|
|
||||||
{
|
|
||||||
// Restore the window back to previous state
|
|
||||||
SDL_RestoreWindow(_window);
|
|
||||||
|
|
||||||
// Remove the resizable flags from borderless windows and maximize the window again
|
|
||||||
auto style = ::GetWindowLong((HWND)_handle, GWL_STYLE);
|
|
||||||
style &= ~STYLE_RESIZABLE;
|
|
||||||
::SetWindowLong((HWND)_handle, GWL_STYLE, style);
|
|
||||||
|
|
||||||
SDL_MaximizeWindow(_window);
|
|
||||||
|
|
||||||
// Re-enable the resizable borderless flags
|
|
||||||
style = ::GetWindowLong((HWND)_handle, GWL_STYLE) | STYLE_RESIZABLE;
|
|
||||||
::SetWindowLong((HWND)_handle, GWL_STYLE, style);
|
|
||||||
|
|
||||||
// The next SDL_EVENT_WINDOW_RESTORED and SDL_EVENT_WINDOW_MAXIMIZED events should be ignored
|
|
||||||
SkipMaximizeEventsCount = 2;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SDL_EVENT_WINDOW_RESTORED:
|
|
||||||
{
|
|
||||||
#if BORDERLESS_MAXIMIZE_WORKAROUND == 2
|
|
||||||
if (SkipMaximizeEventsCount > 0)
|
|
||||||
{
|
|
||||||
SkipMaximizeEventsCount--;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -305,43 +262,6 @@ bool SDLPlatform::UsesX11()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLWindow::Maximize()
|
|
||||||
{
|
|
||||||
if (!_settings.AllowMaximize)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#if BORDERLESS_MAXIMIZE_WORKAROUND == 1
|
|
||||||
// Workaround for "SDL_BORDERLESS_RESIZABLE_STYLE" hint not working as expected when maximizing windows
|
|
||||||
auto style = ::GetWindowLong((HWND)_handle, GWL_STYLE);
|
|
||||||
style &= ~STYLE_RESIZABLE;
|
|
||||||
::SetWindowLong((HWND)_handle, GWL_STYLE, style);
|
|
||||||
|
|
||||||
SDL_MaximizeWindow(_window);
|
|
||||||
|
|
||||||
style = ::GetWindowLong((HWND)_handle, GWL_STYLE) | STYLE_RESIZABLE;
|
|
||||||
::SetWindowLong((HWND)_handle, GWL_STYLE, style);
|
|
||||||
#else
|
|
||||||
SDL_MaximizeWindow(_window);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void SDLWindow::Restore()
|
|
||||||
{
|
|
||||||
#if BORDERLESS_MAXIMIZE_WORKAROUND == 1
|
|
||||||
// Workaround for "SDL_BORDERLESS_RESIZABLE_STYLE" hint not working as expected when maximizing windows
|
|
||||||
auto style = ::GetWindowLong((HWND)_handle, GWL_STYLE);
|
|
||||||
style &= ~STYLE_RESIZABLE;
|
|
||||||
::SetWindowLong((HWND)_handle, GWL_STYLE, style);
|
|
||||||
|
|
||||||
SDL_RestoreWindow(_window);
|
|
||||||
|
|
||||||
style = ::GetWindowLong((HWND)_handle, GWL_STYLE) | STYLE_RESIZABLE;
|
|
||||||
::SetWindowLong((HWND)_handle, GWL_STYLE, style);
|
|
||||||
#else
|
|
||||||
SDL_RestoreWindow(_window);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void SDLWindow::Focus()
|
void SDLWindow::Focus()
|
||||||
{
|
{
|
||||||
auto activateWhenRaised = SDL_GetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED);
|
auto activateWhenRaised = SDL_GetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED);
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ private:
|
|||||||
static bool HandleEvent(SDL_Event& event);
|
static bool HandleEvent(SDL_Event& event);
|
||||||
#if PLATFORM_WINDOWS
|
#if PLATFORM_WINDOWS
|
||||||
static bool EventMessageHook(void* userdata, MSG* msg);
|
static bool EventMessageHook(void* userdata, MSG* msg);
|
||||||
|
static bool SDLPlatform::EventFilterCallback(void* userdata, SDL_Event* event);
|
||||||
#elif PLATFORM_LINUX
|
#elif PLATFORM_LINUX
|
||||||
static bool X11EventHook(void* userdata, _XEvent* xevent);
|
static bool X11EventHook(void* userdata, _XEvent* xevent);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
#if PLATFORM_WINDOWS
|
#if PLATFORM_WINDOWS
|
||||||
#include "Engine/Platform/Win32/IncludeWindowsHeaders.h"
|
#include "Engine/Platform/Win32/IncludeWindowsHeaders.h"
|
||||||
#define STYLE_RESIZABLE (WS_THICKFRAME | WS_MAXIMIZEBOX)
|
|
||||||
#define BORDERLESS_MAXIMIZE_WORKAROUND 2
|
|
||||||
#if USE_EDITOR
|
#if USE_EDITOR
|
||||||
#include <oleidl.h>
|
#include <oleidl.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -530,8 +528,6 @@ void SDLWindow::Minimize()
|
|||||||
SDL_MinimizeWindow(_window);
|
SDL_MinimizeWindow(_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !PLATFORM_WINDOWS
|
|
||||||
|
|
||||||
void SDLWindow::Maximize()
|
void SDLWindow::Maximize()
|
||||||
{
|
{
|
||||||
if (!_settings.AllowMaximize)
|
if (!_settings.AllowMaximize)
|
||||||
@@ -540,8 +536,6 @@ void SDLWindow::Maximize()
|
|||||||
SDL_MaximizeWindow(_window);
|
SDL_MaximizeWindow(_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void SDLWindow::SetBorderless(bool isBorderless, bool maximized)
|
void SDLWindow::SetBorderless(bool isBorderless, bool maximized)
|
||||||
{
|
{
|
||||||
if (IsFullscreen())
|
if (IsFullscreen())
|
||||||
@@ -564,15 +558,11 @@ void SDLWindow::SetBorderless(bool isBorderless, bool maximized)
|
|||||||
CheckForWindowResize();
|
CheckForWindowResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !PLATFORM_WINDOWS
|
|
||||||
|
|
||||||
void SDLWindow::Restore()
|
void SDLWindow::Restore()
|
||||||
{
|
{
|
||||||
SDL_RestoreWindow(_window);
|
SDL_RestoreWindow(_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool SDLWindow::IsClosed() const
|
bool SDLWindow::IsClosed() const
|
||||||
{
|
{
|
||||||
return _handle == nullptr;
|
return _handle == nullptr;
|
||||||
@@ -586,20 +576,7 @@ bool SDLWindow::IsForegroundWindow() const
|
|||||||
|
|
||||||
void SDLWindow::BringToFront(bool force)
|
void SDLWindow::BringToFront(bool force)
|
||||||
{
|
{
|
||||||
#if PLATFORM_WINDOWS // FIXME
|
|
||||||
auto activateWhenRaised = SDL_GetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED);
|
|
||||||
SDL_SetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, "0");
|
|
||||||
SDL_RaiseWindow(_window);
|
SDL_RaiseWindow(_window);
|
||||||
SDL_SetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, activateWhenRaised);
|
|
||||||
#endif
|
|
||||||
//if (SDLPlatform::UsesX11())
|
|
||||||
{
|
|
||||||
auto activateWhenRaised = SDL_GetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED);
|
|
||||||
SDL_SetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, "0");
|
|
||||||
SDL_RaiseWindow(_window);
|
|
||||||
SDL_SetHint(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, activateWhenRaised);
|
|
||||||
SDL_SyncWindow(_window);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLWindow::SetClientBounds(const Rectangle& clientArea)
|
void SDLWindow::SetClientBounds(const Rectangle& clientArea)
|
||||||
|
|||||||
Reference in New Issue
Block a user