Compare commits

...

5 Commits

6 changed files with 46 additions and 95 deletions

View File

@ -81,7 +81,6 @@ namespace MUtils
//Sheet of glass
MUTILS_API bool sheet_of_glass(QWidget *const window);
MUTILS_API bool sheet_of_glass_update(QWidget *const window);
//System colors
MUTILS_API QColor system_color(const int &color_id);

View File

@ -75,7 +75,6 @@ namespace MUtils
unsigned int versionMinor; ///< The *minor* version of the underlaying operating system
unsigned int versionBuild; ///< The *build* number of the underlaying operating system
unsigned int versionSPack; ///< The *service pack* version of the underlaying operating system
bool overrideFlag;
MUTILS_API bool operator> (const _os_version_t &rhs) const;
MUTILS_API bool operator>= (const _os_version_t &rhs) const;

View File

@ -232,44 +232,6 @@ bool MUtils::GUI::sheet_of_glass(QWidget *const window)
return true;
}
bool MUtils::GUI::sheet_of_glass_update(QWidget *const window)
{
const DwmIsCompositionEnabledFun dwmIsCompositionEnabledFun = MUtils::Win32Utils::resolve<DwmIsCompositionEnabledFun> (QLatin1String("dwmapi"), QLatin1String("DwmIsCompositionEnabled") );
const DwmExtendFrameIntoClientAreaFun dwmExtendFrameIntoClientAreaFun = MUtils::Win32Utils::resolve<DwmExtendFrameIntoClientAreaFun>(QLatin1String("dwmapi"), QLatin1String("DwmExtendFrameIntoClientArea"));
const DwmEnableBlurBehindWindowFun dwmEnableBlurBehindWindowFun = MUtils::Win32Utils::resolve<DwmEnableBlurBehindWindowFun> (QLatin1String("dwmapi"), QLatin1String("DwmEnableBlurBehindWindow") );
//Required functions available?
BOOL bCompositionEnabled = FALSE;
if(dwmIsCompositionEnabledFun && dwmExtendFrameIntoClientAreaFun && dwmEnableBlurBehindWindowFun)
{
//Check if composition is currently enabled
if(HRESULT hr = dwmIsCompositionEnabledFun(&bCompositionEnabled))
{
qWarning("DwmIsCompositionEnabled function has failed! (error %d)", hr);
return false;
}
}
//All functions available *and* composition enabled?
if(!bCompositionEnabled)
{
return false;
}
//Create and populate the Blur Behind structure
DWM_BLURBEHIND bb;
memset(&bb, 0, sizeof(DWM_BLURBEHIND));
bb.fEnable = TRUE;
bb.dwFlags = DWM_BB_ENABLE;
if(HRESULT hr = dwmEnableBlurBehindWindowFun(reinterpret_cast<HWND>(window->winId()), &bb))
{
qWarning("DwmEnableBlurBehindWindow function has failed! (error %d)", hr);
return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
// SYSTEM COLORS
///////////////////////////////////////////////////////////////////////////////

View File

@ -288,7 +288,7 @@ g_os_version_lut[] =
{ MUtils::OS::Version::WINDOWS_WIN70, "Windows 7 or Windows Server 2008 R2" }, //7
{ MUtils::OS::Version::WINDOWS_WIN80, "Windows 8 or Windows Server 2012" }, //8
{ MUtils::OS::Version::WINDOWS_WIN81, "Windows 8.1 or Windows Server 2012 R2" }, //8.1
{ MUtils::OS::Version::WINDOWS_WIN10, "Windows 10 or Windows Server 2016/2019" }, //10
{ MUtils::OS::Version::WINDOWS_WIN10, "Windows 10 or Windows Server 2016" }, //10
{ MUtils::OS::Version::WINDOWS_WIN11, "Windows 11 or Windows Server 2022" }, //11
{ MUtils::OS::Version::UNKNOWN_OPSYS, "N/A" }
};
@ -307,15 +307,15 @@ namespace MUtils
bool os_version_t::operator<= (const os_version_t &rhs) const { return (versionMajor < rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor < rhs.versionMinor)) || ((versionMajor == rhs.versionMajor) && (versionMinor == rhs.versionMinor) && (versionBuild <= rhs.versionBuild)); }
//Known Windows NT versions
const os_version_t WINDOWS_WIN2K = { OS_WINDOWS, 5, 0, 2195, 0 }; // 2000
const os_version_t WINDOWS_WINXP = { OS_WINDOWS, 5, 1, 2600, 0 }; // XP
const os_version_t WINDOWS_XPX64 = { OS_WINDOWS, 5, 2, 3790, 0 }; // XP_x64
const os_version_t WINDOWS_VISTA = { OS_WINDOWS, 6, 0, 6000, 0 }; // Vista
const os_version_t WINDOWS_WIN70 = { OS_WINDOWS, 6, 1, 7600, 0 }; // 7
const os_version_t WINDOWS_WIN80 = { OS_WINDOWS, 6, 2, 9200, 0 }; // 8
const os_version_t WINDOWS_WIN81 = { OS_WINDOWS, 6, 3, 9600, 0 }; // 8.1
const os_version_t WINDOWS_WIN10 = { OS_WINDOWS, 10, 0, 10240, 0 }; // 10
const os_version_t WINDOWS_WIN11 = { OS_WINDOWS, 10, 0, 20348, 0 }; // 11
const os_version_t WINDOWS_WIN2K = { OS_WINDOWS, 5U, 0U, 0U, 0U }; // 2000
const os_version_t WINDOWS_WINXP = { OS_WINDOWS, 5U, 1U, 0U, 0U }; // XP
const os_version_t WINDOWS_XPX64 = { OS_WINDOWS, 5U, 2U, 0U, 0U }; // XP_x64
const os_version_t WINDOWS_VISTA = { OS_WINDOWS, 6U, 0U, 0U, 0U }; // Vista
const os_version_t WINDOWS_WIN70 = { OS_WINDOWS, 6U, 1U, 0U, 0U }; // 7
const os_version_t WINDOWS_WIN80 = { OS_WINDOWS, 6U, 2U, 0U, 0U }; // 8
const os_version_t WINDOWS_WIN81 = { OS_WINDOWS, 6U, 3U, 0U, 0U }; // 8.1
const os_version_t WINDOWS_WIN10 = { OS_WINDOWS, 10U, 0U, 0U, 0U }; // 10
const os_version_t WINDOWS_WIN11 = { OS_WINDOWS, 10U, 0U, 22000U, 0U }; // 11
//Unknown OS
const os_version_t UNKNOWN_OPSYS = { OS_UNKNOWN, 0, 0, 0, 0 }; // N/A
@ -369,16 +369,14 @@ static bool rtl_get_version(OSVERSIONINFOEXW *const osInfo)
#pragma warning(pop)
static bool get_real_os_version(unsigned int *const major, unsigned int *const minor, unsigned int *const build, unsigned int *const spack, bool *const pbOverride)
static bool get_real_os_version(unsigned int *const major, unsigned int *const minor, unsigned int *const build, unsigned int *const spack)
{
static const DWORD MAX_VERSION = MAXWORD;
static const DWORD MAX_BUILDNO = MAXINT;
static const DWORD MAX_SRVCPCK = MAXWORD;
*major = *minor = *build = *spack = 0U;
*pbOverride = false;
//Initialize local variables
*major = *minor = *build = *spack = 0U;
OSVERSIONINFOEXW osvi;
memset(&osvi, 0, sizeof(OSVERSIONINFOEXW));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
@ -427,15 +425,14 @@ const MUtils::OS::Version::os_version_t &MUtils::OS::os_version(void)
}
//Detect OS version
unsigned int major, minor, build, spack; bool overrideFlg;
if(get_real_os_version(&major, &minor, &build, &spack, &overrideFlg))
unsigned int major, minor, build, spack;
if(get_real_os_version(&major, &minor, &build, &spack))
{
g_os_version_info.type = Version::OS_WINDOWS;
g_os_version_info.versionMajor = major;
g_os_version_info.versionMinor = minor;
g_os_version_info.versionBuild = build;
g_os_version_info.versionSPack = spack;
g_os_version_info.overrideFlag = overrideFlg;
}
else
{
@ -450,14 +447,13 @@ const MUtils::OS::Version::os_version_t &MUtils::OS::os_version(void)
const char *MUtils::OS::os_friendly_name(const MUtils::OS::Version::os_version_t &os_version)
{
const char *friendly_name = NULL;
for(size_t i = 0; g_os_version_lut[i].version.type != MUtils::OS::Version::OS_UNKNOWN; i++)
for (size_t i = 0; g_os_version_lut[i].version.type != MUtils::OS::Version::OS_UNKNOWN; i++)
{
if(os_version >= g_os_version_lut[i].version)
const MUtils::OS::Version::os_version_t &version = g_os_version_lut[i].version;
if ((os_version.versionMajor == version.versionMajor) && (os_version.versionMinor == version.versionMinor) && (os_version.versionBuild >= version.versionBuild))
{
friendly_name = g_os_version_lut[i].friendlyName;
continue;
}
break;
}
return friendly_name;
@ -1785,7 +1781,7 @@ const QLatin1String &MUtils::OS::null_device(void)
// DEBUGGER CHECK
///////////////////////////////////////////////////////////////////////////////
#if (!(MUTILS_DEBUG))
#if 0//(!(MUTILS_DEBUG))
static __forceinline bool is_debugger_present(void)
{
__try

View File

@ -330,14 +330,6 @@ QApplication *MUtils::Startup::create_qt(int &argc, char **argv, const QString &
{
qFatal("%s", MUTILS_L1STR(QApplication::tr("Executable '%1' requires Windows XP or later.").arg(executableName)));
}
else if (!CHECK_SPACK(WINDOWS_WINXP, WINDOWS_XPX64, 3))
{
qFatal("%s", MUTILS_L1STR(QApplication::tr("Executable '%1' requires Service Pack 3 for Windows XP.").arg(executableName)));
}
else if (!CHECK_SPACK(WINDOWS_XPX64, WINDOWS_VISTA, 2))
{
qFatal("%s", MUTILS_L1STR(QApplication::tr("Executable '%1' requires Service Pack 2 for Windows XP x64-Edition.").arg(executableName)));
}
}
else
{
@ -345,27 +337,28 @@ QApplication *MUtils::Startup::create_qt(int &argc, char **argv, const QString &
{
qFatal("%s", MUTILS_L1STR(QApplication::tr("Executable '%1' requires Windows Vista or later.").arg(executableName)));
}
else if (!CHECK_SPACK(WINDOWS_VISTA, WINDOWS_WIN70, 2))
}
//Check for required service packs
if (!CHECK_SPACK(WINDOWS_WINXP, WINDOWS_XPX64, 3))
{
qFatal("%s", MUTILS_L1STR(QApplication::tr("Executable '%1' requires Service Pack 3 for Windows XP.").arg(executableName)));
}
if (!CHECK_SPACK(WINDOWS_XPX64, WINDOWS_VISTA, 2))
{
qFatal("%s", MUTILS_L1STR(QApplication::tr("Executable '%1' requires Service Pack 2 for Windows XP x64-Edition.").arg(executableName)));
}
if (!CHECK_SPACK(WINDOWS_VISTA, WINDOWS_WIN70, 2))
{
qFatal("%s", MUTILS_L1STR(QApplication::tr("Executable '%1' requires Service Pack 2 for Windows Vista.").arg(executableName)));
}
}
//Check for Windows 8.0
if ((osVersion >= MUtils::OS::Version::WINDOWS_WIN80) && (osVersion < MUtils::OS::Version::WINDOWS_WIN81))
{
qFatal("%s", MUTILS_L1STR(QApplication::tr("Executable '%1' requires Windows 8.1 or later.").arg(executableName)));
}
//Check for compat mode
if(osVersion.overrideFlag && (osVersion <= MUtils::OS::Version::WINDOWS_WIN10))
{
qWarning("Windows compatibility mode detected!");
if(!arguments.contains("ignore-compat-mode"))
{
qFatal("%s", QApplication::tr("Executable '%1' doesn't support Windows compatibility mode.").arg(executableName).toLatin1().constData());
return NULL;
}
}
//Check for Wine
if(MUtils::OS::running_on_wine())
{

View File

@ -32,14 +32,14 @@
<ProjectGuid>{B7BCA0A5-17AD-4F20-A42C-CD6FFBD55D89}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>MUtilitiesTest_VS2017</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
<ProjectName>MUtilitiesTest</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
@ -133,6 +133,7 @@
<AdditionalLibraryDirectories>$(SolutionDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Shared\lib;$(SolutionDir)\..\Prerequisites\GoogleTest\lib\$(PlatformToolset)\Shared;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>notelemetry.obj;gtest.lib;QtCore4.lib;QtGui4.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ShowProgress>LinkVerboseLib</ShowProgress>
<MinimumRequiredVersion>5.1</MinimumRequiredVersion>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
@ -160,6 +161,7 @@
<AdditionalLibraryDirectories>$(SolutionDir)\..\Prerequisites\Qt4\$(PlatformToolset)\Static\lib;$(SolutionDir)\..\Prerequisites\GoogleTest\lib\$(PlatformToolset)\Static;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>notelemetry.obj;gtest.lib;QtCore.lib;QtGui.lib;Ws2_32.lib;Winmm.lib;Imm32.lib;PowrProf.lib;Version.lib;Psapi.lib;Sensapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ShowProgress>LinkVerboseLib</ShowProgress>
<MinimumRequiredVersion>5.1</MinimumRequiredVersion>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />