From af802fbff8d4266af027b7a7aadeffaccc2b4618 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Sun, 14 Aug 2022 18:45:39 +0000 Subject: [PATCH] [util] Delete util_monitor No longer used, replaced by new wsi interface --- src/util/meson.build | 1 - src/util/util_monitor.cpp | 162 -------------------------------------- src/util/util_monitor.h | 78 ------------------ 3 files changed, 241 deletions(-) delete mode 100644 src/util/util_monitor.cpp delete mode 100644 src/util/util_monitor.h diff --git a/src/util/meson.build b/src/util/meson.build index 34da01eeb..50044a00b 100644 --- a/src/util/meson.build +++ b/src/util/meson.build @@ -5,7 +5,6 @@ util_src = files([ 'util_gdi.cpp', 'util_luid.cpp', 'util_matrix.cpp', - 'util_monitor.cpp', 'util_shared_res.cpp', 'thread.cpp', diff --git a/src/util/util_monitor.cpp b/src/util/util_monitor.cpp deleted file mode 100644 index 69f60d165..000000000 --- a/src/util/util_monitor.cpp +++ /dev/null @@ -1,162 +0,0 @@ -#include "util_monitor.h" -#include "util_string.h" - -#include "./log/log.h" - -namespace dxvk { - - HMONITOR GetDefaultMonitor() { - return ::MonitorFromPoint({ 0, 0 }, MONITOR_DEFAULTTOPRIMARY); - } - - - BOOL SetMonitorDisplayMode( - HMONITOR hMonitor, - DEVMODEW* pMode) { - ::MONITORINFOEXW monInfo; - monInfo.cbSize = sizeof(monInfo); - - if (!::GetMonitorInfoW(hMonitor, reinterpret_cast(&monInfo))) { - Logger::err("Failed to query monitor info"); - return E_FAIL; - } - - Logger::info(str::format("Setting display mode: ", - pMode->dmPelsWidth, "x", pMode->dmPelsHeight, "@", - pMode->dmDisplayFrequency)); - - DEVMODEW curMode = { }; - curMode.dmSize = sizeof(curMode); - - if (GetMonitorDisplayMode(hMonitor, ENUM_CURRENT_SETTINGS, &curMode)) { - bool eq = curMode.dmPelsWidth == pMode->dmPelsWidth - && curMode.dmPelsHeight == pMode->dmPelsHeight - && curMode.dmBitsPerPel == pMode->dmBitsPerPel; - - if (pMode->dmFields & DM_DISPLAYFREQUENCY) - eq &= curMode.dmDisplayFrequency == pMode->dmDisplayFrequency; - - if (eq) - return true; - } - - LONG status = ::ChangeDisplaySettingsExW(monInfo.szDevice, - pMode, nullptr, CDS_FULLSCREEN, nullptr); - - if (status != DISP_CHANGE_SUCCESSFUL) { - pMode->dmFields &= ~DM_DISPLAYFREQUENCY; - - status = ::ChangeDisplaySettingsExW(monInfo.szDevice, - pMode, nullptr, CDS_FULLSCREEN, nullptr); - } - - return status == DISP_CHANGE_SUCCESSFUL; - } - - - BOOL GetMonitorDisplayMode( - HMONITOR hMonitor, - DWORD modeNum, - DEVMODEW* pMode) { - ::MONITORINFOEXW monInfo; - monInfo.cbSize = sizeof(monInfo); - - if (!::GetMonitorInfoW(hMonitor, reinterpret_cast(&monInfo))) { - Logger::err("Failed to query monitor info"); - return false; - } - - return ::EnumDisplaySettingsW(monInfo.szDevice, modeNum, pMode); - } - - - BOOL CALLBACK RestoreMonitorDisplayModeCallback( - HMONITOR hMonitor, - HDC hDC, - LPRECT pRect, - LPARAM pUserdata) { - auto success = reinterpret_cast(pUserdata); - - DEVMODEW devMode = { }; - devMode.dmSize = sizeof(devMode); - - if (!GetMonitorDisplayMode(hMonitor, ENUM_REGISTRY_SETTINGS, &devMode)) { - *success = false; - return false; - } - - Logger::info(str::format("Restoring display mode: ", - devMode.dmPelsWidth, "x", devMode.dmPelsHeight, "@", - devMode.dmDisplayFrequency)); - - if (!SetMonitorDisplayMode(hMonitor, &devMode)) { - *success = false; - return false; - } - - return true; - } - - - BOOL RestoreMonitorDisplayMode() { - bool success = true; - bool result = ::EnumDisplayMonitors(nullptr, nullptr, - &RestoreMonitorDisplayModeCallback, - reinterpret_cast(&success)); - - return result && success; - } - - - void GetWindowClientSize( - HWND hWnd, - UINT* pWidth, - UINT* pHeight) { - RECT rect = { }; - ::GetClientRect(hWnd, &rect); - - if (pWidth) - *pWidth = rect.right - rect.left; - - if (pHeight) - *pHeight = rect.bottom - rect.top; - } - - - void GetMonitorClientSize( - HMONITOR hMonitor, - UINT* pWidth, - UINT* pHeight) { - ::MONITORINFOEXW monInfo; - monInfo.cbSize = sizeof(monInfo); - - if (!::GetMonitorInfoW(hMonitor, reinterpret_cast(&monInfo))) { - Logger::err("Failed to query monitor info"); - return; - } - - auto rect = monInfo.rcMonitor; - - if (pWidth) - *pWidth = rect.right - rect.left; - - if (pHeight) - *pHeight = rect.bottom - rect.top; - } - - - void GetMonitorRect( - HMONITOR hMonitor, - RECT* pRect) { - ::MONITORINFOEXW monInfo; - monInfo.cbSize = sizeof(monInfo); - - if (!::GetMonitorInfoW(hMonitor, reinterpret_cast(&monInfo))) { - Logger::err("Failed to query monitor info"); - return; - } - - *pRect = monInfo.rcMonitor; - } - -} diff --git a/src/util/util_monitor.h b/src/util/util_monitor.h deleted file mode 100644 index 41c6ebee8..000000000 --- a/src/util/util_monitor.h +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once - -#include "./com/com_include.h" - -namespace dxvk { - - /** - * \brief Retrieves primary monitor - * \returns The primary monitor - */ - HMONITOR GetDefaultMonitor(); - - /** - * \brief Sets monitor display mode - * - * Note that \c pMode may be altered by this function. - * \param [in] hMonitor The monitor to change - * \param [in] pMode The desired display mode - * \returns \c true on success - */ - BOOL SetMonitorDisplayMode( - HMONITOR hMonitor, - DEVMODEW* pMode); - - /** - * \brief Enumerates monitor display modes - * - * \param [in] hMonitor The monitor to query - * \param [in] modeNum Mode number or enum - * \param [in] pMode The display mode - * \returns \c true on success - */ - BOOL GetMonitorDisplayMode( - HMONITOR hMonitor, - DWORD modeNum, - DEVMODEW* pMode); - - /** - * \brief Change display modes to registry settings - * \returns \c true on success - */ - BOOL RestoreMonitorDisplayMode(); - - /** - * \brief Queries window client size - * - * \param [in] hWnd Window to query - * \param [out] pWidth Client width - * \param [out] pHeight Client height - */ - void GetWindowClientSize( - HWND hWnd, - UINT* pWidth, - UINT* pHeight); - - /** - * \brief Queries monitor size - * - * \param [in] hMonitor Monitor to query - * \param [out] pWidth Client width - * \param [out] pHeight Client height - */ - void GetMonitorClientSize( - HMONITOR hMonitor, - UINT* pWidth, - UINT* pHeight); - - /** - * \brief Queries monitor rect - * - * \param [in] hMonitor Monitor to query - * \param [out] pRect The rect to return - */ - void GetMonitorRect( - HMONITOR hMonitor, - RECT* pRect); - -}