Skip to content

Commit

Permalink
fix: no GetDpiForWindow on Windows 7
Browse files Browse the repository at this point in the history
  • Loading branch information
amorphobia committed Sep 11, 2024
1 parent 67f231c commit a9ddbae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,11 @@ jobs:
- name: Download Dependencies
uses: actions/download-artifact@v4

- name: Copy Artifacts
- name: Copy Artifacts and Apply Patches
run: |
git apply --stat ./Lib/GetCaretPosEx/GetCaretPosEx.patch
git apply --check ./Lib/GetCaretPosEx/GetCaretPosEx.patch
git apply ./Lib/GetCaretPosEx/GetCaretPosEx.patch
cp AutoHotkey/${{ matrix.ahk }} Rabbit.exe
cp Rime/${{ matrix.rime }} rime.dll
cp Icon/* Lib/
Expand Down
19 changes: 19 additions & 0 deletions Lib/GetCaretPosEx/GetCaretPosEx.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/Lib/GetCaretPosEx/GetCaretPosEx.ahk b/Lib/GetCaretPosEx/GetCaretPosEx.ahk
index ff9a7f7..b3ee558 100644
--- a/Lib/GetCaretPosEx/GetCaretPosEx.ahk
+++ b/Lib/GetCaretPosEx/GetCaretPosEx.ahk
@@ -332,8 +332,12 @@ end:
}

static getWindowScale(hwnd) {
- if winDpi := DllCall("GetDpiForWindow", "ptr", hwnd, "uint")
- return A_ScreenDPI / winDpi
+ try {
+ if winDpi := DllCall("GetDpiForWindow", "ptr", hwnd, "uint")
+ return A_ScreenDPI / winDpi
+ } catch {
+ ; ignore error
+ }
return 1
}

0 comments on commit a9ddbae

Please sign in to comment.