Windows: Don't be too aggressive in clipping the cursor. Fixes a problem where the window is moved out of the screen when clicking the title bar while having the mouse grabbed

This commit is contained in:
Elias Naur 2007-07-28 21:19:58 +00:00
parent 8bb3e5aec0
commit 3f21f95b2f
1 changed files with 14 additions and 3 deletions

View File

@ -220,6 +220,8 @@ final class WindowsDisplay implements DisplayImplementation {
setForegroundWindow(getHwnd()); setForegroundWindow(getHwnd());
setFocus(getHwnd()); setFocus(getHwnd());
did_maximize = true; did_maximize = true;
if (isFullscreen)
checkCursorClip();
} else if (isFullscreen) { } else if (isFullscreen) {
showWindow(getHwnd(), SW_SHOWMINNOACTIVE); showWindow(getHwnd(), SW_SHOWMINNOACTIVE);
resetDisplayMode(); resetDisplayMode();
@ -629,7 +631,7 @@ final class WindowsDisplay implements DisplayImplementation {
return false; return false;
} }
private boolean doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) { private void checkCursorClip() {
if ((isFullscreen || (mouse != null && mouse.isGrabbed())) && !isMinimized && isFocused) { if ((isFullscreen || (mouse != null && mouse.isGrabbed())) && !isMinimized && isFocused) {
try { try {
setupCursorClipping(getHwnd()); setupCursorClipping(getHwnd());
@ -639,6 +641,14 @@ final class WindowsDisplay implements DisplayImplementation {
} else { } else {
resetCursorClipping(); resetCursorClipping();
} }
}
private void setMinimized(boolean m) {
isMinimized = m;
checkCursorClip();
}
private boolean doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
switch (msg) { switch (msg) {
// disable screen saver and monitor power down messages which wreak havoc // disable screen saver and monitor power down messages which wreak havoc
case WM_ACTIVATE: case WM_ACTIVATE:
@ -656,10 +666,10 @@ final class WindowsDisplay implements DisplayImplementation {
switch ((int)wParam) { switch ((int)wParam) {
case SIZE_RESTORED: case SIZE_RESTORED:
case SIZE_MAXIMIZED: case SIZE_MAXIMIZED:
isMinimized = false; setMinimized(false);
break; break;
case SIZE_MINIMIZED: case SIZE_MINIMIZED:
isMinimized = true; setMinimized(true);
break; break;
} }
return false; return false;
@ -667,6 +677,7 @@ final class WindowsDisplay implements DisplayImplementation {
int xPos = (int)(short)(lParam & 0xFFFF); int xPos = (int)(short)(lParam & 0xFFFF);
int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF)); int yPos = transformY(getHwnd(), (int)(short)((lParam >> 16) & 0xFFFF));
handleMouseMoved(xPos, yPos, millis); handleMouseMoved(xPos, yPos, millis);
checkCursorClip();
return true; return true;
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
int dwheel = (int)(short)((wParam >> 16) & 0xFFFF); int dwheel = (int)(short)((wParam >> 16) & 0xFFFF);