1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-22 10:42:29 +01:00

Change monitor selection when using Windows scaling

This commit is contained in:
Elias Steurer 2021-11-20 19:22:11 +01:00
parent db4a7c7391
commit a5cc167d1f
2 changed files with 41 additions and 6 deletions

View File

@ -135,6 +135,41 @@ QVariant MonitorListModel::data(const QModelIndex& index, int role) const
*/
void MonitorListModel::loadMonitors()
{
#ifdef Q_OS_WIN
QModelIndex index;
ScreenPlayUtil::WinMonitorStats monitors;
// This offset lets us center the monitor selection view in the center
int offsetX = 0;
int offsetY = 0;
for (int i = 0; i < monitors.iMonitors.size(); i++) {
const int x = monitors.rcMonitors[i].left;
const int y = monitors.rcMonitors[i].top;
if (x < 0) {
offsetX += (x * -1);
}
if (y < 0) {
offsetY += (y * -1);
}
}
for (int i = 0; i < monitors.iMonitors.size(); i++) {
const int width = std::abs(monitors.rcMonitors[i].right - monitors.rcMonitors[i].left);
const int height = std::abs(monitors.rcMonitors[i].top - monitors.rcMonitors[i].bottom);
const int x = monitors.rcMonitors[i].left;
const int y = monitors.rcMonitors[i].top;
QRect availableVirtualGeometry(
x + offsetX,
y + offsetY,
width,
height);
beginInsertRows(index, m_monitorList.size(), m_monitorList.size());
m_monitorList.append(Monitor { i, availableVirtualGeometry, QApplication::screens().at(i) });
endInsertRows();
}
#else
QModelIndex index;
int offsetX = 0;
int offsetY = 0;
@ -148,7 +183,6 @@ void MonitorListModel::loadMonitors()
}
}
QModelIndex index;
for (int i = 0; i < QApplication::screens().count(); i++) {
QScreen* screen = QApplication::screens().at(i);
@ -166,6 +200,7 @@ void MonitorListModel::loadMonitors()
m_monitorList.append(Monitor { i, availableVirtualGeometry, screen });
endInsertRows();
}
#endif
emit monitorReloadCompleted();
}

View File

@ -258,11 +258,11 @@ void WinWindow::setupWallpaperForOneScreen(int activeScreen)
const float scaling = getScaling(activeScreen);
const int borderOffset = -1;
ScreenPlayUtil::WinMonitorStats Monitors;
const int width = std::abs(Monitors.rcMonitors[activeScreen].right - Monitors.rcMonitors[activeScreen].left);
const int height = std::abs(Monitors.rcMonitors[activeScreen].top - Monitors.rcMonitors[activeScreen].bottom);
const int x = Monitors.rcMonitors[activeScreen].left + m_zeroPoint.x() + borderOffset;
const int y = Monitors.rcMonitors[activeScreen].top + m_zeroPoint.y() + borderOffset;
ScreenPlayUtil::WinMonitorStats monitors;
const int width = std::abs(monitors.rcMonitors[activeScreen].right - monitors.rcMonitors[activeScreen].left);
const int height = std::abs(monitors.rcMonitors[activeScreen].top - monitors.rcMonitors[activeScreen].bottom);
const int x = monitors.rcMonitors[activeScreen].left + m_zeroPoint.x() + borderOffset;
const int y = monitors.rcMonitors[activeScreen].top + m_zeroPoint.y() + borderOffset;
qInfo() << QString("Setup window activeScreen: %1 scaling: %2 x: %3 y: %4 width: %5 height: %6").arg(activeScreen).arg(scaling).arg(x).arg(y).arg(width).arg(height);
{