1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-26 06:28:30 +02:00

Fix fullscreen focus behavior

This commit is contained in:
Ethan Lee 2020-06-13 10:35:05 -04:00
parent 506628cef1
commit a15d01ad80
3 changed files with 16 additions and 7 deletions

View File

@ -68,7 +68,7 @@ void KeyPoll::disabletextentry()
SDL_StopTextInput(); SDL_StopTextInput();
} }
void KeyPoll::Poll() void KeyPoll::Poll(Screen *screen)
{ {
SDL_Event evt; SDL_Event evt;
while (SDL_PollEvent(&evt)) while (SDL_PollEvent(&evt))
@ -246,9 +246,14 @@ void KeyPoll::Poll()
isActive = true; isActive = true;
if (!useFullscreenSpaces) if (!useFullscreenSpaces)
{ {
SDL_Window *window = SDL_GetWindowFromID(evt.window.windowID); if (wasFullscreen)
wasFullscreen = SDL_GetWindowFlags(window); {
SDL_SetWindowFullscreen(window, 0); screen->isWindowed = false;
SDL_SetWindowFullscreen(
SDL_GetWindowFromID(evt.window.windowID),
SDL_WINDOW_FULLSCREEN_DESKTOP
);
}
} }
SDL_DisableScreenSaver(); SDL_DisableScreenSaver();
} }
@ -257,9 +262,11 @@ void KeyPoll::Poll()
isActive = false; isActive = false;
if (!useFullscreenSpaces) if (!useFullscreenSpaces)
{ {
wasFullscreen = !screen->isWindowed;
screen->isWindowed = true;
SDL_SetWindowFullscreen( SDL_SetWindowFullscreen(
SDL_GetWindowFromID(evt.window.windowID), SDL_GetWindowFromID(evt.window.windowID),
wasFullscreen 0
); );
} }
SDL_EnableScreenSaver(); SDL_EnableScreenSaver();

View File

@ -7,6 +7,8 @@
#include "SDL.h" #include "SDL.h"
#include "Screen.h"
enum Kybrd enum Kybrd
{ {
KEYBOARD_UP = SDLK_UP, KEYBOARD_UP = SDLK_UP,
@ -52,7 +54,7 @@ public:
void disabletextentry(); void disabletextentry();
void Poll(); void Poll(Screen *screen);
bool isDown(SDL_Keycode key); bool isDown(SDL_Keycode key);

View File

@ -338,7 +338,7 @@ int main(int argc, char *argv[])
key.Poll(); key.Poll(&gameScreen);
if(key.toggleFullscreen) if(key.toggleFullscreen)
{ {
if(!gameScreen.isWindowed) if(!gameScreen.isWindowed)