mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
windisplay: Fix some situations in which the mouse could stay confined
Fixes #1115
This commit is contained in:
parent
c1c2183561
commit
7f4d030032
@ -434,7 +434,9 @@ set_properties_now(WindowProperties &properties) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WindowProperties::M_confined:
|
case WindowProperties::M_confined:
|
||||||
if (confine_cursor()) {
|
// If we are not the foreground window, we defer confining the cursor
|
||||||
|
// until we are.
|
||||||
|
if (GetForegroundWindow() != _hWnd || confine_cursor()) {
|
||||||
_properties.set_mouse_mode(WindowProperties::M_confined);
|
_properties.set_mouse_mode(WindowProperties::M_confined);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -475,6 +477,11 @@ close_window() {
|
|||||||
set_cursor_out_of_window();
|
set_cursor_out_of_window();
|
||||||
DestroyWindow(_hWnd);
|
DestroyWindow(_hWnd);
|
||||||
|
|
||||||
|
if (_properties.has_mouse_mode() &&
|
||||||
|
_properties.get_mouse_mode() == WindowProperties::M_confined) {
|
||||||
|
ClipCursor(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
if (is_fullscreen()) {
|
if (is_fullscreen()) {
|
||||||
// revert to default display mode.
|
// revert to default display mode.
|
||||||
do_fullscreen_disable();
|
do_fullscreen_disable();
|
||||||
@ -758,12 +765,6 @@ do_reshape_request(int x_origin, int y_origin, bool has_origin,
|
|||||||
view_rect.bottom - view_rect.top,
|
view_rect.bottom - view_rect.top,
|
||||||
flags);
|
flags);
|
||||||
|
|
||||||
// If we are in confined mode, we must update the clip region.
|
|
||||||
if (_properties.has_mouse_mode() &&
|
|
||||||
_properties.get_mouse_mode() == WindowProperties::M_confined) {
|
|
||||||
confine_cursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
handle_reshape();
|
handle_reshape();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -813,6 +814,28 @@ handle_reshape() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we are in confined mode, we must update the clip region. However,
|
||||||
|
// we ony do that if the cursor in currently inside the window, to properly
|
||||||
|
// handle the case where someone is resizing the window straight after
|
||||||
|
// switching to it (you can do this if you press the start menu key to
|
||||||
|
// deactive the window, and then trying to resize it)
|
||||||
|
if (_properties.has_mouse_mode() &&
|
||||||
|
_properties.get_mouse_mode() == WindowProperties::M_confined &&
|
||||||
|
_hWnd == GetForegroundWindow()) {
|
||||||
|
|
||||||
|
POINT cpos;
|
||||||
|
if (GetCursorPos(&cpos) && PtInRect(&view_rect, cpos)) {
|
||||||
|
windisplay_cat.info()
|
||||||
|
<< "ClipCursor() to " << view_rect.left << "," << view_rect.top
|
||||||
|
<< " to " << view_rect.right << "," << view_rect.bottom << endl;
|
||||||
|
|
||||||
|
if (!ClipCursor(&view_rect)) {
|
||||||
|
windisplay_cat.warning()
|
||||||
|
<< "Failed to re-confine cursor to window.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WindowProperties properties;
|
WindowProperties properties;
|
||||||
properties.set_size((view_rect.right - view_rect.left),
|
properties.set_size((view_rect.right - view_rect.left),
|
||||||
(view_rect.bottom - view_rect.top));
|
(view_rect.bottom - view_rect.top));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user