Re-create TargetWindow on resolution change

Should fix most blackscreen issues
pull/130/head
Peter Repukat 3 years ago
parent 037a54d6a9
commit 295ea46327

@ -51,8 +51,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,0,0004160
PRODUCTVERSION 0,0,0,0004160
FILEVERSION 0,0,0,9051419
PRODUCTVERSION 0,0,0,9051419
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -69,12 +69,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Peter Repukat - FlatspotSoftware"
VALUE "FileDescription", "GlosSI - SteamTarget"
VALUE "FileVersion", "0.0.0.ebc416b"
VALUE "FileVersion", "0.0.0.9c51419"
VALUE "InternalName", "GlosSITarget"
VALUE "LegalCopyright", "Copyright (C) 2021 Peter Repukat - FlatspotSoftware"
VALUE "OriginalFilename", "GlosSITarget.exe"
VALUE "ProductName", "GlosSI"
VALUE "ProductVersion", "0.0.0.ebc416b"
VALUE "ProductVersion", "0.0.0.9c51419"
END
END
BLOCK "VarFileInfo"
@ -536,6 +536,30 @@ END

@ -83,7 +83,6 @@ void TargetWindow::setClickThrough(bool click_through)
void TargetWindow::update()
{
sf::Event event{};
while (window_.pollEvent(event)) {
Overlay::ProcessEvent(event);
if (event.type == sf::Event::Closed) {
@ -99,6 +98,16 @@ void TargetWindow::update()
if (toggle_window_mode_after_frame_) {
createWindow(!windowed_);
}
// As SFML screws us out of most windows-events, just poll resolution every once in a while
// If changed, recreate window.
// Fixes Blackscreen issues when user does funky stuff and still uses GlosSI in non windowed mod...
// (WHY?!)
if (check_resolution_clock_.getElapsedTime().asSeconds() > RES_CHECK_SECONDS) {
if (sf::VideoMode::getDesktopMode().width != old_desktop_mode_.width) {
createWindow(windowed_);
}
check_resolution_clock_.restart();
}
}
void TargetWindow::close()
@ -228,6 +237,7 @@ void TargetWindow::createWindow(bool window_mode)
toggle_window_mode_after_frame_ = false;
auto desktop_mode = sf::VideoMode::getDesktopMode();
old_desktop_mode_ = desktop_mode;
if (window_mode) {
window_.create(sf::VideoMode(desktop_mode.width * 0.75, desktop_mode.height * 0.75, 32), "GlosSITarget");
windowed_ = true;

@ -68,6 +68,10 @@ class TargetWindow {
std::vector<std::string> screenshot_keys_;
const std::function<void()> on_window_changed_;
sf::VideoMode old_desktop_mode_;
sf::Clock check_resolution_clock_;
static constexpr int RES_CHECK_SECONDS = 1;
std::shared_ptr<Overlay> overlay_;

Loading…
Cancel
Save