From 8c91d6a77d387c1b91a1d4be438f6418cf97b704 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 10 Mar 2019 15:11:16 +0100 Subject: [PATCH] Platform/Window: Fix SetCursor always changing cursor --- ChangeLog.md | 1 + src/Nazara/Platform/Win32/WindowImpl.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index a5606276d..58c91edc9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -162,6 +162,7 @@ Nazara Engine: - Added RigidBody2D::ForEachArbiter - Added possibility to change the RigidBody2D velocity function called by the physics engine - Fixed MouseButtonEvent and MouseMoveEvent mouse absolute position being unsigned (now signed) +- Fixed Window::SetCursor changing cursor even if window was in foreground on Windows Nazara Development Kit: - Added ImageWidget (#139) diff --git a/src/Nazara/Platform/Win32/WindowImpl.cpp b/src/Nazara/Platform/Win32/WindowImpl.cpp index 07f952e96..f22569872 100644 --- a/src/Nazara/Platform/Win32/WindowImpl.cpp +++ b/src/Nazara/Platform/Win32/WindowImpl.cpp @@ -289,7 +289,9 @@ namespace Nz { m_cursor = cursor.m_impl->GetCursor(); - ::SetCursor(m_cursor); + // Applies cursor only if we have focus + if (GetForegroundWindow() == m_handle) + ::SetCursor(m_cursor); } void WindowImpl::SetEventListener(bool listener) @@ -653,7 +655,7 @@ namespace Nz { m_mouseInside = true; - // On créé un évènement pour être informé de la sortie de la fenêtre + // Track mouse event to be notified when mouse leaves window TRACKMOUSEEVENT mouseEvent; mouseEvent.cbSize = sizeof(TRACKMOUSEEVENT); mouseEvent.dwFlags = TME_LEAVE;