Skip to content

Commit

Permalink
fix: reset window state
Browse files Browse the repository at this point in the history
  • Loading branch information
zeromake committed Mar 19, 2023
1 parent a3f27e4 commit d5be945
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions wiliwili/source/utils/config_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include "bilibili.h"
#include "borealis/core/cache_helper.hpp"
#include <borealis/core/geometry.hpp>
#include "utils/number_helper.hpp"
#include "utils/image_helper.hpp"
#include "utils/config_helper.hpp"
Expand Down Expand Up @@ -253,27 +252,25 @@ void ProgramConfig::loadHomeWindowState() {
&hHeight, &hXPos, &hYPos);

if (hWidth == 0 || hHeight == 0) return;
struct brls::Rect rect;
rect.size.width = hWidth;
rect.size.height = hHeight;
rect.origin.x = (float)hXPos;
rect.origin.y = (float)hYPos;
VideoContext::setWindowState(rect);

VideoContext::sizeH = hHeight;
VideoContext::sizeW = hWidth;
VideoContext::posX = (float)hXPos;
VideoContext::posY = (float)hYPos;
VideoContext::monitorIndex = monitor;

brls::Logger::info("Load window state: {}x{},{}x{}", hWidth, hHeight, hXPos,
hYPos);
}

void ProgramConfig::saveHomeWindowState() {
struct brls::Rect rect;
VideoContext::getWindowState(&rect);
if (isnan(rect.origin.x) || isnan(rect.origin.y)) return;
if (isnan(VideoContext::posX) || isnan(VideoContext::posY)) return;
auto videoContext = brls::Application::getPlatform()->getVideoContext();
uint32_t width = rect.size.width;
uint32_t height = rect.size.height;
int xPos = rect.origin.x;
int yPos = rect.origin.y;

uint32_t width = VideoContext::sizeW;
uint32_t height = VideoContext::sizeH;
int xPos = VideoContext::posX;
int yPos = VideoContext::posY;

int monitor = videoContext->getCurrentMonitorIndex();
if (width == 0) width = brls::ORIGINAL_WINDOW_WIDTH;
Expand Down

0 comments on commit d5be945

Please sign in to comment.