1
0
Fork 0

Display/Display: Cache position when entering fullscreen and restore when entering window mode again.

This commit is contained in:
Henrik Hautakoski 2022-09-12 22:24:19 +02:00
parent d34d20361d
commit d12d60b1ba
2 changed files with 13 additions and 0 deletions

View file

@ -4,6 +4,7 @@
#include "DisplayMode.h"
#include "DisplayDescription.h"
#include <Spectre/Math/Vector2.h>
#include <Spectre/Display/GLContext.h>
#include <cstdint>
#include <string>
@ -71,6 +72,10 @@ protected :
protected :
enum Mode m_fmode;
// Cache window position when entering fullscreen
// So it can be restored when returning to window mode.
Vector2u m_cachePos;
DisplayDescription m_description;
DisplayDescription m_cacheDesc;

View file

@ -106,6 +106,11 @@ void Display::setVideoMode(Mode mode)
m_impl->exitFullscreen();
}
// Cache window position when entering fullscreen.
if (mode == FULLSCREEN || mode == WINDOWEDFULLSCREEN) {
m_cachePos = m_impl->getPosition();
}
// True fullscreen
if (mode == FULLSCREEN) {
m_impl->enterFullscreen(m_description.mode);
@ -120,6 +125,9 @@ void Display::setVideoMode(Mode mode)
else {
// Set stored decoration.
m_impl->setDecoration(m_description.decoration);
// Restore position.
m_impl->setPosition(m_cachePos.x, m_cachePos.y);
}
m_fmode = mode;