mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-03 11:59:40 +02:00
Win32: reset/restore display mode when activated/deactivated
This commit is contained in:
parent
db332762f5
commit
3c5a231ec7
|
|
@ -265,6 +265,8 @@ extern "C" {
|
|||
#define org_lwjgl_input_Keyboard_STATE_UNKNOWN 2L
|
||||
#undef org_lwjgl_input_Keyboard_BUFFER_SIZE
|
||||
#define org_lwjgl_input_Keyboard_BUFFER_SIZE 50L
|
||||
#undef org_lwjgl_input_Keyboard_EVENT_SIZE
|
||||
#define org_lwjgl_input_Keyboard_EVENT_SIZE 3L
|
||||
/* Inaccessible static: keyName */
|
||||
/* Inaccessible static: keyMap */
|
||||
/* Inaccessible static: counter */
|
||||
|
|
@ -305,7 +307,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nPoll
|
|||
/*
|
||||
* Class: org_lwjgl_input_Keyboard
|
||||
* Method: nRead
|
||||
* Signature: (Ljava/nio/ByteBuffer;I)I
|
||||
* Signature: (Ljava/nio/IntBuffer;I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead
|
||||
(JNIEnv *, jclass, jobject, jint);
|
||||
|
|
|
|||
|
|
@ -39,8 +39,13 @@ extern "C" {
|
|||
/* Inaccessible static: readBuffer */
|
||||
/* Inaccessible static: eventButton */
|
||||
/* Inaccessible static: eventState */
|
||||
/* Inaccessible static: event_dx */
|
||||
/* Inaccessible static: event_dy */
|
||||
/* Inaccessible static: event_dwheel */
|
||||
#undef org_lwjgl_input_Mouse_BUFFER_SIZE
|
||||
#define org_lwjgl_input_Mouse_BUFFER_SIZE 50L
|
||||
#undef org_lwjgl_input_Mouse_EVENT_SIZE
|
||||
#define org_lwjgl_input_Mouse_EVENT_SIZE 5L
|
||||
/* Inaccessible static: isGrabbed */
|
||||
/* Inaccessible static: trackingEnabled */
|
||||
/*
|
||||
|
|
@ -126,7 +131,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nEnableBuffer
|
|||
/*
|
||||
* Class: org_lwjgl_input_Mouse
|
||||
* Method: nRead
|
||||
* Signature: (Ljava/nio/ByteBuffer;I)I
|
||||
* Signature: (Ljava/nio/IntBuffer;I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nRead
|
||||
(JNIEnv *, jclass, jobject, jint);
|
||||
|
|
|
|||
|
|
@ -232,48 +232,6 @@ void switchDisplayMode(JNIEnv * env, jobject mode)
|
|||
modeSet = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Temporarily reset display settings. This is called when the window is minimized.
|
||||
*/
|
||||
/*static void tempResetDisplayMode() {
|
||||
// Return device gamma to normal
|
||||
HDC screenDC = GetDC(NULL);
|
||||
if (!SetDeviceGammaRamp(screenDC, originalGamma)) {
|
||||
printfDebug("Could not reset device gamma\n");
|
||||
}
|
||||
ReleaseDC(NULL, screenDC);
|
||||
|
||||
if (modeSet) {
|
||||
printfDebug("Attempting to temporarily reset the display mode\n");
|
||||
modeSet = false;
|
||||
// Under Win32, all we have to do is:
|
||||
ChangeDisplaySettings(NULL, 0);
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
* Put display settings back to what they were when the window is maximized.
|
||||
*/
|
||||
/*static void tempRestoreDisplayMode() {
|
||||
// Restore gamma
|
||||
HDC screenDC = GetDC(NULL);
|
||||
if (!SetDeviceGammaRamp(screenDC, currentGamma)) {
|
||||
printfDebug("Could not restore device gamma\n");
|
||||
}
|
||||
ReleaseDC(NULL, screenDC);
|
||||
|
||||
if (!modeSet) {
|
||||
printfDebug("Attempting to restore the display mode\n");
|
||||
modeSet = true;
|
||||
LONG cdsret = ChangeDisplaySettings(&devmode, CDS_FULLSCREEN);
|
||||
|
||||
if (cdsret != DISP_CHANGE_SUCCESSFUL) {
|
||||
printfDebug("Failed to restore display mode\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
int getGammaRampLength(void)
|
||||
{
|
||||
return 256;
|
||||
|
|
@ -328,9 +286,7 @@ jobject initDisplay(JNIEnv * env)
|
|||
return newMode;
|
||||
}
|
||||
|
||||
void resetDisplayMode(JNIEnv * env)
|
||||
{
|
||||
|
||||
void resetDisplayMode(JNIEnv * env) {
|
||||
// Return device gamma to normal
|
||||
HDC screenDC = GetDC(NULL);
|
||||
if (!SetDeviceGammaRamp(screenDC, originalGamma)) {
|
||||
|
|
@ -344,7 +300,30 @@ void resetDisplayMode(JNIEnv * env)
|
|||
ChangeDisplaySettings(NULL, 0);
|
||||
|
||||
// And we'll call init() again to put the correct mode back in Display
|
||||
initDisplay(env);
|
||||
if (env != NULL)
|
||||
initDisplay(env);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Put display settings back to what they were when the window is maximized.
|
||||
*/
|
||||
void restoreDisplayMode(void) {
|
||||
// Restore gamma
|
||||
HDC screenDC = GetDC(NULL);
|
||||
if (!SetDeviceGammaRamp(screenDC, currentGamma)) {
|
||||
printfDebug("Could not restore device gamma\n");
|
||||
}
|
||||
ReleaseDC(NULL, screenDC);
|
||||
|
||||
if (!modeSet) {
|
||||
printfDebug("Attempting to restore the display mode\n");
|
||||
modeSet = true;
|
||||
LONG cdsret = ChangeDisplaySettings(&devmode, CDS_FULLSCREEN);
|
||||
|
||||
if (cdsret != DISP_CHANGE_SUCCESSFUL) {
|
||||
printfDebug("Failed to restore display mode\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@
|
|||
extern jobjectArray getAvailableDisplayModes(JNIEnv *env);
|
||||
extern void switchDisplayMode(JNIEnv * env, jobject mode);
|
||||
extern void resetDisplayMode(JNIEnv * env);
|
||||
extern void restoreDisplayMode(void);
|
||||
extern int getGammaRampLength(void);
|
||||
extern void setGammaRamp(JNIEnv * env, jobject gammaRampBuffer);
|
||||
extern jobject initDisplay(JNIEnv * env);
|
||||
|
|
|
|||
|
|
@ -284,10 +284,13 @@ void closeWindow(HWND hwnd, HDC hdc)
|
|||
static void appActivate(bool active)
|
||||
{
|
||||
if (active) {
|
||||
if (isFullScreen)
|
||||
restoreDisplayMode();
|
||||
SetForegroundWindow(display_hwnd);
|
||||
ShowWindow(display_hwnd, SW_RESTORE);
|
||||
} else if (isFullScreen) {
|
||||
ShowWindow(display_hwnd, SW_MINIMIZE);
|
||||
resetDisplayMode(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue