mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-25 20:22:39 +01:00
Replace manual offset calc with workerW
This now works when the monitors are in the negative coordinate system aka left top from the main monitor.
This commit is contained in:
parent
9c9a3d4509
commit
d5efc93bc1
@ -160,14 +160,20 @@ WinWindow::WinWindow(
|
|||||||
qFatal("No worker window found");
|
qFatal("No worker window found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RECT rect {};
|
||||||
|
if (!GetWindowRect(m_windowHandleWorker, &rect)) {
|
||||||
|
qFatal("Unable to get WindoeRect from worker");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Windows coordante system begins at 0x0 at the
|
||||||
|
// main monitors upper left and not at the most left top monitor.
|
||||||
|
// This can be easily read from the worker window.
|
||||||
|
m_zeroPoint = { std::abs(rect.left), std::abs(rect.top) };
|
||||||
|
|
||||||
// WARNING: Setting Window flags must be called *here*!
|
// WARNING: Setting Window flags must be called *here*!
|
||||||
SetWindowLongPtr(m_windowHandle, GWL_EXSTYLE, WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT);
|
SetWindowLongPtr(m_windowHandle, GWL_EXSTYLE, WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT);
|
||||||
SetWindowLongPtr(m_windowHandle, GWL_STYLE, WS_POPUPWINDOW);
|
SetWindowLongPtr(m_windowHandle, GWL_STYLE, WS_POPUPWINDOW);
|
||||||
|
|
||||||
// Windows coordante system begins at 0x0 at the
|
|
||||||
// main monitors upper left and not at the most left top monitor
|
|
||||||
calcOffsets();
|
|
||||||
|
|
||||||
// Ether for one Screen or for all
|
// Ether for one Screen or for all
|
||||||
if ((QApplication::screens().length() == activeScreensList.length()) && (activeScreensList.length() != 1)) {
|
if ((QApplication::screens().length() == activeScreensList.length()) && (activeScreensList.length() != 1)) {
|
||||||
setupWallpaperForAllScreens();
|
setupWallpaperForAllScreens();
|
||||||
@ -237,24 +243,15 @@ BOOL CALLBACK GetMonitorByIndex(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMo
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinWindow::calcOffsets()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < QApplication::screens().count(); i++) {
|
|
||||||
QScreen* screen = QApplication::screens().at(i);
|
|
||||||
if (screen->availableGeometry().x() < 0) {
|
|
||||||
m_windowOffsetX += (screen->availableGeometry().x() * -1);
|
|
||||||
}
|
|
||||||
if (screen->availableGeometry().y() < 0) {
|
|
||||||
m_windowOffsetY += (screen->availableGeometry().y() * -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WinWindow::setupWallpaperForOneScreen(int activeScreen)
|
void WinWindow::setupWallpaperForOneScreen(int activeScreen)
|
||||||
{
|
{
|
||||||
const QRect screenRect = QApplication::screens().at(activeScreen)->geometry();
|
const QRect screenRect = QApplication::screens().at(activeScreen)->geometry();
|
||||||
|
|
||||||
float scaling = getScaling(activeScreen);
|
float scaling = 1; // getScaling(activeScreen);
|
||||||
|
for (int i = 0; i < QApplication::screens().count(); i++) {
|
||||||
|
qInfo() << i << "scaling " << getScaling(i) << QApplication::screens().at(i)->geometry();
|
||||||
|
}
|
||||||
|
qInfo() << scaling;
|
||||||
|
|
||||||
cMonitorsVec Monitors;
|
cMonitorsVec Monitors;
|
||||||
int width = std::abs(Monitors.rcMonitors[activeScreen].right - Monitors.rcMonitors[activeScreen].left);
|
int width = std::abs(Monitors.rcMonitors[activeScreen].right - Monitors.rcMonitors[activeScreen].left);
|
||||||
@ -275,8 +272,8 @@ void WinWindow::setupWallpaperForOneScreen(int activeScreen)
|
|||||||
if (!SetWindowPos(
|
if (!SetWindowPos(
|
||||||
m_windowHandle,
|
m_windowHandle,
|
||||||
nullptr,
|
nullptr,
|
||||||
screenRect.x() + m_windowOffsetX,
|
screenRect.x() + m_zeroPoint.x(),
|
||||||
screenRect.y() + m_windowOffsetY,
|
screenRect.y() + m_zeroPoint.y(),
|
||||||
screenRect.width() / scaling,
|
screenRect.width() / scaling,
|
||||||
screenRect.height() / scaling,
|
screenRect.height() / scaling,
|
||||||
SWP_HIDEWINDOW)) {
|
SWP_HIDEWINDOW)) {
|
||||||
@ -326,7 +323,7 @@ void WinWindow::setupWallpaperForMultipleScreens(const QVector<int>& activeScree
|
|||||||
rect.setX(upperLeftScreen->geometry().x());
|
rect.setX(upperLeftScreen->geometry().x());
|
||||||
rect.setY(upperLeftScreen->geometry().y());
|
rect.setY(upperLeftScreen->geometry().y());
|
||||||
|
|
||||||
if (!SetWindowPos(m_windowHandle, nullptr, rect.x() + m_windowOffsetX, rect.y() + m_windowOffsetY, rect.width(), rect.height(), SWP_SHOWWINDOW)) {
|
if (!SetWindowPos(m_windowHandle, nullptr, rect.x() + m_zeroPoint.x(), rect.y() + m_zeroPoint.y(), rect.width(), rect.height(), SWP_SHOWWINDOW)) {
|
||||||
qFatal("Could not set window pos: ");
|
qFatal("Could not set window pos: ");
|
||||||
}
|
}
|
||||||
if (SetParent(m_windowHandle, m_windowHandleWorker) == nullptr) {
|
if (SetParent(m_windowHandle, m_windowHandleWorker) == nullptr) {
|
||||||
|
@ -99,11 +99,10 @@ private slots:
|
|||||||
void checkForFullScreenWindow();
|
void checkForFullScreenWindow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_windowOffsetX = 0;
|
QPoint m_zeroPoint {};
|
||||||
int m_windowOffsetY = 0;
|
|
||||||
QQuickView m_window;
|
QQuickView m_window;
|
||||||
HWND m_windowHandle;
|
HWND m_windowHandle {};
|
||||||
HWND m_windowHandleWorker;
|
HWND m_windowHandleWorker {};
|
||||||
QTimer m_checkForFullScreenWindowTimer;
|
QTimer m_checkForFullScreenWindowTimer;
|
||||||
std::unique_ptr<WindowsDesktopProperties> m_windowsDesktopProperties;
|
std::unique_ptr<WindowsDesktopProperties> m_windowsDesktopProperties;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user