Win32: Improve fullscreen task switching
This commit is contained in:
parent
074175fa89
commit
b1c183235c
|
@ -298,10 +298,10 @@ static void appActivate(bool active)
|
||||||
if (isFullScreen) {
|
if (isFullScreen) {
|
||||||
restoreDisplayMode();
|
restoreDisplayMode();
|
||||||
}
|
}
|
||||||
ShowWindow(display_hwnd, SW_RESTORE);
|
ShowWindow(display_hwnd, SW_SHOWDEFAULT);
|
||||||
SetForegroundWindow(display_hwnd);
|
SetForegroundWindow(display_hwnd);
|
||||||
} else if (isFullScreen) {
|
} else if (isFullScreen) {
|
||||||
ShowWindow(display_hwnd, SW_MINIMIZE);
|
ShowWindow(display_hwnd, SW_SHOWMINIMIZED);
|
||||||
resetDisplayMode(NULL);
|
resetDisplayMode(NULL);
|
||||||
}
|
}
|
||||||
inAppActivate = false;
|
inAppActivate = false;
|
||||||
|
@ -320,6 +320,7 @@ LRESULT CALLBACK lwjglWindowProc(HWND hWnd,
|
||||||
int dwheel;
|
int dwheel;
|
||||||
bool oldIsMinimized;
|
bool oldIsMinimized;
|
||||||
bool oldIsFocused;
|
bool oldIsFocused;
|
||||||
|
LRESULT res;
|
||||||
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_SYSCOMMAND:
|
case WM_SYSCOMMAND:
|
||||||
|
@ -337,6 +338,19 @@ LRESULT CALLBACK lwjglWindowProc(HWND hWnd,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case WM_ACTIVATE:
|
||||||
|
// default action
|
||||||
|
//res = DefWindowProc(hWnd, msg, wParam, lParam);
|
||||||
|
switch (wParam) {
|
||||||
|
case WA_ACTIVE:
|
||||||
|
case WA_CLICKACTIVE:
|
||||||
|
appActivate(true);
|
||||||
|
break;
|
||||||
|
case WA_INACTIVE:
|
||||||
|
appActivate(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0L;
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
{
|
{
|
||||||
xPos = GET_X_LPARAM(lParam);
|
xPos = GET_X_LPARAM(lParam);
|
||||||
|
@ -390,26 +404,6 @@ LRESULT CALLBACK lwjglWindowProc(HWND hWnd,
|
||||||
{
|
{
|
||||||
isDirty = true;
|
isDirty = true;
|
||||||
}
|
}
|
||||||
/*case WM_MOVE: {
|
|
||||||
// get fields of display
|
|
||||||
jclass cls_display = (*env)->FindClass(env, "org/lwjgl/opengl/Display");
|
|
||||||
jfieldID fid_x = (*env)->GetStaticFieldID(env, cls_display, "x", "I");
|
|
||||||
jfieldID fid_y = (*env)->GetStaticFieldID(env, cls_display, "y", "I");
|
|
||||||
|
|
||||||
// set fields
|
|
||||||
(*env)->SetStaticIntField(env, cls_display, fid_x, (int)(short) LOWORD(lParam));
|
|
||||||
(*env)->SetStaticIntField(env, cls_display, fid_y, (int)(short) HIWORD(lParam));
|
|
||||||
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update window state directly having processed window messages
|
|
||||||
oldIsMinimized = isMinimized;
|
|
||||||
oldIsFocused = isFocused;
|
|
||||||
isMinimized = IsIconic(display_hwnd);
|
|
||||||
isFocused = GetForegroundWindow() == display_hwnd;
|
|
||||||
if (oldIsMinimized != isMinimized || oldIsFocused != isFocused) {
|
|
||||||
appActivate(isFocused && !isMinimized);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// default action
|
// default action
|
||||||
|
@ -424,14 +418,14 @@ static bool registerWindow()
|
||||||
{
|
{
|
||||||
WNDCLASS windowClass;
|
WNDCLASS windowClass;
|
||||||
if (!oneShotInitialised) {
|
if (!oneShotInitialised) {
|
||||||
windowClass.style = CS_GLOBALCLASS | CS_OWNDC;
|
windowClass.style = CS_OWNDC;
|
||||||
windowClass.lpfnWndProc = lwjglWindowProc;
|
windowClass.lpfnWndProc = lwjglWindowProc;
|
||||||
windowClass.cbClsExtra = 0;
|
windowClass.cbClsExtra = 0;
|
||||||
windowClass.cbWndExtra = 0;
|
windowClass.cbWndExtra = 0;
|
||||||
windowClass.hInstance = dll_handle;
|
windowClass.hInstance = dll_handle;
|
||||||
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
windowClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
windowClass.hbrBackground = NULL;
|
||||||
windowClass.lpszMenuName = NULL;
|
windowClass.lpszMenuName = NULL;
|
||||||
windowClass.lpszClassName = WINDOWCLASSNAME;
|
windowClass.lpszClassName = WINDOWCLASSNAME;
|
||||||
|
|
||||||
|
@ -660,7 +654,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Win32Display_createWindow(JNIEnv *e
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowWindow(display_hwnd, SW_SHOW);
|
ShowWindow(display_hwnd, SW_SHOWDEFAULT);
|
||||||
UpdateWindow(display_hwnd);
|
UpdateWindow(display_hwnd);
|
||||||
SetForegroundWindow(display_hwnd);
|
SetForegroundWindow(display_hwnd);
|
||||||
SetFocus(display_hwnd);
|
SetFocus(display_hwnd);
|
||||||
|
|
Loading…
Reference in New Issue