diff --git a/QtScrcpy/CMakeLists.txt b/QtScrcpy/CMakeLists.txt index cc3568133..deeb394c3 100755 --- a/QtScrcpy/CMakeLists.txt +++ b/QtScrcpy/CMakeLists.txt @@ -149,6 +149,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows") set(QC_UTIL_SOURCES ${QC_UTIL_SOURCES} util/mousetap/winmousetap.h util/mousetap/winmousetap.cpp + util/winutils.h + util/winutils.cpp ) endif() if(CMAKE_SYSTEM_NAME STREQUAL "Linux") diff --git a/QtScrcpy/ui/dialog.cpp b/QtScrcpy/ui/dialog.cpp index 1fbdf689f..610e244bb 100644 --- a/QtScrcpy/ui/dialog.cpp +++ b/QtScrcpy/ui/dialog.cpp @@ -11,6 +11,10 @@ #include "videoform.h" #include "../groupcontroller/groupcontroller.h" +#ifdef Q_OS_WIN32 +#include "../util/winutils.h" +#endif + QString s_keyMapPath = ""; const QString &getKeyMapPath() @@ -137,6 +141,10 @@ void Dialog::initUI() setWindowTitle(Config::getInstance().getTitle()); +#ifdef Q_OS_WIN32 + WinUtils::setDarkBorderToWindow((HWND)this->winId(), true); +#endif + ui->bitRateEdit->setValidator(new QIntValidator(1, 99999, this)); ui->maxSizeBox->addItem("640"); diff --git a/QtScrcpy/util/winutils.cpp b/QtScrcpy/util/winutils.cpp new file mode 100644 index 000000000..53e450cb5 --- /dev/null +++ b/QtScrcpy/util/winutils.cpp @@ -0,0 +1,28 @@ +#include +#include +#include +#pragma comment(lib, "dwmapi") + +#include "winutils.h" + +enum : WORD +{ + DwmwaUseImmersiveDarkMode = 20, + DwmwaUseImmersiveDarkModeBefore20h1 = 19 +}; + +WinUtils::WinUtils(){}; + +WinUtils::~WinUtils(){}; + +// Set dark border to window +// Reference: qt/qtbase.git/tree/src/plugins/platforms/windows/qwindowswindow.cpp +bool WinUtils::setDarkBorderToWindow(const HWND &hwnd, const bool &d) +{ + const BOOL darkBorder = d ? TRUE : FALSE; + const bool ok = SUCCEEDED(DwmSetWindowAttribute(hwnd, DwmwaUseImmersiveDarkMode, &darkBorder, sizeof(darkBorder))) + || SUCCEEDED(DwmSetWindowAttribute(hwnd, DwmwaUseImmersiveDarkModeBefore20h1, &darkBorder, sizeof(darkBorder))); + if (!ok) + qWarning("%s: Unable to set dark window border.", __FUNCTION__); + return ok; +} diff --git a/QtScrcpy/util/winutils.h b/QtScrcpy/util/winutils.h new file mode 100644 index 000000000..58f1fc989 --- /dev/null +++ b/QtScrcpy/util/winutils.h @@ -0,0 +1,16 @@ +#ifndef WINUTILS_H +#define WINUTILS_H + +#include +#include + +class WinUtils +{ +public: + WinUtils(); + ~WinUtils(); + + static bool setDarkBorderToWindow(const HWND &hwnd, const bool &d); +}; + +#endif // WINUTILS_H