mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-19 05:52:11 +01:00
[util] Delete util_monitor
No longer used, replaced by new wsi interface
This commit is contained in:
parent
f3992658a4
commit
af802fbff8
@ -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',
|
||||
|
@ -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<MONITORINFO*>(&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<MONITORINFO*>(&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<bool*>(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<LPARAM>(&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<MONITORINFO*>(&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<MONITORINFO*>(&monInfo))) {
|
||||
Logger::err("Failed to query monitor info");
|
||||
return;
|
||||
}
|
||||
|
||||
*pRect = monInfo.rcMonitor;
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user