diff --git a/QtScrcpy/CMakeLists.txt b/QtScrcpy/CMakeLists.txt index cc35681..deeb394 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/QtScrcpyCore b/QtScrcpy/QtScrcpyCore index 24b496a..f81d369 160000 --- a/QtScrcpy/QtScrcpyCore +++ b/QtScrcpy/QtScrcpyCore @@ -1 +1 @@ -Subproject commit 24b496a8be2f487ea0223386e5daf0ac24209aa4 +Subproject commit f81d3696cb79964e073415798bc070415337877d diff --git a/QtScrcpy/ui/dialog.cpp b/QtScrcpy/ui/dialog.cpp index 1fbdf68..610e244 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 0000000..53e450c --- /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 0000000..58f1fc9 --- /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 diff --git a/README.md b/README.md index d8a909b..1561f6e 100644 --- a/README.md +++ b/README.md @@ -248,14 +248,14 @@ All the dependencies are provided and it is easy to compile. #### Non-Arch Linux Users 1. Set up the Qt development environment with the official Qt installer or third-party tools such as [aqt](https://github.com/miurahr/aqtinstall) on the target platform. Qt version bigger than 5.12 is required. (use MSVC 2019 on Windows) -2. Clone the project with `git clone --recurse-submodules https://barry-ran/QtScrcpy.git` +2. Clone the project with `git clone --recurse-submodules git@github.com:barry-ran/QtScrcpy.git` 3. For Windows, open CMakeLists.txt with QtCreator and compile Release 4. For Linux, directly run `./ci/linux/build_for_linux.sh "Release"` Note: compiled artifacts are located at `output/x64/Release` #### Arch Linux Users 1. Install packages: `base-devel cmake qt5-base qt5-multimedia qt5-x11extras` (`qtcreator` is recommended) -2. Clone the project with `git clone --recurse-submodules https://barry-ran/QtScrcpy.git` +2. Clone the project with `git clone --recurse-submodules git@github.com:barry-ran/QtScrcpy.git` 3. Run `./ci/linux/build_for_linux.sh "Release"` ### Scrcpy-Server diff --git a/README_zh.md b/README_zh.md index 76ecbf6..79bae22 100644 --- a/README_zh.md +++ b/README_zh.md @@ -246,14 +246,14 @@ Mac OS 平台,你可以直接使用我编译好的可执行程序: #### 非 Arch Linux 1. 使用官方 Qt Installer 或非官方工具(如 [aqt](https://github.com/miurahr/aqtinstall))在目标平台上搭建Qt开发环境。 需要 5.12 以上版本 Qt(在 Windows 上使用 MSVC 2019) -2. 克隆该项目:`git clone --recurse-submodules https://github.com/barry-ran/QtScrcpy.git` +2. 克隆该项目:`git clone --recurse-submodules git@github.com:barry-ran/QtScrcpy.git` 3. Windows 使用 QtCreator 打开项目下 CMakeLists.txt 并编译 Release 4. Linux 用终端执行 `./ci/linux/build_for_linux.sh "Release"` 注:编译结果位于 `output/x64/Release` 中 #### Arch Linux 1. 安装以下包:`qt5-base qt5-multimedia qt5-x11extras`(推荐安装 `qtcreator`) -2. 克隆该项目:`git clone --recurse-submodules https://github.com/barry-ran/QtScrcpy.git` +2. 克隆该项目:`git clone --recurse-submodules git@github.com:barry-ran/QtScrcpy.git` 3. 用终端执行 `./ci/linux/build_for_linux.sh "Release"` 注:编译结果位于 `output/x64/Release` 中