This is happening for me in .NET, but not sure if its from the SFML core. When the cursor is out of the screen to the left or top, the position relative to the window is negative. Normally, SFML won't even send these events since the cursor is out of the screen. However, when passing a manual handle and you click (and hold) on the form then move the cursor out of the form, these events will continue to be sent. Here is a minimalist example in C#:
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using SFML.Graphics;
using SFML.Window;
using Color = SFML.Graphics.Color;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
Application.Run(new Form1());
}
}
public class Form1 : Form
{
readonly RenderWindow rw;
string _displayText = string.Empty;
public Form1()
{
InitializeComponent();
SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
rw = new RenderWindow(Handle);
rw.MouseMoved += rw_MouseMoved;
Focus();
}
void InitializeComponent()
{
SuspendLayout();
AutoScaleDimensions = new SizeF(6F, 13F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(284, 262);
ResumeLayout(false);
}
protected override void OnPaint(PaintEventArgs e)
{
try
{
rw.DispatchEvents();
rw.Clear();
using (var text = new Text { Color = Color.White, Font = SFML.Graphics.Font.DefaultFont, Size = 16 })
{
text.DisplayedString = _displayText;
rw.Draw(text);
}
rw.Display();
}
finally
{
Invalidate();
}
}
void rw_MouseMoved(object sender, MouseMoveEventArgs e)
{
_displayText = e.X + "," + e.Y;
}
}
}