mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-10-06 09:17:07 +02:00
Fix window position by setting it at the right time
This commit is contained in:
parent
bbb1732120
commit
6972929d98
@ -82,8 +82,10 @@ bool ScreenPlayGodotWallpaper::init(int activeScreen)
|
||||
ShowWindow(m_hook->windowHandle, SW_HIDE);
|
||||
|
||||
WindowsIntegration windowsIntegration;
|
||||
std::optional<Monitor> monitor = windowsIntegration.setupWallpaperForOneScreen(activeScreen,m_hook->windowHandle,m_hook->windowHandleWorker);
|
||||
displayServer->window_set_size(godot::Vector2((real_t)monitor->size.cx, (real_t)monitor->size.cy));
|
||||
auto updateWindowSize = [this, &displayServer](const int width, const int height){
|
||||
displayServer->window_set_size(godot::Vector2((real_t)width, (real_t)height));
|
||||
};
|
||||
std::optional<Monitor> monitor = windowsIntegration.setupWallpaperForOneScreen(activeScreen,m_hook->windowHandle,m_hook->windowHandleWorker,updateWindowSize);
|
||||
|
||||
const std::string windowTitle = "ScreenPlayWallpaperGodot";
|
||||
SetWindowText(hwnd, windowTitle.c_str());
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <shellscalingapi.h>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#include <functional>
|
||||
|
||||
// Do not sort !
|
||||
#include "WinUser.h"
|
||||
@ -166,7 +167,7 @@ public:
|
||||
* scale factors.
|
||||
*/
|
||||
|
||||
std::optional<Monitor> setupWallpaperForOneScreen(const int activeScreen, HWND windowHwnd, HWND parentWindowHwnd)
|
||||
std::optional<Monitor> setupWallpaperForOneScreen(const int activeScreen, HWND windowHwnd, HWND parentWindowHwnd, std::function<void(int,int)>updateWindowSize)
|
||||
{
|
||||
std::vector<Monitor> monitors = GetAllMonitors();
|
||||
for (const auto& monitor : monitors) {
|
||||
@ -179,6 +180,9 @@ public:
|
||||
monitor.size.cx, monitor.size.cy,
|
||||
SWP_NOZORDER | SWP_NOACTIVATE);
|
||||
|
||||
// Must be called here to fix window positions!
|
||||
updateWindowSize(monitor.size.cx, monitor.size.cy);
|
||||
|
||||
RECT oldRect;
|
||||
GetWindowRect(windowHwnd, &oldRect);
|
||||
std::cout << "Old Window Position: (" << oldRect.left << ", " << oldRect.top << ")" << std::endl;
|
||||
|
@ -186,11 +186,14 @@ void WinWindow::destroyThis()
|
||||
void WinWindow::setupWallpaperForOneScreen(int activeScreen)
|
||||
{
|
||||
WindowsIntegration windowsIntegration;
|
||||
std::optional<Monitor> monitor = windowsIntegration.setupWallpaperForOneScreen(activeScreen,m_windowHandle,m_windowHandleWorker);
|
||||
setWidth(monitor->size.cx);
|
||||
setHeight(monitor->size.cy);
|
||||
m_window.setWidth(width());
|
||||
m_window.setHeight(height());
|
||||
auto updateWindowSize = [this](const int width, const int height){
|
||||
setWidth(width);
|
||||
setHeight(height);
|
||||
m_window.setWidth(width);
|
||||
m_window.setHeight(height);
|
||||
};
|
||||
std::optional<Monitor> monitor = windowsIntegration.setupWallpaperForOneScreen(activeScreen,m_windowHandle,m_windowHandleWorker,updateWindowSize);
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Loading…
Reference in New Issue
Block a user