Fixed error in Mouse::Set/GetPosition when the given window was already closed
This commit is contained in:
parent
61adc51d09
commit
73665bd50a
@ -228,16 +228,24 @@ Vector2i InputImpl::GetMousePosition()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2i InputImpl::GetMousePosition(const Window& relativeTo)
|
Vector2i InputImpl::GetMousePosition(const Window& relativeTo)
|
||||||
{
|
{
|
||||||
// we don't care about these but they are required
|
WindowHandle handle = relativeTo.GetSystemHandle();
|
||||||
::Window root, child;
|
if (handle)
|
||||||
int gx, gy;
|
{
|
||||||
unsigned int buttons;
|
// we don't care about these but they are required
|
||||||
|
::Window root, child;
|
||||||
|
int gx, gy;
|
||||||
|
unsigned int buttons;
|
||||||
|
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
XQueryPointer(global.display, relativeTo.GetSystemHandle(), &root, &child, &gx, &gy, &x, &y, &buttons);
|
XQueryPointer(global.display, handle, &root, &child, &gx, &gy, &x, &y, &buttons);
|
||||||
|
|
||||||
return Vector2i(x, y);
|
return Vector2i(x, y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Vector2i();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -252,8 +260,12 @@ void InputImpl::SetMousePosition(const Vector2i& position)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void InputImpl::SetMousePosition(const Vector2i& position, const Window& relativeTo)
|
void InputImpl::SetMousePosition(const Vector2i& position, const Window& relativeTo)
|
||||||
{
|
{
|
||||||
XWarpPointer(global.display, None, relativeTo.GetSystemHandle(), 0, 0, 0, 0, position.x, position.y);
|
WindowHandle handle = relativeTo.GetSystemHandle();
|
||||||
XFlush(global.display);
|
if (handle)
|
||||||
|
{
|
||||||
|
XWarpPointer(global.display, None, handle, 0, 0, 0, 0, position.x, position.y);
|
||||||
|
XFlush(global.display);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
@ -178,10 +178,18 @@ Vector2i InputImpl::GetMousePosition()
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2i InputImpl::GetMousePosition(const Window& relativeTo)
|
Vector2i InputImpl::GetMousePosition(const Window& relativeTo)
|
||||||
{
|
{
|
||||||
POINT point;
|
WindowHandle handle = relativeTo.GetSystemHandle();
|
||||||
GetCursorPos(&point);
|
if (handle)
|
||||||
ScreenToClient(relativeTo.GetSystemHandle(), &point);
|
{
|
||||||
return Vector2i(point.x, point.y);
|
POINT point;
|
||||||
|
GetCursorPos(&point);
|
||||||
|
ScreenToClient(handle, &point);
|
||||||
|
return Vector2i(point.x, point.y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Vector2i();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -195,9 +203,13 @@ void InputImpl::SetMousePosition(const Vector2i& position)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void InputImpl::SetMousePosition(const Vector2i& position, const Window& relativeTo)
|
void InputImpl::SetMousePosition(const Vector2i& position, const Window& relativeTo)
|
||||||
{
|
{
|
||||||
POINT point = {position.x, position.y};
|
WindowHandle handle = relativeTo.GetSystemHandle();
|
||||||
ClientToScreen(relativeTo.GetSystemHandle(), &point);
|
if (handle)
|
||||||
SetCursorPos(point.x, point.y);
|
{
|
||||||
|
POINT point = {position.x, position.y};
|
||||||
|
ClientToScreen(handle, &point);
|
||||||
|
SetCursorPos(point.x, point.y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
Loading…
Reference in New Issue
Block a user