From f5380bc514c1f6b3aeccc7c64280cb98289203c2 Mon Sep 17 00:00:00 2001 From: FrzMtrsprt Date: Fri, 7 Oct 2022 12:20:14 +0800 Subject: [PATCH 1/5] Enable dark window border on Windows --- QtScrcpy/CMakeLists.txt | 2 ++ QtScrcpy/ui/dialog.cpp | 6 ++++++ QtScrcpy/util/winutils.cpp | 24 ++++++++++++++++++++++++ QtScrcpy/util/winutils.h | 16 ++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 QtScrcpy/util/winutils.cpp create mode 100644 QtScrcpy/util/winutils.h 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/ui/dialog.cpp b/QtScrcpy/ui/dialog.cpp index 1fbdf68..a9da8bb 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,8 @@ void Dialog::initUI() setWindowTitle(Config::getInstance().getTitle()); + WinUtils::setDarkBorderToWindow((HWND)this->winId(), true); + 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..234bc83 --- /dev/null +++ b/QtScrcpy/util/winutils.cpp @@ -0,0 +1,24 @@ +#include +#include +#include +#pragma comment(lib, "dwmapi") + +#include "winutils.h" + +enum : WORD +{ + DwmwaUseImmersiveDarkMode = 20, + DwmwaUseImmersiveDarkModeBefore20h1 = 19 +}; + +// 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 From bd51fa19a0bcad0ed18f0c1a6dc2a06148f91bf9 Mon Sep 17 00:00:00 2001 From: FrzMtrsprt Date: Sun, 16 Oct 2022 21:29:47 +0800 Subject: [PATCH 2/5] Fix build error --- QtScrcpy/ui/dialog.cpp | 2 ++ QtScrcpy/util/winutils.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/QtScrcpy/ui/dialog.cpp b/QtScrcpy/ui/dialog.cpp index a9da8bb..610e244 100644 --- a/QtScrcpy/ui/dialog.cpp +++ b/QtScrcpy/ui/dialog.cpp @@ -141,7 +141,9 @@ 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)); diff --git a/QtScrcpy/util/winutils.cpp b/QtScrcpy/util/winutils.cpp index 234bc83..53e450c 100644 --- a/QtScrcpy/util/winutils.cpp +++ b/QtScrcpy/util/winutils.cpp @@ -11,6 +11,10 @@ enum : WORD 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) From 4b0e42c2857ba9b782502997379003e7c1201610 Mon Sep 17 00:00:00 2001 From: Barry <870709864@qq.com> Date: Tue, 18 Oct 2022 10:03:41 +0800 Subject: [PATCH 3/5] fix: server start failed on samsung --- QtScrcpy/QtScrcpyCore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 1f776d842f75cec7548222830f2ce709bedaf3e6 Mon Sep 17 00:00:00 2001 From: Barry <870709864@qq.com> Date: Tue, 18 Oct 2022 10:07:39 +0800 Subject: [PATCH 4/5] docs: update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 3658ebbef09f09fae429ecba6599fb39e2b90033 Mon Sep 17 00:00:00 2001 From: Barry <870709864@qq.com> Date: Tue, 18 Oct 2022 10:10:11 +0800 Subject: [PATCH 5/5] docs: update readme --- README_zh.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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` 中