Skip to content

Commit

Permalink
Merge branch 'dev' into onnx
Browse files Browse the repository at this point in the history
  • Loading branch information
Blinue committed May 13, 2024
2 parents eace2e8 + fc551e3 commit b568096
Show file tree
Hide file tree
Showing 204 changed files with 5,399 additions and 4,084 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
key: Conan-${{ hashFiles('src/**/conanfile.txt') }}-${{ matrix.platform }}

- name: Build
run: python publish.py ${{ matrix.platform }}
run: python publish.py ${{ matrix.platform }} unpackaged certs\Magpie.pfx "${{ secrets.MAGPIE_PFX_PASSWORD }}"

- name: Save hash
id: hash
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
uses: actions/cache@v4
with:
path: ~/.conan2/p
key: ${{ runner.os }}-conan-${{ hashFiles('src/**/conanfile.txt') }}
key: Conan-${{ hashFiles('src/**/conanfile.txt') }}-${{ matrix.platform }}

- name: Generate tag
id: tag
Expand All @@ -54,7 +54,7 @@ jobs:
echo "tag=$tag" >> $env:GITHUB_OUTPUT
- name: Build
run: python publish.py ${{ matrix.platform }}
run: python publish.py ${{ matrix.platform }} unpackaged certs\Magpie.pfx "${{ secrets.MAGPIE_PFX_PASSWORD }}"
env:
MAJOR: ${{ inputs.major }}
MINOR: ${{ inputs.minor }}
Expand Down
14 changes: 12 additions & 2 deletions Magpie.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ VisualStudioVersion = 17.1.32228.430
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Magpie", "src\Magpie\Magpie.vcxproj", "{1801171B-65B6-400F-92FF-73EAF499CFB3}"
ProjectSection(ProjectDependencies) = postProject
{05B51BB8-08CB-4907-884F-8E2AD6BF6052} = {05B51BB8-08CB-4907-884F-8E2AD6BF6052}
{1239537C-E5B8-427A-9E7F-EA443D1F3529} = {1239537C-E5B8-427A-9E7F-EA443D1F3529}
{456CCAE4-2C51-4CF2-8D3A-1EFCE8C41A2D} = {456CCAE4-2C51-4CF2-8D3A-1EFCE8C41A2D}
{62503530-B84B-4CC2-80B6-3F89618172B7} = {62503530-B84B-4CC2-80B6-3F89618172B7}
Expand All @@ -23,9 +24,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
src\Common.Post.props = src\Common.Post.props
src\Common.Pre.props = src\Common.Pre.props
Directory.Build.props = Directory.Build.props
src\extract_winui_runtime.py = src\extract_winui_runtime.py
src\HybridCRT.props = src\HybridCRT.props
src\WinUI.props = src\WinUI.props
src\WinUI.targets = src\WinUI.targets
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Shared", "src\Shared\Shared.vcxitems", "{4EB33017-68C1-40FE-877A-BCFAB2832F18}"
Expand All @@ -48,6 +48,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Natvis", "Natvis", "{9808D3
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Updater", "src\Updater\Updater.vcxproj", "{E82B7A20-0557-4DC1-B418-87977D7450A4}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TouchHelper", "src\TouchHelper\TouchHelper.vcxproj", "{05B51BB8-08CB-4907-884F-8E2AD6BF6052}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM64 = Debug|ARM64
Expand Down Expand Up @@ -104,6 +106,14 @@ Global
{E82B7A20-0557-4DC1-B418-87977D7450A4}.Release|ARM64.Build.0 = Release|ARM64
{E82B7A20-0557-4DC1-B418-87977D7450A4}.Release|x64.ActiveCfg = Release|x64
{E82B7A20-0557-4DC1-B418-87977D7450A4}.Release|x64.Build.0 = Release|x64
{05B51BB8-08CB-4907-884F-8E2AD6BF6052}.Debug|ARM64.ActiveCfg = Debug|ARM64
{05B51BB8-08CB-4907-884F-8E2AD6BF6052}.Debug|ARM64.Build.0 = Debug|ARM64
{05B51BB8-08CB-4907-884F-8E2AD6BF6052}.Debug|x64.ActiveCfg = Debug|x64
{05B51BB8-08CB-4907-884F-8E2AD6BF6052}.Debug|x64.Build.0 = Debug|x64
{05B51BB8-08CB-4907-884F-8E2AD6BF6052}.Release|ARM64.ActiveCfg = Release|ARM64
{05B51BB8-08CB-4907-884F-8E2AD6BF6052}.Release|ARM64.Build.0 = Release|ARM64
{05B51BB8-08CB-4907-884F-8E2AD6BF6052}.Release|x64.ActiveCfg = Release|x64
{05B51BB8-08CB-4907-884F-8E2AD6BF6052}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@

</div>

:earth_africa: **English** | [简体中文](./README_ZH.md)
🌍 **English** | [简体中文](./README_ZH.md)

Magpie is a lightweight window scaling tool that comes equipped with various efficient scaling algorithms and filters. Its primary purpose is to enhance game graphics and enable non-fullscreen games to display in fullscreen mode.

We are using [Weblate](https://weblate.org/) for localization work and would appreciate your help in translating Magpie into more languages.

[![Translation status](https://hosted.weblate.org/widgets/magpie/-/287x66-white.png)](https://hosted.weblate.org/engage/magpie/)

:point_right: [Download](https://github.com/Blinue/Magpie/releases)
👉 [Download](https://github.com/Blinue/Magpie/releases)

:point_right: [FAQ](https://github.com/Blinue/Magpie/wiki/FAQ%20(EN))
👉 [FAQ](https://github.com/Blinue/Magpie/wiki/FAQ%20(EN))

:point_right: [Built-in effects](https://github.com/Blinue/Magpie/wiki/Built-in%20effects)
👉 [Built-in effects](https://github.com/Blinue/Magpie/wiki/Built-in%20effects)

:point_right: [Compilation guide](https://github.com/Blinue/Magpie/wiki/Compilation%20guide)
👉 [Compilation guide](https://github.com/Blinue/Magpie/wiki/Compilation%20guide)

:point_right: [Contributing](./CONTRIBUTING.md)
👉 [Contributing](./CONTRIBUTING.md)

## Features

Expand Down
10 changes: 5 additions & 5 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ Magpie 是一个轻量级的窗口缩放工具,内置了多种高效的缩放

[![翻译状态](https://hosted.weblate.org/widgets/magpie/-/287x66-white.png)](https://hosted.weblate.org/engage/magpie/)

:point_right: [下载](https://github.com/Blinue/Magpie/releases)
👉 [下载](https://github.com/Blinue/Magpie/releases)

:point_right: [FAQ](https://github.com/Blinue/Magpie/wiki/FAQ)
👉 [FAQ](https://github.com/Blinue/Magpie/wiki/FAQ)

:point_right: [内置效果介绍](https://github.com/Blinue/Magpie/wiki/内置效果介绍)
👉 [内置效果介绍](https://github.com/Blinue/Magpie/wiki/内置效果介绍)

:point_right: [编译指南](https://github.com/Blinue/Magpie/wiki/编译指南)
👉 [编译指南](https://github.com/Blinue/Magpie/wiki/编译指南)

:point_right: [贡献指南](./CONTRIBUTING_ZH.md)
👉 [贡献指南](./CONTRIBUTING_ZH.md)

## 功能

Expand Down
1 change: 1 addition & 0 deletions certs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!*.pfx
Binary file added certs/Magpie.pfx
Binary file not shown.
13 changes: 13 additions & 0 deletions docs/About touch support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Due to OS security restrictions, Magpie requires UIAccess privileges to support touch input. Obtaining this privilege necessitates meeting two conditions:

1. The application must possess a digital signature, and this signature must be verified by a certificate associated with a trusted root certificate authority store on the local machine.
2. The application must reside in a "secure location", such as the Program Files or System32 folders.

When enabling touch support, Magpie performs the following actions:

1. Adds a self-signed certificate to the trusted root certificate authority store.
2. Copies the TouchHelper.exe to `System32\Magpie`. During scaling, Magpie runs this program to enable touch support.

Both of these actions constitute significant changes to the OS, thus requiring administrator privileges. If touch support is no longer needed, this option should be disabled. Magpie will then revert these changes, leaving no traces in the OS.

Touch support may fail for various reasons, such as when TouchHelper.exe requires an update. In such cases, Magpie will request administrator privileges before scaling to resolve the issue.
16 changes: 15 additions & 1 deletion docs/Compilation guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ In order to compile Magpie, you need to first install:
conan --version
```

### Compile
### Compiling

1. Clone the repo

Expand All @@ -29,3 +29,17 @@ In order to compile Magpie, you need to first install:
```

2. Open the Magpie.sln in the root directory and build the solution.

### Enabling Touch Support

To enable touch input support, TouchHelper.exe needs to be signed. While signing is automatically done in the CI pipeline, you can also manually sign it. Follow these steps:

1. Create a self-signed certificate and export it as a pfx file.
2. Replace the `CERT_FINGERPRINT` constant in `src/Magpie/TouchHelper.cpp` with the SHA-1 hash (i.e., fingerprint) of your certificate.
3. Run the following command in the root directory of the repository:

```bash
python publish.py x64 unpackaged <pfx path> <pfx password>
```

This will compile Magpie and sign TouchHelper.exe. The compiled files will be located in `publish\x64`.
89 changes: 89 additions & 0 deletions docs/Interact with Magpie programally.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
Magpie provides mechanisms for interaction with other programs. Through these mechanisms, your application can cooperate with Magpie.

[MagpieWatcher](https://github.com/Blinue/MagpieWatcher) demonstrates how to use these mechanisms.

## How to Receive Notifications When Scaling State Changes

You should listen for the MagpieScalingChanged message.

```c++
UINT WM_MAGPIE_SCALINGCHANGED = RegisterWindowMessage(L"MagpieScalingChanged");
```

### Parameters

`wParam` is the event ID. For different events, `lParam` has different meanings. Currently, two events are supported:

* 0: Scaling has ended. `lParam` is not used.
* 1: Scaling has started. `lParam` is the handle of the scaling window.

### Notes

If your process has a higher integrity level than Magpie, you won't receive messages broadcasted by Magpie due to User Interface Privilege Isolation (UIPI). In such cases, call [ChangeWindowMessageFilterEx](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-changewindowmessagefilterex) to allow receiving the MagpieScalingChanged message.

```c++
ChangeWindowMessageFilterEx(hYourWindow, WM_MAGPIE_SCALINGCHANGED, MSGFLT_ADD, nullptr);
```
## How to Get the Handle of the Scaling Window
You can listen for the MagpieScalingChanged message to obtain the handle of the scaling window. Additionally, while Magpie is scaling, you can also search for the window with the class name `Window_Magpie_967EB565-6F73-4E94-AE53-00CC42592A22`. Magpie ensures that this class name remains unchanged and that only one scaling window exists at a time.
```c++
HWND hwndScaling = FindWindow(L"Window_Magpie_967EB565-6F73-4E94-AE53-00CC42592A22", nullptr);
```

## How to Place Your Window Above the Scaling Window

Your window must be topmost. You should also listen for the MagpieScalingChanged message; you will receive one after the scaling window is shown, and then you can use `BringWindowToTop` to place your window above it. The scaling window does not attempt to adjust its position on the Z-axis while it exists.

```c++
HWND hWnd = CreateWindowEx(WS_EX_TOPMOST, ...);
...
if (message == WM_MAGPIE_SCALINGCHANGED) {
switch (wParam) {
case 0:
// Scaling has ended
break;
case 1:
// Scaling has started
// Place this window above the scaling window
BringWindowToTop(hWnd);
break;
default:
break;
}
}
```

## How to Obtain Scaling Information

Scaling information is stored in the [window properties](https://learn.microsoft.com/en-us/windows/win32/winmsg/about-window-properties) of the scaling window. Currently available properties include:

* `Magpie.SrcHWND`: Handle of the source window
* `Magpie.SrcLeft``Magpie.SrcTop``Magpie.SrcRight``Magpie.SrcBottom`: Source region of scaling
* `Magpie.DestLeft``Magpie.DestTop``Magpie.DestRight``Magpie.DestBottom`: Destination region of scaling

```c++
HWND hwndSrc = (HWND)GetProp(hwndScaling, L"Magpie.SrcHWND");

RECT srcRect;
srcRect.left = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.SrcLeft");
srcRect.top = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.SrcTop");
srcRect.right = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.SrcRight");
srcRect.bottom = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.SrcBottom");

RECT destRect;
destRect.left = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.DestLeft");
destRect.top = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.DestTop");
destRect.right = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.DestRight");
destRect.bottom = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.DestBottom");
```

## How to Keep Magpie Scaling When Your Window Is in the Foreground

Magpie stops scaling when the foreground window changes, with some system windows being exceptions. By setting the `Magpie.ToolWindow` property, you can include your window and all its owned windows in the exceptions list.

```c++
SetProp(hYourWindow, L"Magpie.ToolWindow", (HANDLE)TRUE);
```
89 changes: 89 additions & 0 deletions docs/以编程方式与 Magpie 交互.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
Magpie 提供了和其他程序交互的机制。通过它们,你的应用可以和 Magpie 配合使用。

[MagpieWatcher](https://github.com/Blinue/MagpieWatcher) 演示了如何使用这些机制。

## 如何在缩放状态改变时得到通知

你应该监听 MagpieScalingChanged 消息。

```c++
UINT WM_MAGPIE_SCALINGCHANGED = RegisterWindowMessage(L"MagpieScalingChanged");
```

### 参数

`wParam` 为事件 ID,对于不同的事件 `lParam` 有不同的含义。目前支持两个事件:

* 0: 缩放已结束。不使用 `lParam`
* 1: 缩放已开始。`lParam` 为缩放窗口句柄。

### 注意事项

如果你的进程完整性级别 (Integration level) 比 Magpie 更高,由于用户界面特权隔离 (UIPI),你将无法收到 Magpie 广播的消息。这种情况下请调用 [ChangeWindowMessageFilterEx](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-changewindowmessagefilterex) 以允许接收 MagpieScalingChanged 消息。

```c++
ChangeWindowMessageFilterEx(hYourWindow, WM_MAGPIE_SCALINGCHANGED, MSGFLT_ADD, nullptr);
```
## 如何获取缩放窗口句柄
你可以监听 MagpieScalingChanged 消息来获取缩放窗口句柄,也可以查找类名为`Window_Magpie_967EB565-6F73-4E94-AE53-00CC42592A22`的窗口以在缩放中途获取该句柄。Magpie 将确保此类名不会改变,且不会同时存在多个缩放窗口。
```c++
HWND hwndScaling = FindWindow(L"Window_Magpie_967EB565-6F73-4E94-AE53-00CC42592A22", nullptr);
```

## 如何将你的窗口置于缩放窗口上方

你的窗口必须是置顶的。你还应该监听 MagpieScalingChanged 消息,当收到该消息时缩放窗口已经显示,然后你可以使用 `BringWindowToTop` 函数将自己的窗口置于缩放窗口上方。缩放窗口在存在期间不会尝试调整自己在 Z 轴的位置。

```c++
HWND hWnd = CreateWindowEx(WS_EX_TOPMOST, ...);
...
if (message == WM_MAGPIE_SCALINGCHANGED) {
switch (wParam) {
case 0:
// 缩放已结束
break;
case 1:
// 缩放已开始
// 将本窗口置于缩放窗口上面
BringWindowToTop(hWnd);
break;
default:
break;
}
}
```

## 如何获取缩放信息

缩放窗口的[窗口属性](https://learn.microsoft.com/en-us/windows/win32/winmsg/about-window-properties)中存储着缩放信息。目前支持以下属性:

* `Magpie.SrcHWND`: 源窗口句柄
* `Magpie.SrcLeft``Magpie.SrcTop``Magpie.SrcRight``Magpie.SrcBottom`: 被缩放区域的边界
* `Magpie.DestLeft``Magpie.DestTop``Magpie.DestRight``Magpie.DestBottom`: 缩放后区域矩形边界

```c++
HWND hwndSrc = (HWND)GetProp(hwndScaling, L"Magpie.SrcHWND");

RECT srcRect;
srcRect.left = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.SrcLeft");
srcRect.top = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.SrcTop");
srcRect.right = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.SrcRight");
srcRect.bottom = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.SrcBottom");

RECT destRect;
destRect.left = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.DestLeft");
destRect.top = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.DestTop");
destRect.right = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.DestRight");
destRect.bottom = (LONG)(INT_PTR)GetProp(hwndScaling, L"Magpie.DestBottom");
```

## 如何使 Magpie 在你的窗口位于前台时保持缩放

前台窗口改变时 Magpie 会停止缩放,只对某些系统窗口例外。你可以通过设置属性 `Magpie.ToolWindow` 将自己的窗口添加入例外,这对由该窗口拥有 (owned) 的窗口也有效。

```c++
SetProp(hYourWindow, L"Magpie.ToolWindow", (HANDLE)TRUE);
```
13 changes: 13 additions & 0 deletions docs/关于触控支持.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
由于操作系统的安全限制,Magpie 需要 UIAccess 权限来支持触控输入。获得此权限需要满足两个条件:

1. 应用程序必须有一个数字签名,且该签名能够通过与本地计算机上受信任的根证书颁发机构存储相关联的证书来验证。
2. 应用程序必须位于“安全位置”,例如 Program Files、System32 等文件夹中。

启用触控支持时,Magpie 将进行以下操作:

1. 向受信任的根证书颁发机构存储添加自签名证书。
2. 将 TouchHelper.exe 文件复制到 `System32\Magpie` 文件夹。在缩放时,Magpie 会运行此程序以实现触控支持。

这两项操作都对操作系统构成重大更改,因此需要管理员权限。如果不再需要触控支持,应关闭此选项,Magpie 会撤销这些更改,不在操作系统中留下痕迹。

触控支持可能会因为某些原因失效(比如 TouchHelper.exe 需要更新时),如果发生这种情况,Magpie 会在缩放前请求管理员权限来修复它。
14 changes: 14 additions & 0 deletions docs/编译指南.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,17 @@
```

2. 打开根目录的 Magpie.sln 然后生成解决方案。

## 启用触控支持

为了支持触控输入,TouchHelper.exe 应签名。签名是在 CI 中自动进行的,但你也可以手动签名,请执行以下步骤:

1. 创建自签名证书,将其导出为 pfx。
2.`src/Magpie/TouchHelper.cpp` 中的 `CERT_FINGERPRINT` 常量替换为你的证书的 SHA-1 哈希值(也即该证书的指纹)。
3. 在存储库根目录下执行以下命令:

```bash
python publish.py x64 unpackaged <pfx 路径> <pfx 密码>
```

这将编译 Magpie 并为 TouchHelper.exe 签名。编译出的程序位于 `publish\x64`
Loading

0 comments on commit b568096

Please sign in to comment.