Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ on:
pull_request:
workflow_dispatch:

# This workflow only builds and uploads an artifact; it makes no repository
# writes. release.yml needs contents: write for `gh release create` — do not
# copy this block there.
permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -68,10 +74,19 @@ jobs:
done
exit $status

# Extracted per macro rather than with one alternation piped through
# `paste`, which silently assumed MAJOR/MINOR/PATCH appear in that order
# in the header. An empty component would build a nonsense version like
# "1..0", so each is asserted non-empty.
- name: Verify the version resource matches app_strings.h
run: |
src=$(grep -oP 'APP_VERSION_(MAJOR|MINOR|PATCH)\s+\K\d+' \
resources/app_strings.h | paste -sd.)
maj=$(grep -oP 'APP_VERSION_MAJOR\s+\K\d+' resources/app_strings.h)
min=$(grep -oP 'APP_VERSION_MINOR\s+\K\d+' resources/app_strings.h)
pat=$(grep -oP 'APP_VERSION_PATCH\s+\K\d+' resources/app_strings.h)
for c in "$maj" "$min" "$pat"; do
[ -n "$c" ] || { echo "::error::Could not read APP_VERSION_* from resources/app_strings.h"; exit 1; }
done
src="$maj.$min.$pat"
echo "Source version: $src"
strings -el Primary.exe | grep -qF "$src" || {
echo "::error::Binary does not report source version $src"; exit 1; }
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@ jobs:
- name: Verify the tag matches the source version
run: |
tag="${GITHUB_REF_NAME#v}"
src=$(grep -oP 'APP_VERSION_(MAJOR|MINOR|PATCH)\s+\K\d+' \
resources/app_strings.h | paste -sd.)
# Extracted per macro rather than with one alternation piped through
# `paste`, which silently assumed MAJOR/MINOR/PATCH appear in that
# order in the header. An empty component would build a nonsense
# version like "1..0", so each is asserted non-empty.
maj=$(grep -oP 'APP_VERSION_MAJOR\s+\K\d+' resources/app_strings.h)
min=$(grep -oP 'APP_VERSION_MINOR\s+\K\d+' resources/app_strings.h)
pat=$(grep -oP 'APP_VERSION_PATCH\s+\K\d+' resources/app_strings.h)
for c in "$maj" "$min" "$pat"; do
[ -n "$c" ] || { echo "::error::Could not read APP_VERSION_* from resources/app_strings.h"; exit 1; }
done
src="$maj.$min.$pat"
echo "Tag: $tag / source: $src"
if [ "$tag" != "$src" ]; then
echo "::error::Tag $tag does not match source version $src. Bump APP_VERSION_* in resources/app_strings.h."
Expand Down
12 changes: 5 additions & 7 deletions src/primary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,6 @@ INT_PTR CALLBACK OptionsDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
// Start or stop monitoring based on setting
if (autoSwitchEnabled) {
StartAutoSwitchMonitoring(g_hwndMain);
CheckAndApplyAutoSwitch(); // Apply immediately (will detect change and apply)
} else {
StopAutoSwitchMonitoring(g_hwndMain);
}
Expand All @@ -529,16 +528,15 @@ INT_PTR CALLBACK OptionsDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
L"Failed to update base mouse count. Please check your permissions.",
L"Error",
MB_ICONERROR | MB_OK);
} else {
// Re-check if auto-switch is enabled, to apply new settings immediately
if (autoSwitchEnabled) {
CheckAndApplyAutoSwitch();
}
}

// Single re-apply point: every setting the check reads —
// direction, auto-switch flag, base device count — is
// persisted by now, so one pass covers them all.
//
// Settings may have changed the mapping without the device
// state changing, so discard the cached state to force the
// next check to apply the new configuration.
// check to apply the new configuration.
if (autoSwitchEnabled && autoSwitchWritten) {
g_lastExternalMouseState = EXTERNAL_MOUSE_UNKNOWN;
CheckAndApplyAutoSwitch();
Expand Down
Loading