mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-25 04:02:50 +01:00
Remove old code
This commit is contained in:
parent
4849905a4a
commit
c9498b366e
@ -114,16 +114,15 @@ void MonitorListModel::loadMonitors()
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QModelIndex index;
|
||||
WinMonitorStats monitors;
|
||||
auto monitors = WindowsIntegration().GetAllMonitors();
|
||||
|
||||
// This offset lets us center the monitor selection view in the center
|
||||
int offsetX = 0;
|
||||
int offsetY = 0;
|
||||
const int moinitorCount = monitors.iMonitors.size();
|
||||
|
||||
for (int i = 0; i < moinitorCount; i++) {
|
||||
const int x = monitors.rcMonitors[i].left;
|
||||
const int y = monitors.rcMonitors[i].top;
|
||||
for (auto& monitor : monitors) {
|
||||
const int x = monitor.position.left;
|
||||
const int y = monitor.position.top;
|
||||
if (x < 0) {
|
||||
offsetX += (x * -1);
|
||||
}
|
||||
@ -132,11 +131,11 @@ void MonitorListModel::loadMonitors()
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < moinitorCount; 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;
|
||||
for(int i = 0; auto& monitor : monitors) {
|
||||
const int width = std::abs(monitor.position.right - monitor.position.left);
|
||||
const int height = std::abs(monitor.position.top - monitor.position.bottom);
|
||||
const int x = monitor.position.left;
|
||||
const int y = monitor.position.top;
|
||||
QRect geometry(
|
||||
x + offsetX,
|
||||
y + offsetY,
|
||||
@ -145,6 +144,7 @@ void MonitorListModel::loadMonitors()
|
||||
beginInsertRows(index, m_monitorList.size(), m_monitorList.size());
|
||||
m_monitorList.append(Monitor { i, geometry });
|
||||
endInsertRows();
|
||||
i++;
|
||||
}
|
||||
#else
|
||||
QModelIndex index;
|
||||
|
@ -1,111 +0,0 @@
|
||||
#include "windowshook.h"
|
||||
|
||||
BOOL CALLBACK WinMonitorStats::MonitorEnum(HMONITOR hMon, HDC hdc, LPRECT lprcMonitor, LPARAM pData)
|
||||
{
|
||||
WinMonitorStats* pThis = reinterpret_cast<WinMonitorStats*>(pData);
|
||||
auto scaleFactor = DEVICE_SCALE_FACTOR::DEVICE_SCALE_FACTOR_INVALID;
|
||||
GetScaleFactorForMonitor(hMon, &scaleFactor);
|
||||
|
||||
UINT x = 0;
|
||||
UINT y = 0;
|
||||
GetDpiForMonitor(hMon, MONITOR_DPI_TYPE::MDT_RAW_DPI, &x, &y);
|
||||
pThis->sizes.push_back({ x, y });
|
||||
pThis->scaleFactor.push_back(scaleFactor);
|
||||
pThis->hMonitors.push_back(hMon);
|
||||
pThis->hdcMonitors.push_back(hdc);
|
||||
pThis->rcMonitors.push_back(*lprcMonitor);
|
||||
pThis->iMonitors.push_back(static_cast<int>(pThis->hdcMonitors.size()));
|
||||
|
||||
// qInfo() << std::abs(lprcMonitor->right - lprcMonitor->left) << std::abs(lprcMonitor->top - lprcMonitor->bottom);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
/*!
|
||||
\brief Searches for the worker window for our window to parent to.
|
||||
*/
|
||||
BOOL WINAPI SearchForWorkerWindow(HWND hwnd, LPARAM lparam)
|
||||
{
|
||||
// 0xXXXXXXX "" WorkerW
|
||||
// ...
|
||||
// 0xXXXXXXX "" SHELLDLL_DefView
|
||||
// 0xXXXXXXXX "FolderView" SysListView32
|
||||
// 0xXXXXXXXX "" WorkerW <---- We want this one
|
||||
// 0xXXXXXXXX "Program Manager" Progman
|
||||
if (FindWindowExW(hwnd, nullptr, L"SHELLDLL_DefView", nullptr))
|
||||
*reinterpret_cast<HWND*>(lparam) = FindWindowExW(nullptr, hwnd, L"WorkerW", nullptr);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool WindowsHook::searchWorkerWindowToParentTo()
|
||||
{
|
||||
|
||||
HWND progman_hwnd = FindWindowW(L"Progman", L"Program Manager");
|
||||
const DWORD WM_SPAWN_WORKER = 0x052C;
|
||||
SendMessageTimeoutW(progman_hwnd, WM_SPAWN_WORKER, 0xD, 0x1, SMTO_NORMAL,
|
||||
10000, nullptr);
|
||||
|
||||
return EnumWindows(SearchForWorkerWindow, reinterpret_cast<LPARAM>(&windowHandleWorker));
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns scaling factor as reported by Windows.
|
||||
*/
|
||||
float WindowsHook::getScaling(const int monitorIndex) const
|
||||
{
|
||||
// Get all monitors
|
||||
int monitorCount = GetSystemMetrics(SM_CMONITORS);
|
||||
|
||||
if (monitorIndex < 0 || monitorIndex >= monitorCount) {
|
||||
// Invalid monitor index
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
DISPLAY_DEVICE displayDevice;
|
||||
ZeroMemory(&displayDevice, sizeof(displayDevice));
|
||||
displayDevice.cb = sizeof(displayDevice);
|
||||
|
||||
// Enumerate through monitors until we find the one we're looking for
|
||||
for (int i = 0; EnumDisplayDevices(NULL, i, &displayDevice, 0); i++) {
|
||||
if (i == monitorIndex) {
|
||||
DEVMODE devMode;
|
||||
ZeroMemory(&devMode, sizeof(devMode));
|
||||
devMode.dmSize = sizeof(devMode);
|
||||
|
||||
// Get settings for selected monitor
|
||||
if (!EnumDisplaySettings(displayDevice.DeviceName, ENUM_CURRENT_SETTINGS, &devMode)) {
|
||||
// Unable to get monitor settings
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
// Get DPI for selected monitor
|
||||
HMONITOR hMonitor = MonitorFromPoint({ devMode.dmPosition.x, devMode.dmPosition.y }, MONITOR_DEFAULTTONEAREST);
|
||||
UINT dpiX = 0, dpiY = 0;
|
||||
if (SUCCEEDED(GetDpiForMonitor(hMonitor, MDT_EFFECTIVE_DPI, &dpiX, &dpiY))) {
|
||||
return (float)dpiX / 96.0f; // Standard DPI is 96
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we reach here, it means we couldn't find the monitor with the given index or couldn't get the DPI.
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns true of at least one monitor has active scaling enabled.
|
||||
*/
|
||||
bool WindowsHook::hasWindowScaling() const
|
||||
{
|
||||
auto enumMonitorCallback = [](HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) -> BOOL {
|
||||
int scaling = GetDeviceCaps(hdcMonitor, LOGPIXELSX) / 96;
|
||||
if (scaling != 1) {
|
||||
*(bool*)dwData = true;
|
||||
return false; // Stop enumeration
|
||||
}
|
||||
return true; // Continue enumeration
|
||||
};
|
||||
|
||||
bool hasScaling = false;
|
||||
EnumDisplayMonitors(NULL, NULL, enumMonitorCallback, (LPARAM)&hasScaling);
|
||||
|
||||
return hasScaling;
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include <Windows.h>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <shellscalingapi.h>
|
||||
#include <vector>
|
||||
|
||||
struct WinMonitorStats {
|
||||
|
||||
WinMonitorStats()
|
||||
{
|
||||
EnumDisplayMonitors(NULL, NULL, MonitorEnum, (LPARAM)this);
|
||||
}
|
||||
|
||||
static BOOL CALLBACK MonitorEnum(HMONITOR hMon, HDC hdc, LPRECT lprcMonitor, LPARAM pData);
|
||||
std::vector<int> iMonitors;
|
||||
std::vector<HMONITOR> hMonitors;
|
||||
std::vector<HDC> hdcMonitors;
|
||||
std::vector<RECT> rcMonitors;
|
||||
std::vector<DEVICE_SCALE_FACTOR> scaleFactor;
|
||||
std::vector<std::pair<UINT, UINT>> sizes;
|
||||
int index = 0;
|
||||
};
|
||||
|
||||
struct Point {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
};
|
||||
|
||||
struct WindowsHook {
|
||||
bool searchWorkerWindowToParentTo();
|
||||
float getScaling(const int monitorIndex) const;
|
||||
bool hasWindowScaling() const;
|
||||
HWND windowHandle {};
|
||||
HWND windowHandleWorker {};
|
||||
Point zeroPoint;
|
||||
};
|
@ -41,38 +41,7 @@ BOOL CALLBACK GetMonitorByHandle(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcM
|
||||
BOOL CALLBACK FindTheDesiredWnd(HWND hWnd, LPARAM lParam);
|
||||
BOOL WINAPI SearchForWorkerWindow(HWND hwnd, LPARAM lparam);
|
||||
|
||||
struct WinMonitorStats {
|
||||
|
||||
WinMonitorStats()
|
||||
{
|
||||
EnumDisplayMonitors(NULL, NULL, MonitorEnum, (LPARAM)this);
|
||||
}
|
||||
|
||||
static BOOL CALLBACK MonitorEnum(HMONITOR hMon, HDC hdc, LPRECT lprcMonitor, LPARAM pData)
|
||||
{
|
||||
WinMonitorStats* pThis = reinterpret_cast<WinMonitorStats*>(pData);
|
||||
auto scaleFactor = DEVICE_SCALE_FACTOR::DEVICE_SCALE_FACTOR_INVALID;
|
||||
GetScaleFactorForMonitor(hMon, &scaleFactor);
|
||||
|
||||
UINT x = 0;
|
||||
UINT y = 0;
|
||||
GetDpiForMonitor(hMon, MONITOR_DPI_TYPE::MDT_RAW_DPI, &x, &y);
|
||||
pThis->sizes.push_back({ x, y });
|
||||
pThis->scaleFactor.push_back(scaleFactor);
|
||||
pThis->hMonitors.push_back(hMon);
|
||||
pThis->hdcMonitors.push_back(hdc);
|
||||
pThis->rcMonitors.push_back(*lprcMonitor);
|
||||
pThis->iMonitors.push_back(pThis->hdcMonitors.size());
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
std::vector<size_t> iMonitors;
|
||||
std::vector<HMONITOR> hMonitors;
|
||||
std::vector<HDC> hdcMonitors;
|
||||
std::vector<RECT> rcMonitors;
|
||||
std::vector<DEVICE_SCALE_FACTOR> scaleFactor;
|
||||
std::vector<std::pair<UINT, UINT>> sizes;
|
||||
};
|
||||
|
||||
struct Point {
|
||||
int x = 0;
|
||||
|
@ -107,7 +107,7 @@ def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Build and Package ScreenPlay')
|
||||
parser.add_argument('--skip-aqt', action="store_true", dest="skip_aqt",
|
||||
help="Downloads QtCreator and needed binaries \Windows: C:\aqt\nLinux & macOS:~/aqt/.")
|
||||
help="Downloads QtCreator and needed binaries Windows: C:\\aqt\\nLinux & macOS:~/aqt/.")
|
||||
parser.add_argument('--setup-godot', action="store_true", dest="setup_godot",
|
||||
help="Downloads Godot Editor.")
|
||||
args = parser.parse_args()
|
||||
|
Loading…
Reference in New Issue
Block a user